Skip to content

Instantly share code, notes, and snippets.

@oddlittleturtle
Created February 2, 2023 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oddlittleturtle/b3992d3c9b85e6623bf95065eeeb02f7 to your computer and use it in GitHub Desktop.
Save oddlittleturtle/b3992d3c9b85e6623bf95065eeeb02f7 to your computer and use it in GitHub Desktop.
Start Me Up Redux Xbox Raiders 2 Script
ScriptName StartMeUp:SMU_OnHitRaider2 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_RaiderFaction2 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.TryToRemoveFromFaction(pRaiderFaction)
self.TryToAddToFaction(pSMU_RaiderFaction2)
; give 'em a push
Raider.EvaluatePackage()
EndEvent
Event OnLoad()
WriteLine(Log, "Raiders: Stopping aggression and waitingfor player punchiness.")
RegisterForHitEvent(self, PlayerREF)
; stop any combat behavior
Raider.SetValue(Game.GetAggressionAV(),0)
Raider.StopCombatAlarm()
Raider.StopCombat()
Self.TryToRemoveFromFaction(pRaiderFaction)
Self.TryToAddToFaction(pSMU_RaiderFaction2)
; 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()
;add the alias back to their faction
Self.TryToAddToFaction(pRaiderFaction)
Self.TryToRemoveFromFaction(pSMU_RaiderFaction2)
;remove the player from the temporary faction
PlayerREF.RemoveFromFaction(pSMU_RaiderFaction2)
;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