Jump to content

Need experienced modding help fixing a script


Recommended Posts

Hey there. I've been trying to make a script that does the following:

 

-once you enter an area, three sets of cannons "fire" around you at random locations

-each cannon as a specified fire time, like once every 5 seconds, ext

-once you destroy the cannons, they stop firing

 

Here's what my script looks like:

 

scn ZLQ4ArtilleryHitScript

 

short Artillery1Destroyed

short Artillery2Destroyed

short Artillery3Destroyed

 

float timer1

float timer2

float timer3

 

short randomspot1

short randomspot2

 

Begin OnTriggerEnter Player

 

If GetStage ZLegionQuest3 == 1 && Artillery1Destroyed == 0

 

set timer1 to (timer1 + GetSecondsPassed)

 

Endif

 

If GetStage ZLegionQuest3 == 1 && Artillery2Destroyed == 0

 

set timer2 to (timer2 + GetSecondsPassed)

 

Endif

 

If GetStage ZLegionQuest3 == 1 && Artillery3Destroyed == 0

 

set timer3 to (timer3 + GetSecondsPassed)

 

Endif

 

If GetStage ZLegionQuest4 == 1 && Artillery1Destroyed == 0

 

set timer1 to (timer1 + GetSecondsPassed)

 

Endif

 

If GetStage ZLegionQuest4 == 1 && Artillery2Destroyed == 0

 

set timer2 to (timer2 + GetSecondsPassed)

 

Endif

 

If GetStage ZLegionQuest4 == 1 && Artillery3Destroyed == 0

 

set timer3 to (timer3 + GetSecondsPassed)

 

Endif

 

End

 

Begin Gamemode

 

If timer1 >= 5 && Artillery1Destroyed == 0

 

set randomspot1 to (GetRandomPercent * 5)

set randomspot2 to (GetRandomPercent * 10)

 

ZLQ4ArtilleryHit1.moveto player randomspot1 randomspot2 0

ZLQ4ArtilleryHit1.placeatme MissileExplosion

 

set timer1 to 0

set timer1 to (timer1 + GetSecondsPassed)

 

endif

 

If timer2 >= 8 && Artillery2Destroyed == 0

 

set randomspot1 to (GetRandomPercent * 5)

set randomspot2 to (GetRandomPercent * 10)

 

ZLQ4ArtilleryHit2.moveto player randomspot1 randomspot2 0

ZLQ4ArtilleryHit2.placeatme MissileExplosion

 

set timer2 to 0

set timer2 to (timer1 + GetSecondsPassed)

 

endif

 

If timer3 >= 7 && Artillery3Destroyed == 0

 

set randomspot1 to (GetRandomPercent * 5)

set randomspot2 to (GetRandomPercent * 10)

 

ZLQ4ArtilleryHit3.moveto player randomspot1 randomspot2 0

ZLQ4ArtilleryHit3.placeatme MissileExplosion

 

set timer3 to 0

set timer3 to (timer1 + GetSecondsPassed)

 

endif

 

End

 

Begin Gamemode

 

If ZArtillery1.GetDestroyed == 1

 

Set Artillery1Destroyed to 2

 

endif

 

If ZArtillery2.GetDestroyed == 1

 

Set Artillery2Destroyed to 2

 

endif

 

If ZArtillery3.GetDestroyed == 1

 

Set Artillery3Destroyed to 2

 

endif

 

End

 

 

NOTHING WORKS THOUGH! EVEN THE SECOND I ENTER THE TRIGGER ZONE, NOTHING HAPPENS! WHAT CAN I DO TO FIX THIS SCRIPT!?!?!

Link to comment
Share on other sites

Hey there. I've been trying to make a script that does the following:

 

-once you enter an area, three sets of cannons "fire" around you at random locations

-each cannon as a specified fire time, like once every 5 seconds, ext

-once you destroy the cannons, they stop firing

 

Here's what my script looks like:

 

I'll repost it within [ code ] tags, add some indenting, and a few other logic adjustments.

scn ZLQ4ArtilleryHitScript

short Artillery1Destroyed
short Artillery2Destroyed
short Artillery3Destroyed

float timer1
float timer2
float timer3

short randomspot1
short randomspot2

Begin OnTriggerEnter Player

 If GetStage ZLegionQuest3 == 1
   If Artillery1Destroyed == 0
     set timer1 to (timer1 + GetSecondsPassed)
   Endif

   If Artillery2Destroyed == 0
     set timer2 to (timer2 + GetSecondsPassed)
   Endif

   If Artillery3Destroyed == 0
     set timer3 to (timer3 + GetSecondsPassed)
   Endif
 Endif

 If GetStage ZLegionQuest4 == 1
   If Artillery1Destroyed == 0
     set timer1 to (timer1 + GetSecondsPassed)
   Endif

   If Artillery2Destroyed == 0
     set timer2 to (timer2 + GetSecondsPassed)
   Endif

   If Artillery3Destroyed == 0
     set timer3 to (timer3 + GetSecondsPassed)
   Endif
 Endif

End

Begin Gamemode

 If timer1 >= 5 && Artillery1Destroyed == 0
   set randomspot1 to (GetRandomPercent * 5)
   set randomspot2 to (GetRandomPercent * 10)
   ZLQ4ArtilleryHit1.moveto player randomspot1 randomspot2 0
   ZLQ4ArtilleryHit1.placeatme MissileExplosion
   set timer1 to 0
   set timer1 to (timer1 + GetSecondsPassed)
 endif

 If timer2 >= 8 && Artillery2Destroyed == 0
   set randomspot1 to (GetRandomPercent * 5)
   set randomspot2 to (GetRandomPercent * 10)
   ZLQ4ArtilleryHit2.moveto player randomspot1 randomspot2 0
   ZLQ4ArtilleryHit2.placeatme MissileExplosion
   set timer2 to 0
   set timer2 to (timer1 + GetSecondsPassed)
 endif

 If timer3 >= 7 && Artillery3Destroyed == 0
   set randomspot1 to (GetRandomPercent * 5)
   set randomspot2 to (GetRandomPercent * 10)
   ZLQ4ArtilleryHit3.moveto player randomspot1 randomspot2 0
   ZLQ4ArtilleryHit3.placeatme MissileExplosion
   set timer3 to 0
   set timer3 to (timer1 + GetSecondsPassed)
 endif

 If ZArtillery1.GetDestroyed == 1
   Set Artillery1Destroyed to 2
 endif

 If ZArtillery2.GetDestroyed == 1
   Set Artillery2Destroyed to 2
 endif

 If ZArtillery3.GetDestroyed == 1
   Set Artillery3Destroyed to 2
 endif

End

 

Looks like you are not incrementing your timers, so the gamemode checks never fire.

Link to comment
Share on other sites

OK, after looking at the formatted version I think I get what you are trying to do.

I've added an 'IsFiring' variable too.

It should start if you've set one of those 2 quests to stage 1

 

scn ZLQ4ArtilleryHitScript

short Artillery1Destroyed
short Artillery2Destroyed
short Artillery3Destroyed

float timer1
float timer2
float timer3

short randomspot1
short randomspot2

short IsFiring

Begin OnTriggerEnter Player

 If GetStage ZLegionQuest3 == 1
   set IsFiring to 1
 ElseIf GetStage ZLegionQuest4 == 1
   set IsFiring to 1
 Endif

 If IsFiring
   ;Set these higher if you want all three to immediately fire.
   set timer1 to 0
   set timer2 to 0
   set timer3 to 0
 Endif

End

Begin Gamemode

 If ZArtillery1.GetDestroyed == 1
   Set Artillery1Destroyed to 2
 endif

 If ZArtillery2.GetDestroyed == 1
   Set Artillery2Destroyed to 2
 endif

 If ZArtillery3.GetDestroyed == 1
   Set Artillery3Destroyed to 2
 endif

 If ( (Artillery1Destroyed + Artillery2Destroyed + Artillery3Destroyed ) == 6)
   set IsFiring to 0
 Endif

 If IsFiring
   set timer1 to (timer1 + GetSecondsPassed)
   set timer2 to (timer2 + GetSecondsPassed)
   set timer3 to (timer3 + GetSecondsPassed)
 Else
   return
 Endif

 If timer1 >= 5 && Artillery1Destroyed == 0
   set randomspot1 to (GetRandomPercent * 5)
   set randomspot2 to (GetRandomPercent * 10)
   ZLQ4ArtilleryHit1.moveto player randomspot1 randomspot2 0
   ZLQ4ArtilleryHit1.placeatme MissileExplosion
   set timer1 to 0
 endif

 If timer2 >= 8 && Artillery2Destroyed == 0
   set randomspot1 to (GetRandomPercent * 5)
   set randomspot2 to (GetRandomPercent * 10)
   ZLQ4ArtilleryHit2.moveto player randomspot1 randomspot2 0
   ZLQ4ArtilleryHit2.placeatme MissileExplosion
   set timer2 to 0
 endif

 If timer3 >= 7 && Artillery3Destroyed == 0
   set randomspot1 to (GetRandomPercent * 5)
   set randomspot2 to (GetRandomPercent * 10)
   ZLQ4ArtilleryHit3.moveto player randomspot1 randomspot2 0
   ZLQ4ArtilleryHit3.placeatme MissileExplosion
   set timer3 to 0
 endif

End

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...