View previous topic :: View next topic |
Author |
Message |
Jukki
Joined: 07 Apr 2010 Posts: 19
|
Posted: Fri May 14, 2010 10:00 am Post subject: couple of questions |
|
|
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: | 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 |
|
Back to top |
|
 |
frag.machine

Joined: 25 Nov 2006 Posts: 728
|
Posted: Fri May 14, 2010 1:20 pm Post subject: |
|
|
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. _________________ frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/ |
|
Back to top |
|
 |
Pulseczar

Joined: 12 Aug 2006 Posts: 37
|
Posted: Fri May 14, 2010 2:25 pm Post subject: |
|
|
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: | 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. _________________ http://www.customtf.net/
Last edited by Pulseczar on Tue May 18, 2010 1:54 pm; edited 1 time in total |
|
Back to top |
|
 |
Jukki
Joined: 07 Apr 2010 Posts: 19
|
Posted: Fri May 14, 2010 2:46 pm Post subject: |
|
|
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: | 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. |
|
Back to top |
|
 |
Lardarse

Joined: 05 Nov 2005 Posts: 243 Location: Bristol, UK
|
Posted: Sat May 15, 2010 3:39 am Post subject: |
|
|
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. _________________ <ekiM> Son, you're writing data structures your CPU can't cache. |
|
Back to top |
|
 |
Urre

Joined: 05 Nov 2004 Posts: 1073 Location: Sweden
|
Posted: Mon May 17, 2010 11:17 am Post subject: |
|
|
Don't be afraid of spawning entities, it's imperative for any interesting kind of programming  _________________ Look out for Twigboy |
|
Back to top |
|
 |
r00k
Joined: 13 Nov 2004 Posts: 483
|
Posted: Mon May 17, 2010 10:07 pm Post subject: |
|
|
Code: |
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... |
|
Back to top |
|
 |
Spike
Joined: 05 Nov 2004 Posts: 944 Location: UK
|
Posted: Mon May 17, 2010 10:36 pm Post subject: |
|
|
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. _________________ What's a signature? |
|
Back to top |
|
 |
Jukki
Joined: 07 Apr 2010 Posts: 19
|
Posted: Tue May 18, 2010 3:22 pm Post subject: |
|
|
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. |
|
Back to top |
|
 |
|