• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Whats wrong with this?

Status
Not open for further replies.
Level 17
Joined
Jun 28, 2008
Messages
776
Whats wrong with this?

JASS:
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

JASS:
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.
 
Status
Not open for further replies.
Top