Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

[SKY] Add / Remove Faction from a REFerenced Actor


Ashenfire
 Share

Recommended Posts

I am working on a script to activate a dwarven automaton then choose a target for it to attack.

I got the activation to work.  I added an option to disable it as well.

The only thing left is to choose a target for it to attack.

I am doing this via FACTIONS.

 

I can not get the lever to change the actor's faction.

I managed to change the players faction with a lever  but that is not what I want.

 

Script so far compiles but does not have the necessary command in the

function (it changes the players faction, not the automaton).

Scriptname DisableAndEnableReferencedObjectsAsh extends ObjectReference Conditional
{ 1. LinkREf a Lever to any object
  2. Paste ONLY this script in the lever Script area
}
import debug
import utility

ObjectReference property objSelf auto hidden
Faction property DwarvenAutomatonFaction auto
Faction property akFaction auto


bool property isInPullPosition = True Auto
{Push turns it off  Pull turns it on}
EVENT OnLoad()
SetDefaultState()
endEVENT

Event OnReset()
SetDefaultState()
EndEvent

;This has to be handled as a function, since OnLoad and OnReset can fire in either order, and we can't handle competing animation calls.
Function SetDefaultState()
if (isInPullPosition)
  playAnimation("FullPull")
  gotoState("pulledPosition")
Else
  playAnimation("FullPush")
  gotoState("pushedPosition")
EndIf
EndFunction

Auto STATE pulledPosition
EVENT onActivate (objectReference triggerRef)
  gotoState ("busy")
               ObjectReference Tempref = GetlinkedRef()

              isInPullPosition = False
  playAnimationandWait("FullPush","FullPushedUp")
  gotoState("pushedPosition")
endEVENT
endState

STATE pushedPosition
EVENT onActivate (objectReference triggerRef)
  gotoState ("busy")
              ObjectReference Tempref = GetlinkedRef()
              PerformActionDisable(Tempref)

  isInPullPosition = True
  playAnimationandWait("FullPull","FullPulledDown")
  gotoState("pulledPosition")
endEVENT
endState

STATE busy
; This is the state when I'm busy animating
  EVENT onActivate (objectReference triggerRef)
   ;do nothing
  endEVENT
endSTATE

Function AddToFaction(Faction akfaction)
  game.getplayer().addtofaction(akFaction)
EndFunction


Function PerformActionDisable(ObjectReference Target)
     setdefaultstate()
Target.Disable()
EndFunction

Function PerformActionEnable(ObjectReference Target)
         Target.Enable()
EndFunction

 

What am I missing?  CreationKit.com does not explain the relationship well as

 it mostly gives raw code to use. 

 

 

Link to comment
Share on other sites

  • 2 months later...

Issue reolved. :good:

 

This script can be put on any lever and the values can be changed to

make an actor be removed from a faction or added to a faction.

 

;Scriptname AshChangeActorsFactionViaSwitch extends ObjectReference
{Change Referenced Actors Factions via Switch
Multiple Targets (6)}

objectReference property RefToGovern auto
objectReference property RefToGovern2 auto
objectReference property RefToGovern3 auto
objectReference property RefToGovern4 auto
objectReference property RefToGovern5 auto
objectReference property RefToGovern6 auto
faction property factionToLeave auto
faction property factionToLeave2 auto
faction property factionToLeave3 auto
faction property factionToLeave4 auto
faction property factionToLeave5 auto
faction property factionToLeave6 auto

faction property factionToJoin auto
{Actor1 Joins a faction, NOT the player}

faction property factionToJoin2 auto
{Actor2 Joins a faction, NOT the player}
faction property factionToJoin3 auto
faction property factionToJoin4 auto
faction property factionToJoin5 auto
faction property factionToJoin6 auto
faction property factionforplayer auto
{Only the PLAYER joins chosen faction}

bool property FrenzyOnActivate = FALSE auto

bool property beenActivated auto hidden

EVENT onActivate(objectReference akActivatingRef)
    if !beenActivated
        beenActivated = TRUE
         Game.getplayer().addtofaction(factionforplayer)
        if factionToLeave
            (refToGovern as actor).removeFromFaction(factionToLeave)
            (refToGovern as actor).removeFromFaction(factionToLeave2)
            (refToGovern as actor).removeFromFaction(factionToLeave3)
            (refToGovern as actor).removeFromFaction(factionToLeave4)
            (refToGovern as actor).removeFromFaction(factionToLeave5)
            (refToGovern as actor).removeFromFaction(factionToLeave6)
        endif
        if factionToJoin
            (refToGovern as actor).addToFaction(factionToJoin)
            (refToGovern as actor).addToFaction(factionToJoin2)
            (refToGovern as actor).addToFaction(factionToJoin3)
            (refToGovern as actor).addToFaction(factionToJoin4)
            (refToGovern as actor).addToFaction(factionToJoin5)
            (refToGovern as actor).addToFaction(factionToJoin6)

       endif

        if FrenzyOnActivate
            (refToGovern as actor).setAV("aggression",3)
            (refToGovern2 as actor).setAV("aggression",3)
            (refToGovern3 as actor).setAV("aggression",3)
            (refToGovern4 as actor).setAV("aggression",3)
            (refToGovern5 as actor).setAV("aggression",3)
            (refToGovern6 as actor).setAV("aggression",3)

        endif
    endif
endEVENT



 

Edited by Ashenfire
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...