Vehicle Spawn Delay

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
DakkerDB

Vehicle Spawn Delay

Post by DakkerDB »

This may seem like a stupid question, but I wish to know how to make the initial spawn of a vehicle take place after a certain ammount of time has passed. I don't mean respawn.

The situation is: I want to make an AT-TE spawn at an uncapturable commandpost after about 3 minutes of game time have passed, is it possible to do so?

I've tried searching the forums, and I'm quite confused when it comes to understanding every little bit of the documentation.

The answer to this question is probably basic and somewhere in the documentation, but I've probably missed it. :p

Thanks for the help in advance.
User avatar
Rends
Sith
Sith
Posts: 1278
Joined: Fri Oct 15, 2004 6:34 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Germany
Contact:

RE: Vehicle Spawn Delay

Post by Rends »

select the spawn_item_vehicle_ spawn and set the time in the Spawntime option box you find under object instance.
DakkerDB

RE: Vehicle Spawn Delay

Post by DakkerDB »

I'm pretty sure that sets the respawn only. My AT-TE spawns at the start of the game and respawns after the time specified after being destroyed.
Captain_Mazda

RE: Vehicle Spawn Delay

Post by Captain_Mazda »

In short, I don't think so.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

RE: Vehicle Spawn Delay

Post by [RDH]Zerted »

Start a 3 minute timer when your map begins. When the timer ends, spawn the AT-AE. You can spawn the At-AE with CreateEntity("[vehicle odf]", [spawn location], "[object name]")

Example lua code:
--put this right after "ScriptPostLoad()"
ATAESpawnTimer();

--put this after ScriptPostLoad()'s "end" and before the start of "ScriptInit()"
function ATAESpawnTimer()
ATAE_timer = CreateTimer( "ATAE_timer" )
SetTimerValue( ATAE_timer, 180 )
StartTimer( "ATAE_timer" )
ShowTimer( ATAE_timer )
ATAE_elaspe = OnTimerElaspe(
function(timer)
CreateEntity( "rep_walk_atte", [vehicle spawn], "ATAE" )
end, ATAE_timer
)
end
[vehicle spawn] should be the only thing you need to change. You don't need the "ShowTimer()", but its good to see when you are trying to get it working. The code can be improved, its just a starting point.
DakkerDB

RE: Vehicle Spawn Delay

Post by DakkerDB »

I'm pretty sure you mean AT-TE, not AT-AE... but thanks a lot for the help.

Only problem is, I have no idea how to do the timer thing and stuff.

Edit: Very bad timing. Me posting right when you edit your post. <.<
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

RE: Vehicle Spawn Delay

Post by [RDH]Zerted »

I tested the timer out. It should work. SetTimerValue uses seconds. I haven't tested the CreateEntity(). By the examples for the scripts, it should work. I don't have the time right now to setup a map with vehicles to test that section out.
DakkerDB

RE: Vehicle Spawn Delay

Post by DakkerDB »

I don't think the CreateEntity() works... my map crashes when the time runs out. Oh and, you made a typo.
ATAE_elaspe = OnTimerElaspe
Shouldn't that be elapse?
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

RE: Vehicle Spawn Delay

Post by [RDH]Zerted »

Yeah, I didn't directly test the timer code, I typed it up after I tested a different timer.

I was messing around with creating an infantry unit. Even when CreateEntity() didn't work, it never crashed the map. Did you add the memory for the walker? Did you remember to read in the rep_walk_atte?

You could try disabling the spawn point, then enabling it when the timer runs out instead of using CreateEntity().
DakkerDB

RE: Vehicle Spawn Delay

Post by DakkerDB »

Been trying a lot of different things throughout the day. It either doesn't work, or it crashes.

Although I kinda got the AT-TE into a disabled state until the timer runs out. But that doesn't really work well, since the jedi can destroy it when it is disabled.

How to disable the spawn point? I've tried a few methods, but not none really gave the desired results. Hopefully, I'm just missing something, and this can be actually done.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

RE: Vehicle Spawn Delay

Post by [RDH]Zerted »

This can be done, we are just trying to get it working the better way (using CreateEntity() ). CreateEntity() isn't documented, so thats why we are having problems with it.

There are many ways to do what you want. Another way would be to spawn the AT-TE under the ground on a platform. After the timer is up, run an animation which moves the platform (and thus the AT-TE) up to ground level (a simple elevator). Now reset the animation. The AT-TE will now be sitting on the ground and the platform is at its starting point to 'catch' another spawning AT-TE. You want the platform to move really fast or the players will notice the AT-TE slowing comming out of the gound. However if you make it too fast, the platform may 'jump' to ground level letting the AT-TE fall into nothingness.

You can also blow up the AT-TE on its first spawn. Then the spawn point's timer will kick in and spawn the AT-TE in 3 minutes.

Here are some CreateEntity() examples from the game code:
CreateEntity("dea_icon_disk", PlansSpawn, "plans") --spawns the flag
CreateEntity("fel1_flag_powercell", PowerCellSpawn, "powercell") --Spawns the Holocron.
CreateEntity("geo1_flag_disk", plans_spawn, "plans") --spawns the flag
CreateEntity("hot1_flag_bomb", Holocron1Spawn, "holodisk")
CreateEntity("mus_flag_bomb", bomblocation2, "bomb2") --spawns the bomb
CreateEntity("myg1_flag_crystal", Holocron1Spawn, "crystal") --spawns the disk
DakkerDB

RE: Vehicle Spawn Delay

Post by DakkerDB »

I figured out how to use CreateEntity, but apparently a vehicle spawn is a too complicated thing to use. And destroying the AT-TE on its initial spawn doesn't help that much either. That crashes the level too. Maybe vehicle spawns are just too complicated.

I'll keep messing around with it today. Hopefully I will find somethng.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

RE: Vehicle Spawn Delay

Post by [RDH]Zerted »

How did you get CreateEntity to work?
DakkerDB

Post by DakkerDB »

Code: Select all

        Holocron1Spawn = GetPathPoint("becon", 0)
        CreateEntity("hot1_flag_bomb", Holocron1Spawn, "holodisk")
You put a simple spawnpath with one node on your node. In the shipped Hoth level, we have one called "becon". In the level scrip, they make the Holocron1Spawn use the path called "becon", then they use the path to create an entity in the place of that path.

Not too hard.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Post by [RDH]Zerted »

Ahh, I look at everything first in terms of single lines so I missed that.
Post Reply