MMD_PRC8/_module/nss/xx_pc_3_endround.nss
Jaysyn904 d77404f157 2025/07/15 Update
Added PEPS AI.
Updated module name.
Set all henchmen to have a random race &/or class based name using a custom version of Markshire's Nomeclature scripts, as well as appearance.
Set Constructs, Undead, Outsiders & Elementals to not require food or drink.
Full compile.
2025-07-15 22:19:46 -04:00

61 lines
2.8 KiB
Plaintext

/*//////////////////////////////////////////////////////////////////////////////
Script: xx_pc_3_endround
Programmer: Philos
////////////////////////////////////////////////////////////////////////////////
Player OnCombatRoundEnd event script for PC AI;
Fires at the end of each combat round (6 seconds).
This will fire as long as oCreature is in combat (GetIsInCombat()).
This event starts counting once a combat action is started.
Every time a spell is cast it will queue another end combat round so haste with
two spells cast will fire this twice in one round.
It will also fire at the end of a hostile effect that stops actions i.e Stunned, Knockdown etc.
Action modes are also cleared prior to this event executing!
GetAttemptedAttackTarget() & GetAttemptedSpellTarget() also get cleared prior to this event.
This event can be canceled with ClearAllActions(TRUE) and SurrenderToEnemies.
*///////////////////////////////////////////////////////////////////////////////
#include "0i_associates"
void main()
{
object oCreature = OBJECT_SELF;
if(AI_DEBUG) ai_Debug("xx_pc_3_endround", "20", GetName(oCreature) + " ends combat round.");
if(ai_Disabled(oCreature)) return;
// Action modes get cleared prior to each OnCombatRoundEnd!
// We do this to keep the action mode going.
int nActionMode = GetLocalInt(oCreature, AI_CURRENT_ACTION_MODE);
if(nActionMode > 0)
{
SetActionMode(oCreature, nActionMode, TRUE);
// We don't want to use up all of the Dwarven Defenders uses!
if(nActionMode == 12) IncrementRemainingFeatUses(oCreature, FEAT_DWARVEN_DEFENDER_DEFENSIVE_STANCE);
}
int nAction = GetCurrentAction(oCreature);
if(AI_DEBUG) ai_Debug("xx_pc_3_endround", "32", "nAction: " + IntToString(nAction));
switch(nAction)
{
// These actions are uninteruptable.
case ACTION_MOVETOPOINT :
case ACTION_CASTSPELL :
case ACTION_ITEMCASTSPELL :
case ACTION_COUNTERSPELL : return;
// Might be doing a special action that is not a defined action.
case ACTION_INVALID :
{
int nCombatWait = GetLocalInt(oCreature, AI_COMBAT_WAIT_IN_SECONDS);
if(AI_DEBUG) ai_Debug("xx_pc_3_endround", "47", "nCombatWait: " + IntToString(nCombatWait));
if(nCombatWait)
{
if(ai_IsInCombatRound(oCreature, nCombatWait)) return;
DeleteLocalInt(oCreature, AI_COMBAT_WAIT_IN_SECONDS);
}
break;
}
// We always want to interupt an attack action at the end of a round (6 seconds).
case ACTION_ATTACKOBJECT :
{
if(ai_IsInCombatRound(oCreature, AI_COMBAT_ROUND_IN_SECONDS)) return;
}
}
if(ai_GetIsInCombat(oCreature)) ai_DoAssociateCombatRound (oCreature);
}