I’ve got a battle with a bunch of Xvarts, a couple of pigs a sorcerer and an Orc Boss. The way I want it to go down is - after a certain amount of HP is left on the orc boss, all fighting will cease, everybody becomes friends, then a conversation will ensue. That’s it in a nutshell.
I’ve tried using: GetIsReactionTypeHostile(), ChangeToStandardFaction()
All w/ no luck.
As of right now - exactly nothing happens. As if the script didn’t exist. She (The Orc Boss) and all the xvarts, boars and sorcerer just keep fighting until one of us is dead. She’s supposed to stop fighting when she’s down to about 25%.
I would put in some feedback to see where things might not be firing.
Since you actually have the script get the OBJECT_SELF, you should park that in the GetMaxHitPoints(oVyxara) and GetCurrentHitPoints(oVyxara). You may also want to do the x100 math outside of the nRatio declaration. While it makes sense for coding how you put it, NWNscript can find weirdness in simple sections.
int nMaxHP = GetMaxHitPoints();
int nCurHP = GetCurrentHitPoints();
int nCurHPx100 = 100*nCurHP;
int nRatio = nCurHPx100/nMaxHP;
SendMessageToPC(oPC, "Current HPs are "+IntToString(nCurHP)+". The Ratio is "+IntToString(nRatio));
if (nRatio >= 25)
{
SendMessageToPC(oPC, "Ratio triggered");
if ( GetIsReactionTypeHostile(oVyxara, oPC) )
{
SendMessageToPC(oPC, "I am Hostile");
if (nRatio <= 25) is correct not the above quote. Cant believe I missed that.
All is well. Code is firing perfectly now. Thanks to everybody who helped!
Checking over my own code, it can help to set the plot flag on the NPC, too.
That prevents the NPC from retaliating if some delayed combat activity occurs for any reason.
Further action is required in the special case that, by design, not all enemies are surrendering at once.
The default AI tells the NPC to fight the remaining enemies, rather than wait for the PC to speak to them. Highly undesirable if the NPC is immortal and/or plot!
The reason for this seems to be that SurrenderToEnemies() sets the party’s reputation to friendly (100), not 89 as stated in the Lexicon.
As far as I can see there is a very simple solution - set the NPC’s plot flag, then. in their OnConversation script, don’t respond to shouts if the plot flag is set.
P.S. It’s strange that Bioware didn’t place a universal block on plot characters entering combat. Several of the default AI scripts block this at the outset, but it looks like that change was quite late in the day and incomplete.
Hmm, I get halfway through the conversation, and everyone attacks again. Can’t quite figure out what sets them off again?
Initially I thought the poison from the Xvart spears was causing the disruption - They do, however, cause everyone to turn hostile, but it’s not the only disruption.
After a small amount of time elapses, if for no other reason than there is none, everyone turns hostile again.
I’m going to have a look at few dialog nodes to see if I can glean anything useful.
It’s intermittent in nature. Sometimes they attack, sometimes it even goes off without a hitch.
The last dialog node of the conversation causes everyone to attack!