Jump to content

"Factionalize" Clothing for NPCs


kingtitan

Recommended Posts

I hope the title is self explanatory, but if not here is what I am trying to do. I am currently trying to attach a script to a piece of armor/clothing in the construction set that, when equipped, would make the NPC part of the faction - as long as they are wearing that specific item. I am pretty familiar with C++, but Oblivion scripting is all new to me! Nonetheless, here is the script I have so far:

 

 

Scn mycode

Begin OnEquip
setfactionrank 2006dce 0
end

Begin OnUnequip
setfactionrank 2006dce -1
end

 

 

 

For Clarification, the "2006dce" is the form ID of the faction in the construction set. However, this faction is custom which could be part of the problems that I am experiencing.

 

So my problem is this: Whenever I have an NPC equip this piece of clothing, they do not join the faction. And I don't use the "EquipItem" command to do it either, I know that does not work (http://cs.elderscrol...dex.php/OnEquip). Could someone with a bit more scripting experience enlighten me on this please so that when the NPC puts on the clothing they become part of the faction until they take it off?

Edited by kingtitan
Link to comment
Share on other sites

<code placed in spoilers>

 

I hope the title is self explanatory, but if not here is what I am trying to do. I am currently trying to attach a script to a piece of armor/clothing in the construction set that, when equipped, would make the NPC part of the faction - as long as they are wearing that specific item. I am pretty familiar with C++, but Oblivion scripting is all new to me! Nonetheless, here is the script I have so far:

 

 

Scn mycode

Begin OnEquip
setfactionrank 2006dce 0
end

Begin OnUnequip
setfactionrank 2006dce -1
end

 

 

 

For Clarification, the "2006dce" is the form ID of the faction in the construction set. However, this faction is custom which could be part of the problems that I am experiencing.

 

So my problem is this: Whenever I have an NPC equip this piece of clothing, they do not join the faction. And I don't use the "EquipItem" command to do it either, I know that does not work (http://cs.elderscrol...dex.php/OnEquip). Could someone with a bit more scripting experience enlighten me on this please so that when the NPC puts on the clothing they become part of the faction until they take it off?

 

SetFactionRank should have a player reference, and use faction names, not BaseIDs -- that won't work as mod order changes, anyway. So try (untested):

 

 

Scn mycode

Short self

Begin OnEquip
Set self To GetSelf
self.SetFactionRank MyNewFaction 0
End

Begin OnUnequip
Set self To GetSelf
self.SetFactionRank MyNewFaction -1
End

 

Link to comment
Share on other sites

Thanks for the quick response Hickory. I actually had been wondering about the load order thing, I noticed something about that earlier when trying to sort through the code. Anyway, I tested it and got this message:

" Script 'Mycode', line 7: Syntax error. Invalid reference 'self' (only object references and reference variables are allowed in this context)."

 

So what would be the next course of action?

Link to comment
Share on other sites

Thanks for the quick response Hickory. I actually had been wondering about the load order thing, I noticed something about that earlier when trying to sort through the code. Anyway, I tested it and got this message:

" Script 'Mycode', line 7: Syntax error. Invalid reference 'self' (only object references and reference variables are allowed in this context)."

 

So what would be the next course of action?

 

Ah, a big 'derp' on my side, I'm afraid. That should have been a Ref self, not Short self at the start. Sorry for that.

Link to comment
Share on other sites

I realized that myself shortly thereafter! Here is the new code (still not working unfortunately)

 

 


Scn ATPrisonerCollarScript

ref self

Begin OnEquip
       Set self To GetSelf
       self.SetFactionRank ATPrisonerFaction 0
End

Begin OnUnequip
       Set self To GetSelf
       self.SetFactionRank ATPrisonerFaction -1
End

 

 

I went ahead and included the actual script name and faction name just to make it easier. Basically I want the NPC to only be a prisoner as long as they have a collar equipped. However, even this current script has yet to work http://forums.nexusmods.com/public/style_emoticons/dark/wallbash.gif

Link to comment
Share on other sites

Hmm, that's very odd. Do you have many prisoners? Would it be possible to test the script on a persistent reference NPC? Give one the editor name 'Prisoner01' and call that name instead of the 'self' reference:

 

Prisoner01.SetFactionRank ATPrisonerFaction 0

 

I know this is not what you want from your collar, but I'm trying to rule out a possible reference bug -- a long shot. I remember (vaguely) seeing official quest scripts using persistent references for adding and removing NPCs from factions.

 

Link to comment
Share on other sites

I attempted that in the CS but got the same syntax error message of "Only ref vars and object references are allowed in this context."

 

Perhaps some of the notes from this page could be of assistance to us?

 

I also edited the script for testing purposes only to see if it worked on just the player:

 

 


Scn ATPrisonerCollarScript

Begin OnEquip
       player.SetFactionRank ATPrisonerFaction 0
End

Begin OnUnequip
       player.SetFactionRank ATPrisonerFaction -1
End

 

 

This code was successful; whenever I equipped the collar on the player character it was added to the faction correctly. However, I am still having issues with this applying to NPCs! Argh!

Edited by kingtitan
Link to comment
Share on other sites

I attempted that in the CS but got the same syntax error message of "Only ref vars and object references are allowed in this context."

 

Perhaps some of the notes from this page could be of assistance to us?

 

I also edited the script for testing purposes only to see if it worked on just the player:

 

 


Scn ATPrisonerCollarScript

Begin OnEquip
       player.SetFactionRank ATPrisonerFaction 0
End

Begin OnUnequip
       player.SetFactionRank ATPrisonerFaction -1
End

 

 

This code was successful; whenever I equipped the collar on the player character it was added to the faction correctly. However, I am still having issues with this applying to NPCs! Argh!

 

I don't understand why you are getting that syntax error on a persistent actor reference, nor why it works for player and not NPC -- unless it's an OnEquip issue. For example, here is a portion of Falcar's script (MG17Script) that set's him hostile towards the player and the mage's guild, where the ambush occurs.

 

FalcarRef.SetFactionRank NecromancerFaction 1

FalcarRef.SetFactionRank MagesGuild -1

 

I don't have the CS installed on this rig -- haven't played Oblivion in a long time -- so I'm firing blind here.

 

One thing: the script you have is set to an object script, yes?

Link to comment
Share on other sites

Yes it is an object script and that is very very strange. I think that somehow the "GetSelf" call is not actually taking the NPC's reference because the script is too open? I'm guessing completely seeing as I'm all new to learning scripting in Oblivion.
Link to comment
Share on other sites

Curiouser and curiouser. How are you going about getting the collars equipped on the NPCs? Are you certain they are actually equipping them?
Link to comment
Share on other sites

  • Recently Browsing   0 members

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