• 🏆 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!

[JASS] Code Problems

Status
Not open for further replies.
Level 2
Joined
Jun 15, 2007
Messages
12
JASS:
function Deal_AoE_Bonus takes integer high, unit caster, location p returns nothing
local group g
local unit u
local integer result
local unit y
set result = GetRandomInt(1,high)
set g = GetUnitsInRangeOfLocAll(GetHandleReal(y, "range"), p)
set u = FirstOfGroup(g)
    //DEBUGSHITcall DisplayTextToPlayer(Player(0),0,0,I2S(result))
loop
      exitwhen u==null
      set u = FirstOfGroup(g)
      if  IsUnitEnemy(u, GetOwningPlayer(caster))==true then
      //DEBUGSHITcall UnitDamageTarget(caster, u, I2R(result), true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
      call SetUnitState (u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_LIFE)-I2R(result))
      call DisplayTextToPlayer(Player(0),0,0,I2S(result))
      call GroupRemoveUnit(g,u)     
      endif
endloop
set g = null
set u = null
//set caster = null
//set p = null
set y= null
call SetHandleInt(y, "range", 0)
call FlushHandleLocals(y)
endfunction






//=========================================
//The Trigger
//=========================================

function CheckAoESpell takes nothing returns boolean
local unit y = GetTriggerUnit()

//WhateverSpell
if GetSpellAbilityId()=='A020' then
call SetHandleReal(y, "range", 350.00)
set y = null
return true
endif

set y = null
return false
endfunction



function AoE_Bonus takes nothing returns nothing

local integer loopcounter = 0
local integer currentitem
local unit x
//DEBUGSHITcall call DisplayTextToPlayer(Player(0),0,0,"HIT")

//========================================================
//Whatever Item
//========================================================
if UnitHasItemOfTypeBJ(GetTriggerUnit(),'I02A') == true then
set x = GetTriggerUnit()
set currentitem = 'I02A'
call DisplayTextToPlayer(Player(0),0,0,"Sorc Dagger")
call CountNumberOfItemOnUnit(currentitem,GetTriggerUnit())
//call TriggerSleepAction(.10)
set loopcounter = GetHandleInt(x, "sum")
loop    
    exitwhen loopcounter == 0
    //DEBUGSHITcall DisplayTextToPlayer(Player(0),0,0,"|CFF8801BDThis loop will be fired "+I2S(loopcounter)+" time(s).") 
    call Deal_AoE_Bonus(25,GetTriggerUnit(),GetUnitLoc(GetTriggerUnit()))
    set loopcounter = loopcounter - 1
endloop
endif   
set x = null
call SetHandleInt(x, "sum", 0)
//========================================================

call FlushHandleLocals(x)
endfunction



function InitTrig_AoEBonus takes nothing returns nothing

    set gg_trg_AoEBonus = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_AoEBonus, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_AoEBonus, Condition(function CheckAoESpell))
    call TriggerAddAction(gg_trg_AoEBonus, function AoE_Bonus)
endfunction

Deal_AoE_Bonus isn't getting fired. Everything else is though, even the loop within AoE_Bonus. Please help :(
 
Level 3
Joined
May 27, 2007
Messages
43
Please download this software: http://hiveworkshop.com/resources_new/tools/469/

Paste your trigger code in there. Hold SHIFT and press F5.
Repaste you trigger code here.

Indenting makes it a lot easier to find errors on codes.

Additionally, download the JASSNewGen package by Vexorian (on wc3campaigns) and re-run your map with it. It's a very good tool to detect minor mistakes on your code (such as not initializing all variables)
 
Status
Not open for further replies.
Top