Hey people,
From what I've seen looking at other people's QuakeC, if you have Function_1 which does something temporarily, the 'standard practice' is to make a timer entity, which calls Function_2 to undo what Function_1 did.
Q: Is there a reason why no-one does it like this?:
Code: Select all
// EXAMPLE FUNCTION
// This function is first called when a player is stunned, and then calls itself again, to remove the stun
void() Stun =
{
local entity e;
if (self.classname == "stun_timer")
{
// if we're here, 'self' is the timer whose job it is to undo the stunned state
e = self; // e is now the timer entity
self = self.owner; // self is now the stunned player
// [Code to remove stun effect]
remove(e); // remove the timer, sequence complete.
}
else
{
// if we're here, 'self' is the player who is about to get stunned
// [Code to stun the player]
e = spawn();
e.classname = "stun_timer";
e.owner = self; // the player
e.think = Stun;
e.nextthink = time + 10;
}
};
thanks
OneManClan
ps If someone can think of a better/clearer way to describe the "subject" of this post, please let me know