Page 1 of 1
Random spawnpoint ?
Posted: Mon Dec 23, 2002 8:33 am
by Gizzy (nl)
I was wondering if it is possible to make random spawnpoints? When the level loads it should spawn an ai actor, but when it reloads, the ai should spawn somewhere else...any idea ???
Posted: Mon Dec 23, 2002 8:35 am
by jv_map
Yeah I've got that working in my bot script

.
I'll post some code later

.
Posted: Mon Dec 23, 2002 9:28 am
by Gizzy (nl)
Posted: Mon Dec 23, 2002 9:36 am
by jv_map
I guess something like this will work. For example create a bunch of script_origins where you want a particular actor to spawn. Targetname them
all the same, e.g. 'spawn1'.
Then create a thread like this in your script:
Code: Select all
spawn local.num:
// find a spawnpoint
local.spawnpoints = $("spawn" + local.num)
// local.spawnpoints is now the list of available spawnpoints
// find a random index
local.index = randomint (local.spawnpoints.size - 1) + 1
// randomint <max> returns a number between o and max
// so randomint <size - 1> returns a number between o and
// the number of spawnpoints - 1
// after +1 local.index is a number between 1 and the number
// of spawnpoints.
local.spawnpoint = local.spawnpoints[local.index]
// ordinary spawn code here, e.g.
local.enemy = spawn models/human/german_waffenss_nco.tik
local.enemy.origin = local.spawnpoint.origin
local.enemy.angles = local.spawnpoint.angles
end
You can make endless variations to this script if you want.
Posted: Mon Dec 23, 2002 9:59 am
by Gizzy (nl)
thank you thank you very much... dankjewel...tack so myckett...
Posted: Sat Jan 11, 2003 12:34 am
by Guest
So could you use the random spawn point to say - make a player with weapon a) spawn to the north, weapon b spawn to the south, etc? Im talking player spawn, not bots? Something like that possible?
Posted: Sat Jan 11, 2003 1:14 am
by mohaa_rox
Maybe not in SP, but I don't know.
Posted: Thu Jan 30, 2003 1:42 pm
by Slyk
Aging thread, but new question as I'm kinda dumb on this stuff....
IF I want to randomize the locations of both ALLIED and AXIS spawn objectives, i.e. Opel trucks that when blown stop that side from respawning, would I just replace the text:
local.enemy with local.allied_truck_spawner
if that is the target name for the allied spawner objective???? Where else then would I need to code the target names? I'm guessing anywhere that 'spawn' or 'spawnpoints' is used, I need to prefix it with "targetname_".
and then the model tik, of course, I'd replace with the truck model code.
Understand me?? I hope.
Posted: Thu Jan 30, 2003 2:29 pm
by jv_map
Uh honestly I have no idea where you're talking about
Maybe you're used to global/ai.scr, but the code posted above doesn't use it. So you only have to replace the model name. Also, a truck probably needs a collisionent and destroyed model code.
To set a targetname, just set 'local.enemy.targetname = mytargetname', but there's really no use for that.
Hope I cleared some clouds, otherwise please clear some clouds for me

.
Posted: Thu Jan 30, 2003 3:30 pm
by mohaa_rox
Do you mean something like the TOW? Where by the enemy has to destroy the spawn points? This can be found @
http://www.3dchad.com.
Posted: Thu Jan 30, 2003 7:27 pm
by Slyk
OK, sorry.......about the confusion. Don't look for it to end too soon.
Firstly, yes, I've used Chad's tutorial to great success on most points. I combined it with the 'Flughafen' script and got my Tractor Works TOW moving forward, still having scoreboard issues in showing properly though. Chad's looking at it now.
What I'm talking about in the above is a straight forward example for random spawn locations for an ALLY and AXIS truck. Yep, did the destroyed model thing and the collision stuff. Works fine but just wanted to trouble shoot the random spawn thing. I've got three switches that at least two will be stagnant, always in the same location. I'd like to have BOTH spawn objectives (trucks) bounce around to one of three spots to force play to flow differently each round. Also, if possible, I'd like to float the one switch around one of the big buildings (generator objective).
Damn wordy, but hopefully more clear.

Posted: Thu Jan 30, 2003 7:59 pm
by jv_map
There you go:
Code: Select all
spawn local.team:
local.spawnpoints = $(local.team + "spawn")
local.index = randomint (local.spawnpoints.size - 1) + 1
local.spawnpoint = local.spawnpoints[local.index]
local.truck = spawn models/vehicles/opeltruck.tik
local.truck.origin = local.spawnpoint.origin
local.truck.angles = local.spawnpoint.angles
// collisionent and other code here
local.truck waittill death
// destroyed model code here, maybe a teamwin?
end
Then in your main thread add:
thread spawn allies
thread spawn axis
In your map, use $alliesspawn entities for allied trucks and $axisspawn for axis trucks. If you want to use the same spawn points for both teams, just enter the same team name for both trucks, e.g.
thread spawn allies
thread spawn allies
If you want to spawn more trucks, you'd best use a for loop. If you need any more special code, you'll also need some small modifications.
Posted: Thu Jan 30, 2003 8:10 pm
by Slyk
HAHA! I knew if I could hang around long enough without the boss knowing it you would come up with an answer! Wahoooo....... but, that assumes I can place everything correctly!
Many thanks, JV. Just gonna be one truck per side for now.
Although you did tweak my interest in 're-spawning' the spawner.... hmmmm... like if you can reach a certain trigger, your 'transport/spawner' could be reactivated...like getting reinforcements??? Sound possible?? I've got a ton of ideas, just not so many answers when it comes to scripts.
By the way, where's my Mark IV/Tiger/T-34 MP scripts?????

Long time since I bugged ya with that one. I appreciate the help above though, muchly!
Posted: Fri Jan 31, 2003 4:18 pm
by Slyk
Ok, idiot at work, so bear with me....
entity info for the trucks:
key: $targetname value: alliesspawn
key: $targetname value: axisspawn
right? You can see how progress goes for my scripting............
Ok, if so, or not, next issue: BINDING the bomb trigger and bomb script object to the trucks, wherever they spawn.
Told ya, idiot at work! IF only mapping included 'drop-ins' and auto-complete scripts.......yeah, and........
Posted: Sat Feb 01, 2003 3:35 am
by mohaa_rox
You mean you want your trucks to be bombed? There's a tut @ Nemesis Page I think.