SetEnemy Vs. SetPlayerEnemy

Post » Mon Jun 18, 2012 11:33 pm

I'm wondering how these commands actually differ. It seems as though they can be used to accomplish the same goal but my testing has shown otherwise.

Wiki on SetPlayerEnemy():
Function SetPlayerEnemy(bool abIsEnemy = true) native
"True if the player should be an enemy of the faction, false if the player shouldn't be."


Ok so You call it on a faction, and if set to True, the player will be made an enemy of the faction. Easy enough.

Let's look at SetEnemy():
Function SetEnemy(Faction akOther, bool abSelfIsNeutralToOther = false, bool abOtherIsNeutralToSelf = false) native
akOther: The Faction to form a relationship with.
abSelfIsNeutralToOther: If true, the faction this function is called on will be neutral to the other faction. If false, it will be an enemy.

Default: False
abOtherIsNeutralToSelf: If true, the other faction will be neutral to this faction. If false, it will be an enemy.

Default: False

I read this, and I think: Ok, so I should be able to accomplish the same thing as SetPlayerEnemy with SetEnemy, as long as the player is in the faction I use, right?

I took this code from the werewolf script. It makes anyone and everyone hostile against the player.
    Game.GetPlayer().AddToFaction(PlayerWerewolfFaction)    Game.GetPlayer().AddToFaction(WerewolfFaction)    int cfIndex = 0    while (cfIndex < CrimeFactions.GetSize());         Debug.Trace("WEREWOLF: Setting enemy flag on " + CrimeFactions.GetAt(cfIndex))        (CrimeFactions.GetAt(cfIndex) as Faction).SetPlayerEnemy()        cfIndex += 1    endwhile

Based off of JUST that code, this should work right? Or am I just doing it wrong?
    Game.GetPlayer().AddToFaction(PlayerWerewolfFaction)    Game.GetPlayer().AddToFaction(WerewolfFaction)    int cfIndex = 0    while (cfIndex < CrimeFactions.GetSize());         Debug.Trace("WEREWOLF: Setting enemy flag on " + CrimeFactions.GetAt(cfIndex))        (CrimeFactions.GetAt(cfIndex) as Faction).SetEnemy(WerewolfFaction, False, True)        cfIndex += 1    endwhile

I have a custom faction that I'm using, but it's literally the same block of code. I'm trying to make it work for more than just the player, so I don't want to use the SetPlayerEnemy() function. If I use SetPlayerEnemy, the code works fine. If I use SetEnemy, it seems like everyone except guards hates me. Which is weird, because it's the exact same list of factions that I am running it on. In the above example I have tried SetEnemy(WerewolfFaction, False, False) and SetEnemy(WerewolfFaction, True, True), just to be make sure I wasn't crazy--no luck. It seems as though the guards remain allies unless I use SetPlayerEnemy() and truthfully I don't know what else remains an ally. With this code, the guards go on a killing spree in town because the peasents try to kill me. While funny, it is not my intended effect.

Anyone got any ideas?
User avatar
Peter lopez
 
Posts: 3383
Joined: Mon Sep 10, 2007 5:55 pm

Post » Mon Jun 18, 2012 12:18 pm

Bump
User avatar
Lindsay Dunn
 
Posts: 3247
Joined: Sun Sep 10, 2006 9:34 am

Post » Mon Jun 18, 2012 4:46 pm

Bump.
User avatar
Angel Torres
 
Posts: 3553
Joined: Thu Oct 25, 2007 7:08 am

Post » Mon Jun 18, 2012 10:51 pm

SetEnemy - this is the way to establish normal friend/ally/enemy/neutral relations between two factions. Difference here is that if NPC1 is in two factions (FactionA and FactionB), and FactionA is enemy of NPC2, but FactionB is friend of NPC2, NPC1 will NOT attack NPC2 (because friend/ally status trumps enemy status).

SetPlayerEnemy - this sets the "enemy flag" on a faction, which means the player is treated as an enemy by every member of that faction - the same thing that happens when you commit a crime against a faction (even if that faction was normally friendly to you) - this temporarily overrides the faction relation status of the faction towards the player (enemy/neutral/ally) and allows even friendly/allied factions to aggro on the player.
User avatar
Alister Scott
 
Posts: 3441
Joined: Sun Jul 29, 2007 2:56 am

Post » Mon Jun 18, 2012 12:18 pm

SetEnemy - this is the way to establish normal friend/ally/enemy/neutral relations between two factions. Difference here is that if NPC1 is in two factions (FactionA and FactionB), and FactionA is enemy of NPC2, but FactionB is friend of NPC2, NPC1 will NOT attack NPC2 (because friend/ally status trumps enemy status).

SetPlayerEnemy - this sets the "enemy flag" on a faction, which means the player is treated as an enemy by every member of that faction - the same thing that happens when you commit a crime against a faction (even if that faction was normally friendly to you) - this temporarily overrides the faction relation status of the faction towards the player (enemy/neutral/ally) and allows even friendly/allied factions to aggro on the player.
Don't know what I'd do if you didn't reply to most of my questions Maturin, thanks.

Is there any other way to replicate tripping the enemy flag for any actor I specify? From what you said it seems like I'd have to force an actual crime to be made against the faction. Can I do that, would that work?
User avatar
k a t e
 
Posts: 3378
Joined: Fri Jan 19, 2007 9:00 am

Post » Mon Jun 18, 2012 12:27 pm

You could use SendAssaultAlarm, but that has other consequences (e.g. alerting nearby actors to the crime). I don't think there's a way to directly set the "actor enemy" flag through script.
User avatar
Gemma Flanagan
 
Posts: 3432
Joined: Sun Aug 13, 2006 6:34 pm

Post » Mon Jun 18, 2012 11:02 pm

You could use SendAssaultAlarm, but that has other consequences (e.g. alerting nearby actors to the crime). I don't think there's a way to directly set the "actor enemy" flag through script.

I see, unfortunate. Although now that I think about it, it may not be an issue. In your explanation, you stated that there was only abnormal behavior in the event of a conflicting ally/friend status. I could set it so that if the actor I'm passing to the function is the player, it uses SetPlayerEnemy, and if not, it will use SetEnemy instead. The way that I am intending to use this script, there should be no conflicting alliances with other factions.
User avatar
Terry
 
Posts: 3368
Joined: Mon Jul 09, 2007 1:21 am


Return to V - Skyrim