PDA

View Full Version : Minor NPC Spells Recast Delay Adjustment


trevius
08-05-2008, 06:18 PM
I was having a problem getting recast timers for NPC spell lists to work properly, and found that it is because they are currently limited to a max of 1000 for some reason. I was trying to implement disciplines for NPCs and some Pets, but due to the 1000 second limit, the disc reuse timers longer than that were getting completely ignored. Some of them are 20 minutes or more. And in seconds, that is 1200.

I looked at recast delay settings in the source and I found this:

MobAI.cpp
void NPC::AI_Event_SpellCastFinished(bool iCastSucceeded, int8 slot) {
if (slot == 1) {
int32 recovery_time = 0;
if (iCastSucceeded) {
if (casting_spell_AIindex < MAX_AISPELLS) {
recovery_time += spells[AIspells[casting_spell_AIindex].spellid].recovery_time;
if (AIspells[casting_spell_AIindex].recast_delay >= 0){
if (AIspells[casting_spell_AIindex].recast_delay <1000)
AIspells[casting_spell_AIindex].time_cancast = Timer::GetCurrentTime() + (AIspells[casting_spell_AIindex].recast_delay*1000);
}
else
AIspells[casting_spell_AIindex].time_cancast = Timer::GetCurrentTime() + spells[AIspells[casting_spell_AIindex].spellid].recast_time;
}
if (!IsEngaged())
recovery_time += RandomTimer(2000, 3000);
if (recovery_time < AIautocastspell_timer->GetSetAtTrigger())
recovery_time = AIautocastspell_timer->GetSetAtTrigger();
AIautocastspell_timer->Start(recovery_time, false);
}
else
AIautocastspell_timer->Start(800, false);
casting_spell_AIindex = MAX_AISPELLS;
}
}

And I simply changed the check for < 1000 to < 10000 and now my recast delays are working perfectly. Here is the change I made, highlighted in RED:

void NPC::AI_Event_SpellCastFinished(bool iCastSucceeded, int8 slot) {
if (slot == 1) {
int32 recovery_time = 0;
if (iCastSucceeded) {
if (casting_spell_AIindex < MAX_AISPELLS) {
recovery_time += spells[AIspells[casting_spell_AIindex].spellid].recovery_time;
if (AIspells[casting_spell_AIindex].recast_delay >= 0){
if (AIspells[casting_spell_AIindex].recast_delay <10000)
AIspells[casting_spell_AIindex].time_cancast = Timer::GetCurrentTime() + (AIspells[casting_spell_AIindex].recast_delay*1000);
}
else
AIspells[casting_spell_AIindex].time_cancast = Timer::GetCurrentTime() + spells[AIspells[casting_spell_AIindex].spellid].recast_time;
}
if (!IsEngaged())
recovery_time += RandomTimer(2000, 3000);
if (recovery_time < AIautocastspell_timer->GetSetAtTrigger())
recovery_time = AIautocastspell_timer->GetSetAtTrigger();
AIautocastspell_timer->Start(recovery_time, false);
}
else
AIautocastspell_timer->Start(800, false);
casting_spell_AIindex = MAX_AISPELLS;
}
}

I don't see any reason why this couldn't be added to the source updates. I am not sure why the current limit was set to 1000 or less. I guess it wouldn't even apply in most cases, but disciplines for pets and NPC encounters that might last 20+ minutes could be effected by this. This isn't anything major, and probably wouldn't be used much, but I don't think it would be bad to have in there.