• 🏆 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] Need a little help over here PLZ

Status
Not open for further replies.
Level 7
Joined
Nov 6, 2009
Messages
279
Ok can somebody check if the code is ok (leaks, BJs, etc)? I think my GroupRemoveUnit is crap.

JASS:
function LOOP takes nothing returns nothing
    local unit creep = GetTriggerUnit()
    local integer creeplvl = GetUnitLevel(creep)
    local integer xpbase = 25
    local integer totalxp = ( creeplvl * xpbase )
    local integer goldbase = 2
    local integer totalgold = ( creeplvl * goldbase )
    local texttag xptag
    local texttag goldtag
    if ( IsUnitType(GetEnumUnit(), UNIT_TYPE_HERO) == true ) then
        call AddHeroXP( GetEnumUnit(), totalxp, true )
        set xptag = CreateTextTag()
        call SetTextTagPosUnit(xptag, GetEnumUnit(), 0)
        call SetTextTagText( xptag, ( "+" + I2S(totalxp) ), 0.018 )
        call SetTextTagColor(xptag, 175, 75, 255, 255)
        call SetTextTagVelocity( xptag, (TextTagSpeed2Velocity(60) * Cos(75 * bj_DEGTORAD)), (TextTagSpeed2Velocity(60) * Sin(75 * bj_DEGTORAD)) )
        call SetTextTagLifespan( xptag, 2.00 )
        call SetTextTagFadepoint( xptag, 1.50 )
        call SetPlayerState(GetOwningPlayer(GetEnumUnit()), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(GetOwningPlayer(GetEnumUnit()), PLAYER_STATE_RESOURCE_GOLD) + totalgold)
        set goldtag = CreateTextTag()
        call SetTextTagPosUnit(goldtag, GetEnumUnit(), 0)
        call SetTextTagText( goldtag, ( "+" + I2S(totalgold) ), 0.015 )
        call SetTextTagColor(goldtag, 175, 255, 75, 255)
        call SetTextTagVelocity( goldtag, (TextTagSpeed2Velocity(74) * Cos(90 * bj_DEGTORAD)), (TextTagSpeed2Velocity(74) * Sin(90 * bj_DEGTORAD)) )
        call SetTextTagPermanent( goldtag, false )
        call SetTextTagLifespan( goldtag, 2.00 )
        call SetTextTagFadepoint( xptag, 1.50 )
    endif
    set creep = null
endfunction

function INITACTIONS takes nothing returns nothing
    local real range = 1200.00
    local unit creep = GetTriggerUnit()
    local group g = GetUnitsInRangeOfLocAll(range, GetUnitLoc(creep))
    call ForGroup( g, function LOOP )
    set creep = null
    set g = null
    call GroupRemoveUnit(g, GetEnumUnit())
endfunction

//===========================================================================
function InitTrig_XP_AND_GOLD_SYSTEM takes nothing returns nothing
    local trigger TRG = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( TRG, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( TRG, function INITACTIONS )
endfunction
 
Last edited:
JASS:
function LOOP takes nothing returns nothing
    local unit creep = GetTriggerUnit()
    local integer creeplvl = GetUnitLevel(creep)
    local integer xpbase = 25
    local integer totalxp = ( creeplvl * xpbase )
    local integer goldbase = 2
    local integer totalgold = ( creeplvl * goldbase )
    local texttag xptag
    local texttag goldtag
    if ( IsUnitType(GetEnumUnit(), UNIT_TYPE_HERO) == true ) then
        call AddHeroXP( GetEnumUnit(), totalxp, true )
        set xptag = CreateTextTag()
        call SetTextTagPosUnit(xptag, GetEnumUnit(), 0)
        call SetTextTagText( xptag, ( "+" + I2S(totalxp) ), 0.018 )
        call SetTextTagColor(xptag, 175, 75, 255, 255)
        call SetTextTagVelocity( xptag, (TextTagSpeed2Velocity(60) * Cos(75 * bj_DEGTORAD)), (TextTagSpeed2Velocity(60) * Sin(75 * bj_DEGTORAD)) )
        call SetTextTagPermanent( xptag, false )
        call SetTextTagLifespan( xptag, 2.00 )
        call SetTextTagFadepoint( xptag, 1.50 )
        call SetPlayerState(GetOwningPlayer(GetEnumUnit()), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(GetOwningPlayer(GetEnumUnit()), PLAYER_STATE_RESOURCE_GOLD) + totalgold)
        set goldtag = CreateTextTag()
        call SetTextTagPosUnit(goldtag, GetEnumUnit(), 0)
        call SetTextTagText( goldtag, ( "+" + I2S(totalgold) ), 0.015 )
        call SetTextTagColor(goldtag, 175, 255, 75, 255)
        call SetTextTagVelocity( goldtag, (TextTagSpeed2Velocity(74) * Cos(90 * bj_DEGTORAD)), (TextTagSpeed2Velocity(74) * Sin(90 * bj_DEGTORAD)) )
        call SetTextTagPermanent( goldtag, false )
        call SetTextTagLifespan( goldtag, 2.00 )
        call SetTextTagFadepoint( goldtag, 1.50 )
    endif
    set creep = null
    set xptag = null
    set goldtag = null
endfunction
Works for me fine when killing creeps with hero.
SetTextTagLifespan automatically destroyes the texttag after given time as far as I know.
 
Level 7
Joined
Nov 6, 2009
Messages
279
JASS:
function LOOP takes nothing returns nothing
    local unit creep = GetTriggerUnit()
    local integer creeplvl = GetUnitLevel(creep)
    local integer xpbase = 25
    local integer totalxp = ( creeplvl * xpbase )
    local integer goldbase = 2
    local integer totalgold = ( creeplvl * goldbase )
    local texttag xptag
    local texttag goldtag
    if ( IsUnitType(GetEnumUnit(), UNIT_TYPE_HERO) == true ) then
        call AddHeroXP( GetEnumUnit(), totalxp, true )
        set xptag = CreateTextTag()
        call SetTextTagPosUnit(xptag, GetEnumUnit(), 0)
        call SetTextTagText( xptag, ( "+" + I2S(totalxp) ), 0.018 )
        call SetTextTagColor(xptag, 175, 75, 255, 255)
        call SetTextTagVelocity( xptag, (TextTagSpeed2Velocity(60) * Cos(75 * bj_DEGTORAD)), (TextTagSpeed2Velocity(60) * Sin(75 * bj_DEGTORAD)) )
        call SetTextTagPermanent( xptag, false )
        call SetTextTagLifespan( xptag, 2.00 )
        call SetTextTagFadepoint( xptag, 1.50 )
        call SetPlayerState(GetOwningPlayer(GetEnumUnit()), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(GetOwningPlayer(GetEnumUnit()), PLAYER_STATE_RESOURCE_GOLD) + totalgold)
        set goldtag = CreateTextTag()
        call SetTextTagPosUnit(goldtag, GetEnumUnit(), 0)
        call SetTextTagText( goldtag, ( "+" + I2S(totalgold) ), 0.015 )
        call SetTextTagColor(goldtag, 175, 255, 75, 255)
        call SetTextTagVelocity( goldtag, (TextTagSpeed2Velocity(74) * Cos(90 * bj_DEGTORAD)), (TextTagSpeed2Velocity(74) * Sin(90 * bj_DEGTORAD)) )
        call SetTextTagPermanent( goldtag, false )
        call SetTextTagLifespan( goldtag, 2.00 )
        call SetTextTagFadepoint( goldtag, 1.50 )
    endif
    set creep = null
    set xptag = null
    set goldtag = null
endfunction
Works for me fine when killing creeps with hero.
SetTextTagLifespan automatically destroyes the texttag after given time as far as I know.

Doesnt work for me...
EDIT: Works with 255 alpha my bad can some1 tell wtf does alpha do for floationg text?
 
Status
Not open for further replies.
Top