nonplusultra Posted December 29, 2010 Share Posted December 29, 2010 hey guys, I'm working on a mod and want to put an automated artillery in it like the boomers have. I've copied the NAFB script, changed some refs and deleted the quest stuff in the script.when I'm entering the trigger the artillery is shooting - that's not the problem, but instead of one shot it shoots like a minigun without reload time :<Here is the script, if u see any mistakes pls let me know: scn AirportArtilleryScript int iArtilleryFiringfloat panglefloat ranglefloat anglefloat fRelativePosfloat 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 onLoad set fArtilleryFireRate to 5 set fArtilleryFireDuration to 10 set fArtilleryReloadTime to 15 set Drift to 1.2end ;; 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 if rActor.GetInFaction BoomerFaction ;do Nothing; ;set iArtilleryFiring to 0 ;ShowWarning "Actor is a Boomer Friend. Don't Fire"; ;set rTarget to 0; ;set ActorCount to ActorCount - 1 return elseif CurrentActor1 == 0 set CurrentActor1 to GetActionRef ;set SpawnedRef1 to rActor.Placeatme AirportTargetPicker elseif CurrentActor2 == 0 set CurrentActor2 to GetActionRef ;set SpawnedRef2 to rActor.Placeatme AirportTargetPicker elseif CurrentActor3 == 0 set CurrentActor3 to GetActionRef ;set SpawnedRef3 to rActor.Placeatme AirportTargetPicker endif set iArtilleryFiring to 1 ; Sets the artillery to fire set ActorCount to ActorCount +1 ; Track the number of actors in the trigger ;showWarning "Actor Entering"End Begin OnTriggerLeave set rActor to GetActionRef if rActor.GetPlayerTeammate == 1 ; Do not run for player teammates return endif if rActor.GetInFaction BoomerFaction ;do Nothing return elseif (CurrentActor1 == rActor) set CurrentActor1 to 0 ;set LeavingActor1 to GetActionRef elseif (CurrentActor2 == rActor) set CurrentActor2 to 0 elseif (CurrentActor3 == rActor) set CurrentActor3 to 0 ;elseif LeavingActor2 == 0 ; set LeavingActor2 to GetActionRef ;elseif LeavingActor3 == 0 ; set LeavingActor3 to GetActionRef endif set ActorCount to ActorCount - 1 if ActorCount <= 0 set iArtilleryFiring to 0 set ActorCount to 0 set rTarget to 0 set ActiveTime to 0 set timer1 to 0 set timer2 to 0 set fire to 0 set boom to 0 endifEnd 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 10 set boom to 10 set Fire to 0 endif elseif timer2 > (fArtilleryReloadTime + fArtilleryFireDuration) set timer1 to 10 set timer2 to 10 endif if Boom == 1 set Boom to 2 ArtillerySoundMarker2REF.MoveTo Player ArtillerySoundMarker2REF.playsound FXExplosionArtilleryMortar 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 iVariance > 75 set fRelativePos to rTarget.GetPos Y - fRandom ArtillerySourceMarker2.setPos Y fRelativePos set fRelativePos to rTarget.GetPos X - fRandom ArtillerySourceMarker2.setPos X fRelativePos elseif iVariance > 50 set fRelativePos to rTarget.GetPos Y + fRandom ArtillerySourceMarker2.setPos Y fRelativePos set fRelativePos to rTarget.GetPos X - fRandom ArtillerySourceMarker2.setPos X fRelativePos elseif iVariance > 25 set fRelativePos to rTarget.GetPos Y - fRandom ArtillerySourceMarker2.setPos Y fRelativePos set fRelativePos to rTarget.GetPos X + fRandom ArtillerySourceMarker2.setPos X fRelativePos else set fRelativePos to rTarget.GetPos Y + fRandom ArtillerySourceMarker2.setPos Y fRelativePos set fRelativePos to rTarget.GetPos X + fRandom ArtillerySourceMarker2.setPos X fRelativePos endif set angle to ArtillerySourceMarker2.GetHeadingAngle ArtillerySourceMarker3 ArtillerySourceMarker2.SetAngle Z angle ArtillerySourceMarker2.PlaceAtMe FXNellisArtilleryStrike01 else set Fire to 3 set fRelativePos to rTarget.GetPos Z + 100 ArtillerySourceMarker2.setPos Z fRelativePos set fRelativePos to rTarget.GetPos Y + fRandom ArtillerySourceMarker2.setPos Y fRelativePos set fRelativePos to rTarget.GetPos X - fRandom ArtillerySourceMarker2.setPos X fRelativePos set angle to ArtillerySourceMarker2.GetHeadingAngle ArtillerySourceMarker3 ArtillerySourceMarker2.SetAngle Z angle ArtillerySourceMarker2.PlaceAtMe FXNellisArtilleryStrike01 endif endif endifEnd Link to comment Share on other sites More sharing options...
Recommended Posts