[Toolset] Script: Ignore Target Rules (How SpellTargetting Neutral NPC?)

Anyone know how this thing works?
I simply need a PC to target a neutral NPC with hostile spells.
In a global way.
Anyone know what flags to check?
What I want is that players are allowed to attack with offensive spells, even neutral targets.
At the moment if I try to launch a magic missile on a commoner, it does not highlight it as a possible target.
Anyone know how to change this thing?
Thank you. I’m stuck on this thing.

Set Faction Neutral under 50.


1 Like

Under 50, means 49? Actually is 50. I’m going to try fast.

If you want them to react, they must be almost hostile towards you.
However, if it’s only one “specific” NPC, it’s best to script everything, as the neutral faction will be aggressive towards the PC after that.

No, it doesn’t work. If set to 11 the NPC is still neutral and not targetable.
If set 10, it becomes hostile.
I want to be able to launch a magic missile at a fucking neutral farmer and then make him hostile.
It is inconceivable how fucking stupid this program is.

There is probably some flag to tick that matches the name of the ignore target, but I can’t find how to do it anywhere.

Make a faction for the specific NPC and modify the scripts so that your NPC acts as desired (see picture). Mainly nw_c2_default9 (rename it). In the image it is named z3_c2_default9.


1 Like

I have already something like this. I have this neutral faction, (50).
I can physical attack them, but I can’t cast offensive spells on them.
This means that a PC caster couldn’t never shot first.
I want that a PC caster could shot first.

You did well to make this post. You just made me realize that my scripts placed on “On User Defined Scripts” do not work like I tought. Will try to figure it out myself over the day, but scripting is not my best strength.

Although I don’t allow any players to attack neutral NPCs anymore than I allow bashing stuff in a store, because it doesn’t make sense, I still want to know how to write and trigger these kinds of scripts.

People abble to fix this issue or help us if they want, because it’s mostly a script adjustment, it’s @Lance_Botelle and @kevL_s .

1 Like

Hi Raymond,

Yes, I have circumvented this “issue” in my own module, The Scroll. :wink:

However, even though I have a solution, it is not something that I recommend lightly as it involves quite a large amount of other considerations. Anyway, the first and easiest way to do it is to set the Campaign setting PlayerCanAttackNeutrals, which then allows an attack. However, I cannot recall if this resolved the spell target issue. (I just read my own blog and it appears that this did not resolve the issue, which is why I went the way I did … next.)

That I solved by adding a button to an EXAMINE window. (New XML code.) It looks like a small sword (in swing). So when a player EXAMINES the NPC, they have the option to toggle hostility on or off. Once “hostile”, the NPC can be targeted with spells. I give this as an option for players to use judiciously. However, I have also taken steps to ensure that button cannot be used in some situations … and may be disabled completely (not show) when EXAMINING certain creatures.

That all said, this is more complex than one may first think, and all I can say is to check out my module and look at what I did.

I wrote a whole blog post on it once: https://worldofalthea.blogspot.com/2010/12/casting-hostile-spells-on-neutrals.html

My goodness, I was wrestling with this issue ten years ago now … how time flies by! :slight_smile:

EDIT: Actually, there is one minor difference from this original post (iirc), and that is the NPC turned “hostile” may end up attacking the PCs if they are noticed first.

Cheers, Lance.


@Lance_Botelle Isn’t there also a variable to insert in the “Module Property” if it is not a campaign and we can’t switch on/off the “PlayerCanAttackNeutrals” option?

Hi Raymond,

I am not aware of one, but that’s not to say there isn’t one. :wink:

EDIT: By the way, this is an area of my module code that I am currently working on some improvements that will be part of the next version. (Timing of auto-pausing with optional TB Combat play.)

Cheers, Lance.

1 Like

I ended up taking the cue from Lance and added a “Make Hostile” button on the Examine gui. But, like Lance says, there are many considerations/complications …

Nwn1 has this worked out way better than Nwn2. A possible further consideration is the use-personal-reputations flag(s). just to make things even more thorny, this flag can be set as a Campaign variable, a Module variable, and/or a Faction variable …

but i don’t know for sure what they all do or how they differ, and personally I decided to never use Personal Reps ( although i did prefer designing factions and NPCs by using personal reps in Nwn1 )

basically… good luck,

ps. If all you want is a mock battle, it might be possible to use ActionCastFakeSpellAt*() and script the results …


Same here! Never used them either. (I think I say reputations in my blog post, but that was when I did not know what to call stuff as well as I do now. :wink: ) i.e. I change the target’s faction and not reputation. Just wanted to clear that point.

Things get really complicated in this area. :slight_smile:


Indeed, I was consulting my old paper notes (I have like a nwn builder’s paper notebook) and my efforts in the past had given nothing either (I sould have reread my notes before making efforts for nothing … that betrays my age enormously… And yes, I write things down on paper, so I don’t have to remember everything … there are already enough things in my head…). :crazy_face:

However, if I find a tip, I would let everyone know. Although I don’t really need these kinds of scripts. Give players the power to kill neutral NPCs and the game will be unplayable. Anyway.

I hope @Sean_Maxhell will not be too disappointed. :neutral_face:

1 Like

Hi Raymond,

It became a rather philosophical debate in my own mind by the time I released the module. i.e. I wanted to give the player as much flexibility as possible. That was my first approach, but the task to maintain the integrity of the game if a player killed a main quest giver became horrendous to workaround. You can still see early workings of that initial goal in my code. E.g. Learning about the murder from investigating the areas without needing to glean that info from Orechin.

Then I realised that I would (potentially) have to do that for every quest! It nearly broke me, until I took the decision to tame down the ability to attack every NPC. In the end, what was the point really? That said, I definitely wanted to leave it in for careful players in special situations … e.g. (Spoiler alert) The player may work out that Ravel is a bad guy and want to get an edge on him. Therefore, that is one situation when a player could sneak up on him, use the toggle and attack. :wink:

Cheers, Lance.

1 Like

Actually, I gave it up.
I wanted to create a system where the player saw all the neutral creatures around him, and therefore could not predict whether the creature would prove hostile once it sensed him.
Forcing him to decide whether to preemptively attack the creature or try to communicate.
But apparently a neutral creature cannot be targeted with spells, and this would have penalized the casters who, in this way, could not have fired first.
So I don’t like it and I let it go.
Too bad because now the penalized is the low level rogue, which can pickpocket creatures (always hostile), but with an impossible CD of 30.


This might be the longest shot ever, but I wonder if one could cheese the rules by changing the 2da column which controls if a spell can be cast on hostiles or friendlies for the particular module where this is supposed to happen.

I know it works because I’ve done it for my campaign, but I needed a friendly spell (buff) cast on a hostile creature. Changing the column for that particular spell did the trick for me. Have no clue if this would work for the opposite way.

Hi Sean,

Did you read my post? :slight_smile:

Basically, you can do exactly what you want to do! I even gave that same example of a pre-emptive strike, or try communication. i.e. Spell casters CAN cast first if you go down the route I proposed. I quote myself below.

However, my point is that you would have to take more care regarding others around with respect to their factions relative to the situation.

Although, I can’t say I’m not relieved you are avoiding it, as unless you know more about this, you would have likely ended up in a real pickle. :wink:

The point and LOGIC being, attacking anyone with spells turns them into something other than neutral, for they are no longer neutral are they? And anybody who is of the same faction as them will likely turn hostile to the PCs too. i.e. They won’t or should not remain neutral! :roll_eyes: And the whole point about a pre-emptive strike is YOU, (or the player) are making the decision to say they are now hostile to you, whether you are correct or not.

Cheers, Lance.

Actually I don’t know how to manage GUI. Can I manage to add a button without creating external files?

to modify a stock gui-screen, make a copy of it to a higher priority folder and do edits there …


a note on Spells.2da “HostileSetting”

this likely isn’t feasible but remember that a ‘duplicate’ entry can be made for any spell in Spells.2da … one w/ HostileSetting=1 and the other w/ HostileSetting=0

The first is targetable against hostiles, the other against friendlies and neutrals …

( sry that isn’t really a solution, i just wanted to note it – I mean if it’s only one spell, eg Magic Missile, it might afford a tractible workaround, in some way )