SurrenderToEnemies()

From NWN Lexicon
Jump to navigationJump to search

Causes all creatures in a 45 meter (4.5 tile) radius to stop actions, improves the creature's reputation with nearby enemies. Only works for NPCs.

void SurrenderToEnemies();

Description

Use this on an NPC to cause all nearby creatures to stop what they are doing and sets the NPC's enemies within this range to be neutral towards the NPC with nearby enemies. If this command is run on a PC or an object that is not a creature, nothing will happen.


Remarks

Very useful function. Can for instance be used to make an enemy surrender just before dying, to try and cut a deal with his attackers...

It applies to creatures in a radius of about 45m from the caller, which is sufficient for almost all purposes (the official Bioware description says 10m, but that seems to be out-of-date - 45m is the maximum object distance for placeables and NPCs).

Note that the function applies to the caller. As always, if the creature due to surrender is not the caller of the current script, AssignCommand can be used. However, in that case, the function will not take effect immediately. Anything that needs to happen afterwards must be delayed (by assigning further commands to the same creature, for example).

The function adjusts personal reputation. Even members of global factions are affected.

The function pretty much does this:

  • Heal wounding from self (easiest done with EffectHeal) and ClearAllActions(TRUE) to stop combat.
  • All GetIsEnemy of self we:
    • ClearPersonalReputation(oTarget, oSelf) and ClearPersonalReputation(oSelf, oTarget)
    • SetIsTemporaryNeutral(oTarget, oSelf, FALSE), SetIsTemporaryNeutral(oSelf, oTarget, FALSE) - however the value set is not 50 but +79 (so if 0 reputation it becomes 79, if 10 it becomes 89 just shy of friendly) (as of writing this function is bugged, SetIsTemporaryFriend seems to work better).
    • AssignCommand(oTarget, ClearAllActions(TRUE));

You'd need to call this from every creature surrendering if there is more than one NPC enemy you want to surrender.

After some testing the 3 minute timeout never occurs - thus the FALSE part of SetIsTemporaryNeutral above.

It would be wise to also call SetPlotFlag or similar so the NPC doesn't immediately go hostile if inside of a hostile AOE spell or similar.


Known Bugs

Previous bug about wounding fixed in 1.62, the function does remove wounding effects from creatures so you can talk to them.

The description is wrong in two instances:

  • The 3 minutes doesn't apply - the neutral effect is permanent
  • The distance it applies to is 45M not 10M


Version

1.61

Example

//Cause an NPC to attack a player and then surrender so the player does not auto attack back at them.
void main()
{
     object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC);
     DelayCommand(2.0, SurrenderToEnemies()); 
     ActionAttack(oPC, TRUE);
}

It is possible to make the caller change sides during a battle:

// In this example, oNewEnemy is a creature previously on our side who we will now attack.
SurrenderToEnemies();
ClearPersonalReputation(OBJECT_SELF, oNewEnemy);
ClearPersonalReputation(oNewEnemy, OBJECT_SELF);
DetermineCombatRound();

See Also

functions: 

SurrenderAllToEnemies

SetIsTemporaryNeutral

ClearAllActions



 author: John Shuell, editor: Jasperre