Friday, 2024-05-03, 1:51 AM


Main
Registration
Login
Welcome Guest | RSS  
[ New messages · Members · Forum rules · Search · RSS ]
  • Page 1 of 1
  • 1
Forum moderator: Hanky, Fireeye  
Clan NgO Forums » Discussions » Junk Yard » [vJASS] DestroyEffectTimed (A small system for removing effects over time)
[vJASS] DestroyEffectTimed
DynastiDate: Wednesday, 2008-12-10, 6:12 PM | Message # 1
Private
Group: Users
Messages: 11
Reputation: 1
Status: Offline
I did this to make an efficient code for removing effects over a period of time.

System Script:
Code
library EffectOverTime

       globals
           private constant real Tick = 0.1

           private timer Tim = CreateTimer()

           private integer array Er
           private integer Total = 0
       endglobals

       private struct Effect
           effect StoredEffect
           real Counter    = 0
           real CounterMax = 0
              
           static method ExecuteEffect takes nothing returns nothing
               local Effect dat
               local integer i = 0
                  
               loop
                   exitwhen i >= Total
                   set dat = Er[i]

                   if dat.Counter >= dat.CounterMax then

                       set Total = Total - 1
                       set Er[i] = Er[Total]

                       set i = i - 1

                       call dat.destroy()
                   else
                       set dat.Counter = dat.Counter + Tick
                   endif
                      
                   set i = i + 1
               endloop
                  
               if Total == 0 then
                   call PauseTimer(Tim)
               endif
           endmethod
                      
              
           static method create takes effect StoringEffect, real Time returns Effect
               local Effect dat = Effect.allocate()
                  
               set dat.StoredEffect = StoringEffect

               set dat.CounterMax = Time - Tick
                  
               if Total == 0 then
                   call TimerStart(Tim, Tick, true, function Effect.ExecuteEffect)
               endif
                  
               set Er[Total] = dat
               set Total = Total + 1
                  
               return dat
           endmethod
              
           method onDestroy takes nothing returns nothing
               call DestroyEffect(.StoredEffect)
               set .StoredEffect = null
           endmethod
       endstruct

       function DestroyEffectTimed takes effect StoringEffect, real Time returns nothing
           call Effect.create(StoringEffect, Time)
       endfunction
          
endlibrary

Ok if you find any bugs with it or ways of improvement, please reply.

Example map: DestroyEffectTimed.w3x


If you got it, then.. Yeah what do you get realy?

Message edited by Dynasti - Thursday, 2008-12-11, 4:57 PM
 
Darkt3mpl3rDate: Wednesday, 2008-12-10, 6:45 PM | Message # 2
Sergeant
Group: Administrators
Messages: 35
Reputation: 4
Status: Offline
Looks exactly like this one. http://www.hiveworkshop.com/forums/resource.php?t=109932

 
DynastiDate: Wednesday, 2008-12-10, 7:00 PM | Message # 3
Private
Group: Users
Messages: 11
Reputation: 1
Status: Offline
Quote (Darkt3mpl3r)
Looks exactly like this one. http://www.hiveworkshop.com/forums/resource.php?t=109932

Because i made it biggrin


If you got it, then.. Yeah what do you get realy?
 
Darkt3mpl3rDate: Wednesday, 2008-12-10, 8:52 PM | Message # 4
Sergeant
Group: Administrators
Messages: 35
Reputation: 4
Status: Offline
So why having multiaccount and why changed the system then ?

 
DynastiDate: Wednesday, 2008-12-10, 9:33 PM | Message # 5
Private
Group: Users
Messages: 11
Reputation: 1
Status: Offline
Quote (Darkt3mpl3r)
So why having multiaccount and why changed the system then ?

huh? I'm posting my systems and spells at both Hive and Ngo :P


If you got it, then.. Yeah what do you get realy?
 
Darkt3mpl3rDate: Wednesday, 2008-12-10, 10:01 PM | Message # 6
Sergeant
Group: Administrators
Messages: 35
Reputation: 4
Status: Offline
The System on Hive is posted by Justify. You also wrote comments on his submission. And thus, I think that you're using a second account when you say, that that resources is yours.

And this System != System by Justify ( Some names changed in the code and a bit different structure )


 
DynastiDate: Thursday, 2008-12-11, 4:56 PM | Message # 7
Private
Group: Users
Messages: 11
Reputation: 1
Status: Offline
I asked him for permission to use his example, but the code i made is made from scratch :P

If you got it, then.. Yeah what do you get realy?
 
FireeyeDate: Friday, 2008-12-12, 10:39 PM | Message # 8
Private
Group: Moderators
Messages: 16
Reputation: 5
Status: Offline
I personally wouldn't call it a system, more like a code snippet.
However there's 1 con you propably should mind, if you use a HIGH (i guess > .5 seconds) Tick value,
the effect duration won't last exactly as long as you want it to.


 
DynastiDate: Friday, 2008-12-12, 11:09 PM | Message # 9
Private
Group: Users
Messages: 11
Reputation: 1
Status: Offline
Quote (Fireeye)
However there's 1 con you propably should mind, if you use a HIGH (i guess > .5 seconds) Tick value,

know, that is why i recommend a tick rate from 0.1 - 0.05


If you got it, then.. Yeah what do you get realy?
 
Clan NgO Forums » Discussions » Junk Yard » [vJASS] DestroyEffectTimed (A small system for removing effects over time)
  • Page 1 of 1
  • 1
Search:

Clan NgO © 2024Powered by uCoz