mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-10 10:50:24 +00:00
[Bots] Cleanup Bot Spell Functions, reduce reliance on NPC Functions/Attributes (#2495)
* [Bots] Initial Cleanup of Functions, moved Bot Casting out of mob_ai.cpp * Moved Bots off NPC AI_Spells Struct, and AI_Spells private attribute. * Formatting Fixes, fixed LogAI entries, Added LogAIModerate Alias * Add Constants. * Added Bot DB Struct, fixed some potential casting issues * Formatting * Formatting
This commit is contained in:
+59
-18
@@ -843,7 +843,7 @@ void Bot::GenerateBaseStats()
|
||||
int32 CorruptionResist = _baseCorrup;
|
||||
|
||||
// pulling fixed values from an auto-increment field is dangerous...
|
||||
switch(GetClass()) {
|
||||
switch (GetClass()) {
|
||||
case WARRIOR:
|
||||
BotSpellID = 3001;
|
||||
Strength += 10;
|
||||
@@ -2173,6 +2173,47 @@ bool Bot::Process()
|
||||
return true;
|
||||
}
|
||||
|
||||
void Bot::AI_Bot_Start(uint32 iMoveDelay) {
|
||||
Mob::AI_Start(iMoveDelay);
|
||||
if (!pAIControlled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (AIBot_spells.empty()) {
|
||||
AIautocastspell_timer = std::make_unique<Timer>(1000);
|
||||
AIautocastspell_timer->Disable();
|
||||
} else {
|
||||
AIautocastspell_timer = std::make_unique<Timer>(500);
|
||||
AIautocastspell_timer->Start(RandomTimer(0, 300), false);
|
||||
}
|
||||
|
||||
if (NPCTypedata) {
|
||||
AI_AddBotSpells(NPCTypedata->npc_spells_id);
|
||||
ProcessSpecialAbilities(NPCTypedata->special_abilities);
|
||||
AI_AddNPCSpellsEffects(NPCTypedata->npc_spells_effects_id);
|
||||
}
|
||||
|
||||
SendTo(GetX(), GetY(), GetZ());
|
||||
SaveGuardSpot(GetPosition());
|
||||
}
|
||||
|
||||
void Bot::AI_Bot_Init()
|
||||
{
|
||||
AIautocastspell_timer.reset(nullptr);
|
||||
casting_spell_AIindex = static_cast<uint8>(AIBot_spells.size());
|
||||
|
||||
roambox_max_x = 0;
|
||||
roambox_max_y = 0;
|
||||
roambox_min_x = 0;
|
||||
roambox_min_y = 0;
|
||||
roambox_distance = 0;
|
||||
roambox_destination_x = 0;
|
||||
roambox_destination_y = 0;
|
||||
roambox_destination_z = 0;
|
||||
roambox_min_delay = 2500;
|
||||
roambox_delay = 2500;
|
||||
}
|
||||
|
||||
void Bot::SpellProcess() {
|
||||
if(spellend_timer.Check(false)) {
|
||||
NPC::SpellProcess();
|
||||
@@ -2259,7 +2300,7 @@ void Bot::BotRangedAttack(Mob* other) {
|
||||
if (spellbonuses.NegateIfCombat)
|
||||
BuffFadeByEffect(SE_NegateIfCombat);
|
||||
|
||||
if(hidden || improved_hidden){
|
||||
if (hidden || improved_hidden) {
|
||||
hidden = false;
|
||||
improved_hidden = false;
|
||||
EQApplicationPacket* outapp = new EQApplicationPacket(OP_SpawnAppearance, sizeof(SpawnAppearance_Struct));
|
||||
@@ -5161,7 +5202,7 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b
|
||||
#endif
|
||||
//Live AA - Sinister Strikes *Adds weapon damage bonus to offhand weapon.
|
||||
if (Hand == EQ::invslot::slotSecondary) {
|
||||
if (aabonuses.SecondaryDmgInc || itembonuses.SecondaryDmgInc || spellbonuses.SecondaryDmgInc){
|
||||
if (aabonuses.SecondaryDmgInc || itembonuses.SecondaryDmgInc || spellbonuses.SecondaryDmgInc) {
|
||||
ucDamageBonus = GetWeaponDamageBonus(weapon ? weapon->GetItem() : (const EQ::ItemData*) nullptr);
|
||||
my_hit.min_damage = ucDamageBonus;
|
||||
hate += ucDamageBonus;
|
||||
@@ -6430,9 +6471,9 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(ka_time){
|
||||
if (ka_time) {
|
||||
|
||||
switch(GetClass()){
|
||||
switch (GetClass()) {
|
||||
case SHADOWKNIGHT: {
|
||||
CastSpell(SPELL_NPC_HARM_TOUCH, target->GetID());
|
||||
knightattack_timer.Start(HarmTouchReuseTime * 1000);
|
||||
@@ -6530,9 +6571,9 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) {
|
||||
int level = GetLevel();
|
||||
int reuse = (TauntReuseTime * 1000);
|
||||
bool did_attack = false;
|
||||
switch(GetClass()) {
|
||||
switch (GetClass()) {
|
||||
case WARRIOR:
|
||||
if(level >= RuleI(Combat, NPCBashKickLevel)){
|
||||
if (level >= RuleI(Combat, NPCBashKickLevel)) {
|
||||
bool canBash = false;
|
||||
if ((GetRace() == OGRE || GetRace() == TROLL || GetRace() == BARBARIAN) || (m_inv.GetItem(EQ::invslot::slotSecondary) && m_inv.GetItem(EQ::invslot::slotSecondary)->GetItem()->ItemType == EQ::item::ItemTypeShield) || (m_inv.GetItem(EQ::invslot::slotPrimary) && m_inv.GetItem(EQ::invslot::slotPrimary)->GetItem()->IsType2HWeapon() && GetAA(aa2HandBash) >= 1))
|
||||
canBash = true;
|
||||
@@ -6552,7 +6593,7 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) {
|
||||
case CLERIC:
|
||||
case SHADOWKNIGHT:
|
||||
case PALADIN:
|
||||
if(level >= RuleI(Combat, NPCBashKickLevel)){
|
||||
if (level >= RuleI(Combat, NPCBashKickLevel)) {
|
||||
if ((GetRace() == OGRE || GetRace() == TROLL || GetRace() == BARBARIAN) || (m_inv.GetItem(EQ::invslot::slotSecondary) && m_inv.GetItem(EQ::invslot::slotSecondary)->GetItem()->ItemType == EQ::item::ItemTypeShield) || (m_inv.GetItem(EQ::invslot::slotPrimary) && m_inv.GetItem(EQ::invslot::slotPrimary)->GetItem()->IsType2HWeapon() && GetAA(aa2HandBash) >= 1))
|
||||
skill_to_use = EQ::skills::SkillBash;
|
||||
}
|
||||
@@ -7006,7 +7047,7 @@ int64 Bot::GetActSpellDamage(uint16 spell_id, int64 value, Mob* target) {
|
||||
}
|
||||
|
||||
else if (GetClass() == WIZARD || (IsMerc() && GetClass() == CASTERDPS)) {
|
||||
if ((GetLevel() >= RuleI(Spells, WizCritLevel)) && zone->random.Roll(RuleI(Spells, WizCritChance))){
|
||||
if ((GetLevel() >= RuleI(Spells, WizCritLevel)) && zone->random.Roll(RuleI(Spells, WizCritChance))) {
|
||||
//Wizard innate critical chance is calculated seperately from spell effect and is not a set ratio. (20-70 is parse confirmed)
|
||||
ratio += zone->random.Int(20,70);
|
||||
Critical = true;
|
||||
@@ -7436,16 +7477,16 @@ bool Bot::CastSpell(uint16 spell_id, uint16 target_id, EQ::spells::CastingSlot s
|
||||
MessageString(Chat::White, MELEE_SILENCE);
|
||||
|
||||
if(casting_spell_id)
|
||||
AI_Event_SpellCastFinished(false, static_cast<uint16>(casting_spell_slot));
|
||||
AI_Bot_Event_SpellCastFinished(false, static_cast<uint16>(casting_spell_slot));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(IsDetrimentalSpell(spell_id) && !zone->CanDoCombat()){
|
||||
if (IsDetrimentalSpell(spell_id) && !zone->CanDoCombat()) {
|
||||
MessageString(Chat::White, SPELL_WOULDNT_HOLD);
|
||||
if(casting_spell_id)
|
||||
AI_Event_SpellCastFinished(false, static_cast<uint16>(casting_spell_slot));
|
||||
AI_Bot_Event_SpellCastFinished(false, static_cast<uint16>(casting_spell_slot));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -7733,7 +7774,7 @@ bool Bot::DoFinishedSpellSingleTarget(uint16 spell_id, Mob* spellTarget, EQ::spe
|
||||
if(IsGrouped() && (spellTarget->IsBot() || spellTarget->IsClient()) && RuleB(Bots, GroupBuffing)) {
|
||||
bool noGroupSpell = false;
|
||||
uint16 thespell = spell_id;
|
||||
for(int i = 0; i < AIspells.size(); i++) {
|
||||
for (int i = 0; i < AIBot_spells.size(); i++) {
|
||||
int j = BotGetSpells(i);
|
||||
int spelltype = BotGetSpellType(i);
|
||||
bool spellequal = (j == thespell);
|
||||
@@ -7833,7 +7874,7 @@ void Bot::CalcBonuses() {
|
||||
end_regen = CalcEnduranceRegen();
|
||||
}
|
||||
|
||||
int64 Bot::CalcHPRegenCap(){
|
||||
int64 Bot::CalcHPRegenCap() {
|
||||
int level = GetLevel();
|
||||
int64 hpregen_cap = 0;
|
||||
hpregen_cap = (RuleI(Character, ItemHealthRegenCap) + itembonuses.HeroicSTA / 25);
|
||||
@@ -7841,7 +7882,7 @@ int64 Bot::CalcHPRegenCap(){
|
||||
return (hpregen_cap * RuleI(Character, HPRegenMultiplier) / 100);
|
||||
}
|
||||
|
||||
int64 Bot::CalcManaRegenCap(){
|
||||
int64 Bot::CalcManaRegenCap() {
|
||||
int64 cap = RuleI(Character, ItemManaRegenCap) + aabonuses.ItemManaRegenCap;
|
||||
switch(GetCasterClass()) {
|
||||
case 'I':
|
||||
@@ -8278,7 +8319,7 @@ int64 Bot::CalcManaRegen() {
|
||||
|
||||
uint64 Bot::GetClassHPFactor() {
|
||||
uint32 factor;
|
||||
switch(GetClass()) {
|
||||
switch (GetClass()) {
|
||||
case BEASTLORD:
|
||||
case BERSERKER:
|
||||
case MONK:
|
||||
@@ -9101,7 +9142,7 @@ void Bot::AddItemBonuses(const EQ::ItemInstance *inst, StatBonuses* newbon, bool
|
||||
}
|
||||
}
|
||||
|
||||
if (item->SkillModValue != 0 && item->SkillModType <= EQ::skills::HIGHEST_SKILL){
|
||||
if (item->SkillModValue != 0 && item->SkillModType <= EQ::skills::HIGHEST_SKILL) {
|
||||
if ((item->SkillModValue > 0 && newbon->skillmod[item->SkillModType] < item->SkillModValue) ||
|
||||
(item->SkillModValue < 0 && newbon->skillmod[item->SkillModType] > item->SkillModValue))
|
||||
{
|
||||
@@ -9194,7 +9235,7 @@ void Bot::CalcBotStats(bool showtext) {
|
||||
|
||||
CalcBonuses();
|
||||
|
||||
AI_AddNPCSpells(GetBotSpellID());
|
||||
AI_AddBotSpells(GetBotSpellID());
|
||||
|
||||
if(showtext) {
|
||||
GetBotOwner()->Message(Chat::Yellow, "%s has been updated.", GetCleanName());
|
||||
|
||||
Reference in New Issue
Block a user