Skip to content

Instantly share code, notes, and snippets.

@oddlittleturtle
Created February 2, 2023 22:11
Show Gist options
  • Save oddlittleturtle/20d86e36ef02ed7d767c37aece388de0 to your computer and use it in GitHub Desktop.
Save oddlittleturtle/20d86e36ef02ed7d767c37aece388de0 to your computer and use it in GitHub Desktop.
Start Me Up Redux Xbox Raiders script updated
Scriptname StartMeUp:SMU_OnHitRaider extends ReferenceAlias
{updates factions for raider group}
Import StartMeUp:SMU_Debugger
Group Factions
Faction Property pRaiderFaction Auto Const mandatory
{faction they're already a part of}
Faction Property pSMU_RaiderFaction Auto Const mandatory
{temporary faction}
EndGroup
;variable
Actor PlayerREF
Actor Raider
UserLog Log
Event OnAliasInit()
Log = new UserLog
Log.Caller = self
Log.FileName = "StartMeUp"
PlayerREF = Game.GetPlayer()
Raider = self.GetActorReference()
WriteLine(Log, " Raiders: Stopping aggression and waiting for player punchiness.")
; stop any combat behavior
Raider.SetValue(Game.GetAggressionAV(),0)
Raider.StopCombatAlarm()
Raider.StopCombat()
RegisterForHitEvent(self, PlayerREF)
Self.TryToAddToFaction(pSMU_RaiderFaction)
Self.TryToRemoveFromFaction(pRaiderFaction)
; give 'em a push
Raider.EvaluatePackage()
EndEvent
Event OnLoad()
WriteLine(Log, "Raiders: Stopping aggression and waitingfor player punchiness.")
; stop any combat behavior
Raider.SetValue(Game.GetAggressionAV(),0)
Raider.StopCombatAlarm()
Raider.StopCombat()
RegisterForHitEvent(self, PlayerREF)
Self.TryToAddToFaction(pSMU_RaiderFaction)
Self.TryToRemoveFromFaction(pRaiderFaction)
; give 'em a push
Raider.EvaluatePackage()
EndEvent
Event OnUnload()
WriteLine(Log, "Player has left area. Clean up everything.")
CleanUpFactions()
UnregisterForAllHitEvents()
Clear()
EndEvent
Event OnHit(ObjectReference akTarget, ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked, string apMaterial)
if akAggressor == PlayerREF
WriteLine(Log, " I was hit by: "+ PlayerREF+ " Attack!")
CleanUpFactions()
UnregisterForAllHitEvents()
Clear()
else
RegisterForHitEvent(self, PlayerREF)
EndIf
EndEvent
Event ReferenceAlias.OnDeath(ReferenceAlias akSender, Actor akKiller)
if akKiller == PlayerREF
WriteLine(Log, "I was killed by: " + PlayerREF + " wtf.")
CleanUpFactions()
UnregisterForAllHitEvents()
Clear()
else
RegisterForHitEvent(self, PlayerREF)
endif
EndEvent
;called when quest shuts down
Function CleanUpFactions()
WriteLine(Log, "Removing raider from factions.")
;add the alias back to their faction
Self.TryToAddToFaction(pRaiderFaction)
Self.TryToRemoveFromFaction(pSMU_RaiderFaction)
;remove the player from the temporary faction
PlayerREF.RemoveFromFaction(pSMU_RaiderFaction)
;poke em if they're still in the alias
if !Raider.isDead()
Raider.EvaluatePackage()
endif
EndFunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment