• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] get unit life not working ?

Status
Not open for further replies.
Level 29
Joined
Oct 24, 2012
Messages
6,543
hello im trying to find out y this isnt working all it does is set a value to unit life but for some reason it keeps returning units max life instead of its current life can anyone see a problem in this trigger ill show u a cutout then the whole trigger for ease of seeing what i think is the problem

this is the part tht isnt working right
JASS:
    if ( u == Unit_Damage_Test_Player[0] ) then
        set Damage_Test_Life_Red_Reg[2] = ( DamageTest_MaxLife_Player[0] - GetUnitState(Unit_Damage_Test_Player[0], UNIT_STATE_LIFE) )
        set DPS_Red_Region[2] = ( ( Damage_Test_Life_Red_Reg[2] - Damage_Test_Life_Red_Reg[1] ) / udg_Timer_Region_Player[0] )

this is the full trigger
JASS:
function Trig_Unit_Move_Red_region_2_to_Red_region_3_Actions takes nothing returns nothing
    local real rx = GetRectCenterX(gg_rct_Red_Region_3)
    local real ry = GetRectCenterY(gg_rct_Red_Region_3)
    local real dlife
    local multiboarditem mbi
    local string color = "|r"
    local unit u = GetTriggerUnit()
    if ( IsUnitInGroup(u, Unit_Spawns_Group_Player[0] ) or u == Boss_Unit_Player[0] or ( u == Unit_Damage_Test_Player[0] ) ) then
        call IssuePointOrder( u, "move", rx, ry )
        call SetUnitUserData( u, 3 )
    endif
    if ( u == Unit_Damage_Test_Player[0] ) then
        set Damage_Test_Life_Red_Reg[2] = ( DamageTest_MaxLife_Player[0] - GetUnitState(Unit_Damage_Test_Player[0], UNIT_STATE_LIFE) )
        set DPS_Red_Region[2] = ( ( Damage_Test_Life_Red_Reg[2] - Damage_Test_Life_Red_Reg[1] ) / udg_Timer_Region_Player[0] )
        set mbi = MultiboardGetItem( damagebossMultiboard, 7, 1 )
        call MultiboardSetItemValue( mbi, playerColors[0] + R2S(DPS_Red_Region[2]) + color )
        set udg_Timer_Region_Player[0] = 0.00
        call DisplayTextToForce( GetPlayersAll(), "3" )
    endif
    set Creep_Checkpoints_Red_Region[2] = ( Creep_Checkpoints_Red_Region[2] + 1 )
    set mbi = MultiboardGetItem( creepstatisticsMultiboard, 8, 1 )
    call MultiboardSetItemValue( mbi, playerColors[0] + I2S(Creep_Checkpoints_Red_Region[2]) + color )
    set mbi = null
    set color = null
    set u = null
endfunction

//===========================================================================
function InitTrig_Unit_Move_Red_region_2_to_Red_region_3 takes nothing returns nothing
    local trigger t = CreateTrigger()
    local region r 
    set r = RegionAddRect( r, gg_rct_Red_Region_2 )
    call TriggerRegisterEnterRegion( t, r, null )
    call TriggerAddCondition( t, Condition( function Trig_Unit_Move_Red_region_2_to_Red_region_3_Conditions ) )
    call TriggerAddAction( t, function Trig_Unit_Move_Red_region_2_to_Red_region_3_Actions )
    set r = null
    set t = null
endfunction


edit: i found the reason i was adding str which gives hp to the unit i guess if u add to much str the get unit life glitches or something thx for looking at this to try to help me tho
 
Last edited:
Status
Not open for further replies.
Top