HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Sigh...JASS newb needs some quick help!

06-03-2004, 01:18 AM#1
7smurfs
Sorry I keeep posting questions but I can't seem to find somehwere to answer else thats this good in getting them answered. Ok, I made a JASS script to practice some of the beginnings of JASS. So I made a custom spell based off of Breath of Fire withe the data code: A004. Ok, so I make the following JASS trigger:
function Trig_Make_Dead_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A004' ) ) then
return false
endif
return true
endfunction

function Trig_Make_Dead_Actions takes nothing returns nothing
local integer i
local location p
loop
exitwhen i > 5
set i = 0
set p = (GetUnitLoc(GetTriggerUnit()))
call CreateNUnitsAtLoc(1,'hfoo', Player(0), p, bj_PI)
call DisplayTextToPlayer(Player(0),0,0,I2S(i)+"units created")
set i = i + 1
call RemoveLocation(p)
set p = null
call PolledWait(1)
endloop
endfunction

//===========================================================================
function InitTrig_Make_Dead takes nothing returns nothing
set gg_trg_Make_Dead = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Make_Dead, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Make_Dead, Condition( function Trig_Make_Dead_Conditions ) )
call TriggerAddAction( gg_trg_Make_Dead, function Trig_Make_Dead_Actions )
endfunction

But it doesn't do anything! It does not display the text, it does not create the units, and as far as I can tell it does nothing! What is wrong with it? I'm thinking that maybe the event is the problem but I've tried all the spell events and none of them worked =(




edit: er nevermind I just fixed it... anyone know where the delete button is?
06-03-2004, 10:34 AM#2
AIAndy
You are accessing an uninitialised i in the exitwhen i > 5. That cancels the thread. Besides that loop is endless because you set i = 0 within the loop. Best remove that line and use
local integer i = 0
06-03-2004, 02:07 PM#3
Narwanza
Its a good idea to always initialize your locals with something. Most often are the Create(some handle)() like CreateTrigger() CreateGroup() CreateTimer(). With a handle that you are going to set to something else or add to it (groups) then you definitly need to put Create(someHandle)() or null. Example.

Code:
function myfunc takes nothing returns nothing
    local group g = CreateGroup()
    local group p = null
    set p = GetUnitsInRectAll(GetEntireMapRect())
    call GroupAddGroup(p,g)
endfunction

you couldn't set p to anything if you hadn't set it to null on declaration. And you couldn't have added a group unless it had been set to CreateGroup().
06-04-2004, 01:21 AM#4
7smurfs
Ok thanks for the help guys. But now I have yet (sigh) another question :(
I, for some unkown reason, cannot get ANY trigger or function or anything to do damage to a unit. Example is this:
call SetUnitLifeBJ( GetSpellTargetUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetSpellTargetUnit()) - 10.00 ) )

It simply does not work. I have tried making that part of the trigger GUI and copying the made cuztom text, wich did nothing. I tried looking at how other maps did it, and to the same prevail. I have a feeling this might have something to do with the unit groups the person above me was speaking about. I am at a loss as to how to get this to work tho.
06-11-2004, 04:21 PM#5
Aiursrage2k
The problem is you are want to get the target of the spell, but that only works for single target spells like storm bolt. To pick the units that would be hit by the flame you would have to do some experimentation, luckily someone made a function to do just that.

http://kattana.users.whitehat.dk/viewfunc.php?id=267
06-11-2004, 09:42 PM#6
7smurfs
THanks for the explanation. I got this fixed awhile ago but thanks for explaining why it had to be that way.