Question about localplayer and floaty text

Lord_Kakashi

The Wabbits are attacking
Reaction score
27
Okay so I'm very new to the whole JASS front in it's non-GUI form, so I was wondering if this would cause a desync or if it's okay for battle.net use.

Basically I went ahead and made my own "bounty" system for my tower defence map because the monsters spawned are not the same every level... e.g. first time playing the map.. round two monsters might be worms.. the next time it might be knights..

Anyway.. here's the actual trigger. (GUI with custom code)
Code:
Bounty Give
    Events
        Unit - A unit owned by Player 12 (Brown) Dies
    Conditions
    Actions
        Custom script:   if GetLocalPlayer() == GetOwningPlayer(GetKillingUnitBJ()) then
        Set monBountyPoint[(Player number of (Owner of (Killing unit)))] = (Position of (Dying unit))
        Floating Text - Create floating text that reads (TempStrings[1] + (+ + (String(MonBounty[level])))) at monBountyPoint[(Player number of (Owner of (Killing unit)))] with Z offset 0.00, using font size 10.00, color (100.00%, 80.00%, 20.00%), and 0.00% transparency
        Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
        Floating Text - Show (Last created floating text) for (Player group((Owner of (Killing unit))))
        Floating Text - Change (Last created floating text): Disable permanence
        Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
        Floating Text - Change the fading age of (Last created floating text) to 0.50 seconds
        Player - Add MonBounty[level] to (Owner of (Killing unit)) Current gold
        Custom script:   endif
        Custom script:   call RemoveLocation(udg_monBountyPoint[GetConvertedPlayerId(GetOwningPlayer(GetKillingUnitBJ()))])

Obviously the intention is to have the +[income variable] floating text only to display for one player. The one killing the unit
 
Reaction score
456
You're creating a floating text (a handle) for a local player and that causes desyncs.. or some other problems may occur.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
You're already only showing it to the killing unit. You don't need the local player line. Also, Uberplayer is right.

If you wanted to create the floating text using local player (and the Show (Last created floating text) for (Player group) didn't work), you'd have to set the string inside a local player if-then. The floating text would still be created for all players, but for all players except the player that is checked with the if-then, you would have to set the string to "".
 

Lord_Kakashi

The Wabbits are attacking
Reaction score
27
You're already only showing it to the killing unit. You don't need the local player line. Also, Uberplayer is right.

If you wanted to create the floating text using local player (and the Show (Last created floating text) for (Player group) didn't work), you'd have to set the string inside a local player if-then. The floating text would still be created for all players, but for all players except the player that is checked with the if-then, you would have to set the string to "".

well i just tested and it shows the floating text regardless of the show/hide action apparently.. So I'll have to do the thing where I set it to something else for other players?

Meaning this would be better?
Code:
Bounty Give
    Events
        Unit - A unit owned by Player 12 (Brown) Dies
    Conditions
    Actions
        Set FloatyStrings = <Empty String>
        Custom script:   if GetLocalPlayer() == GetOwningPlayer(GetKillingUnitBJ()) then
        Set FloatyStrings = (TempStrings[1] + (+ + (String(MonBounty[level]))))
        Custom script:   endif
        Set monBountyPoint[(Player number of (Owner of (Killing unit)))] = (Position of (Dying unit))
        Floating Text - Create floating text that reads FloatyStrings at monBountyPoint[(Player number of (Owner of (Killing unit)))] with Z offset 0.00, using font size 10.00, color (100.00%, 80.00%, 20.00%), and 0.00% transparency
        Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
        Floating Text - Change (Last created floating text): Disable permanence
        Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
        Floating Text - Change the fading age of (Last created floating text) to 0.50 seconds
        Player - Add MonBounty[level] to (Owner of (Killing unit)) Current gold
        Custom script:   call RemoveLocation(udg_monBountyPoint[GetConvertedPlayerId(GetOwningPlayer(GetKillingUnitBJ()))])

Or rather this, since it needs to be a local?..
JASS:
function Trig_Bounty_Give_Copy_Actions takes nothing returns nothing
    local string FloatyStrings = &quot;&quot;
    set FloatyStrings = &quot;&quot;
    if GetLocalPlayer() == GetOwningPlayer(GetKillingUnitBJ()) then
    set FloatyStrings = ( udg_TempStrings[1] + ( &quot;+&quot; + I2S(udg_MonBounty[udg_level]) ) )
    endif
    set udg_monBountyPoint[GetConvertedPlayerId(GetOwningPlayer(GetKillingUnitBJ()))] = GetUnitLoc(GetDyingUnit())
    call CreateTextTagLocBJ(FloatyStrings, udg_monBountyPoint[GetConvertedPlayerId(GetOwningPlayer(GetKillingUnitBJ()))], 0, 10.00, 100, 80.00, 20.00, 0 )
    call SetTextTagVelocityBJ( GetLastCreatedTextTag(), 64, 90 )
    call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
    call SetTextTagLifespanBJ( GetLastCreatedTextTag(), 2.00 )
    call SetTextTagFadepointBJ( GetLastCreatedTextTag(), 0.50 )
    call AdjustPlayerStateBJ( udg_MonBounty[udg_level], GetOwningPlayer(GetKillingUnitBJ()), PLAYER_STATE_RESOURCE_GOLD )
    call RemoveLocation(udg_monBountyPoint[GetConvertedPlayerId(GetOwningPlayer(GetKillingUnitBJ()))])
endfunction

//===========================================================================
function InitTrig_Bounty_Give_Copy takes nothing returns nothing
    set gg_trg_Bounty_Give_Copy = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_Bounty_Give_Copy, Player(11), EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( gg_trg_Bounty_Give_Copy, function Trig_Bounty_Give_Copy_Actions )
endfunction
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
You're creating a floating text (a handle) for a local player and that causes desyncs.. or some other problems may occur.

Texttags aren't allocated normally like regular handles, I don't think it causes desyncs creating them locally but it could lead to some problems. You should probably just stick to the good ol' hide and show locally thing.
 

Lord_Kakashi

The Wabbits are attacking
Reaction score
27
Texttags aren't allocated normally like regular handles, I don't think it causes desyncs creating them locally but it could lead to some problems. You should probably just stick to the good ol' hide and show locally thing.

which makes my above post wrong or...?
 

Lord_Kakashi

The Wabbits are attacking
Reaction score
27
yes (no point hiding a non-existant text tag ^^)

Okay uh.. I think I've got it then.. I'll edit my post in a sec with the updated part :)

I think this is right?. hehe :)
JASS:
function Trig_Bounty_Give_Copy_Actions takes nothing returns nothing
    local string FloatyStrings = &quot;&quot;
    set FloatyStrings = ( udg_TempStrings[1] + ( &quot;+&quot; + I2S(udg_MonBounty[udg_level]) ) )
    
    set udg_monBountyPoint[GetConvertedPlayerId(GetOwningPlayer(GetKillingUnitBJ()))] = GetUnitLoc(GetDyingUnit())
    call CreateTextTagLocBJ(FloatyStrings, udg_monBountyPoint[GetConvertedPlayerId(GetOwningPlayer(GetKillingUnitBJ()))], 0, 10.00, 100, 80.00, 20.00, 0 )
    call SetTextTagVisibility(FloatyStrings, false)  
      if GetLocalPlayer() == GetOwningPlayer(GetKillingUnitBJ()) then
           call SetTextTagVisibility(FloatyStrings, true)
      endif

    call SetTextTagVelocityBJ( GetLastCreatedTextTag(), 64, 90 )
    call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
    call SetTextTagLifespanBJ( GetLastCreatedTextTag(), 2.00 )
    call SetTextTagFadepointBJ( GetLastCreatedTextTag(), 0.50 )
    

    call AdjustPlayerStateBJ( udg_MonBounty[udg_level], GetOwningPlayer(GetKillingUnitBJ()), PLAYER_STATE_RESOURCE_GOLD )
    call RemoveLocation(udg_monBountyPoint[GetConvertedPlayerId(GetOwningPlayer(GetKillingUnitBJ()))])
endfunction

//===========================================================================
function InitTrig_Bounty_Give_Copy takes nothing returns nothing
    set gg_trg_Bounty_Give_Copy = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_Bounty_Give_Copy, Player(11), EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( gg_trg_Bounty_Give_Copy, function Trig_Bounty_Give_Copy_Actions )
endfunction


well guess not.. now it's giving me some sort of error when i try to enable it.

Well it worked when i replaced the string with GetLastCreatedTextTag(), maybe I should use another local variable? just to make sure that it's the right one which gets displayed and removed for each player? Since the one i have now is the string
 

Artificial

Without Intelligence
Reaction score
326

Lord_Kakashi

The Wabbits are attacking
Reaction score
27
Ah i see, so i should hide the text tag for other players than the localplayer running the trigger.

I guess i should convert the string to a global then? Or doesn't that matter anything since locals (by what i've gathered) are fine for all players, but only valid inside the function where they're declared??
 

Flare

Stops copies me!
Reaction score
662
Ah i see, so i should hide the text tag for other players than the localplayer running the trigger.

I guess i should convert the string to a global then? Or doesn't that matter anything since locals (by what i've gathered) are fine for all players, but only valid inside the function where they're declared??

Just do what Artificial said :p There's no need for globals and such if you are only creating a simple text tag (by simple, I mean that it has an lifespan so it doesn't have to be manually destroyed)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top