Snippet Flawless Bounty Imitation FX

Weep

Godspeed to the sound of the pounding
Reaction score
400
Flawless Bounty Imitation FX
by Weep
Version 1.0.1​

FBI? :D Yes, the name is for laughs.

-- General Information --
These snippets create effects as close to matching the in-game gold bounty FX and text as I know to be possible. There are three levels of complexity, trading off with decreasing generality of which kinds of units are properly handled.

The demo map demonstrates all 3 snippets on all the various kinds of units, showing the differences (snippet FX on the blue player's units on the left half, true WC3 bounty on the neutral hostile units on the right half).

-- Full FX --
Requires one dummy unit-type ([ljass]'z000'[/ljass] in the demo map). Almost exactly matches any kind of unit, be it ground, floating, or flying, even at cliffs and over trees. The use of a dummy unit is required to get an accurate height of a flying unit over any terrain (GetUnitFlyHeight is not accurate).

- Code -
JASS:
function GoldBountyFXFull 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

-- Ground FX --
Requires no unit-type and does not create any units, and will accurately match hovering units with height, but will only approximate the height of flying units over varied terrain. Still creates a temporary platform destructable to create the special effect at a particular height.

- Code -
JASS:
function GoldBountyFXGround 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

-- Strict Ground FX --
Requires no unit-type and does not create any units nor destructables, but will only be accurate for ground units with no flying height (eg. not for the default hovering units).

- Code -
JASS:
function GoldBountyFXStrictGround takes unit u, integer gold, player p returns nothing
    local texttag t = CreateTextTag()
    local real ux = GetUnitX(u)-16
    local real uy = GetUnitY(u)-16
    call SetTextTagText(t, "+" + I2S(gold), 0.024)
    call SetTextTagPos(t, ux, uy, GetUnitFlyHeight(u)) //Meh.
    call DestroyEffect(AddSpecialEffect("UI\\Feedback\\GoldCredit\\GoldCredit.mdl", ux, uy))
    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

-- Notes --
It's originally based off of the bounty text found in Cohadar's Pyramidal Sandbox map, but significantly tweaked from there to better match WC3's look.

I've not vJASS-ified it nor ObjectMerger'd the dummy unit due to lack of access to the necessary programs to test the results. If someone would care to do so, I'll gladly add it to the post and give credit.

This uses arrays, so can have a maximum of 8190 instances at a time, and cleans up data at a rate of 33.33 per second. This should be enough for most maps.

-- Credits --
Cohadar for the original bounty text code.
KaTTaNa for the method to create a special effect at a specified height, without using a unit.

Credit in your map not needed.

-- Version History --
1.0.1: Minor optimization.
1.0.0: First release.

--------------------------------------​

All comments welcome.
 

Attachments

  • Bounty FX Demo.w3x
    22 KB · Views: 277

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
why are you using the local reals in the second code if you only refer to them once?
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
oh sorry didnt see the effect on but why dont you minus 16 for the variables where you declare them?

Edit: the third one is what the changes i suggested must happen if you want to.
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
*insert cursing here* I realized I hadn't tested floating/amphibious units. Gonna need to update for those...
 

Nestharus

o-o
Reaction score
84
This is quite a useful snippet for good looking bounty and I've actually done something very similar to this in a map. The only problem is what happens when the text tag limit has been reached? Crash : (.


You need to do some sort of safety to prevent text tag limit from being reached, otherwise map will crash. On the map I was working on a long time ago, it crashed every single game because of the bounty text tags I had done (1 per killed unit, like norm).

I personally think bounty text tags are a bad idea because of this. If you have safety, then sometimes they won't show (eep). If you don't have safety, then map crash (eep).

I've tried to solve this dilemma, but I've found no way around it ; (.
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
The only problem is what happens when the text tag limit has been reached? Crash : (.
Um, what? It doesn't for me.

I just edited my demo map with over 200 peasants with triggered bounty, and no crash. Since there's a 100 texttag limit, of course, some of the text didn't show, but that also happened when I tried it with native bounty.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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