HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Something is wrong with this

12-24-2006, 07:27 PM#1
Joker
Collapse JASS:
function Trig_Money_Setup_Conditions takes nothing returns boolean
    return IsUnitType(GetDyingUnit(), UNIT_TYPE_STRUCTURE) == false and IsUnitType(GetDyingUnit(), UNIT_TYPE_HERO) == false and IsUnitType(GetKillingUnit(), UNIT_TYPE_HERO) and GetOwningPlayer(GetKillingUnit()) != GetOwningPlayer(GetDyingUnit()) or IsUnitType(GetKillingUnit(), UNIT_TYPE_SUMMONED) == true
endfunction

function Trig_Money_Setup_Actions takes nothing returns nothing
    local unit a = GetDyingUnit()
    local unit d = GetKillingUnit()
    local integer b = GetUnitTypeId(a)
    local integer c = GetRandomInt(33,48)
    local integer cc = GetRandomInt(38,59)
    local integer ca = GetPlayerState(GetOwningPlayer(d), PLAYER_STATE_RESOURCE_GOLD) + c
    local integer cca = GetPlayerState(GetOwningPlayer(d), PLAYER_STATE_RESOURCE_GOLD) + cc
    local string cas = "+" + I2S(c)
    local string ccas = "+" + I2S(cc)
    local texttag t = CreateTextTag()
    local real ux = GetUnitX(a)
    local real uy = GetUnitY(a)
    local real vel = TextTagSpeed2Velocity(30)
    local real velx = vel * Cos(90 * bj_DEGTORAD)
    local real vely = vel * Sin(90 * bj_DEGTORAD)

    call SetTextTagPermanent(t, false)
    call SetTextTagPos( t, ux, uy, 0)
    call SetTextTagColorBJ(t, 85, 85, 15, 100)
    call SetTextTagVelocity(t, velx, vely)
    call SetTextTagLifespan(t, 5)
    call SetTextTagFadepoint(t, 3)
    
    if b == 'hfoo' or b == 'ugho' or b == 'edoc' or b == 'ogru' then
        call SetTextTagText( t, cas, TextTagSize2Height(11) )
        call SetPlayerState( GetOwningPlayer(d), PLAYER_STATE_RESOURCE_GOLD, ca)
    elseif b == 'hsor' or b == 'uban' or b == 'ohun' or b == 'even' then
            call SetTextTagText( t, ccas, TextTagSize2Height(11) )
            call SetPlayerState( GetOwningPlayer(d), PLAYER_STATE_RESOURCE_GOLD, cca)
    endif
    set t = null
    set a = null
    set d = null
endfunction

//===========================================================================
function InitTrig_Money_Setup takes nothing returns nothing
    set gg_trg_Money_Setup = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Money_Setup, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Money_Setup, Condition( function Trig_Money_Setup_Conditions ) )
    call TriggerAddAction( gg_trg_Money_Setup, function Trig_Money_Setup_Actions )
endfunction
Idk if half those variables are really necessary, but it works. The problem is that when a unit dies, the text doesnt show up until about 3 seconds later, which is really annoying. Have I dont something wrong/Bad?
12-24-2006, 08:17 PM#2
darkwulfv
umm... Idk, perhaps its something to do with all those variables, the booleans, and bj's and stuff... personally, I haven't a clue.
12-25-2006, 12:52 AM#3
Rising_Dusk
Collapse JASS:
    local real velx = vel * Cos(90 * bj_DEGTORAD)
    local real vely = vel * Sin(90 * bj_DEGTORAD)
Just so you know, the Cosine of Pi/2 is zero and the Sin of Pi/2 is 1.
So that can all be reduced to this:

Collapse JASS:
    local real velx = 0
    local real vely = vel
And you can simplify the other variables from there.

Otherwise, the code looks fine.
Consider adding BJDebugMsg() calls into the function to make sure it is passing its conditions when you want it to.
If it is, then it should be relatively instantly visible.

Notice also --
call SetTextTagColorBJ(t, 85, 85, 15, 100)
Collapse JASS:
function SetTextTagColorBJ takes texttag tt, real red, real green, real blue, real transparency returns nothing
    call SetTextTagColor(tt, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-transparency))
endfunction
From the way the BJ calls, you're setting the texttag to 0% visibility.
This may also explain why you're not seeing it.
12-25-2006, 01:24 AM#4
PipeDream
Texttags aren't regular handles, are they? If it's not >0x100000 you don't need to null it.
12-25-2006, 06:51 AM#5
The)TideHunter(
Quote:
Originally Posted by PipeDream
Texttags aren't regular handles, are they? If it's not >0x100000 you don't need to null it.

So could you check via (I2R(HtoI(SomeTextTag))>0x100000)?
12-28-2006, 03:06 PM#6
Joker
so..theres nothing really wrong with it that would delay the text by 2-3 seconds? The text does eventually show, just very delayed.
12-30-2006, 10:40 PM#7
Joker
Ok, everything is perfect now (Ty dusk), except for the condition.
Collapse JASS:
function Trig_Money_Setup_Conditions takes nothing returns boolean
    return IsUnitType(GetDyingUnit(), UNIT_TYPE_STRUCTURE) == false and IsUnitType(GetDyingUnit(), UNIT_TYPE_HERO) == false and IsUnitType(GetKillingUnit(), UNIT_TYPE_HERO) and GetOwningPlayer(GetKillingUnit()) != GetOwningPlayer(GetDyingUnit()) or IsUnitType(GetKillingUnit(), UNIT_TYPE_SUMMONED) == true
endfunction
(how do you highlight)
the or part doesnt seem to be working b/c when i kill one of the units with a summon, it doesnt run
12-31-2006, 12:46 AM#8
PipeDream
Hmm.. maybe because one of your IsUnitType's is missing the "== true"
12-31-2006, 02:22 AM#9
Joker
thx ;>< my bad