Jump to content

In need of help scripting explosions...


Mlucci4036

Recommended Posts

Let me try to explain what I was going for here. I've made a location my mod that is essentially a battle between two factions. They are in a stalemate, and there is essentially this large No-Mans-Land between their two trenches. I want to script a sequence that will cause the player to be attacked by mortar and shell fire when her enters this cubic activator, much like the area outside of Nellis Airforce Base when entering the area for the first time. I want this to occur ever time the player enters the activator, but stop when he exits it.

 

I'm not sure quite how to do this, is there anyone that can help me?

 

Here is a reference photo of the location I have made.

Link to comment
Share on other sites

  On 1/18/2015 at 12:55 AM, Ladez said:

Just study how it works for Nellis AFB and adapt it to your own needs. :smile:

I tried, but I just couldn't figure it out for the life of me! There are so many variable in the Nellis Artillery scrip that I have no idea what to edit!

Link to comment
Share on other sites

Take a look at script for NellisArtilleryActivatorEntrance activator. When player enters (begin OnTriggerEnter) some vars are set for begin gamemode block.

Then game randomly creates explosions near player (I think rTarget is set to be player reference somwhere in the script)

					
                                        set fRelativePos to rTarget.GetPos Y + fRandom
					ArtillerySourceMarker.setPos Y fRelativePos
					set fRelativePos to rTarget.GetPos X + fRandom
					ArtillerySourceMarker.setPos X fRelativePos
				        endif
				set angle to ArtillerySourceMarker.GetHeadingAngle NellisMainGateREF
				ArtillerySourceMarker.SetAngle Z angle
				ArtillerySourceMarker.PlaceAtMe FXNellisArtilleryStrike01

Explore this script.

Link to comment
Share on other sites

  On 1/18/2015 at 1:09 PM, tomm434 said:

Take a look at script for NellisArtilleryActivatorEntrance activator. When player enters (begin OnTriggerEnter) some vars are set for begin gamemode block.

Then game randomly creates explosions near player (I think rTarget is set to be player reference somwhere in the script)

					
                                        set fRelativePos to rTarget.GetPos Y + fRandom
					ArtillerySourceMarker.setPos Y fRelativePos
					set fRelativePos to rTarget.GetPos X + fRandom
					ArtillerySourceMarker.setPos X fRelativePos
				        endif
				set angle to ArtillerySourceMarker.GetHeadingAngle NellisMainGateREF
				ArtillerySourceMarker.SetAngle Z angle
				ArtillerySourceMarker.PlaceAtMe FXNellisArtilleryStrike01

Explore this script.

I just spent a good deal of time experimenting with the script, but still no luck. Correct me if I'm wrong, but shouldn't this script run the sequence?

 

scn BigAppleArtilleryScript
int iArtilleryFiring
float pangle
float rangle
float angle
float fRelativePos
float fQuestDelayTime
float fRandom
float timer1
float timer2
int ActorCount ; Tracks the number of actors that have entered the trigger volume
int Boom ; Tracks whether to make the shooting sound
int Fire ; Tracks whether to shoot
int InCover ; This check to see if the player is in cover and make the artillery less accurate
int XOffset
int YOffset
int ZOffset
float Drift
float ActiveTime ; The amount of the time artillery has been active this cycle
float iVariance
ref CurrentActor1 ; These are holder variables for actors that enter the volume
ref CurrentActor2 ; They get cleared by spawned activators every couple of frames
ref CurrentActor3 ; There are 3 in case they don't get cleared before a new actor enters
ref SpawnedRef1 ; See NellisTargetPickerScript (Attached to NellisTargetPicker) for more associated scripting
ref SpawnedRef2
ref SpawnedRef3
ref LeavingActor1
ref LeavingActor2
ref LeavingActor3
ref rActor
ref rTarget
int iRandomTarget ; RandomTargetPicker
float fArtilleryFireRate ;Time between each shell
float fArtilleryFireDuration ;How long the player is shelled for before there is a pause
float fArtilleryReloadTime ;How long it takes the artillery to reload
begin onLoad
set fArtilleryFireRate to 2
set fArtilleryFireDuration to 30
set fArtilleryReloadTime to 15
set Drift to 1.2
end
;; Double comments are for temp fixes
Begin OnTriggerEnter
set rActor to GetActionRef ; Store the current actor in the trigger
if rActor.GetPlayerTeammate == 1 ; Do not run for player teammates
return
endif
End
Begin OnTriggerLeave
set rActor to GetActionRef
if rActor.GetPlayerTeammate == 1 ; Do not run for player teammates
return
endif
End
Begin GameMode
if ActorCount <= 0 && iArtilleryFiring == 1 ; Fallthrough to catch actors dying
set iArtilleryFiring to 0
set ActorCount to 0
set rTarget to 0
set ActiveTime to 0
endif
if iArtilleryFiring == 0 && (Timer1 || Timer2 || Fire || Boom)
set timer1 to 0
set timer2 to 0
set fire to 0
set boom to 0
endif
if iArtilleryFiring == 0
set timer1 to -5
set rTarget to 0
elseif iArtilleryFiring ==1
set ActiveTime to GetSecondsPassed + ActiveTime
if ActiveTime <= 3
set Drift to 5
elseif ActiveTime <= 10
set Drift to 4
elseif ActiveTime <= 12
set Drift to 3
elseif ActiveTime <= 15
set Drift to 2
elseif ActiveTime <= 30
set Drift to 1
else
set Drift to 0
endif
set iRandomTarget to GetRandomPercent
if iRandomTarget >= 0 && CurrentActor1 != 0 && CurrentActor1.GetDead == 0
set rTarget to CurrentActor1
endif
if iRandomTarget >= 33 && CurrentActor2 != 0 && CurrentActor2.GetDead == 0
set rTarget to CurrentActor2
endif
if iRandomTarget >= 67 && CurrentActor3 != 0 && CurrentActor3.GetDead == 0
set rTarget to CurrentActor3
endif
if rTarget == 0 || rTarget.GetDead
set iArtilleryFiring to 0
set ActorCount to 0
set rTarget to 0
set ActiveTime to 0
return
endif
set timer1 to GetSecondsPassed + timer1
set timer2 to GetSecondsPassed + timer2
if timer2 < fArtilleryFireDuration
if boom == 0
set Boom to 1
elseif timer1 >= fArtilleryFireRate && fire == 0
set fire to 1
elseif timer1 > fArtilleryFireRate && fire == 2
set timer1 to 0
set boom to 0
set Fire to 0
endif
elseif timer2 > (fArtilleryReloadTime + fArtilleryFireDuration)
set timer1 to 0
set timer2 to 0
endif
if Fire == 1 && rTarget != 0
set fRandom to GetRandomPercent
if fRandom <= 50
set fRandom to getRandomPercent * 3.0 * Drift ; Was 10* drift
else
set fRandom to getRandomPercent * -3.0 * Drift ; Was 10 * drift
endif
if rTarget == Player && InCover == 1
set Fire to 2
set fRelativePos to rTarget.GetPos Z + 100
ArtillerySourceMarker.setPos Z fRelativePos
set iVariance to getrandompercent
set fRandom to fRandom + 1500
if iVariance > 75
set fRelativePos to rTarget.GetPos Y - fRandom
ArtillerySourceMarker.setPos Y fRelativePos
set fRelativePos to rTarget.GetPos X - fRandom
ArtillerySourceMarker.setPos X fRelativePos
elseif iVariance > 50
set fRelativePos to rTarget.GetPos Y + fRandom
ArtillerySourceMarker.setPos Y fRelativePos
set fRelativePos to rTarget.GetPos X - fRandom
ArtillerySourceMarker.setPos X fRelativePos
elseif iVariance > 25
set fRelativePos to rTarget.GetPos Y - fRandom
ArtillerySourceMarker.setPos Y fRelativePos
set fRelativePos to rTarget.GetPos X + fRandom
ArtillerySourceMarker.setPos X fRelativePos
else
set fRelativePos to rTarget.GetPos Y + fRandom
ArtillerySourceMarker.setPos Y fRelativePos
set fRelativePos to rTarget.GetPos X + fRandom
ArtillerySourceMarker.setPos X fRelativePos
endif
set angle to ArtillerySourceMarker.GetHeadingAngle GreatExpanseGateRef
ArtillerySourceMarker.SetAngle Z angle
ArtillerySourceMarker.PlaceAtMe FXNellisArtilleryStrike01
else
set Fire to 2
set fRelativePos to rTarget.GetPos Z + 100
ArtillerySourceMarker.setPos Z fRelativePos
set fRelativePos to rTarget.GetPos Y + fRandom
ArtillerySourceMarker.setPos Y fRelativePos
set fRelativePos to rTarget.GetPos X - fRandom
ArtillerySourceMarker.setPos X fRelativePos
set angle to ArtillerySourceMarker.GetHeadingAngle GreatExpanseGateRef
ArtillerySourceMarker.SetAngle Z angle
ArtillerySourceMarker.PlaceAtMe FXNellisArtilleryStrike01
endif
endif
endif
End
Link to comment
Share on other sites

Wow, that sure is a big script :laugh:

 

Have you tried something a bit different perhaps? Not as elaborate as what the vanilla game does, but it would be something. You could have a timer script (linked to a quest I'd say) that, every once in a while, will place an explosion by the player. You'd make it so the quest starts when the player enters the trigger box, and stops when they leave it.

 

You could try a script like this. It's something I altered from a script I have in my own mod I'm making at the moment.

scn TimedExplosionScript

Float Timer

Begin Gamemode

if (Timer <10)
   set timer to timer + GetSecondsPassed
Else
   iMod ExplosionInFace
   player.PlaceAtMe MineFragExplosion
   PlayerREF.Say Hit
   PlayerREF.DamageActorValue Health 50
   Set timer to 0
Endif

End

This would make it so every 10 seconds or so (can be changed of course) an explosion will blind the player. The player will yell in pain and receive a bit of damage. Then the timer will reset and start again.

 

As I said, not nearly as elaborate as what you had in mind, but it could tide you over in the meantime :smile:

 

EDIT: If I remember correctly the explosion effect from the artillery is FXNellisArtilleryStrike01, so you could replace MineFragExplosion in the script with that and see how it looks.

Edited by Jokerine
Link to comment
Share on other sites

  On 1/18/2015 at 7:40 PM, Jokerine said:

Wow, that sure is a big script :laugh:

 

Have you tried something a bit different perhaps? Not as elaborate as what the vanilla game does, but it would be something. You could have a timer script (linked to a quest I'd say) that, every once in a while, will place an explosion by the player. You'd make it so the quest starts when the player enters the trigger box, and stops when they leave it.

 

You could try a script like this. It's something I altered from a script I have in my own mod I'm making at the moment.

scn TimedExplosionScript

Float Timer

Begin Gamemode

if (Timer <10)
   set timer to timer + GetSecondsPassed
Else
   iMod ExplosionInFace
   player.PlaceAtMe MineFragExplosion
   PlayerREF.Say Hit
   PlayerREF.DamageActorValue Health 50
   Set timer to 0
Endif

End

This would make it so every 10 seconds or so (can be changed of course) an explosion will blind the player. The player will yell in pain and receive a bit of damage. Then the timer will reset and start again.

 

As I said, not nearly as elaborate as what you had in mind, but it could tide you over in the meantime :smile:

 

EDIT: If I remember correctly the explosion effect from the artillery is FXNellisArtilleryStrike01, so you could replace MineFragExplosion in the script with that and see how it looks.

Thanks! Thats actually very useful. :smile:

I took the script and tested it using Begin Gamemode, and the Artillery strike does work. The only problem is, when I change it to Begin OnTriggerEnter Player, the sequence will not run.

scn BigAppleArtilleryScript
Float Timer
Begin OnTriggerEnter Player
if (Timer <10)
set timer to timer + GetSecondsPassed
Else
iMod ExplosionInFace
player.PlaceAtMe FXNellisArtilleryStrike01
PlayerREF.Say Hit
PlayerREF.DamageActorValue Health 10
Set timer to 0
Endif
End
Any Idea how to get it to run when the player enters the Trigger, but stop when he/she leaves it?
Edited by Mlucci4036
Link to comment
Share on other sites

Well, that's why you need to make it run with a quest. Gamemode is what makes the timer work.

 

So make a new quest (just any ID because it won't show up, for instance ArtilleryQuestThingy), priority 55, start game enabled, script processing default. Save it and open it again, then assign the timer script from earlier to it. Now make your trigger box wherever and give it a script like this. I'm not on my computer at the moment so it's off the top of my head... Just got up so I haven't had my coffee :laugh:

scn ArtilleryTriggerScript


Begin OnTriggerEnter Player

   StartQuest ArtilleryQuestThingy

Begin OnTriggerLeave Player

   StopQuest ArtilleryQuestThingy

END 

Something like that should do it. In my mod the quest starts when the player equips and unequips a piece of apparel so you could try that too. But hopefully the script above should do it. Good luck! :thumbsup:

 

EDIT: On second thought I guess it shouldn't be start game enabled because then strikes will follow the player everywhere in the game, haha :laugh: so just don't tick start game enabled and let the trigger start it instead.

Edited by Jokerine
Link to comment
Share on other sites

  On 1/19/2015 at 5:19 AM, Jokerine said:

Well, that's why you need to make it run with a quest. Gamemode is what makes the timer work.

 

So make a new quest (just any ID because it won't show up, for instance ArtilleryQuestThingy), priority 55, start game enabled, script processing default. Save it and open it again, then assign the timer script from earlier to it. Now make your trigger box wherever and give it a script like this. I'm not on my computer at the moment so it's off the top of my head... Just got up so I haven't had my coffee :laugh:

scn ArtilleryTriggerScript


Begin OnTriggerEnter Player

   StartQuest ArtilleryQuestThingy

Begin OnTriggerLeave Player

   StopQuest ArtilleryQuestThingy

END 

Something like that should do it. In my mod the quest starts when the player equips and unequips a piece of apparel so you could try that too. But hopefully the script above should do it. Good luck! :thumbsup:

 

EDIT: On second thought I guess it shouldn't be start game enabled because then strikes will follow the player everywhere in the game, haha :laugh: so just don't tick start game enabled and let the trigger start it instead.

Alright, thanks for the help. I'm still tweaking that second script to work properly, but despite the 1st script being hooked to a quest, wouldn't the Begin Gamemode command cause the artillery to fire all the time despite being attached to a quest?

Link to comment
Share on other sites

That's why you don't set the quest that holds the timer script as "start game enabled". The quest will not start (and therefore the artillery strikes won't fall) until the player enters your trigger. Then while they are inside the strikes will fall until they exit the trigger and the strikes will stop (until they enter the trigger box again).

Link to comment
Share on other sites

  • Recently Browsing   0 members

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