Updated Jasperre's AI

Updated Jasperre's AI to 1.4, fixed a few other coding bugs & fully compiled module.
This commit is contained in:
Jaysyn904
2021-08-30 17:31:44 -04:00
parent 2e0b5b615b
commit 1c1c90e986
404 changed files with 11239 additions and 7881 deletions

View File

@@ -1,26 +1,25 @@
/************************ [On Phisical Attacked] *******************************
Filename: j_ai_onphiattack or nw_c2_default5
************************* [On Phisical Attacked] *******************************
/*/////////////////////// [On Phisical Attacked] ///////////////////////////////
Filename: J_AI_OnPhiAttack or nw_c2_default5
///////////////////////// [On Phisical Attacked] ///////////////////////////////
On Attacked
No checking for fleeing or warnings.
Very boring really!
************************* [History] ********************************************
///////////////////////// [History] ////////////////////////////////////////////
1.3 - Added hiding things
************************* [Workings] *******************************************
1.4 - Missing Silent Shouts have been added.
///////////////////////// [Workings] ///////////////////////////////////////////
Got some simple Knockdown timer, so that we use heal sooner if we keep getting
a creature who is attempting to knock us down.
************************* [Arguments] ******************************************
///////////////////////// [Arguments] //////////////////////////////////////////
Arguments: GetLastAttacker, GetLastWeaponUsed, GetLastAttackMode, GetLastAttackType
************************* [On Phisical Attacked] ******************************/
///////////////////////// [On Phisical Attacked] /////////////////////////////*/
#include "j_inc_other_ai"
#include "J_INC_OTHER_AI"
void main()
{
// Pre-attacked-event
if(FireUserEvent(AI_FLAG_UDE_ATTACK_PRE_EVENT, EVENT_ATTACK_PRE_EVENT))
// We may exit if it fires
if(ExitFromUDE(EVENT_ATTACK_PRE_EVENT)) return;
// Pre-attacked-event. Returns TRUE if we interrupt this script call.
if(FirePreUserEvent(AI_FLAG_UDE_ATTACK_PRE_EVENT, EVENT_ATTACK_PRE_EVENT)) return;
// AI status check. Is the AI on?
if(GetAIOff()) return;
@@ -28,11 +27,11 @@ void main()
// Set up objects.
object oAttacker = GetLastAttacker();
object oWeapon = GetLastWeaponUsed(oAttacker);
int iMode = GetLastAttackMode(oAttacker); // Currently unused
int iAttackType = GetLastAttackType(oAttacker);
//int nMode = GetLastAttackMode(oAttacker); // Currently unused
int nAttackType = GetLastAttackType(oAttacker);
if(GetIsObjectValid(oAttacker) && !GetFactionEqual(oAttacker) &&
!GetIsDM(oAttacker) && !GetIgnore(oAttacker))
// Check if they are valid, a DM, we are ignoring them, they are dead now, or invalid
if(!GetIgnoreNoFriend(oAttacker))
{
// Adjust automatically if set.
if(GetSpawnInCondition(AI_FLAG_OTHER_CHANGE_FACTIONS_TO_HOSTILE_ON_ATTACK, AI_OTHER_MASTER))
@@ -42,23 +41,28 @@ void main()
AdjustReputation(oAttacker, OBJECT_SELF, -100);
}
}
// If we were attacked by knockdown, for a timer of X seconds, we make
// sure we attempt healing at a higher level.
if(!GetLocalTimer(AI_TIMER_KNOCKDOWN) &&
(iAttackType == SPECIAL_ATTACK_IMPROVED_KNOCKDOWN ||
iAttackType == SPECIAL_ATTACK_KNOCKDOWN) &&
(nAttackType == SPECIAL_ATTACK_IMPROVED_KNOCKDOWN ||
nAttackType == SPECIAL_ATTACK_KNOCKDOWN) &&
!GetIsImmune(OBJECT_SELF, IMMUNITY_TYPE_KNOCKDOWN) &&
GetBaseAttackBonus(oAttacker) + i20 >= GetAC(OBJECT_SELF))
GetBaseAttackBonus(oAttacker) + 20 >= GetAC(OBJECT_SELF))
{
SetLocalTimer(AI_TIMER_KNOCKDOWN, f30);
SetLocalTimer(AI_TIMER_KNOCKDOWN, 30.0);
}
// Set last hostile attacker.
// Set last hostile, valid attacker (Used in the On Damaged event)
SetAIObject(AI_STORED_LAST_ATTACKER, oAttacker);
// Speak the phisically attacked string, if applicable.
// Speak the damaged string, if applicable.
SpeakArrayString(AI_TALK_ON_PHISICALLY_ATTACKED);
// * Don't speak when dead. 1.4 change (an obvious one to make)
if(CanSpeak())
{
// Speak the phisically attacked string, if applicable.
// Speak the damaged string, if applicable.
SpeakArrayString(AI_TALK_ON_PHISICALLY_ATTACKED);
}
// Turn of hiding, a timer to activate Hiding in the main file. This is
// done in each of the events, with the opposition checking seen/heard.
@@ -79,19 +83,52 @@ void main()
// If we are not fighting, and they are in the area, attack. Else, determine anyway.
if(!CannotPerformCombatRound())
{
// Must be in our area to go after now.
if(GetArea(oAttacker) == GetArea(OBJECT_SELF))
{
// 59: "[Phisically Attacked] Attacking back. [Attacker(enemy)] " + GetName(oAttacker)
DebugActionSpeakByInt(59, oAttacker);
// Attack the attacker
DetermineCombatRound(oAttacker);
// Shout to allies to attack the enemy who attacked me
AISpeakString(AI_SHOUT_I_WAS_ATTACKED);
}
else
{
// Shout to allies to attack, or be prepared.
AISpeakString(AI_SHOUT_CALL_TO_ARMS);
// 60: "[Phisically Attacked] Not same area. [Attacker(enemy)] " + GetName(oAttacker)
DebugActionSpeakByInt(60, oAttacker);
DetermineCombatRound();// May find another hostile to attack...
// May find another hostile to attack...
DetermineCombatRound();
}
}
else
{
// Shout to allies to attack, or be prepared.
AISpeakString(AI_SHOUT_CALL_TO_ARMS);
}
}
// Else, invalid, DM, ally, etc...must be prepared at least (could be
// they are charmed or something!)
else
{
// If we are not fighting, prepare for battle. Something bad must have
// happened.
if(!CannotPerformCombatRound())
{
// Respond to oAttacker as if they shouted for help.
IWasAttackedResponse(oAttacker);
}
else
{
// Shout to allies to attack, or be prepared.
AISpeakString(AI_SHOUT_CALL_TO_ARMS);
}
}
// Fire End of Attacked event