Choose Your Language

Tuesday, 28 December 2010

Casting Hostile Spells On Neutrals

I was going to leave posting a new blog for another week in case the holiday season had kept people away and not given them time to catch up with what is already written. However, I was caught up in an interesting topic raised by Matthew Rieder (of The Wizard's Apprentice module) about an age old issue I have also looked at regarding targeting "neutrals" in a game with direct hostile spells. E.g. It is impossible to target a "neutral" NPC (considered friendly) with the Magic Missile spell. While on the surface of things this may not appear to be a huge problem, it can be argued that such a system is railroading the player into who they can or cannot consider a foe and attack if required. While there is a setting in the Campaign Options to allow a PC to physically attack neutrals, it still does not allow the PC to target them with hostile spells until after they have turned "hostile" (normally after the initial attack from the player's PC).

Therefore, this week, I decided to come up with a system that would overcome this problem. Initially, I tried to overcome the problem by directly implementing a new cursor system as proposed by 0100010 (Edward Beck), but this turned out to be rather unwieldy for my own purposes and so I decided to go about the problem a different way and came up with the following system. As usual, all your comments, questions and suggestions for improvements are welcome!

Before I go into more detail, however, I would still like to receive feedback from last week's blog and the for the current poll: Will You Be Crafting? Even if you have nothing more to say about the topic, I would be interested to see what the general consensus is regarding crafting. Please find more detail in this post about Increased Spell Power.

Know Thy Enemy

In the end, I decided that simply targeting a neutral with a hostile spell was against the spirit of the game anyway. After all, why would someone simply cast a magic missile at a neutral? OK, all chaotic evil players need not answer that. Even so, there is normally a little more reason to attack a neutral than just as something to do. In most circumstances, the player will have a little idea of who the NPC is before they attack them. At the very least they will examine them to read a bit about them (if available). With this in mind, I determined that it could be via the examine window that the player could decide whether they wanted to attack the NPC in question or not.

Goodie Or Baddie?

To this end, I added a new button to the examine GUI that allows a player to switch the hostile/neutral status of the NPC they are examining. Switching the NPC's status this way does not affect the hostile settings to other creatures in the area, as the NPC simply turns hostile to the party by using an Anti-Party faction setting. At the same time, the player's party AI is switched off to prevent any party members automatically starting to attack the new hostile NPC. Once turned hostile, the player can target the NPC with their PC's hostile spells without any further problems. If the player changes their mind about attacking this NPC, then the same toggle switch can be used to turn the NPC back to a neutral. Note, however, hostile creatures or those factions already Anti-Party by default cannot be turned to a neutral faction.

Consequences

Attacking a neutral in an area of other neutrals comes with consequences. After all, people are not going to stand around and allow one of their own to be attacked, physically or with spells, if they are close enough to witness the event and can help. Therefore, a player must use this facility with due consideration for the consequences of their actions. Using it to attack a villager in a village of people may not be such a good idea, whereas suddenly attacking an evil NPC in their home to avoid greater bloodshed later on may be a wise move.

Other Information

The new examine window has been modified to give "live" distance to target as well, updating the GUI four times every second. This can be useful if you are preparing to use a spell that is restricted to a range and you only want to release the spell when the target is within range (and to avoid your PC from running forward to cast the spell). Furthermore, the range has the category of spell range within parenthesis after it (Touch, Short, Medium, Long) to help easily work out what spell range the target is within.

Now follows some composite screenshots giving an idea of what the system will look like in action:


1) We are examining a neutral NPC villager, currently at 30 feet (short spell range).


2) Note how the villager has moved closer and the range has dropped to 7 feet, now at Touch spell range (for the campaign).


3) When choosing to turn this villager hostile to the party, all party AI is disabled to prevent unplanned assaults. Chat window gives feedback. If "Pause On Hostile Sighted" is enabled, auto-pause will also start.


4) Faction settings prevent "hostile" villagers reacting to any other creatures until actually attacked.


5) Re-examining the villager shows it now as hostile (has a red ring) and updated range.


6) Player has chosen to revert this NPC back to a neutral. The chat window is updated.

13 comments:

Anonymous said...

hi Lance,
I'm not too hep on XML/GUI script calls, but this idea is def. something I would like to implement (on my system & hobby-mod). Will you be making this implementation public, whether as a standalone package or simply as copypasta?

Myself, what I need is the chunk of XML code that calls that faction-change script, the latter which I hope to be able to doctor, using something like 'SetPersonalReputation' against my PC (thereby avoiding setting up a custom faction, as suggested above) - all for use in the OC etc.

Like I say, I'm assuming a lot here .. but it should be simple as that, yes?


(if it sounds like I'm grinding my teeth here, it's because I'm trying not to (toothache))

-kevL

Anonymous said...

hi Lance,

I'm not too hep on XML/GUI script calls, but this idea is def. something I would like to implement (on my system & hobby-mod). Will you be making this implementation public, whether as a standalone package or simply as copypasta?

Myself, what I need is the chunk of XML code that calls that faction-change script, the latter which I hope to be able to doctor, using something like 'SetPersonalReputation' against my PC (thereby avoiding setting up a custom faction, as suggested above) - all for use in the OC etc.

Like I say, I'm assuming a lot here .. but it should be simple as that, yes?


(if it sounds like I'm grinding my teeth here, it's because I'm trying not to (toothache))

-kevL

Lance Botelle (Bard of Althéa) said...

Hi KevL,

Sorry to hear you have a toothache. :( You have my sympathies.

It *is* as simple as you suggest. The new button on the examine window allows you to fire off a script that does whatever you want. In this case, it is used to change the reputation of the NPC you are examining, with respect to the party.

Adding new elements to the existing and new GUIs is one of the best new facilities we have available to us (as builders) to design new and alter existing mechanics.Grab a copy of my XML tutorial to see how this can be done: http://nwvault.ign.com/View.php?view=NWN2Tutorials.Detail&id=92

The altered XML examine script will be released with the module, and I have already given the altered script to another builder to use who will probably be releasing their own module before mine, so it will be available there too.

However, knowing how to do the alteration for yourself is the best way to go and is why I recommend my tutorial. If, however, you would like the code already done, then contact me again and I will make the XML code available. Note, however, the NWN2 scripts that it fires from within the module would still be up to the builder to create, as they would differ from my own.

Thanks for your interest.

Lance.

Anonymous said...

hey Lance,
tooth feels much better today. I'm truly starting to believe one's best doctor is thyself.

& Tks for the offer, but you're right: I've been putting off the XML tutorial for too long; the scripting shouldn't be any problem on this end ... so, I'm glad to hear that placing a GUI-call on an icon isn't as difficult as say, hard drive recovery.

which speaking of - **make those back-ups** - yes, pronto



Have Good Day, sir!
ps. been following World of Althea, for some time.
pps. have yet to play Wizard's Apprentice.
ppps. looking forward to both!!

-kevL

Lance Botelle (Bard of Althéa) said...

Hi KevL,

Good to hear tooth is feeling better.

Thanks for being a regular follower of my blog. :) I hope you continue to stay in touch long enough to play the module when I finally get it released. :)

Be sure to keep commenting. It helps to keep me focused on what player's want. :)

Lance.

Anonymous said...

hi Lance,
just a word of personal advice

it's what *you* want that's important to us.


-anoN (we are Legion)

Lance Botelle (Bard of Althéa) said...

Hi Anon,

I appreciate your kind words. :)

I hope I will be including a great deal of my own ideas that will appeal to many. However, with respect to mechanics, I do like to try to ensure most player's preferred styles of play are catered for ... if possible. :)

Lance.

Shaughn said...

Lance,

I have a question on how the disabled AI will work.

After the player selects the hostle toggle.
-How long will the NPC remain hostile and have no action?
-How long will the companions AI remain inactive once a NPC is turned hostile?
-Does this also disable the AI of defender faction NPCs?
-Followup to the first two questions. What will happen if a NPC is set to hostile, but the player doesn't attack them and just goes back to the game with no hostile actions?
-And finally is there a chance that the NPC will realize what is going on (spot, listen, intuition) and attack the player right away taking away their advantage and likely causing a concentration check?

Shaughn said...

Sorry, one more question.

-How will the companions react to a third party hostile creature thrown in the mix before attacking the newly toggled hostile NPC?

This system does sound neat and I'm interested in hearing more.

Would something like this be able to be used with companions. I am thinking to my campaign that has an undead companion. It sounds like this may be able to be used to toggle the undead companion to become a target of inflict wounds and get healed by negative energy.

Lance Botelle (Bard of Althéa) said...

Hi Shaughn,

To answer your questions ...

1) Currently, the NPC (normally neautral) will remain hostile until the player chooses to either attack them, or turn them neutral again.

2) I turn the AI for the companions to OFF when the player turns an NPC hostile using this method. The player can turn it back on at any time using the standard NWN control in the bottom left hand corner. NB: All I do is turn all PCs to "Puppet Mode" at the moment of activating the hostile button. The player can then arrange combat as required before letting companions do their thing.

3) All other NPC AI remains unaffected when this option is used to turn an NPC potentially hostile to the party. However, if the party attack the now hostile NPC, nearby NPCs previously not hostile will become hostile because of the player attacking a fellow NPC.

4) The NPC will remain hostile and the PC will not be able to talk to them as the default action is now set to "attack". If the player decides they do want to talk after all, then they must change the NPC back to neutral.

5) As it stands at the moment: no. Although it could be coded if need be. However, I have not done so because the NPC has no suspicion that the PC has any intent on attacking them. If there was any suspicion, then the NPC would already be hostile - and likely changed earlier due to a story role. In hindsight, this option is probably more appropriate to playing an evil PC who might want to kill by surprise. However, there may still be the odd occassion where the player/PC wants to surprise the NPC with an attack ... even if they are wrong in doing so. I can hear it now, "I thought he was evil". The point is, I want to make the lines between the good huys and the bad guys be a little less obvious and may require some careful judgment calls by the player.

6) (From second post.) I have not tested this. In theory, however, the new hostile creature would attack the party along with the now hostile NPC, and the NPC may attack either the party or the new hostile. I would probably need to test this to be sure, but that is my first estimation.

I am glad you like the sound of it. :)

As it currently stands, I have disabled the option to turn companions hostile, but that is because I have other code to handle interaction like this with them, including an influence system and reaction to being physically attacked. As AoE spells can affect party members in my campaign, I had to work some code that allowed damage and *not* turn them hostile as a result. All that said, the same system could (I believe) be used to turn companions hostile. (After all, it did before I disabled it.)

Lance.

kevL said...

hi again Lance,

just want to say thanks for the Mentorship. I got your tutorial under my belt and now read XML almost fluently. This means I can turn those .. irritatingly invulnerable (at times) NPCs in the OC into hittable / spellable boffins! Unfortunately the OC, etc, doesn't seem to have Personal Reputation (only global, haven't actually checked there recently), so great care & tactics need to be taken - plus an emergency button on the Examine panel that sets things to rights again, Lance.

notes: had to put in a number of checks and feeback messages (no items, no friendlies, has to have a target). My next task is to put in an insta-kill button .. for those really bad days when I just gotta see something explode ;)

You were certainly right about the power of the Gui, you mentioned above! A panel could be designed that does a variety of household chores like changing the time of day (for whatever reason, perhaps ya want buffs to wear off so something can be tested or checked). Anyway, thanks a lot for the brainstorm and the advice


hope your project Althea is coming along to yer satisfaction!!!

Lance Botelle (Bard of Althéa) said...

Hi KevL,

You are welcome! I hope you continue to grow in these skills. :)

One thing worth remembering when it comes to allowing a PC to attack an NPC "in the OC", is that they sometimes are used to forward the plot of the game, even if not on first meeting. Therefore, great care must be taken as to which NPCs you can actually attack this way. In your own campaign you can put in a number of safety checks to prevent the untimely death of a quest handler, as I have done.

Checks .. Yes, I too have a number in mine as well, to ensure the correct object has been selected in the first place. :) It makes for good coding to error trap all this kind of thing.

The project is slowly coming along. I hope to have a beta release of module 1 soon ... a few months. Keep an eye open for it. :)

Lance.

kevL said...

i Will (so will many others, no doubt)

It's good you point out 'Plot' characters (in the OC+) - I originally had Plot flagged characters non-hostilable, then noticed at least in the OC that the real plot characters were not set to plot while the nonPlot stand-arounds (ie. those most likely to get a knife in the back from a Chaotic or Neutral Evil PC) were actually marked as Plot, go figur

which of course *should* lead to the issue of Global Reputation.



you aren't going to believe this: my Word Verification is "guilingl" ..