Elevator Pathing Script-Functions not carried out!

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
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Elevator Pathing Script-Functions not carried out!

Post by Ace_Azzameen_5 »

For some reason the following script, designed to to disable plans and barriers (objects too) coninciding with an animated elevator, neglects to kill and respawn objets and apparently, the pathing funtions. However, the next timer is created and started. Any ideas? Also, the spelling is right (I think)
--ELEVATOR1 PLANNING
--///vvvbegin sequence
PlayAnimation("Elevator")
BlockPlanningGraphArcs("Elevator1-down")
BlockPlanningGraphArcs("Elevator1-up")
CreateTimer("Elevator1")--Creates
SetTimerRate("Elevator1", 1)--Sets the rate
SetTimerValue("Elevator1", 10)--and value of
StartTimer("Elevator1")--then starts the downgoing timer
ShowTimer("Elevator1")
--///^^^begin sequence

--///vvvDownGoingTimerElapse-What happens when the downgoing timer ends
OnTimerElapse(
function(timer)
UnblockPlanningGraphArcs("Elevator1-up")--allows units to follow plans onto elevator at bottom
KillObject("elebars2")
KillObject("elebars3")
CreateTimer("Elevator12")--Creates
SetTimerRate("Elevator12", 1)--Sets the rate
SetTimerValue("Elevator12", 20)--and value of
StartTimer("Elevator12")--then starts the bottomwait timer
ShowTimer("Elevator12")
end,

"Elevator1"
)
--///^^^DowngoingTimerElapse

--///vvvbottomwait timer elapse-Stuff that happens when the elevator starts going back up

OnTimerElapse(
function(timer)
BlockPlanningGraphArcs("Elevator1-up")
RespawnObject("elebars2")
RespawnObject("elebars3")
CreateTimer("Elevator13")--Creates
SetTimerRate("Elevator13", 1)--Sets the rate
SetTimerValue("Elevator13", 10)--and value of
StartTimer("Elevator13")--then starts the upgoing timer
ShowTimer("Elevator13")
end,

"Elevator12"
)
--///^^^bottomwait timer elapse

--///vvv upgoing timer elapse-Stuff that happens when the elevator reaches the top again
OnTimerElapse(
function(timer)
DisableBarriers("Elevator1-top")
UnblockPlanningGraphArcs("Elevator1-down")
KillObject("elebars1")
CreateTimer("Elevator14")--Creates
SetTimerRate("Elevator14", 1)--Sets the rate
SetTimerValue("Elevator14", 20)--and value of
StartTimer("Elevator14")--then starts the top waiting timer
ShowTimer("Elevator14")

end,

"Elevator13"
)
--///^^^ upgoing timer elapse

--///vvv top wait timer elapse-Stuff that happens when the elevator starts going back down
RespawnObject("elebars1")
SetTimerRate("Elevator1", 1)--reSets the rate
SetTimerValue("Elevator1", 10)--and value of
StartTimer("Elevator1")--then restarts the downgoing timer
ShowTimer("Elevator1")
--///^^^ top wait timer elapse
--end ELEVATOR1 PLANNING
Edit: The Timer Elevator13 never starts. But the elapse of TImer Elevator1 triggers Timer Elevator 12, without killing the objects or paths.
archer01

Post by archer01 »

First off, NEVER use CreateTimer() inside a timer elapse function. Every time the function runs it will create a new timer and there is no telling what that is doing inside the computer's memory. Create all the timers you need at the top. Even when a timer finishes, it doesn't disappear until you use the DestroyTimer() function. Just keep setting the timer time then starting/stopping it as needed.

Secondly, the planning you are trying to disable/enable, are they "dynamic" connections. Only dynamic planning can be turned on/off at runtime.

Third, are the things you are trying to kill 'props' or 'buildings'? Only entities (like soldiers and destroyables) can be killed using KillObject(). Props/buildings cannot.
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: Elevator Pathing Script-Functions not carried out!

Post by [RDH]Zerted »

You are saying:
Paths blocked
Timer 1 starts
Timer 1 ends
No paths unblocked
No objects killed
Timer 12 starts
Timer 12 ends
No paths blocked
No objects respawned
(13 never starts)

General Tip for debugging:
You can place ShowMessageText("") in your code, then count the number of times it shows up ingame to see which sections of code are really running and which fail to run.
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

RE: Elevator Pathing Script-Functions not carried out!

Post by Ace_Azzameen_5 »

Thanks again.

So, Create 'n' rate all timers directly in post load, and only start them in the elapse.

And, there's no elapse event for timer 14 . . .
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: Elevator Pathing Script-Functions not carried out!

Post by [RDH]Zerted »

If there is no elapse event for a timer, then there is no reason to have that timer. Unless its counting up how long the map has been playing. Though timers don't count up so...
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

RE: Elevator Pathing Script-Functions not carried out!

Post by Ace_Azzameen_5 »

No, It was another mistake, I forget to type in the OntimerElapse( etc around the functions I wanted executed, thats all.
Post Reply