Change NPCs to have their attack delay set in DB

This gives us a much more straight forward way of setting mob
attack delay with respect to live.

The attack_delay column is in 10ths of seconds, just like weapons are
The attack_speed is left for references for now.
This commit is contained in:
Michael Cook (mackal) 2014-09-09 22:42:54 -04:00
parent fa1e33783a
commit ed4e762f03
7 changed files with 14 additions and 5 deletions

View File

@ -0,0 +1,3 @@
ALTER TABLE `npc_types` ADD `attack_delay` TINYINT(3) UNSIGNED DEFAULT '30' NOT NULL AFTER `attack_speed`;
UPDATE `npc_types` SET `attack_delay` = 36 + 36 * (`attack_speed` / 100);
UPDATE `npc_types` SET `attack_delay` = 30 WHERE `attack_speed` = 0;

View File

@ -4907,7 +4907,7 @@ void Client::SetAttackTimer()
void NPC::SetAttackTimer() void NPC::SetAttackTimer()
{ {
float PermaHaste = GetPermaHaste(); float PermaHaste = GetPermaHaste() * 100.0f;
//default value for attack timer in case they have //default value for attack timer in case they have
//an invalid weapon equipped: //an invalid weapon equipped:
@ -4941,7 +4941,7 @@ void NPC::SetAttackTimer()
// What they do is take the lower of their set delay and the weapon's // What they do is take the lower of their set delay and the weapon's
// ex. Mob's delay set to 20, weapon set to 19, delay 19 // ex. Mob's delay set to 20, weapon set to 19, delay 19
// Mob's delay set to 20, weapon set to 21, delay 20 // Mob's delay set to 20, weapon set to 21, delay 20
int speed = static_cast<int>((36 * (100 + DelayMod) / 100) * (100.0f + attack_speed) * PermaHaste); int speed = static_cast<int>((attack_delay * (100 + DelayMod) / 100) * PermaHaste);
TimerToUse->SetAtTrigger(std::max(RuleI(Combat, MinHastedDelay), speed), true); TimerToUse->SetAtTrigger(std::max(RuleI(Combat, MinHastedDelay), speed), true);
} }
} }

View File

@ -174,8 +174,9 @@ Mob::Mob(const char* in_name,
drakkin_heritage = in_drakkin_heritage; drakkin_heritage = in_drakkin_heritage;
drakkin_tattoo = in_drakkin_tattoo; drakkin_tattoo = in_drakkin_tattoo;
drakkin_details = in_drakkin_details; drakkin_details = in_drakkin_details;
attack_speed= 0; attack_speed = 0;
slow_mitigation= 0; attack_delay = 0;
slow_mitigation = 0;
findable = false; findable = false;
trackable = true; trackable = true;
has_shieldequiped = false; has_shieldequiped = false;

View File

@ -1053,6 +1053,7 @@ protected:
Timer attack_dw_timer; Timer attack_dw_timer;
Timer ranged_timer; Timer ranged_timer;
float attack_speed; //% increase/decrease in attack speed (not haste) float attack_speed; //% increase/decrease in attack speed (not haste)
int8 attack_delay; //delay between attacks in 10ths of seconds
float slow_mitigation; // Allows for a slow mitigation (100 = 100%, 50% = 50%) float slow_mitigation; // Allows for a slow mitigation (100 = 100%, 50% = 50%)
Timer tic_timer; Timer tic_timer;
Timer mana_timer; Timer mana_timer;

View File

@ -248,6 +248,7 @@ NPC::NPC(const NPCType* d, Spawn2* in_respawn, float x, float y, float z, float
delaytimer = false; delaytimer = false;
combat_event = false; combat_event = false;
attack_speed = d->attack_speed; attack_speed = d->attack_speed;
attack_delay = d->attack_delay;
slow_mitigation = d->slow_mitigation; slow_mitigation = d->slow_mitigation;
EntityList::RemoveNumbers(name); EntityList::RemoveNumbers(name);

View File

@ -1045,6 +1045,7 @@ const NPCType* ZoneDatabase::GetNPCType (uint32 id) {
"npc_types.adventure_template_id," "npc_types.adventure_template_id,"
"npc_types.trap_template," "npc_types.trap_template,"
"npc_types.attack_speed," "npc_types.attack_speed,"
"npc_types.attack_delay,"
"npc_types.STR," "npc_types.STR,"
"npc_types.STA," "npc_types.STA,"
"npc_types.DEX," "npc_types.DEX,"
@ -1148,6 +1149,7 @@ const NPCType* ZoneDatabase::GetNPCType (uint32 id) {
tmpNPCType->adventure_template = atoi(row[r++]); tmpNPCType->adventure_template = atoi(row[r++]);
tmpNPCType->trap_template = atoi(row[r++]); tmpNPCType->trap_template = atoi(row[r++]);
tmpNPCType->attack_speed = atof(row[r++]); tmpNPCType->attack_speed = atof(row[r++]);
tmpNPCType->attack_delay = atoi(row[r++]);
tmpNPCType->STR = atoi(row[r++]); tmpNPCType->STR = atoi(row[r++]);
tmpNPCType->STA = atoi(row[r++]); tmpNPCType->STA = atoi(row[r++]);
tmpNPCType->DEX = atoi(row[r++]); tmpNPCType->DEX = atoi(row[r++]);
@ -3233,4 +3235,4 @@ void ZoneDatabase::StoreCharacterLookup(uint32 char_id) {
" FROM `character_` " " FROM `character_` "
" WHERE `id` = %i ", char_id); " WHERE `id` = %i ", char_id);
QueryDatabase(c_lookup); QueryDatabase(c_lookup);
} }

View File

@ -111,6 +111,7 @@ struct NPCType
uint8 spawn_limit; //only this many may be in zone at a time (0=no limit) uint8 spawn_limit; //only this many may be in zone at a time (0=no limit)
uint8 mount_color; //only used by horse class uint8 mount_color; //only used by horse class
float attack_speed; //%+- on attack delay of the mob. float attack_speed; //%+- on attack delay of the mob.
uint8 attack_delay; //delay between attacks in 10ths of a second
int accuracy_rating; //10 = 1% accuracy int accuracy_rating; //10 = 1% accuracy
int avoidance_rating; //10 = 1% avoidance int avoidance_rating; //10 = 1% avoidance
bool findable; //can be found with find command bool findable; //can be found with find command