View Single Post
  #1  
Old 03-23-2007, 01:37 AM
number6
Sarnak
 
Join Date: Sep 2006
Posts: 62
Default Clicky items recast timer bug and fix

I noticed that items with clicky effects (in my case and most noticeably, the shadowknight epic) ignored the recastdelay field in the items database, so that it was possible to re-click such items incessantly. I worked up a quick fix to this. I don't 100% like it because if the clicky is cancelled (e.g. by ducking during a long cast) the re-use timer is still set, but I can't work out how to access the m_inv variable (thus accessing the inventory and then the original item to get the recast delay) later on once the spell cast is finished - any ideas appreciated. Anyway for now this might be useful:

Code:
--- client_packet.cpp.orig      2007-03-23 15:33:40.000000000 +0000
+++ client_packet.cpp   2007-03-23 15:31:27.000000000 +0000
@@ -2935,6 +2935,16 @@
                        safe_delete(outapp);
                        if ((item->Click.Type == ET_ClickEffect) || (item->Click.Type == ET_Expendable) || (item->Click.Type == ET_EquipClick) || (item->Click.Type == ET_ClickEffect2))
                        {
+                               // here is where we can check recast times
+                               if (item->RecastDelay > 0) {
+                                       // check to see if it's in progress
+                                       if(!CastToClient()->GetPTimers().Expired(&database, pTimerSpellStart + item->Click.Effect, false)) {
+                                               InterruptSpell(item->Click.Effect);
+                                               Message(13,"Item recast time not yet met, %d seconds left.",CastToClient()->GetPTimers().GetRemainingTime(pTimerSpellStart + item->Click.Effect));
+                                               return;
+                                       }
+                                       CastToClient()->GetPTimers().Start(pTimerSpellStart + item->Click.Effect, item->RecastDelay);
+                               }
                                CastSpell(item->Click.Effect, castspell->target_id, castspell->slot, item->CastTime, 0, 0, castspell->inventoryslot);
                        }
                        else
Cheers

Paul.
Reply With Quote