Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,306 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Making an entity spawn every so often? #399641
04/17/12 22:52
04/17/12 22:52
Joined: Aug 2009
Posts: 8
Bloodtake23 Offline OP
Newbie
Bloodtake23  Offline OP
Newbie

Joined: Aug 2009
Posts: 8
Hello,

I want to have a spawn system for ammo packs that will drop from the sky every 2 minutes. I also want to have an Enemy spawn every 10 seconds. Is there a bit of code for a action that I can assign to a model in WED?

Thanks in advance!

Re: Making an entity spawn every so often? [Re: Bloodtake23] #399648
04/18/12 00:13
04/18/12 00:13
Joined: Aug 2009
Posts: 8
Bloodtake23 Offline OP
Newbie
Bloodtake23  Offline OP
Newbie

Joined: Aug 2009
Posts: 8
It also needs to be in a specific area! laugh

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 Offline
User
Carlos3DGS  Offline
User

Joined: Oct 2008
Posts: 513
declare a global entity pointer for each object you want to use this like so:

Code:
ENTITY* Ammo_Pickup1;




then create an action like this:

Code:
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:

Code:
Ammo_Pickup1=ent_create(ammo.mdl,position,Ammo_Pickup_Action);




"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1
Re: Making an entity spawn every so often? [Re: Bloodtake23] #399699
04/18/12 17:25
04/18/12 17:25
Joined: Aug 2009
Posts: 8
Bloodtake23 Offline OP
Newbie
Bloodtake23  Offline OP
Newbie

Joined: Aug 2009
Posts: 8
For the position bit what should it look like? Also can I use my or another term to just do it where I put it in my wmb file?

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
W
Wjbender Offline
User
Wjbender  Offline
User
W

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 Offline
User
Carlos3DGS  Offline
User

Joined: Oct 2008
Posts: 513
Code:
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).


"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1