Leaking??

INCINERATE

New Member
Reaction score
12
hey guys , would anyone mind taking a look at this code? this is a spell i found on www.thehiveworkshop.com from XXDINGO93XX.

ever since i put it in, i have notice the frame rate drops, and never recovers .. this only started when i put this in , so does this code leak? and if it does can you guys please post the necessary fixes . thanks :p


JASS:
//               °                                        Mapmaking since 2006...
//            °
//          °
//         °
//       °°°ÛÜ
//      °°X°ÛÛÛ                          ÛÛÛÛÛÛÛÛ     ÿÜÛÛÛÛÛÛÛÛÜ 
//     °°XX° ÛÛÛ        ßÛÛÛÛÛ        ÛÛÛÛÛÛÛÛÛÛÛÛ   ÛÛÛÛÛÛÛÛÛÛÛÛÛ
//     °XX ° ÛÛÛÛ         ÛÛÛÛÜ     ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ  ÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
//     °XX °  ÛÛÛÛÛ        ÛÛÛÛ    ÛÛÛÛÛß    ßÛÛÛÛÛÛ  ÛÛÛÛÛÛÛÛÛÛÛÛÛÛ  
//    °°XXX°° ÛÛÛÛÛÛÜ       ÛÛÛÜ  ÛÛÛÛÛ        ßÛÛÛÛÛ ßÛÛÛÛ    ÛÛÛÛÛÛ  
//   °°°°°°°°  ÛÛÛÛÛÛÛ      ÛÛÛÛ  ÛÛÛÛ                 ÛÛÛÛ      ÛÛÛÛÜ  
//             ÛÛÛÛÛÛÛÛ     ÛÛÛÛ  ÛÛÛÛ        ÛÛÛÛÛÛÛ  ÛÛÛÛÛÜ     ÛÛÛÛ  
//   °°°°°°°°  ÛÛÛÛÛÛÛÛÛ    ÛÛÛÛÜ  ÛÛÛÛÜ     ÛÛÛÛÛÛÛÛ   ÛÛÛÛÛÜ  ÜÛÛÛÛÛÛ  
//   °°XXXXX°   ÛÛÛÛ  ÛÛÛÜ  ÛÛÛÛÛ   ÛÛÛÛÛÛÜ    ßÛÛÛÛÛ   ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ  
//   °°XXXXX °° ÛÛÛÛ   ÛÛÛÛÜ ÛÛÛÛ °°°ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ°°° ÛÛÛÛÛÛÛÛÛÛÛÛÛß  
//   °  XXXXX °°ÛÛÛÛÛ°°°°ÛÛÛÛÛÛÛÛ°°XX ÛÛÛÛÛÛÛÛÛÛÛÛÛÛ XXX°°ÛÛÛÛÛÛÛÛÛÛÛ     ÛÛÛ
//   °°  XXXXX ÜÛÛÛÛÛÛ X ÛÛÛÛÛÛÛÛÛ XXX ÛÛÛÛÛÛÛÛÛÛÛ  XXXXXX  ÛÛÛÛÛÛÛ°      ÛÛÛ
//    °°  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX °°°°°°   °°°°
//     °°   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX °°°°°X°°
//      °°°  XXXXXXXXXX  °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° XXXXXXXXXXXXXXXXX°°
//        °°°°°°°°°°°°°°°°                                  °°°°°°°°  XXXXXXX °°°
//                                                                  °°°°°° XX °°
//   ...2009 and still moving on.                                        °°°°°°°
//                                                                             °°
//   Screen Solution: 1280x1024                             Visit <a href="http://www.ngo.clan.su" target="_blank" class="link link--external" rel="nofollow ugc noopener">www.ngo.clan.su</a>!
//========================================================================================
scope SpikedImpact initializer Init
//========================================================================================
//====================================SETUP START=========================================
//========================================================================================
    globals
        //Default: &#039;SpIm&#039;
        private constant integer AID = &#039;SpIm&#039; //the rawcode of the ability &quot;Spike Impact&quot;
        //Default: &#039;eSp1&#039;
        private constant integer SPIKED_ONE = &#039;eSp1&#039; //the rawcode of the unit spike 1
        //Default: &#039;eSp2&#039;
        private constant integer SPIKED_TWO = &#039;eSp2&#039; //the rawcode of the unit spike 2
        //Default: &#039;eSp3&#039;
        private constant integer SPIKED_THREE = &#039;eSp3&#039; //the rawcode of the unit spike 3
        //Default: &#039;eSp4&#039;
        private constant integer SPIKED_FOUR = &#039;eSp4&#039; //the rawcode of the unit spike 4
        //Default: 8
        private constant integer MAX = 8 //the maximal amount of spikes for each heigh
        //Default: &quot;Morph&quot;
        private constant string START_ANIMATION = &quot;Morph&quot; //the animation the caster will play when he casts the spell
        //Default: &quot;Morph Defend&quot;
        private constant string END_ANIMATION = &quot;Morph Defend&quot; //the animation the caster will play when the spell ends
        //Default: 255
        private constant integer RED = 255 //The red RGB color of the affected units from 0 to 255
        //Default: 45
        private constant integer GREEN = 45 //The green RGB color of the affected units from 0 to 255
        //Default: 45
        private constant integer BLUE = 45 //The blue RGB color of the affected units from 0 to 255
        //Default: &quot;Objects\\Spawnmodels\\Orc\\Orcblood\\BattrollBlood.mdl&quot;
        private constant string ENEMY_EFFECT = &quot;Objects\\Spawnmodels\\Orc\\Orcblood\\BattrollBlood.mdl&quot; //the that will be created at the enemy when it is affected, in this case is blood.
        //Default: 0.3
        private constant real SPIKE_GROW = 0.3 //the time the spikes will have to grow before they are paused
        //Default: 1.5
        private constant real SPIKE_PAUSE = 1.5 //the duration of pausing the spikes
        //Default: 1.2
        private constant real SPIKE_DEATH = 1.2 //this is how long the death animation of the spikes lasts
    endglobals

    private constant function Radius takes integer level returns real
        //Default: 650. + level * 50.
        return 650. + level * 50.
    endfunction

    private constant function Damage takes integer level returns real
        //Default: level * 80. + 25.
        return level * 80. + 25.
    endfunction
//========================================================================================
//====================================SETUP END===========================================
//========================================================================================
    globals
        private unit TempCaster = null
    endglobals

    private function Pick takes nothing returns boolean 
        return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(TempCaster)) and (GetWidgetLife(GetFilterUnit()) &gt; 0.405) and not IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE)
    endfunction
    
    private function KillEnemies takes unit caster, unit target, integer level returns nothing
        local real DamageToDeal = Damage(level)
        
        call PauseUnit(target, false)
        call SetUnitTimeScale(target, 100. * 0.01)
        if(GetWidgetLife(target) &lt;= DamageToDeal) then
            call SetUnitExploded(target, true)
            call KillUnit(target)
        else
            call UnitDamageTarget(caster, target, DamageToDeal, true, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNKNOWN, WEAPON_TYPE_WHOKNOWS)
            call SetUnitVertexColor(target, 255, 255, 255, 255)
            call DestroyEffect(AddSpecialEffectTarget(ENEMY_EFFECT, target, &quot;chest&quot;))
        endif
    endfunction
    
    private function RecolorEnemies takes nothing returns nothing
        local unit Enemy = GetEnumUnit()
        
        call PauseUnit(Enemy, true)
        call SetUnitTimeScale(Enemy, 0.00)
        call SetUnitVertexColor(Enemy, RED, GREEN, BLUE, 255)
        call DestroyEffect(AddSpecialEffectTarget(ENEMY_EFFECT, Enemy, &quot;chest&quot;))
        set Enemy = null
    endfunction
    
    private struct SIData
        unit caster
        integer level
        unit array spikes [36]
        timer t
        group g 
        
        static method Reset takes nothing returns nothing
            local SIData data = SIData(GetTimerData(GetExpiredTimer()))
            call data.destroy()
        endmethod
        
        static method End takes nothing returns nothing
            local SIData data = SIData(GetTimerData(GetExpiredTimer()))
            local unit f
            local integer i = 0
            
            loop
                set f = FirstOfGroup(data.g)
                exitwhen f == null
                call KillEnemies(data.caster, f, data.level)
                call GroupRemoveUnit(data.g, f)
            endloop
            set i = 0
            loop
                exitwhen (i == MAX * 4)
                call PauseUnit(data.spikes<i>, false)
                call UnitApplyTimedLife(data.spikes<i>, &#039;BTLF&#039;, 1.00)
                call SetUnitTimeScale(data.spikes<i>, 1)
                set i = i + 1
            endloop
            
            call SetTimerData(data.t, integer(data))
            call SetUnitAnimation(data.caster, END_ANIMATION)
            call TimerStart(data.t, 0.5, false, function SIData.Reset)
        endmethod
        
        static method Growth takes nothing returns nothing
            local SIData data = SIData(GetTimerData(GetExpiredTimer()))
            local integer i = 0
            
            loop
                exitwhen (i == MAX * 4)
                call PauseUnit(data.spikes<i>, true)
                call SetUnitTimeScale(data.spikes<i>, 0.)
                set i = i + 1
            endloop 
            set TempCaster = data.caster
            call GroupEnumUnitsInRange(data.g, GetUnitX(data.caster), GetUnitY(data.caster), Radius(data.level), Condition(function Pick))
            call ForGroup(data.g, function RecolorEnemies)
            
            call SetTimerData(data.t, integer(data))
            call TimerStart(data.t, SPIKE_DEATH, false, function SIData.End)
        endmethod
        
        static method create takes unit aCaster returns SIData
            local SIData data = SIData.allocate()
            local real x
            local real y
            local real Degrees
            local integer SpikeNumber = 0
            local integer i = 0
            local player owner = GetOwningPlayer(aCaster)
            
            set data.caster = aCaster
            set data.level = GetUnitAbilityLevel(aCaster, AID)
            set data.g = CreateGroup()
            loop
                exitwhen (i == MAX)
                set Degrees = (360./MAX * I2R(i))
                set x = GetUnitX(data.caster) + 10.0 * Cos(Degrees * bj_DEGTORAD)
                set y = GetUnitY(data.caster) + 10.0 * Sin(Degrees * bj_DEGTORAD)
                set data.spikes [SpikeNumber]     = CreateUnit(owner, SPIKED_ONE, x, y, Degrees)
                set data.spikes [SpikeNumber + 1] = CreateUnit(owner, SPIKED_TWO, x, y, Degrees)
                set data.spikes [SpikeNumber + 2] = CreateUnit(owner, SPIKED_THREE, x, y, Degrees)
                set data.spikes [SpikeNumber + 3] = CreateUnit(owner, SPIKED_FOUR, x, y, Degrees)
                set SpikeNumber = SpikeNumber + 4
                set i = i + 1
            endloop
            call PauseUnit(data.caster, true)
            call SetUnitAnimation(data.caster, START_ANIMATION)
            
            set data.t = NewTimer() 
            call SetTimerData(data.t, integer(data))
            call TimerStart(data.t, SPIKE_GROW, false, function SIData.Growth)
            
            return data
        endmethod
        
        method onDestroy takes nothing returns nothing
            local integer Index = 1
            
            loop
                exitwhen Index &gt; 36
                set this.spikes [Index] = null
                set Index = Index + 1
            endloop
            call ReleaseTimer(this.t)
            call IssueImmediateOrder(this.caster, &quot;stop&quot;)
            call SetUnitAnimation(this.caster, &quot;stand&quot;)
            call PauseUnit(this.caster, false)
            call GroupClear(this.g)
            set this.caster = null
            set this.g = null
        endmethod
    endstruct
//====================================================================================
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == AID
    endfunction
//====================================================================================
    private function Actions takes nothing returns nothing
        call SIData.create(GetSpellAbilityUnit())
    endfunction
//===========================Creating the trigger=====================================
    private function Init takes nothing returns nothing
        local trigger Tri = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(Tri, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddAction(Tri, function Actions)
        call TriggerAddCondition(Tri, Condition(function Conditions))
        
        // this will remove the first cast lag
        call RemoveUnit(CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),  SPIKED_ONE, 0.00, 0.00, 0.00))
        call RemoveUnit(CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),  SPIKED_TWO, 0.00, 0.00, 0.00))
        call RemoveUnit(CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),  SPIKED_THREE, 0.00, 0.00, 0.00))
        call RemoveUnit(CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),  SPIKED_FOUR, 0.00, 0.00, 0.00))
        
        call Preload(ENEMY_EFFECT)
    endfunction
endscope</i></i></i></i></i>
 
Reaction score
341
Erm, not as far as I could see. But the spell could use some improvements.
Probably nothing that would affect framerate too much.
 

INCINERATE

New Member
Reaction score
12
okay thanks, im just trying to figure out what was causing the lag, im glad it isnt this spell, it has to be my other spell i put in today :p
 

INCINERATE

New Member
Reaction score
12
hey guys , a new problem just aroused with this spell and since i no good with jass can you guys help?

2 problems. shouldn't be to hard for some of you guys



a)the first one is that when units are killed by this spell, it does not give any gold bounties for the units it has killed.


b) the second one is that , it shoots out these huge spikes that grow out,then stabs the units, turn the units red, then retracts back in .. now if a hero happens to die from these spikes, the color wont be reverted back to normal ( the hero is stuck in the color red)


this doesn't happen under normal situations where the hero does not die, as its only temporarily red for a short time ,

in testing we found that if a unit dies from this and revives back(from alter), he will be permanently red until you cast the spikes again on him. if the hero lives his color will change back to normal


can you guys please tell me whats wrong? :confused:
 

Rushhour

New Member
Reaction score
46
For a) Are you sure that the playerflag GIVES_BOUNTY is on (==1) for the owner of killed unit? Another problem could be that the unit is directly killed when the damage amount is greater than its remaining life points.
So you should change that line that turns explosion on and instantly kills the target. ("UnitDamageTarget" gives rewards for killing unit /player)

b) Defeated Heroes aren't "dead" and removed, but only sent to heaven ;P So it keeps all items carried, exprience gained,..., and also the changed color. So I suggest that you simply change the color back when a hero is revived (SetUnitVertexColor(unit,255,255,255,255) )
 

INCINERATE

New Member
Reaction score
12
my map has bounty on , thats forsure, cause its based of killing units for gold .. but only during this trigger it dont work


which part should i put "UnitDamageTarget" ?


how to change the hero color back when its revived? what happens to other heroes in the game that are deliberately made to be another color threwout the game , would this setting of colour screw things up?


its funny cause , even when ur hero is stuck red, if you get spiked again, and dont die, your hero would be reverted back to its orginal color. so i am guessing that its missing the action to turn units back to its orginal color after a hero death event.

where to put in these changes?
 

INCINERATE

New Member
Reaction score
12
bump plz?

nobody???

how to get bounty on for the units this spell kills? (and yes i do have bounty on ) it just doesn't get any from this spell

and how to set the heroes color back to normal if they die from this spell?
 

INCINERATE

New Member
Reaction score
12
okay i found the author, pointed out the 2 bugs, and he hasnt given me any reply .


theres nothing you jass pros out there can suggest? whats causing this spell to not give bounty, i guess the color thing can be fixed , by not allowing it to change colors at all in the configurable constants . that should solve that issue ( prevention better than cure Lol),

but the bounty bugs me, as its needed :p

help anyone?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top