Neverwinter Nights: Enhanced Edition

Neverwinter Nights: Enhanced Edition

Adventures await!
Gather your mods before venturing forth. Discover planes filled with player-created adventures in Steam Workshop, then build your own Neverwinter Nights modules using the Aurora Toolset to share!
Learn More
ICR 19 Jun, 2020 @ 12:08pm
making the monsters random walk away from corpse.
Hey all. Does anyone have any tips on creating a script that activates on the PC dying and makes the NPCs wander away? My current script just has them standing over my body even after I stabilize and stand. A 6 second Sanctuary Effect occurs immediately upon going to zero of less HP.

void main()
{
object oPlayer = GetLastPlayerDying();
if (!GetIsObjectValid(oPlayer))
return;

int iCurrentHP = GetCurrentHitPoints(oPlayer);

if (iCurrentHP > 0) // not dying
return;

if (iCurrentHP <= -10) // dead
{
effect eDeath = EffectDeath(FALSE, FALSE);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDeath, oPlayer);
return;
}

SetLocalInt(oPlayer, "BLEED_STATUS", 2); // bleeding
AssignCommand(oPlayer, ClearAllActions());
SetLocalInt(oPlayer, "LAST_HP", iCurrentHP);

if (GetStandardFactionReputation(STANDARD_FACTION_COMMONER, oPlayer) <= 10)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_COMMONER, 80, oPlayer);
}
if (GetStandardFactionReputation(STANDARD_FACTION_MERCHANT, oPlayer) <= 10)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_MERCHANT, 80, oPlayer);
}
if (GetStandardFactionReputation(STANDARD_FACTION_DEFENDER, oPlayer) <= 10)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_DEFENDER, 80, oPlayer);
}
if (!GetIsObjectValid(oPlayer))
return;
//6 seconds of Sanctuary to stop monster attacks
AssignCommand(oPlayer, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectSanctuary(81), oPlayer, 6.0));
DelayCommand(6.0, ExecuteScript("js_util_bleed", oPlayer));
}
< >
Showing 1-3 of 3 comments
Proleric 5 19 Jun, 2020 @ 2:35pm 
The easiest way is to make waypoints tagged POST_foobar at the initial location of each monster, where foobar is the monster tag.

No scripting required.

When monsters see the PC, combat AI takes priority, but when the PC is dead, walk waypoints AI takes over, and the monsters return to post.

If you need this to happen when the PC is merely dying, SurrenderToEnemies will have the same effect. It also enables random walk or walk waypoints to resume if you prefer.
Last edited by Proleric; 19 Jun, 2020 @ 2:46pm
ICR 27 Jun, 2020 @ 9:01am 
Originally posted by Proleric:
The easiest way is to make waypoints tagged POST_foobar at the initial location of each monster, where foobar is the monster tag.

No scripting required.

When monsters see the PC, combat AI takes priority, but when the PC is dead, walk waypoints AI takes over, and the monsters return to post.

If you need this to happen when the PC is merely dying, SurrenderToEnemies will have the same effect. It also enables random walk or walk waypoints to resume if you prefer.

Hrmm. My only issue would be that the description of SurrenderToEnemies seems to be more of an NPC thing.

"If this command is run on a PC or an object that is not a creature, nothing will happen."

I'll have to see if that is the case. Thanks!
Proleric 5 27 Jun, 2020 @ 10:29am 
True - you might have to loop through the monsters with ClearAllActions(TRUE) and make them temporarily neutral, by faction reputation if global, or SetIsTemporaryNeutral if not.
< >
Showing 1-3 of 3 comments
Per page: 1530 50