|
4 registered members (TipmyPip, vince, 2 invisible),
4,115
guests, and 3
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Making an entity spawn every so often?
[Re: Bloodtake23]
#399650
04/18/12 01:43
04/18/12 01:43
|
Joined: Oct 2008
Posts: 513
Carlos3DGS
User
|
User
Joined: Oct 2008
Posts: 513
|
declare a global entity pointer for each object you want to use this like so: then create an action like this:
action Ammo_Pickup_Action()
{
while(condition for being alive)
{
//code to execute while alive (like spinning, moving, detecting when it has been picked up,etc)
wait(1);
}
ent_remove(me); //destroy when its condition to exsist is not met
wait(-10); //to wait 10 seconds after it has been destroyed for example
Ammo_Pickup1=ent_create(ammo.mdl,position,Ammo_Pickup_Action); //create it again re-using the global pointer 10 seconds after it has been removed
}
Then all that is left to do is create your first one like this, and it will automatically work and when it finished destroys itself, waits 10 seconds, and re-creates another copy of itself:
Ammo_Pickup1=ent_create(ammo.mdl,position,Ammo_Pickup_Action);
|
|
|
Re: Making an entity spawn every so often?
[Re: Bloodtake23]
#399707
04/18/12 19:04
04/18/12 19:04
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
simply create a dummy mdl and place them where you want to in wed and assign a action(code) to that dummy mdl ..
then run the function he gave you from your action
function Ammo_Pickup() { //the code he gave you }
//the position gan then be retrieved from me/you pointers //you would know wich one i suppose
action whatever() { ammo_pickup(); }
Last edited by Wjbender; 04/18/12 19:14.
Compulsive compiler
|
|
|
Re: Making an entity spawn every so often?
[Re: Wjbender]
#399733
04/19/12 00:34
04/19/12 00:34
|
Joined: Oct 2008
Posts: 513
Carlos3DGS
User
|
User
Joined: Oct 2008
Posts: 513
|
action Ammo_Pickup_Action()
{
VECTOR create_pos; //vector for storing starting position
vec_set(create_pos.x,my.x); //save initial position
while(condition for being alive)
{
//code to execute while alive (like spinning, moving, detecting when it has been picked up,etc)
//condition check for while loop to end when the object should be destroyed
wait(1);
}
ent_remove(me); //destroy when its condition to exsist is not met
wait(-10); //to wait 10 seconds after it has been destroyed for example
ent_create("ammo.mdl",create_pos,Ammo_Pickup_Action); //create it again re-using the local vector's stored position 10 seconds after it has been removed
}
There you go, I added two lines at the begining of the function to create a local vector and set it to store the entitie's position on creation. Also modified the new entity creation line at the end to use that local vector. Assuming you are using simple scripts, I removed the need for a global entity pointer. If you are placing in wed, all you need to do is place the object and apply this action, nothing more required (besides filling in the while condition with what you want the entity to do and something to stop the while loop when it should be destroyed).
|
|
|
|