duchessnukem Posted February 16, 2012 Share Posted February 16, 2012 Creation Kit buffs, your help is needed! I did a lot of modding for TESIV in that scripting language, but this is my first attempt at scripting with Papyrus. I am making a "faction armor" mod, that makes it so that when the player dons the armor of a guard, their bounties are ignored and NPCs will not recognize if the player is a stage 4 vampire.I've done pretty well with most of the mod (if I do say so myself), but I'm having trouble with the Vampirism aspect. Most of my code is scripted in an OnEquipped event, and includes a snippet that is supposed to make sure that NPCs do not become hostile to stage 4 vampires: Event OnEquipped(Actor akActor) ; When player puts on Guard's helmet and cuirass... if akActor == Game.GetPlayer() if Game.GetPlayer().IsEquipped(cuirass) && Game.GetPlayer().IsEquipped(helmet) Game.GetPlayer().SetFactionRank(VampirePCFaction, -1) Game.GetPlayer().RemoveFromFaction(VampirePCFaction) Game.GetPlayer().SetAttackActorOnSight(False) endif endif endEvent VampirePCFaction is a Faction property, which is filled with the real VampirePCFaction. When I run the game, I find that the player is not actually getting removed from the VampirePCFaction, even though the script is running correctly otherwise (checked by putting in debug text). If I remove the player from the faction manually via the console, it works just fine. Anyone know what my issue might be? Any help would be greatly appreciated. I've been trying to fix this for hours now. Link to comment Share on other sites More sharing options...
gsmanners Posted February 16, 2012 Share Posted February 16, 2012 Looks good to me. You sure the rest of your scripting is kosher? (It might be some other part of the code not working right, and this is just a side effect.) Link to comment Share on other sites More sharing options...
duchessnukem Posted February 17, 2012 Author Share Posted February 17, 2012 Thank you for the speedy response! Here's the rest of the OnEquipped script, if you wouldn't mind taking a look. There is a companion OnUnequipped script as well, but I don't think that would do anything to interfere with this. And I'm not sure how to get rid of the wonky syntax highlighting the forum is implementing. Sorry. Scriptname MODFactionArmorEquipScript extends ObjectReference {MODfactionarmor equip script.} Armor property cuirass auto {Guard's Cuirass Item} Armor property helmet auto {Guard's Helmet Item} Faction property DisguiseFaction auto {Faction/Hold the player is going to be disguised as} Faction property VampirePCFaction auto {VampirePCFaction} Faction property CrimeFactionReach auto {Put CrimeFaction for The Reach here} GlobalVariable property IsDisguised auto {Global variable storing state of disguise} GlobalVariable property DisguiseFactionCrimeGoldV auto {GlobalVariable for violent crimegold for faction} GlobalVariable property DisguiseFactionCrimeGoldNV auto {GlobalVariable for non-violent crimegold for faction} GlobalVariable property WasVampireBefore auto GlobalVariable property PlayerIsVampire auto String property guard_hold auto {String holding the name of the Hold/Faction the player is disguised as} Quest property MS01 auto {put MS01 in here} Quest property MS02 auto {put MS02 here} ;============================================================================== ;============================================================================== Event OnEquipped(Actor akActor) ; When player puts on Guard's helmet and cuirass... if akActor == Game.GetPlayer() if Game.GetPlayer().IsEquipped(cuirass) && Game.GetPlayer().IsEquipped(helmet) && !IsDisguised.GetValue() if (MS01.IsRunning() || MS02.IsRunning()) && DisguiseFaction == CrimeFactionReach Debug.MessageBox("Markarth Guards are currently on high alert, and are not fooled by your disguise!") elseif Game.GetPlayer().IsInCombat() Debug.MessageBox("The guards are not fooled by your disguise -- someone saw you put it on!") else Disguise(DisguiseFaction) Debug.Notification("You are disguised as a " + guard_hold + " Guard.") endif endif endif endEvent ;============================================================================== ;Store values of Crime Gold before putting on disguise, to be restored when removing disguise Function StoreFactionCrimeGold(Faction DisguiseFaction) DisguiseFactionCrimeGoldV.SetValue(DisguiseFaction.GetCrimeGoldViolent()) DisguiseFactionCrimeGoldNV.SetValue(DisguiseFaction.GetCrimeGoldNonViolent()) endfunction ;----------------------------------------------------------------------------- ;Get rid of current crimegold in specified faction, to be used when in disguise (so guards don't come after you) Function ClearFactionCrimeGold(Faction DisguiseFaction) DisguiseFaction.SetCrimeGold(0) DisguiseFaction.SetCrimeGoldViolent(0) endfunction ;----------------------------------------------------------------------------- ;The main stuff that happens to make the player "disguised" Function Disguise(Faction DisguiseFaction) WasVampireBefore.SetValue(0) ;clear previous values IsDisguised.SetValue(1) Game.GetPlayer().StopCombatAlarm() ;Stop NPCs that want to attack you StoreFactionCrimeGold(DisguiseFaction) ; store crime gold for when you remove the disguise ClearFactionCrimeGold(DisguiseFaction) ; temporarily get rid of crimegold while disguise is on if PlayerIsVampire.GetValue() == 1 WasVampireBefore.SetValue(1) Game.GetPlayer().SetFactionRank(VampirePCFaction, -1) Game.GetPlayer().RemoveFromFaction(VampirePCFaction) Game.GetPlayer().SetAttackActorOnSight(False) endif endfunction Link to comment Share on other sites More sharing options...
gsmanners Posted February 17, 2012 Share Posted February 17, 2012 There is a companion OnUnequipped script as well, but I don't think that would do anything to interfere with this. On the contrary, that's exactly what your problem most likely is. I would suggest looking and seeing whether that is interfering with your disguise variables here. Different scripts for the same object don't really make a whole lot of sense to me, either (especially when you consider that scripts are multi-tasking in this particular VM). Link to comment Share on other sites More sharing options...
duchessnukem Posted February 17, 2012 Author Share Posted February 17, 2012 You make an excellent point. I don't know why I made them separate... making them separate increases the likelihood that there will be some sort of conflict. I'll combine them and let you know the outcome. Link to comment Share on other sites More sharing options...
duchessnukem Posted February 17, 2012 Author Share Posted February 17, 2012 Yup. I combined them and that did the trick. Everything is working perfectly now. Thank you so much for your help. I'll clean this thing up a bit and then put it up on the workshop! Link to comment Share on other sites More sharing options...
Recommended Posts