Mlucci4036 Posted January 17, 2015 Share Posted January 17, 2015 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 More sharing options...
Ladez Posted January 18, 2015 Share Posted January 18, 2015 Just study how it works for Nellis AFB and adapt it to your own needs. :) Link to comment Share on other sites More sharing options...
Mlucci4036 Posted January 18, 2015 Author Share Posted January 18, 2015 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 More sharing options...
tomm434 Posted January 18, 2015 Share Posted January 18, 2015 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 FXNellisArtilleryStrike01Explore this script. Link to comment Share on other sites More sharing options...
Mlucci4036 Posted January 18, 2015 Author Share Posted January 18, 2015 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 FXNellisArtilleryStrike01Explore 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 iArtilleryFiringfloat panglefloat ranglefloat anglefloat fRelativePosfloat fQuestDelayTimefloat fRandomfloat timer1float timer2int ActorCount ; Tracks the number of actors that have entered the trigger volumeint Boom ; Tracks whether to make the shooting soundint Fire ; Tracks whether to shootint InCover ; This check to see if the player is in cover and make the artillery less accurateint XOffsetint YOffsetint ZOffsetfloat Driftfloat ActiveTime ; The amount of the time artillery has been active this cyclefloat iVariance ref CurrentActor1 ; These are holder variables for actors that enter the volumeref CurrentActor2 ; They get cleared by spawned activators every couple of framesref CurrentActor3 ; There are 3 in case they don't get cleared before a new actor entersref SpawnedRef1 ; See NellisTargetPickerScript (Attached to NellisTargetPicker) for more associated scriptingref SpawnedRef2ref SpawnedRef3ref LeavingActor1ref LeavingActor2ref LeavingActor3ref rActorref rTargetint iRandomTarget ; RandomTargetPicker float fArtilleryFireRate ;Time between each shellfloat fArtilleryFireDuration ;How long the player is shelled for before there is a pausefloat fArtilleryReloadTime ;How long it takes the artillery to reload begin onLoadset fArtilleryFireRate to 2set fArtilleryFireDuration to 30set fArtilleryReloadTime to 15set Drift to 1.2end ;; Double comments are for temp fixes Begin OnTriggerEnterset rActor to GetActionRef ; Store the current actor in the triggerif rActor.GetPlayerTeammate == 1 ; Do not run for player teammatesreturnendifEnd Begin OnTriggerLeaveset rActor to GetActionRefif rActor.GetPlayerTeammate == 1 ; Do not run for player teammatesreturnendifEnd Begin GameModeif ActorCount <= 0 && iArtilleryFiring == 1 ; Fallthrough to catch actors dyingset iArtilleryFiring to 0set ActorCount to 0set rTarget to 0set ActiveTime to 0endifif iArtilleryFiring == 0 && (Timer1 || Timer2 || Fire || Boom)set timer1 to 0set timer2 to 0set fire to 0set boom to 0endifif iArtilleryFiring == 0set timer1 to -5set rTarget to 0elseif iArtilleryFiring ==1set ActiveTime to GetSecondsPassed + ActiveTimeif ActiveTime <= 3set Drift to 5elseif ActiveTime <= 10set Drift to 4elseif ActiveTime <= 12set Drift to 3elseif ActiveTime <= 15set Drift to 2elseif ActiveTime <= 30set Drift to 1elseset Drift to 0endifset iRandomTarget to GetRandomPercentif iRandomTarget >= 0 && CurrentActor1 != 0 && CurrentActor1.GetDead == 0set rTarget to CurrentActor1endifif iRandomTarget >= 33 && CurrentActor2 != 0 && CurrentActor2.GetDead == 0set rTarget to CurrentActor2endifif iRandomTarget >= 67 && CurrentActor3 != 0 && CurrentActor3.GetDead == 0set rTarget to CurrentActor3endifif rTarget == 0 || rTarget.GetDeadset iArtilleryFiring to 0set ActorCount to 0set rTarget to 0set ActiveTime to 0returnendif set timer1 to GetSecondsPassed + timer1set timer2 to GetSecondsPassed + timer2 if timer2 < fArtilleryFireDurationif boom == 0set Boom to 1elseif timer1 >= fArtilleryFireRate && fire == 0set fire to 1elseif timer1 > fArtilleryFireRate && fire == 2set timer1 to 0set boom to 0set Fire to 0endifelseif timer2 > (fArtilleryReloadTime + fArtilleryFireDuration)set timer1 to 0set timer2 to 0endifif Fire == 1 && rTarget != 0set fRandom to GetRandomPercentif fRandom <= 50set fRandom to getRandomPercent * 3.0 * Drift ; Was 10* driftelseset fRandom to getRandomPercent * -3.0 * Drift ; Was 10 * driftendif if rTarget == Player && InCover == 1set Fire to 2set fRelativePos to rTarget.GetPos Z + 100ArtillerySourceMarker.setPos Z fRelativePosset iVariance to getrandompercentset fRandom to fRandom + 1500if iVariance > 75set fRelativePos to rTarget.GetPos Y - fRandomArtillerySourceMarker.setPos Y fRelativePosset fRelativePos to rTarget.GetPos X - fRandomArtillerySourceMarker.setPos X fRelativePoselseif iVariance > 50set fRelativePos to rTarget.GetPos Y + fRandomArtillerySourceMarker.setPos Y fRelativePosset fRelativePos to rTarget.GetPos X - fRandomArtillerySourceMarker.setPos X fRelativePoselseif iVariance > 25set fRelativePos to rTarget.GetPos Y - fRandomArtillerySourceMarker.setPos Y fRelativePosset fRelativePos to rTarget.GetPos X + fRandomArtillerySourceMarker.setPos X fRelativePoselseset fRelativePos to rTarget.GetPos Y + fRandomArtillerySourceMarker.setPos Y fRelativePosset fRelativePos to rTarget.GetPos X + fRandomArtillerySourceMarker.setPos X fRelativePosendifset angle to ArtillerySourceMarker.GetHeadingAngle GreatExpanseGateRefArtillerySourceMarker.SetAngle Z angleArtillerySourceMarker.PlaceAtMe FXNellisArtilleryStrike01elseset Fire to 2set fRelativePos to rTarget.GetPos Z + 100ArtillerySourceMarker.setPos Z fRelativePosset fRelativePos to rTarget.GetPos Y + fRandomArtillerySourceMarker.setPos Y fRelativePosset fRelativePos to rTarget.GetPos X - fRandomArtillerySourceMarker.setPos X fRelativePosset angle to ArtillerySourceMarker.GetHeadingAngle GreatExpanseGateRefArtillerySourceMarker.SetAngle Z angleArtillerySourceMarker.PlaceAtMe FXNellisArtilleryStrike01endifendifendifEnd Link to comment Share on other sites More sharing options...
Jokerine Posted January 18, 2015 Share Posted January 18, 2015 (edited) 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 EndThis 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 January 18, 2015 by Jokerine Link to comment Share on other sites More sharing options...
Mlucci4036 Posted January 19, 2015 Author Share Posted January 19, 2015 (edited) 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 EndThis 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 + GetSecondsPassedElse iMod ExplosionInFace player.PlaceAtMe FXNellisArtilleryStrike01 PlayerREF.Say Hit PlayerREF.DamageActorValue Health 10 Set timer to 0Endif End Any Idea how to get it to run when the player enters the Trigger, but stop when he/she leaves it? Edited January 19, 2015 by Mlucci4036 Link to comment Share on other sites More sharing options...
Jokerine Posted January 19, 2015 Share Posted January 19, 2015 (edited) 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 January 19, 2015 by Jokerine Link to comment Share on other sites More sharing options...
Mlucci4036 Posted January 19, 2015 Author Share Posted January 19, 2015 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 More sharing options...
Jokerine Posted January 19, 2015 Share Posted January 19, 2015 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 More sharing options...
Recommended Posts