Jump to content

Help with Faction script commands


Recommended Posts

I am looking to create a script or bat file to check the number of factions of targetted actor NPC and also another one to cause them to be removed from each faction they belong.

I saw the commands GetNumFactions and GetNthFaction but I'm not sure as to how the latter works exactly.

Additionally, I want to know is it possible to use the GetNumFactions command in the game console and have it show the values while in the in-game console? I've tried to do so and it seems to do nothing, this also happens with many other commands added by OBSE, so I'd like to know if there's a way to have them show the values they return.

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...

I've thought about spells to achieve that...

 

First you need a quest and a script attached to it, to save some variables.

scn QuestToSaveFactionsOfActorSCRIPT

array_var arFactionIDs ;=> Used to save the factions of the last hit actor
ref rSaveLastHitActor    ;=> Used to save the ref of the last hit actor

;=> The Quest of this script does NOT have to run as variables are saved in it anyways.
;=> Just attach the script to the respective quest.

This is the first spell with which you save the factions of the hit actor.

scn SpellToGetFactionsOfActor    ;=> Magic Effect Script!

short sNumFactions
ref rFactionID
ref rActorID


;It might be better to apply this effect to a spell and use it not in GameMode but in
;ScriptEffectStart, when the spell hits the respective actor.

Begin ScriptEffectStart
    Let rActorID to GetSelf
    If rActorID.IsActor
        if eval(Ar_Size QuestToSaveFactionsOfActor.arFactionIDs > -1)
            Let QuestToSaveFactionsOfActor.arFactionIDs := ar_Null        
        endif
        Let QuestToSaveFactionsOfActor.rSaveLastHitActor := rActorID    ;=> Be aware of the QUEST NAME!
        Let QuestToSaveFactionsOfActor.arFactionIDs := ar_Construct Array
        While snumFactions < (rActorID.GetNumFactions - 1)    ;=> The number of factions the player is in minus 1, as an index starts at 0.
            if (rActorID.GetNumFactions - 1) == -1
                Break    ;=> Is in no faction, so get outa here.
            endif
            Let rFactionID := rActorID.GetNthFaction sNumFactions
            ar_Append QuestToSaveFactionsOfActor.arFactionIDs rFactionID
            Let sNumFactions += 1
        Loop
        Let sNumFactions := 0
    Endif
End

With the second spell you can remove this actor from all factions.

scn SpellToRemoveActorFromFactions    ;=> Magic Effect Script!

short sNumFactions
ref rFactionID
ref rActorID

Begin ScriptEffectStart
    Let rActorID to GetSelf
    If rActorID.IsActor
        if rActorID == QuestToSaveFactionsOfActor.rSaveLastHitActor
            While eval(ar_Size QuestToSaveFactionsOfActor.arFactionIDs > sNumFactions)
                Let rFactionID := QuestToSaveFactionsOfActor.arFactionIDs[sNumFactions]
                rActorID.SetFactionRank rFactionID -1
                Let sNumFactions += 1
            Loop
            Let QuestToSaveFactionsOfActor.arFactionIDs := ar_Null
            Let sNumFactions := 0
            Let QuestToSaveFactionsOfActor.rSaveLastHitActor := 0
        Endif
    Endif
End
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...