MMD_PRC8/_module/nss/nw_c2_defaulte.nss

54 lines
2.1 KiB
Plaintext
Raw Normal View History

/*//////////////////////////////////////////////////////////////////////////////
Script: nw_c2_defaulte
Programmer: Philos
////////////////////////////////////////////////////////////////////////////////
Monsters OnBlocked event script;
Can be blocked by a creature or door.
*///////////////////////////////////////////////////////////////////////////////
#include "0i_associates"
2024-08-02 23:18:00 -04:00
void main()
{
object oCreature = OBJECT_SELF;
// This actually gets either a Creature or Door that is blocking OBJECT_SELF.
object oObject = GetBlockingDoor();
if(AI_DEBUG) ai_Debug("nw_c2_defaulte", "14", GetName(oCreature) + " is being blocked by " + GetName(oObject));
int nObjectType = GetObjectType(oObject);
if(nObjectType == OBJECT_TYPE_CREATURE)
2024-08-02 23:18:00 -04:00
{
if(GetIsEnemy(oObject, oCreature))
2024-08-02 23:18:00 -04:00
{
if(ai_CanIAttack(oCreature) && ai_GetIsInCombat(oCreature))
2024-08-02 23:18:00 -04:00
{
ai_DoMonsterCombatRound(oCreature);
return;
2024-08-02 23:18:00 -04:00
}
if(ai_CheckForCombat(oCreature, TRUE)) return;
}
}
// Anything below blocking us is a door.
if(nObjectType != OBJECT_TYPE_DOOR) return;
// Only open the door if the player has turned door opening on.
if(!GetLocalInt(GetModule(), AI_RULE_OPEN_DOORS)) return;
//if(GetLockKeyTag(oObject) != "") return;
else if(GetIsDoorActionPossible(oObject, DOOR_ACTION_OPEN) &&
GetAbilityScore(oCreature, ABILITY_INTELLIGENCE) >= 5)
{
if(AI_DEBUG) ai_Debug("nw_c2_defaulte", "33", GetName(oCreature) + " is opening " + GetName(oObject));
DoDoorAction(oObject, DOOR_ACTION_OPEN);
2024-08-02 23:18:00 -04:00
return;
}
// If we are in combat we should ignore doors that do not easily open.
if(GetIsDoorActionPossible(oObject, DOOR_ACTION_BASH) &&
ai_GetWeaponDamage(oCreature, 3, TRUE) > GetHardness(oObject) &&
GetLockKeyTag(oObject) == "")
2024-08-02 23:18:00 -04:00
{
ActionWait(1.0);
ActionAttack(oObject);
// Give them 3 rounds to break through a door.
DelayCommand(18.0, ai_ClearCreatureActions(TRUE));
return;
2024-08-02 23:18:00 -04:00
}
}