HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

UnitDamageTarget is bugging me for some reason ...

07-29-2007, 11:10 AM#1
Fireeye
I'm currently making a little system with vJASS (nothing really special, only a system to trigger damage types, etc. so you can extend the given limits of attack types), everything works fine except when it comes to the UnitDamageTarget line.
I really don't get the problem, there isn't any syntax error and never had such a problem before, first i though the problem would be somewhere else, but the trigger works fine when i comment the line.

Collapse JASS:
private function Effect takes nothing returns nothing
local unit a = GetEventDamageSource()
local integer i = 1
local trigger t = GetTriggeringTrigger()
local unit u = null
local real chance
local real xdamage
    loop
        exitwhen i >= globi or getunit[i].t == t
            set i = i + 1
    endloop
    if i < globi then
        set u = getunit[i].u
    endif
    //... some other lines
    if u != null then
        if GetRandomReal(0,1) <= chance
           call UnitDamageTarget(a,u,xdamage,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_UNIVERSAL,WEAPON_TYPE_WHOKNOWS)
           //...some other lines again
        endif
    endif
endfuntion
07-29-2007, 11:42 AM#2
Toadcop
Quote:
local unit u
i would suggest intialize it... so if

if i < globi then
set u = getunit[i].u
endif

will not set u. DamageTarget will use undeclared var = thread crash or something like that.
so what i mean... i bet what is something wrong with "u" it not seted to some real unit.

btw a suggestion... INTIALIZE VARS ! it makes not much but will prevent stupid "bugs".
07-29-2007, 11:59 AM#3
Fireeye
That's not the problem as i already said, i forgot to add the if condition.
The entire damage thing won't be done if the unit is null, i'll edit the first post.
And i was also so intelligent to try it with a pre-placed unit, wc3 still crashs.
07-29-2007, 12:21 PM#4
Toadcop
undeclared unit != null ^^ btw...

maybe u got infint damage cycle? == war3 crash
07-29-2007, 01:39 PM#5
blu_da_noob
You haven't told us what happens. You just say it works fine until that point.

First guess is same as Toadcop's, you have an infinite response causing event cycle with the damage. If WC3 suddenly shuts down with no error message this is almost certainly your problem.

Not showing us the whole thing really isn't helping, because we don't know whether you initialise all the variables etc.
07-29-2007, 02:05 PM#6
Fireeye
Found the error, was a problem with another trigger which were also fired, (though i deactivated it) and caused an infinite loop.
I deactivated it and it's working fine now.
Man needed so long time to find such a simple error -.-