1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[JASS] Whats wrong with this?

Discussion in 'Triggers & Scripts' started by Freyleyes, Mar 30, 2009.

  1. Freyleyes

    Freyleyes

    Joined:
    Jun 28, 2008
    Messages:
    766
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Whats wrong with this?

    Code (vJASS):
    function Trig_Defend_Conditions takes nothing returns boolean
        return GetLearnedSkill()=='A001' and IsUnitIllusion(GetTriggerUnit())==false
    endfunction

    function Defend_Main takes nothing returns nothing
        local unit u = GetTriggerUnit()
        local real r = 10*GetUnitAbilityLevel(u,'A001')
        local real tempdmg = GetEventDamage()
       
        if(r > tempdmg)then
            r = tempdmg
        endif
       
        if(udg_Boolean_Active[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))] == true)then
        if(r > 0)then
            if(GetRandomInt(1,100)<=(0 + (10*GetUnitAbilityLevel(u,'A001'))))then
                call SetUnitState(u,UNIT_STATE_LIFE,GetUnitState(u,UNIT_STATE_LIFE)+ r)
                call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Defend\\DefendCaster.mdl",u,"origin"))
            endif
        endif
        endif
    endfunction

    function Trig_Defend_Actions takes nothing returns nothing
        local trigger tr
        if GetUnitAbilityLevel(GetTriggerUnit(),'A001')==1 then
            set tr=CreateTrigger()
            call TriggerRegisterUnitEvent(tr,GetTriggerUnit(),EVENT_UNIT_DAMAGED)
            call TriggerAddAction(tr,function Defend_Main)
        endif
    endfunction

    //===========================================================================
    function InitTrig_Defend takes nothing returns nothing
            set gg_trg_Defend=CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(gg_trg_Defend,EVENT_PLAYER_HERO_SKILL)
        call TriggerAddCondition(gg_trg_Defend,Condition(function Trig_Defend_Conditions))
        call TriggerAddAction(gg_trg_Defend,function Trig_Defend_Actions)
    endfunction


    Every time I run the WE just freezes.

    I know the error is somewhere here

    Code (vJASS):
    local real tempdmg = GetEventDamage()

        if(r > tempdmg)then
            r = tempdmg
    endif


    when I remove that code it works.

    Please see if you can find the problem.
     
  2. mecatronic

    mecatronic

    Joined:
    Jun 20, 2005
    Messages:
    112
    Resources:
    1
    Maps:
    1
    Resources:
    1
    hehehe, you forgot to use the "set" function =]

    try this and you'll be fine:

    Code (vJASS):
    set r = tempdmg


    =]
     
  3. Freyleyes

    Freyleyes

    Joined:
    Jun 28, 2008
    Messages:
    766
    Resources:
    1
    Spells:
    1
    Resources:
    1
    AGHHHH

    I am so stupid.

    Thanks :D, I love U