Forum

couple of questions

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

couple of questions

Postby Jukki » Fri May 14, 2010 10:00 am

Hello everyone. Ineed some help.

1. I want player to be unable to move and take damage. And is ingored by monsters when downed. I tryed to edit clien thing to look like this: (EDIT FIXED)

Code: Select all
   if (self.health > 50)
   {
      self.takedamage = DAMAGE_AIM;
   }
   else
   {
      self.takedamage = DAMAGE_NO;
   }
   self.solid = SOLID_SLIDEBOX;
   if (self.health > 50)
   {
      self.movetype = MOVETYPE_WALK;
   }
   else
   {
      self.movetype = MOVETYPE_NONE;
   }


2. I need to know how to do time triggered function like this:

Function -> time -> new function/effect


thank you allready
Jukki
 
Posts: 214
Joined: Wed Apr 07, 2010 4:59 am

Postby frag.machine » Fri May 14, 2010 1:20 pm

Looks like l4d is the new counter-strike, huh ? :)

I haven't examined your code in depth, but looks to me you're in the right way. You will need to change ImpulseCommands() to check for player health before processing any attack/weapon change impulse.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Postby Pulseczar » Fri May 14, 2010 2:25 pm

In my opinion, you provided too little information for us to help you, without us having to be all-encompassing. We need to know more specifically what you want help with.

"clien thing" and "I need to know how to do time triggered function like this: Function -> time -> new function/effect" are not very specific.

One very typical way to trigger a function at a given time is to use a timer entity.

You would have a function that you want executed at X time. Some where in the code you would create a timer entity to do that.

Code: Select all
local entity timer;                                 // pointer to an entity

timer = spawn();                                 // entity is created; 'timer' now actually points to an entity
timer.nextthink = time + X;
timer.think = FunctionYouWantToRun;   // think runs when time (>)= the current time + X

Inside FunctionYouWantToRun() you'll want to remove the timer entity, to free up the memory it occupies, as it is no longer needed. self will be the timer entity when that function runs. So, somewhere in that function you'll want: remove(self);

Another way to trigger something at a given time is via a function that runs very often, like the player post and pre-think functions. You set a float variable for a given entity with the time you want that entity to do something. And during that fast iterating function somewhere you continuously check whether time has reached the time in that variable.

Check out the code that decides when it's time to take away 666/quad/biosuit effects.
Last edited by Pulseczar on Tue May 18, 2010 1:54 pm, edited 1 time in total.
User avatar
Pulseczar
 
Posts: 37
Joined: Sat Aug 12, 2006 6:45 pm

Postby Jukki » Fri May 14, 2010 2:46 pm

frag.machine wrote:Looks like l4d is the new counter-strike, huh ? :)

I haven't examined your code in depth, but looks to me you're in the right way. You will need to change ImpulseCommands() to check for player health before processing any attack/weapon change impulse.


no. This is not for cs mod. It is for nazi zombies mod. AND i allready got that working ;)

Pulseczar wrote:In my opinion, you provided too little information for us to help you, without us having to be all-encompassing. We need to know more specifically what you want help with.

"clien thing" and "I need to know how to do time triggered function like this: Function -> time -> new function/effect" are not very specific.

One very typical way to trigger a function at a given time is to use a timer entity.

You would have a function that you want executed at X time. Some where in the code you would create a timer entity to do that.

Code: Select all
local entity timer;                                 // pointer to an entity

timer = spawn();                                 // entity is created; 'timer' now actually points to an entity
timer.nexthink = time + X;
timer.think = FunctionYouWantToRun;   // think runs when time (>)= the current time + X

Another way to trigger something at a given time is via a function that runs very often, like the player post and pre-think functions. You set a float variable for a given entity with the time you want that entity to do something. And during that fast iterating function somewhere you continuously check whether time has reached the time in that variable.

Check out the code that decides when it's time to take away 666/quad/biosuit effects.


oh sory. I meaned that when command is executed it takes (ex.) 5 seconds to start. After 5 secs, command is executed.
Jukki
 
Posts: 214
Joined: Wed Apr 07, 2010 4:59 am

Postby Lardarse » Sat May 15, 2010 3:39 am

Jukki wrote:oh sory. I meaned that when command is executed it takes (ex.) 5 seconds to start. After 5 secs, command is executed.

Create a new entity (this isn't always necessary, for reasons I can't explain in a one-liner). Give it nextthink of time + 5, and a think function of what you want it to do. In 5 seconds time, it will happen.
Roaming status: Testing and documentation
User avatar
Lardarse
 
Posts: 266
Joined: Sat Nov 05, 2005 1:58 pm
Location: Bristol, UK

Postby Urre » Mon May 17, 2010 11:17 am

Don't be afraid of spawning entities, it's imperative for any interesting kind of programming :)
I was once a Quake modder
User avatar
Urre
 
Posts: 1109
Joined: Fri Nov 05, 2004 2:36 am
Location: Moon

Postby r00k » Mon May 17, 2010 10:07 pm

Code: Select all
entity (void() think_function, float think_time) event =
{
   local entity event;

   event = spawn ();   
   event.owner = self;
   event.nextthink = (time + think_time);
   event.think = think_function;
   return (event);
};


local entity toe_jam_football;


   if (self.health < 50)
   {
      self.takedamage = DAMAGE_NO;// never die
      self.movetype = MOVETYPE_NONE;
      toe_jam_football = event(BakeMeaCake, 5.0);
      
   }
   else
   {
      self.takedamage = DAMAGE_AIM;
      self.movetype = MOVETYPE_WALK;


please not that somewhere in the function called (bakemeacake), at the end you need to remove(self); as self has become the toejamfootball entity... and should be destroyed after use.

with a little more info about what your event should be we can customize this...
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Postby Spike » Mon May 17, 2010 10:36 pm

warning: if an ent is free()d, it can be re-spawn()ed after 2 seconds. This means that if you have timers on entities that can be free()d, you should make your event function tick multiple times before the final trigger, to make sure that its actually affecting the entity its meant to be affecting, and not an entity that was reused for something else.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby Jukki » Tue May 18, 2010 3:22 pm

thank you guys. But i actualy do have thease thing done already. i just made value "downed" and to playerprethink if your health is 50 or lower it will set downed true.

Thank you guys.
Jukki
 
Posts: 214
Joined: Wed Apr 07, 2010 4:59 am


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest