Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
4 registered members (fogman, Grant, AndrewAMD, juanex), 989 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Spawn system question #359122
02/15/11 19:15
02/15/11 19:15
Joined: Apr 2005
Posts: 795
U.S.A. Michigan
exile Offline OP
User
exile  Offline OP
User

Joined: Apr 2005
Posts: 795
U.S.A. Michigan
Hey there, I have been racking my brain going crazy trying to find a suitable method for a spawn system in my game. So far, here is the system I have thought of.

1. At the start of the game, the number of spawn points would be counted. This number would then become the "maxNumSpawns" variable, and each point will have their skill99 defined with a "spawnID".
2. In a loop, each spawn point would be scanning in a range of 200ft to count how many "enemies" are near it. The number of enemies near the spawn point would then become "skill98".
3. When a player dies, the game will scan to see which spawn points have the lowest number of enemies near it, then this number becomes the "availableSpawnPoints" variable and the "spawnID" of each point is taken as well.
4. Finally, the game takes the "availableSpawnPoints" variable and picks a random number between 1 and the variable, then creates the player at the proper location using the "spawnID".

I already have my netcode finished, I just need a proper spawning system. Any ideas how I can achieve something like this?

Last edited by exile; 02/15/11 19:18.
Re: Spawn system question [Re: exile] #359125
02/15/11 19:26
02/15/11 19:26
Joined: Jul 2005
Posts: 187
L
lostzac Offline
Member
lostzac  Offline
Member
L

Joined: Jul 2005
Posts: 187
After reading this I have come up with several ideas on how to do it for you, I am going to go play around with it, and Ill put a working code example up latter for you


John C Leutz II

Re: Spawn system question [Re: lostzac] #359148
02/15/11 21:45
02/15/11 21:45
Joined: Jul 2005
Posts: 187
L
lostzac Offline
Member
lostzac  Offline
Member
L

Joined: Jul 2005
Posts: 187
Here is a way to do it...that I came up with at the top of my head I haven't tested it so let me know

ENTITY* spawn_point;
#define mycount skill99
#define scanned skill99 //This skill is for your enemies
//This is your spawn action
action spawn()
{
spawn_point = me;

while(1)
{
//Make sure your enemies have enable_scan on
c_scan(my.x,my.pan,vector(3600,0,200),SCAN_ENTS | SCAN_LIMIT);
if(you) //we have found an enemy
{
//Check to see if we counted this enemy
if(you.scanned != ptr_for_handle(me)) //We havent scanned this
{
my.mycount ++; //Add 1 to our count
you.scanned = handle(me);
}
}
wait(1);
}
}


//Now for the spawn
//This will go through all the spawn points once it is done
// the spawn point with the least enemy count is your spawn point
function respawn_player()
{
var last_count = 0;
var this_count;
var spawn_id;

you = ent_next(spawn_point);
while(you)
{
if(last_count != 0) //We have started our comparison counts
{
this_count = you.mycount;
if(this_count < last_count) //Does this one have less Enemies
{
spawn_id = handle(you);
last_count = this_count;
you = ent_next(spawn_point);
}
else
{
you = ent_next(spawn_point);
}
}
else
{
//This is our first spawn_point
last_count = you.mycount;
spawn_id = handle(you);
you = ent_next(spawn_point);
}
}

ENTITY* respawn = ptr_for_handle(spawn_id);
ent_create(some_model,respawn.x,some_func);

}


The only thing I have not accounted for is an enemy leaving the scanned area and subtracting it from the spawn counter or a recount to it....but this should get you started


John C Leutz II

Re: Spawn system question [Re: lostzac] #359186
02/16/11 00:30
02/16/11 00:30
Joined: Apr 2005
Posts: 795
U.S.A. Michigan
exile Offline OP
User
exile  Offline OP
User

Joined: Apr 2005
Posts: 795
U.S.A. Michigan
Great work lostzac, this is definitely a great start! I'll try and refine thsystem and hopefully get a working demo up and running. With any luck, if I can refine this to be perfect, I will upload it to the wiki!

Re: Spawn system question [Re: exile] #359237
02/16/11 11:57
02/16/11 11:57
Joined: Jul 2005
Posts: 187
L
lostzac Offline
Member
lostzac  Offline
Member
L

Joined: Jul 2005
Posts: 187
If you need some more help with it message me, and Ill see what I can do


John C Leutz II


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