Discussion in 'Scripts (LavishScript)' started by yumel, Oct 19, 2012.

  1. yumel

    yumel Member

    Messages:
    31
    Code below works in conjunction with a collection:int (named abilTimerDict) that I have hard coded in my scripts.

    Group buffs, HOTs, Wards, etc. are what I use it for in addition to abilities like Sealed Fate and Necropsy.

    The Lavish:Events VG_onSpawnStatusChange is what I use to control the timers for group buffs. Hope someone else can find some use out of it.

    Code (Text):
    objectdef obj_abilTimer
    {
      variable collection:uint abilDict
        variable int64 ID
     
      method Add(int64 tgtID, string abilName="", int abilT=0)
      {
        This.ID:Set[${tgtID}]
        if ${abilName.Length}>1 && ${abilT}>0
          This:Set[${abilName}, ${abilT}]
      }
     
      method Set(string abilName, int abilTime)
      {
        variable int64 timeAdded
        timeAdded:Set[${Math.Calc[${abilTime}*1000]}]
        This.abilDict:Set[${abilName}, ${Math.Calc[${Script.RunningTime}+${timeAdded}]}]
        echo --- obj_atc:Set --- ${This.ID} - ${abilName} - ${This.abilDict[${abilName}]} vs ${Script.RunningTime}
      }
     
      method Clear()
      {
        This.abilDict:Clear
      }
     
      member:bool isReady(string abilName)
      {
        echo --- obj_abilTimer.isReady --- ${abilName} Time Remaining ${Math.Calc[${This.TimeRemaining[${abilName}]}-(${Math.Calc[${Me.Ability[${abilName}].CastTime}*1000]})]}
        if ${Math.Calc[${This.TimeRemaining[${abilName}]}-(${Math.Calc[${Me.Ability[${abilName}].CastTime}*1000]})]}<=0
          return TRUE
        else
          return FALSE
      }
     
      member:int64 TimeRemaining(string abilName)
      {
        if !${This.abilDict.Element[${abilName}](exists)} || ${Script.RunningTime}>=${This.abilDict[${abilName}]}
          return 0
        else
          return ${Math.Calc[${This.abilDict[${abilName}]}-${Script.RunningTime}]}
      }
    }

    objectdef obj_atc
    {
      variable collection:obj_abilTimer abilTimers
     
      member:bool GetIndex(int64 ID, string abilName="", int abilT=0)
      {
        if !${This.abilTimers.Element["${ID}"](exists)}
        {
          This.abilTimers:Set["${ID}", obj_abilTimer]
          This.abilTimers["${ID}"]:Add[${ID}]
          return TRUE
        }
        if ${abilName.Length}>1 && ${abilT}>0
        {
          This.abilTimers["${ID}"]:Set[${abilName}, ${abilT}]
          return TRUE
        }
        elseif ${abilName.Length}>1
        {
          ;echo --- ${abilName} remaining --- ${This.abilTimers["${ID}"].TimeRemaining[${abilName}]}
          if ${This.abilTimers["${ID}"].TimeRemaining[${abilName}]}>0
            return FALSE
          else
            return TRUE
        }
      }
     
      method Initialize()
      {
        ;Event[OnFrame]:AttachAtom[This:Cull]
      }
     
      method Shutdown()
      {
        ;Event[OnFrame]:DetachAtom[This:Cull]
      }
     
      method Cull()
      {
        ;echo --- obj_atc:Cull ---
        variable iterator abilIter
        This.abilTimers:GetIterator[abilIter]
        if ${abilIter:First(exists)}
        {
          do
          {
            if !${Pawn[id, ${abilIter.Value.ID}](exists)}
              This.abilTimers:Erase[${abilIter.Key}]
          }
          while ${abilIter:Next(exists)}
        }
      }
     
      method ClearDead(int64 tgtID)
      {
        if ${This.abilTimers.Element["${tgtID}"](exists)}
          This.abilTimers["${tgtID}"]:Clear
      }
     
    }

    variable obj_atc obj_atc
    View attachment obj_ATC.iss

    p.s. Thanks to the posters who helped in my first thread and sorry for those who might have downloaded the old version which wasn't working. If you have questions about how to implement this and how I use it, feel free to reply here or PM me.
    Last edited: Oct 20, 2012

Share This Page