Forum Thread
  Posts  
Troops spawning code made easy. (Forums : Coding & Scripting : Troops spawning code made easy.) Locked
Thread Options
Tei
Tei Enginecoder
May 21 2003 Anchor

float iterations;

vector resetloc;

vector (vector loc ) GetSafeSP =
{
local float pos;

trace_ent = world;

traceline(loc,loc+'0 0 -500',FALSE,world);
// gLine(loc, loc+'0 0 -500','0 255 0');

if(!trace_ent)
traceline(loc,loc+'9 0 -500',FALSE,world);
if(!trace_ent)
traceline(loc,loc+'-9 0 -500',FALSE,world);
if(!trace_ent)
traceline(loc,loc+'0 9 -500',FALSE,world);
if(!trace_ent)
traceline(loc,loc+'0 -9 -500',FALSE,world);
if(!trace_ent)
traceline(loc,loc+'-9 -9 -500',FALSE,world);
if(!trace_ent)
traceline(loc,loc+'9 9 -500',FALSE,world);
if(!trace_ent)
traceline(loc,loc+'-9 9 -500',FALSE,world);
if(!trace_ent)
traceline(loc,loc+'9 -9 -500',FALSE,world);

pos = pointcontents(loc);

if(trace_ent || pos == CONTENT_SOLID)
{
if (pos == CONTENT_SOLID)
{
loc = resetloc;
if (iterations > 100) //Anticrash code
{
//print("anti runaway code..\n");//Remove at release
return resetloc;
}
}

loc_x = loc_x +crandom()*100;
loc_y = loc_y +crandom()*100;
//bprint("traceent ", trace_ent.model,"\n");
loc = GetSafeSP(loc);
}

return loc;
};


This search for a non-solid location to spawn troops.

chis
chis Old man.
May 22 2003 Anchor

and what does that do where would you enter it out, eh, hi... :)

--

Nothing.

Tei
Tei Enginecoder
May 22 2003 Anchor

I use my own editor, ::TeiCoder::.

The code is designed for a engine that support QC scripting and tracelines, but you can rewrite easy for other engines, C, C++, TK,... or whatever.

Is not perfect but is better than nothing.

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.