Spell Ice Trap

Discussion in 'Spells' started by BRUTAL, Jun 24, 2008.

  1. BRUTAL

    BRUTAL I'm working

    Ratings:
    +118 / 0 / -0
    Ice Trap

    Requires GTrigger, Key Timers 2; all included in the map.

    Spell Description: Icicles pop out of the ground circling a targeted unit, and trapping everything inside. Any ground units trapped inside cannot get out, and no ground units can enter. This ability can be used to separate you from an army, and fight off a smaller number of enemy at a time. Deals damage per second to enemy ground units near the icicles.

    Screen Shots:
    [​IMG]

    [​IMG]

    Code:
    JASS:
    // Ice Trap by BRUTAL.
    // Requires GT, and KT2.
    // Credits are welcome but not necessary.
    // October 12th 2009.
    
    scope icetrap initializer init
    
    globals
        private constant integer ID='A000' // ID of the ice trap spell.
        private constant integer IMMO_ID='A001' // ID of the ice immolation spell.
        private constant integer DUMMY_ID='h000' // ID of the ice trap unit.
        private constant integer PATH_BLOCK='YTpb' // ID of the path blocker that is created.
        private constant real PERIOD=.04 // Period of the KT2 timer.
        private constant real SCALE=1. // Scale size of ice trap unit.
        private constant integer ALPHA=75 // Percent transparency of ice trap unit.
        private constant integer MAX_UNITS=36 // Number of units that will circle around.
    endglobals
    
    private constant function DURATION takes integer level returns real
        return 6.+3.*level
    endfunction
    
    private constant function DISTANCE takes integer level returns real
        return 270.+ 20.*level
    endfunction
    
    private struct Data
        unit caster
        real x
        real y
        real angle
        integer pbInt=0
        integer ticks
        integer maxTicks
        destructable array pathBlock[MAX_UNITS]
        
        static method create takes unit u, real tx, real ty returns Data
            local Data data=Data.allocate()
            set data.caster=u
            set data.x=tx
            set data.y=ty
            set data.angle=GetUnitFacing(u)+140
            set data.ticks=R2I(DURATION(GetUnitAbilityLevel(data.caster,ID))/PERIOD)+10
            set data.maxTicks=data.ticks
            return data
        endmethod
        
        method circle takes nothing returns nothing
            local integer level=GetUnitAbilityLevel(.caster,ID)
            local real dis=DISTANCE(level)
            local real dur=DURATION(level)
            local real x=.x+dis*Cos(.angle*bj_DEGTORAD)
            local real y=.y+dis*Sin(.angle*bj_DEGTORAD)
            local unit u=CreateUnit(GetOwningPlayer(.caster),DUMMY_ID,x,y,bj_RADTODEG*Atan2(y-.y,x-.x))
            call SetUnitScale(u,SCALE,SCALE,SCALE)
            call SetUnitVertexColor(u,255,255,255,R2I(2.55*ALPHA))
            call UnitApplyTimedLife(u,'BTLF',dur)
            call UnitAddAbility(u,IMMO_ID)
            call SetUnitAbilityLevel(u,IMMO_ID,level)
            call IssueImmediateOrder(u,"immolation")
            set .angle=.angle+360./MAX_UNITS
            set .pathBlock[.pbInt]=CreateDestructable(PATH_BLOCK,x,y,0,1,0)
            set .pbInt=.pbInt+1
            set u=null
        endmethod
        
        method end takes nothing returns nothing
            local integer i=0
            loop
            exitwhen i==MAX_UNITS
                call KillDestructable(.pathBlock[i])
                set i=i+1
            endloop
        endmethod
    endstruct 
    
    private function PeriodicFunc takes nothing returns boolean
        local Data data=KT_GetData()
        set data.ticks=data.ticks-1
        if data.ticks<=0 then  
            call data.end()
            return true
        else
            if data.ticks>=data.maxTicks-MAX_UNITS then
                call data.circle()
            endif
        return false
        endif  
    endfunction 
    
    private function actions takes nothing returns nothing
        call KT_Add(function PeriodicFunc,Data.create(GetTriggerUnit(),GetSpellTargetX(),GetSpellTargetY()),PERIOD)
    endfunction
    
    private function init takes nothing returns nothing
        call TriggerAddAction(GT_RegisterStartsEffectEvent(CreateTrigger(),ID),function actions)
    endfunction
    
    endscope


    Feedback is welcomed, if you see any bugs or mistakes let me know.
    DL the map.
     

    Attached Files:

    • Like Like x 5
  2. 131ackout

    131ackout Guest

    Ratings:
    +0 / 0 / -0
    OMG, THATS INTENSE!!!!

    +rep :p

    EDIT: Can't give the rep, have to spread first. :)
     
  3. Kazuga

    Kazuga Let the game begin...

    Ratings:
    +110 / 0 / -0
    Didn't you make this for the spellcontest...? Cause I have seen this in the contest and I assume you made it?
    Anyway it looks awsome.
     
    • Like Like x 1
  4. Ghostwind

    Ghostwind o________o

    Ratings:
    +171 / 0 / -0
    It looks pretty nice. Maybe to add it so that it makes the weather snow around the area when you use it =)
     
    • Like Like x 1
  5. BRUTAL

    BRUTAL I'm working

    Ratings:
    +118 / 0 / -0
    thanks :p

    ya, i did note the
    that i put :p
    thanks though

    ty, i'll try that
     
  6. BRUTAL

    BRUTAL I'm working

    Ratings:
    +118 / 0 / -0
    okay, added the snow effects, and fixed the loading screen saying "wind tunnel" :p
     
  7. 131ackout

    131ackout Guest

    Ratings:
    +0 / 0 / -0
    I don't see any snow effects in the screenshot.

    I'm busy, don't have time to test the map.

    :p
     
  8. BRUTAL

    BRUTAL I'm working

    Ratings:
    +118 / 0 / -0
    ya, i dont feel like adding new screenshots ><
    just test it when you got time :p
     
  9. Sim

    Sim Forum Administrator Staff Member

    Ratings:
    +531 / 0 / -0
    There's a little mess in the tooltip, has something to do with color codes. :p

    The collision thing is messy. Sometimes the Ice Lord can pass through the wall, sometimes he cannot. Seriously though, remove that feature. Nobody can pass through ice, whether or not he created it. :p Adds a strategy feature too: don't trap yourself in!

    This part of the code is causing it, most probably:

    Code:
    Five
        Events
            Time - Every 0.01 seconds of game time
        Conditions
            (Number of units in ItWalkUg) Greater than 0
        Actions
            Unit Group - Pick every unit in ItUg2 and do (Actions)
                Loop - Actions
                    Set TempInt = (Custom value of (Picked unit))
                    Set ItTriggUnitPos[TempInt] = (Position of ItTriggunit[TempInt])
                    Set ItWalkPos[TempInt] = (Position of ItWalkThrough[TempInt])
                    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        If - Conditions
                            And - All (Conditions) are true
                                Conditions
                                    (Distance between ItWalkPos[TempInt] and ItTriggUnitPos[TempInt]) Greater than (220.00 + ((Real((Level of Ice Trap  for ItCaster[TempInt]))) x 20.00))
                                    (Distance between ItWalkPos[TempInt] and ItTriggUnitPos[TempInt]) Less than (340.00 + ((Real((Level of Ice Trap  for ItCaster[TempInt]))) x 20.00))
                        Then - Actions
                            Unit - Turn collision for ItCaster[TempInt] Off
                        Else - Actions
                            Unit - Turn collision for ItCaster[TempInt] On
            Custom script:   call RemoveLocation(udg_ItTriggUnitPos[udg_TempInt])
            Custom script:   call RemoveLocation(udg_ItWalkPos[udg_TempInt])
    
    Apart from that, well done!
     
    • Like Like x 1
  10. BRUTAL

    BRUTAL I'm working

    Ratings:
    +118 / 0 / -0
    o? i'll check it out

    i know, i couldnt get it perfect . Originally that feature was not put in, i added it because someone suggested it and i thought it would be okay
    i might as well take it out if i cant perfect it :p
    thanks anyways
    ---------------------
    Okay, uploaded a new file;
    -fixed the tooltips
    -fixed a levelskip problem
    -removed the walk in/out part
    -added new screenshots
     
  11. Ghostwind

    Ghostwind o________o

    Ratings:
    +171 / 0 / -0
    I know this is irrelevant, but use this model instead:

    [​IMG]

    It's teh awesomeness D:
     
  12. BRUTAL

    BRUTAL I'm working

    Ratings:
    +118 / 0 / -0
    i would, but its about the spells, not the hero :p
    plus that would make the file size go up
     
  13. Sim

    Sim Forum Administrator Staff Member

    Ratings:
    +531 / 0 / -0
    Approved. :)
     
  14. BRUTAL

    BRUTAL I'm working

    Ratings:
    +118 / 0 / -0
    sweet
    thanks :p
     
  15. Sim

    Sim Forum Administrator Staff Member

    Ratings:
    +531 / 0 / -0
    Merge your other (future) spells in (a) spellpack(s) please, but do not add this one. It will stay as a single submission.
     
  16. BRUTAL

    BRUTAL I'm working

    Ratings:
    +118 / 0 / -0
    bump
     
  17. Bonebuster

    Bonebuster Guest

    Ratings:
    +0 / 0 / -0
    Healing

    Maybe if u are traped in circle it heals u or something like that really cool spell :)
     
    • Like Like x 1
  18. BRUTAL

    BRUTAL I'm working

    Ratings:
    +118 / 0 / -0
    i think its fine as is, but that would be easy to add yourself
    thank you
     
  19. BRUTAL

    BRUTAL I'm working

    Ratings:
    +118 / 0 / -0
    bump
     
  20. Danjamino

    Danjamino New Member

    Ratings:
    +8 / 0 / -0
    if u were to use it in agame the heros range should be able to atk from outside the trap
     

Share This Page