"Bounty" text

jomik

New Member
Reaction score
17
Heey again! :D Does anyone have a way to add some good looking text to hover above a unit when you kill it, using a trigger, or when you give gold to a player, through triggers. How'd I make it hover over a specific unit? :O

Thanks :D
 

BRUTAL

I'm working
Reaction score
118
Make a floating text over the dying unit that displays the bounty and set the colour to something goldish.
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
JASS:
function GoldBountyFX takes unit u, integer gold, player p returns nothing
    local integer FLYING_GOLD_UNITTYPE = 'z000'
    local texttag t = CreateTextTag()
    local real ux = GetUnitX(u)
    local real uy = GetUnitY(u)
    local real uz = GetUnitFlyHeight(u)
    local destructable d
    local unit f
    if(IsUnitType(u, UNIT_TYPE_FLYING)) then
        set f = CreateUnit(Player(15), FLYING_GOLD_UNITTYPE, ux, uy, 0)
        call SetUnitScale(f, 1, 1, 1)
        call SetUnitFlyHeight(f, uz, 0)
        call UnitAddAbility(f, 'Aloc')
        call SetTextTagText(t, "+" + I2S(gold), 0.023)
        call SetTextTagPosUnit(t, f, -13)
        call KillUnit(f)
    else
        call SetTextTagText(t, "+" + I2S(gold), 0.024)
        call SetTextTagPos(t, ux-16, uy-16, uz)
        set d = CreateDestructableZ('OTip', ux-16, uy-16, uz, 0.00, 1, 0) //http://wc3jass.com/viewtopic.php?t=2472
        call DestroyEffect(AddSpecialEffect("UI\\Feedback\\GoldCredit\\GoldCredit.mdl", ux-16, uy-16))
        call RemoveDestructable(d)
    endif
    call SetTextTagColor(t, 255, 220, 0, 255)
    call SetTextTagVelocity(t, 0, 0.03)
    call SetTextTagVisibility(t, GetLocalPlayer() == p)
    call SetTextTagFadepoint(t, 2)
    call SetTextTagLifespan(t, 3)
    call SetTextTagPermanent(t, false)
    set t = null
    set f = null
    set d = null
endfunction


[edit 2] OK, this is as authentic as I know how to make it. It needs the special dummy unit from the attached map.
 

Attachments

  • GoldBountyUnit.w3x
    16.6 KB · Views: 211

jomik

New Member
Reaction score
17
And there's no leaks here?! :O AWESOME! Thanks dude :D
+rep clearly! :D - well if it works :p

EDIT: Works awesomely!! :D
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
OK, so, I've been testing it more since I noticed a big vertical offset that I hadn't previously seen since I'd only tested it with an overhead camera...

It's still not perfect (I've edited my previous post), but I think I'm finally on the right track. ...hate flying units, hate how there's no way to get their exact Z coordinate, hate hate hate....
 

jomik

New Member
Reaction score
17
Well it looks fine to me :O there wont be any units with normal bounty in my map, and probably not alot of flying units either, so this is awesome :D But I'll update it :D Thanks for updating it even now :O
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
JASS:
//==============================================================================
//  TEXT TAG - Floating text system by Cohadar - v5.0
//==============================================================================
//
//  PURPOUSE:
//       * Displaying floating text - the easy way
//       * Has a set of useful and commonly needed texttag functions
//  
//  CREDITS:
//       * DioD - for extracting proper color, fadepoint and lifespan parameters
//         for default warcraft texttags (from miscdata.txt)
//
//  HOW TO IMPORT:
//       * Just create a trigger named TextTag
//         convert it to text and replace the whole trigger text with this one
//==============================================================================

library TextTag

globals    
    // for custom centered texttags
    private constant real MEAN_CHAR_WIDTH = 7
    private constant real MAX_TEXT_SHIFT = 200.0
    private constant real DEFAULT_HEIGHT = 16.0

    // for default texttags
    private constant real   SIGN_SHIFT = 16.0
    private constant real   FONT_SIZE = 0.024
    private constant string MISS = "miss"
    private constant string BLOCK = "block"
endglobals

//===========================================================================
//   Custom centered texttag on (x,y) position
//   color is in default wc3 format, for example "|cFFFFCC00"
//===========================================================================
public function XY takes real x, real y, string text, string color returns nothing
    local texttag tt = CreateTextTag()
    local real shift = RMinBJ(StringLength(text)*MEAN_CHAR_WIDTH, MAX_TEXT_SHIFT)
    call SetTextTagText(tt, color+text, FONT_SIZE)
    call SetTextTagPos(tt, x-shift, y, DEFAULT_HEIGHT)
    call SetTextTagVelocity(tt, 0.0, 0.04)
    call SetTextTagVisibility(tt, true)
    call SetTextTagFadepoint(tt, 2.5)
    call SetTextTagLifespan(tt, 4.0)
    call SetTextTagPermanent(tt, false)
    set tt = null
endfunction

//===========================================================================
//   Custom centered texttag above unit
//===========================================================================
public function Unit takes unit whichUnit, string text, string color returns nothing
    local texttag tt = CreateTextTag()
    local real shift = RMinBJ(StringLength(text)*MEAN_CHAR_WIDTH, MAX_TEXT_SHIFT)
    call SetTextTagText(tt, color+text, FONT_SIZE)
    call SetTextTagPos(tt, GetUnitX(whichUnit)-shift, GetUnitY(whichUnit), DEFAULT_HEIGHT)
    call SetTextTagVelocity(tt, 0.0, 0.04)
    call SetTextTagVisibility(tt, true)
    call SetTextTagFadepoint(tt, 2.5)
    call SetTextTagLifespan(tt, 4.0)
    call SetTextTagPermanent(tt, false)    
    set tt = null
endfunction

//===========================================================================
//  Standard wc3 gold bounty texttag, displayed only to killing player 
//===========================================================================
public function GoldBounty takes unit whichUnit, integer bounty, player killer returns nothing
    local texttag tt = CreateTextTag()
    local string text = "+" + I2S(bounty)
    call SetTextTagText(tt, text, FONT_SIZE)
    call SetTextTagPos(tt, GetUnitX(whichUnit)-SIGN_SHIFT, GetUnitY(whichUnit), 0.0)
    call SetTextTagColor(tt, 255, 220, 0, 255)
    call SetTextTagVelocity(tt, 0.0, 0.03)
    call SetTextTagVisibility(tt, GetLocalPlayer()==killer)
    call SetTextTagFadepoint(tt, 2.0)
    call SetTextTagLifespan(tt, 3.0)
    call SetTextTagPermanent(tt, false)
    set text = null
    set tt = null
endfunction

//==============================================================================
public function LumberBounty takes unit whichUnit, integer bounty, player killer returns nothing
    local texttag tt = CreateTextTag()
    local string text = "+" + I2S(bounty)
    call SetTextTagText(tt, text, FONT_SIZE)
    call SetTextTagPos(tt, GetUnitX(whichUnit)-SIGN_SHIFT, GetUnitY(whichUnit), 0.0)
    call SetTextTagColor(tt, 0, 200, 80, 255)
    call SetTextTagVelocity(tt, 0.0, 0.03)
    call SetTextTagVisibility(tt, GetLocalPlayer()==killer)
    call SetTextTagFadepoint(tt, 2.0)
    call SetTextTagLifespan(tt, 3.0)
    call SetTextTagPermanent(tt, false)
    set text = null
    set tt = null
endfunction

//===========================================================================
public function ManaBurn takes unit whichUnit, integer dmg returns nothing
    local texttag tt = CreateTextTag()
    local string text = "-" + I2S(dmg)
    call SetTextTagText(tt, text, FONT_SIZE)
    call SetTextTagPos(tt, GetUnitX(whichUnit)-SIGN_SHIFT, GetUnitY(whichUnit), 0.0)
    call SetTextTagColor(tt, 82, 82 ,255 ,255)
    call SetTextTagVelocity(tt, 0.0, 0.04)
    call SetTextTagVisibility(tt, true)
    call SetTextTagFadepoint(tt, 2.0)
    call SetTextTagLifespan(tt, 5.0)
    call SetTextTagPermanent(tt, false)    
    set text = null
    set tt = null
endfunction

//===========================================================================
public function Miss takes unit whichUnit returns nothing
    local texttag tt = CreateTextTag()
    call SetTextTagText(tt, MISS, FONT_SIZE)
    call SetTextTagPos(tt, GetUnitX(whichUnit), GetUnitY(whichUnit), 0.0)
    call SetTextTagColor(tt, 255, 0, 0, 255)
    call SetTextTagVelocity(tt, 0.0, 0.03)
    call SetTextTagVisibility(tt, true)
    call SetTextTagFadepoint(tt, 1.0)
    call SetTextTagLifespan(tt, 3.0)
    call SetTextTagPermanent(tt, false)
    set tt = null
endfunction

//===========================================================================
public function Block takes unit whichUnit returns nothing
    local texttag tt = CreateTextTag()
    call SetTextTagText(tt, BLOCK, FONT_SIZE)
    call SetTextTagPos(tt, GetUnitX(whichUnit)-SIGN_SHIFT, GetUnitY(whichUnit), 0.0)
    call SetTextTagColor(tt, 0, 255, 0, 255)
    call SetTextTagVelocity(tt, 0.0, 0.03)
    call SetTextTagVisibility(tt, true)
    call SetTextTagFadepoint(tt, 1.0)
    call SetTextTagLifespan(tt, 3.0)
    call SetTextTagPermanent(tt, false)
    set tt = null
endfunction

//===========================================================================
public function CriticalStrike takes unit whichUnit, integer dmg returns nothing
    local texttag tt = CreateTextTag()
    local string text = I2S(dmg) + "!"
    call SetTextTagText(tt, text, FONT_SIZE)
    call SetTextTagPos(tt, GetUnitX(whichUnit), GetUnitY(whichUnit), 0.0)
    call SetTextTagColor(tt, 255, 0, 0, 255)
    call SetTextTagVelocity(tt, 0.0, 0.04)
    call SetTextTagVisibility(tt, true)
    call SetTextTagFadepoint(tt, 2.0)
    call SetTextTagLifespan(tt, 5.0)
    call SetTextTagPermanent(tt, false)
    set text = null
    set tt = null    
endfunction

//===========================================================================
public function ShadowStrike takes unit whichUnit, integer dmg, boolean initialDamage returns nothing
    local texttag tt = CreateTextTag()
    local string text = I2S(dmg)
    if initialDamage then
        set text = text + "!"
    endif
    call SetTextTagText(tt, text, FONT_SIZE)
    call SetTextTagPos(tt, GetUnitX(whichUnit), GetUnitY(whichUnit), 0.0)
    call SetTextTagColor(tt, 160, 255, 0, 255)
    call SetTextTagVelocity(tt, 0.0, 0.04)
    call SetTextTagVisibility(tt, true)
    call SetTextTagFadepoint(tt, 2.0)
    call SetTextTagLifespan(tt, 5.0)
    call SetTextTagPermanent(tt, false)    
    set text = null
    set tt = null
endfunction

//###########################################################################
//  Custom TextTags for Pyramidal Defence
//###########################################################################

//===========================================================================
public function BonusDamage takes unit whichUnit, integer dmg returns nothing
    local texttag tt = CreateTextTag()
    local string text = I2S(dmg)
    if dmg > 0 then
        set text = "+"+text
    endif
    call SetTextTagText(tt, text, FONT_SIZE)
    call SetTextTagPos(tt, GetUnitX(whichUnit)-SIGN_SHIFT, GetUnitY(whichUnit), 0.0)
    call SetTextTagColor(tt, 255, 0, 0, 255)
    call SetTextTagVelocity(tt, 0.0, 0.04)
    call SetTextTagVisibility(tt, true)
    call SetTextTagFadepoint(tt, 2.0)
    call SetTextTagLifespan(tt, 4.0)
    call SetTextTagPermanent(tt, false)
    set text = null
    set tt = null    
endfunction

//===========================================================================
public function Monster takes unit whichUnit, string text returns nothing
    local texttag tt = CreateTextTag()
    local real shift = RMinBJ(StringLength(text)*MEAN_CHAR_WIDTH, MAX_TEXT_SHIFT)
    call SetTextTagText(tt, text, FONT_SIZE)
    call SetTextTagPos(tt, GetUnitX(whichUnit)-shift, GetUnitY(whichUnit), DEFAULT_HEIGHT)
    call SetTextTagColor(tt, 255, 0, 0, 255)
    call SetTextTagVelocity(tt, 0.0, 0.04)
    call SetTextTagVisibility(tt, true)
    call SetTextTagFadepoint(tt, 2.5)
    call SetTextTagLifespan(tt, 4.0)
    call SetTextTagPermanent(tt, false)    
    set tt = null
endfunction

endlibrary


This is more nice, is it?
 

jomik

New Member
Reaction score
17
@King, ahh nope :S It says -X and theres no gold effect :O I prefer Weep's then :D
But your updated version doesn't work, it says undeclared variable text...
 

BRUTAL

I'm working
Reaction score
118
Because he forgot to put ' "+" + I2S(gold) ' in where it says text i presume.
Try this.
JASS:
function GoldBountyFX takes unit u, integer gold, player p returns nothing
	local texttag t = CreateTextTag()
	local real ux = GetUnitX(u)
	local real uy = GetUnitY(u)
	if(IsUnitType(GetTriggerUnit(), UNIT_TYPE_FLYING)) then
		// NOTE: For perfect accuracy in a later revision, this is going to need a non-tilting 0-size flying dummy unit, I think. 
		call SetTextTagText(t, "+" + I2S(gold), 0.023)
		call SetTextTagPosUnit(t, u, -100)
		call DestroyEffect(AddSpecialEffectTarget("UI\\Feedback\\GoldCredit\\GoldCredit.mdl", u, "origin"))
	else
		call SetTextTagText(t, "+" + I2S(gold), 0.025)
		call SetTextTagPos(t, ux-16, uy-16, 0)
		call DestroyEffect(AddSpecialEffect("UI\\Feedback\\GoldCredit\\GoldCredit.mdl", ux, uy))
	endif
	call SetTextTagColor(t, 255, 220, 0, 255)
	call SetTextTagVelocity(t, 0, 0.03)
	call SetTextTagVisibility(t, GetLocalPlayer() == p)
	call SetTextTagFadepoint(t, 2)
	call SetTextTagLifespan(t, 3)
	call SetTextTagPermanent(t, false)
	set t = null
endfunction


I removed the following parts cause they seemed stupid as hell.
JASS:
else
		call SetUnitX(u, ux - 16) // This.
		call SetUnitY(u, uy - 16) // And this.
		call SetTextTagText(t, "+" + I2S(gold), 0.025)
		call SetTextTagPos(t, ux-16, uy-16, 0)
		call SetUnitX(u, ux) // These two as well. 
		call SetUnitY(u, uy)// <
		call DestroyEffect(AddSpecialEffect("UI\\Feedback\\GoldCredit\\GoldCredit.mdl", ux, uy))
	endif

The SetTextTagPos already had ux-16, and uy-16 in the line anyways, so that is why the commented lines are odd.
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
Because he forgot to put ' "+" + I2S(gold) ' in where it says text i presume.
Yeah, a victim of copy/paste and not enough proofreading. :p

The SetTextTagPos already had ux-16, and uy-16 in the line anyways, so that is why the commented lines are odd.
Indeed, I had been using that to offset the text when it was using SetTextTagPosUnit(), but then I realized that for ground units it should just use SetTextTagPos() (the text appears from their feet, not overhead) and I forgot to take out those lines. That's what I get for editing the code madly late at night... :nuts:

Edited the original post.
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
OK, I edited the previous post again. This is as close to exactly matching the in-game bounty FX and text as I know how.

flying units and effects at a z offset with no tilting FFFFFFFFF
 

jomik

New Member
Reaction score
17
Oww thanks dude :D Is it MUI? I'll be having like... 100++ units that gives this bounty or something? :O So not sure if a dummy is a good idea :O
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
Oww thanks dude :D Is it MUI? I'll be having like... 100++ units that gives this bounty or something? :O So not sure if a dummy is a good idea :O
Heh, WC3 can only display 100 texttags at a time anyway. Yeah, it's MUI.

The unit is only made if the dying unit is a flying unit; it's the only way to accurately do anything at a flying unit's actual height (eg. if it's over trees).

If your map has no trees or buildings or cliffs, or you don't care, you could also use:
JASS:
function GoldBountyFX takes unit u, integer gold, player p returns nothing
    local texttag t = CreateTextTag()
    local real ux = GetUnitX(u)
    local real uy = GetUnitY(u)
    local real uz = GetUnitFlyHeight(u)
    local destructable d
    if(IsUnitType(u, UNIT_TYPE_FLYING)) then
        call SetTextTagText(t, "+" + I2S(gold), 0.023)
        call SetTextTagPos(t, ux, uy, uz)
    else
        call SetTextTagText(t, "+" + I2S(gold), 0.024)
        call SetTextTagPos(t, ux-16, uy-16, uz)
    endif
    set d = CreateDestructableZ('OTip', ux-16, uy-16, uz, 0.00, 1, 0) //http://wc3jass.com/viewtopic.php?t=2472
    call DestroyEffect(AddSpecialEffect("UI\\Feedback\\GoldCredit\\GoldCredit.mdl", ux-16, uy-16))
    call RemoveDestructable(d)
    call SetTextTagColor(t, 255, 220, 0, 255)
    call SetTextTagVelocity(t, 0, 0.03)
    call SetTextTagVisibility(t, GetLocalPlayer() == p)
    call SetTextTagFadepoint(t, 2)
    call SetTextTagLifespan(t, 3)
    call SetTextTagPermanent(t, false)
    set t = null
    set d = null
endfunction
 

jomik

New Member
Reaction score
17
It'll have trees, buildings and cliffs, but no flying units :p
- It can display 100 per player right? :D
I might do it in another way though, with a multiboard or something...
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
- It can display 100 per player right? :D
Maybe?

Also, that business with the destructible is only needed if any of the ground units have a height other than 0 (like most default hovering units). Without that it would be:

JASS:
function GoldBountyStrictGroundFX takes unit u, integer gold, player p returns nothing
    local texttag t = CreateTextTag()
    local real ux = GetUnitX(u)
    local real uy = GetUnitY(u)
    call SetTextTagText(t, "+" + I2S(gold), 0.024)
    call SetTextTagPos(t, ux-16, uy-16, GetUnitFlyHeight(u)) //Meh.
    call DestroyEffect(AddSpecialEffect("UI\\Feedback\\GoldCredit\\GoldCredit.mdl", ux-16, uy-16))
    call SetTextTagColor(t, 255, 220, 0, 255)
    call SetTextTagVelocity(t, 0, 0.03)
    call SetTextTagVisibility(t, GetLocalPlayer() == p)
    call SetTextTagFadepoint(t, 2)
    call SetTextTagLifespan(t, 3)
    call SetTextTagPermanent(t, false)
    set t = null
endfunction
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
Yeah. It'll "work" for flying unit too, just that the bounty FX will be on the ground. :p
 
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

      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