Spell to only affect enemies, not friendly and neutral targe

Post » Wed Jun 20, 2012 8:38 am

I want to create a spell that only affects enemies, meaning that friendly and neutral targets should not be affected.

I could add a condition to work only on mobs attacking the caster, but I want this spell to also work on, for example, enemies that are calmed or feared. They are not attacking the player while influenced, but they are enemies. I basically want to consider friendly and neutral targets the NPCs you can interact around the world.

Which condition or scripted variable can I use to filter that kind of targets?


EDIT: I think what I need is to find out what makes mobs to become hostile in the first place. For example, a Giant will always attack if you get close, so they always have to be considered enemies, even when calmed. But a city guard will not naturally attack, so they are neutral. Maybe anything to do with factions?
User avatar
Alyesha Neufeld
 
Posts: 3421
Joined: Fri Jan 19, 2007 10:45 am

Post » Wed Jun 20, 2012 6:39 am

I assume you already tried "IsHostiletoActor" and "IsinFriendstate"?
User avatar
Brian LeHury
 
Posts: 3416
Joined: Tue May 22, 2007 6:54 am

Post » Wed Jun 20, 2012 4:29 am

"IsHostiletoActor" shouldn't work if an enemy is calmed though. Perhaps you could work with the disposition towards the player, (if such a thing exists as a parameter)? (unless calm affects that for some reason)
User avatar
Bellismydesi
 
Posts: 3360
Joined: Sun Jun 18, 2006 7:25 am

Post » Wed Jun 20, 2012 8:58 am

I assume you already tried "IsHostiletoActor" and "IsinFriendstate"?

IsHostileToActor, does not help because as soon as a mob is calmed, it stops being hostile.
IsInFirendState, I'll try that one!
User avatar
Esther Fernandez
 
Posts: 3415
Joined: Wed Sep 27, 2006 11:52 am

Post » Wed Jun 20, 2012 12:54 pm

IsHostileToActor, does not help because as soon as a mob is calmed, it stops being hostile.
IsInFirendState, I'll try that one!
That sounds more like a variable to marry or recruit. I think you will need to try with factions and it's relations.
User avatar
Elisabete Gaspar
 
Posts: 3558
Joined: Thu Aug 31, 2006 1:15 pm

Post » Wed Jun 20, 2012 2:07 pm

If it is an AoE spell, try changing the Magic Effect archetype to "spawn hazard." Then create a hazard object, and make a new spell that is like a single target version of the spell you want.

I used this method here:
http://www.youtube.com/watch?v=6sSL16ZSd3k


As you can see, normally neutral NPCs such as the Imperials at the beginning clip and the guy in the cart at the end of the clip will NOT have the spell "casted" on them by the hazard, but as soon as I attack them and even if they run away and don't attack back, the hazard will cast the spell on them. This way, the spell will not get you in trouble in towns, and will never hit followers or minions, but will attack anything you are in combat with.



Another alternative, which may be better for single target spells, would be

http://www.creationkit.com/GetFactionReaction_-_Actor


Simply use that in an if statement, with elseifs for each of the four types of reactions that you want stuff to happen.

So...


If ( akTarget.GetFactionReaction(Game.GetPlayer()) < 2)
;do something
EndIf

Where <2 means nuetral or hostile
User avatar
jadie kell
 
Posts: 3497
Joined: Sat Jul 29, 2006 3:54 pm

Post » Wed Jun 20, 2012 6:49 pm

If ( akTarget.GetFactionReaction(Game.GetPlayer()) < 2)
;do something
EndIf

Yes, faction reaction seems the way to go. Only issue I see is if I start attacking, say, a guard till he becomes hostile, then he can still be in a friendly faction even after getting hostile.
But maybe I can mix this with IsHostileToActor to create something like:

if (akTarget.GetFactionReaction(akCaster) < 2 || akTarget.IsHostileToActor(akCaster))
User avatar
Mylizards Dot com
 
Posts: 3379
Joined: Fri May 04, 2007 1:59 pm

Post » Wed Jun 20, 2012 3:41 pm

If you find a good way to handle this, would you mind telling us how you did it in the end?

Would be usefull to create "aura" like spells.
User avatar
jenny goodwin
 
Posts: 3461
Joined: Wed Sep 13, 2006 4:57 am

Post » Wed Jun 20, 2012 2:13 pm

I ended up implementing this:

if (akTarget.GetFactionReaction(akCaster) == 1 || akTarget.IsHostileToActor(akCaster))
...

So, if the target is hostile or belongs to a hostile faction, then trigger the effect. This is working great.
User avatar
Dj Matty P
 
Posts: 3398
Joined: Sat Jun 09, 2007 12:31 am


Return to V - Skyrim