Random spawnpoint ?

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Gizzy (nl)
Sergeant Major
Posts: 101
Joined: Tue Dec 03, 2002 3:41 pm
Location: Netherlands
Contact:

Random spawnpoint ?

Post 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 ???
greets, Gizzy (nl)

Image
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Yeah I've got that working in my bot script :P :lol:.

I'll post some code later ;).
Image
Gizzy (nl)
Sergeant Major
Posts: 101
Joined: Tue Dec 03, 2002 3:41 pm
Location: Netherlands
Contact:

Post by Gizzy (nl) »

nice...this world is so wonderfull...tada.... 8) :lol: :D :wink: :idea:
greets, Gizzy (nl)

Image
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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.
Image
Gizzy (nl)
Sergeant Major
Posts: 101
Joined: Tue Dec 03, 2002 3:41 pm
Location: Netherlands
Contact:

Post by Gizzy (nl) »

thank you thank you very much... dankjewel...tack so myckett...
greets, Gizzy (nl)

Image
Guest

Post 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?
User avatar
mohaa_rox
Field Marshal
Posts: 2760
Joined: Mon Nov 11, 2002 7:05 am
Contact:

Post by mohaa_rox »

Maybe not in SP, but I don't know.
Live to map, not map to live.
-mohaa_rox, .map
moderator
Slyk
Lieutenant Colonel
Posts: 361
Joined: Sun Jul 14, 2002 12:42 am
Location: Elizabethtown, PA

Post 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.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Uh honestly I have no idea where you're talking about :oops:

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 :?.
Image
User avatar
mohaa_rox
Field Marshal
Posts: 2760
Joined: Mon Nov 11, 2002 7:05 am
Contact:

Post 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.
Live to map, not map to live.
-mohaa_rox, .map
moderator
Slyk
Lieutenant Colonel
Posts: 361
Joined: Sun Jul 14, 2002 12:42 am
Location: Elizabethtown, PA

Post 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. :roll:
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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.
Image
Slyk
Lieutenant Colonel
Posts: 361
Joined: Sun Jul 14, 2002 12:42 am
Location: Elizabethtown, PA

Post 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????? :D Long time since I bugged ya with that one. I appreciate the help above though, muchly!
Slyk
Lieutenant Colonel
Posts: 361
Joined: Sun Jul 14, 2002 12:42 am
Location: Elizabethtown, PA

Post 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........
User avatar
mohaa_rox
Field Marshal
Posts: 2760
Joined: Mon Nov 11, 2002 7:05 am
Contact:

Post by mohaa_rox »

You mean you want your trucks to be bombed? There's a tut @ Nemesis Page I think.
Live to map, not map to live.
-mohaa_rox, .map
moderator
Post Reply