Scriptname RaiderPetExample:ExampleQuestScr extends Quest Conditional Actor Property PlayerRef Auto Const ScriptObject RaiderPetScr = None Function Setup( ) ;; Placeholder EndFunction Function Cleanup( ) ;; Placeholder EndFunction Function Maintenance( ) ;; Check for external dependencies: if ( Game.isPluginInstalled( "Raider Pet.esp" ) ) Debug.Trace( "[Example] Raider Pet mod found" ) Form Scr = Game.GetFormFromFile( 0x00000F99, "Raider Pet.esp" ) RaiderPetScr = (Scr as Quest).CastAs( "RaiderPet:DialogueQuestScr" ) else Debug.Trace( "[Example] Raider Pet mod not found" ) RaiderPetScr = None endIf ;; Ensure that events are registered: RegisterForRemoteEvent( PlayerRef, "OnPlayerLoadGame" ) RegisterForCustomEvent( (RaiderPetScr as RaiderPet:DialogueQuestScr), "TakenCaptive" ) RegisterForCustomEvent( (RaiderPetScr as RaiderPet:DialogueQuestScr), "Escaped" ) EndFunction Event OnQuestInit( ) Setup( ) Maintenance( ) EndEvent Event OnQuestShutdown( ) Cleanup( ) EndEvent Event Actor.OnPlayerLoadGame(Actor akSender) Maintenance( ) EndEvent ;; ;; There are 3 main states the player character could be in: ;; 1. Normal ;; 2. Captive - but not yet claimed by a specific gang. ;; 3. Claimed - captured and collared by a specific gang. ;; ;; The 'TakenCaptive' and 'Escaped' events relate to the 'Claimed' state. ;; They do not occur on transitions between 'Normal' and 'Captive'. In the ;; usual operation of the mod, a character in 'Captive' state is unarmed ;; and will not be attacked by much of anything. ;; ;; ;; This event occurs when the character has been taken captive (collared and ;; claimed) by a specific raider gang. The 'captive' is always the player ;; character, and is included primarily for completeness. The 'bossman' is ;; the location's boss, if they could be identified. ;; Event RaiderPet:DialogueQuestScr.TakenCaptive( RaiderPet:DialogueQuestScr akSender, Var[] akArgs ) Actor captive = ( akArgs[0] as Actor ) Actor bossman = ( akArgs[1] as Actor ) String name1 = captive.GetActorBase().GetName( ) String name2 = "Unknown Raider" if ( bossman ) ;; May be 'None' name2 = bossman.GetLeveledActorBase().GetName( ) endIf Debug.Notification( "[Example] " + name1 + " was taken captive by " + name2 ) EndEvent ;; ;; This event occurs when the character returns to normal (hostile) reactions, ;; regardless of whether they are still collared. The 'escapee' is the player ;; character. No other arguments are provided. ;; Event RaiderPet:DialogueQuestScr.Escaped( RaiderPet:DialogueQuestScr akSender, Var[] akArgs ) Actor escapee = ( akArgs[0] as Actor ) Debug.Notification( "[Example] character escaped captivity" ) EndEvent ;; ;; This is an example of using a remote function to notify the Raider Pet mod ;; that the player character should be treated as a potential captive. ;; Function PrepareForCaptivity( ) ;; Do any desired preparations, like placing all weapons in a container... ;; Tell Raider Pet to treat the character as a potential captive: if ( RaiderPetScr != None ) RaiderPetScr.CallFunction( "MakeCaptive", new Var[0] ) endIf ;; At this point, the character is in CaptiveFaction but not yet claimed ;; by a specific raider gang. The dialogue option to be claimed is now ;; active. When and if a raider takes that step, the TakenCaptive event ;; will be sent. If the character has picked up (but not equipped) a ;; weapon prior to that, the weapons will be confiscated at that point. ;; If the character picks up and EQUIPS a weapon prior to being claimed, ;; they will revert to normal behavior without ever generating either the ;; TakenCaptive or Escaped events. EndFunction ;; ;; This is an example of using a remote function to notify the Raider Pet mod ;; that the player character has been captured by this specific Actor. It ;; is recommended to let this happen naturally via the Raider Pet dialogue, ;; instead of forcing it like this... but if you really want full control of ;; that process, this approach will also work. ;; ;; This call must be made with the player character IN THE SAME LOCATION as ;; the Actor in question, the cell must be loaded, and the Actor must be in ;; the Enabled state. Otherwise quest aliases will not fill properly. ;; Function StakeClaim( Actor akSpeaker ) ;; The 'MakeCaptive' call should already have been made, or the results ;; will be unpredictable. And probably horrible. ;; Tell Raider Pet to treat the character a captive of this Actor: if ( RaiderPetScr != None ) Var[] kArgs = new Var[1] kArgs[0] = akSpeaker RaiderPetScr.CallFunction( "ClaimOwnership", kArgs ) endIf ;; The 'TakenCaptive' event will be sent by the function call above. EndFunction ;; ;; This is an example of using a remote function to notify the Raider Pet mod ;; that the player character has made a break for freedom, causing hostilities ;; to resume. So if you wanted to add additional conditions that could cause ;; that to occur (e.g. breaking into the boss safe), you would use this call. ;; Function BreakLoose( ) ;; The 'MakeCaptive' call should already have been made, or the results ;; will be unpredictable. The 'ClaimOwnership' call does NOT necessarily ;; have to precede this. ;; Tell Raider Pet to resume hostilities on sight: if ( RaiderPetScr != None ) RaiderPetScr.CallFunction( "BreakForFreedom", new Var[0] ) endIf ;; The 'Escaped' event will be sent by the function call above, IF there ;; has been a prior 'ClaimOwnership' call. EndFunction