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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top