EXP Floating Text

Hotwer

New Member
Reaction score
0
Wanna know how to make appear the Gain XP of a creep when killed by a Hero. Please, if you will say something in Jass, make the entire trigger, becouse I don't know anything about Jass. I'm newbie in Triggering so, sorry for these noob question.

Sorry about my poor english. I don't live in North America.
 

Ashlebede

New Member
Reaction score
43
Your english ain't bad at all! :D

Anyways, what kind of text would you like to show? Normal message or floating text? I'm guessing floating text. u_u

I would use custom values so units can "remember" an integer value and call a trigger every time a unit dies. (since, as far as I know, there is no "A unit acquires Experience" event) I would then check, for each hero, if their current XP is equal to their previous current XP (which was stored using custom values, get it?)

Trigger:
  • MyTrigger
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Wait 0.10 game-time seconds
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True))) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Custom value of (Picked unit)) Not equal to (Hero experience of (Picked unit))
            • Then - Actions
              • Floating Text - Create floating text that reads (String(((Hero experience of (Picked unit)) - (Custom value of (Picked unit))))) above (Picked unit) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to 16.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
            • Else - Actions
          • Unit - Set the custom value of (Picked unit) to (Hero experience of (Picked unit))


This trigger has been tested and is working, though it requires The Frozen Throne.
 

Hotwer

New Member
Reaction score
0
OMG GUY, you made all trigger for me?
Really thanks man, for all, and about my english, haha.
Thanks so much. I'm testing it right now!

Edit:
Where is the...
(Custom value of (Picked Unit) Not equal to (Hero experience of (Picked Unit))
?
Thanks once again!
 

Ashlebede

New Member
Reaction score
43
Where is the...
(Custom value of (Picked Unit) Not equal to (Hero experience of (Picked Unit))
?

It's an integer comparison.

And no problem, it allows me to practice my GUI, since I only use JASS these days... o_O
 

Hotwer

New Member
Reaction score
0
Theres another part I can't undertand. I tried to make a String + String but didn't worked.
What is that?

String(((Hero experience of (Picked unit)) - (Custom value of (Picked unit)))))
 

Ashlebede

New Member
Reaction score
43
Convert - String to Integer = String(Number)

Arithmetic = Number + Number ; make that Number - Number.

First number = Current experience of the Hero

Second number = Previous experience of the Hero.

So the formula is like this :

Gained XP = Current XP - Previous XP. And then it's converted into a string, so it can be shown as a text message.
 

Ayanami

칼리
Reaction score
288
The trigger above leaks. You can remove it. Plus, there isn't a need to use unit groups at all. And instead of custom value, you could use hashtable instead. Plus, the above trigger shows the experience gained to all the players. The wait is not necessary too. I'll be writing the trigger in JASS. Just let me know if you want a GUI version of it. You need NewGen for this.

JASS:
scope ExpShow initializer InitTrig

globals
    private hashtable Hash = InitHashtable()
    private texttag Text
endglobals

private function Actions takes nothing returns boolean
    local unit KillingUnit = GetKillingUnit()
    local unit KilledUnit = GetTriggerUnit()
    local integer Id = GetHandleId(KillingUnit)
    local integer LoadIntValue
    if IsUnitType(KillingUnit, UNIT_TYPE_HERO) and IsUnitEnemy(KilledUnit, GetOwningPlayer(KillingUnit)) then
        if HaveSavedInteger(Hash, Id, 0) then
            set LoadIntValue = GetHeroXP(KillingUnit) - LoadInteger(Hash, Id, 0)
            call SaveInteger(Hash, Id, 0, GetHeroXP(KillingUnit))
        else
            set LoadIntValue = GetHeroXP(KillingUnit)
            call SaveInteger(Hash, Id, 0, LoadIntValue)
        endif
        set Text = CreateTextTag()
        call SetTextTagText(Text, "|cff8080FF+" + I2S(LoadIntValue) + "|r", TextTagSize2Height(10.00))
        call SetTextTagPos(Text, GetUnitX(KilledUnit), GetUnitY(KilledUnit), 60.00)
        call SetTextTagColor(Text, 255, 255, 255, 255)
        call SetTextTagVelocityBJ(Text, 55.00, 90.00)
        call SetTextTagPermanent(Text, false)
        call SetTextTagLifespan(Text, 3.00)
        call SetTextTagFadepoint(Text, 2.00)
        call SetTextTagVisibility(Text, false)
        if GetLocalPlayer() == GetOwningPlayer(KillingUnit) then
            call SetTextTagVisibility(Text, true)
        endif
    endif
    set KillingUnit = null
    set KilledUnit = null
    return false
endfunction

private function InitTrig takes nothing returns nothing
    local trigger t = CreateTrigger()
    
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition(t, Condition(function Actions))
endfunction

endscope


All you have to do is:

Create Trigger --> Convert to Custom Text --> Replace the whole existing code with the one posted above

The exp text is in purple color and the speed and fading time is equal to the default warcraft gold floating text.
 

xAnaMorphine

Active Member
Reaction score
43
or another option i made up for my rpg which I stopped working on
EDIT: Only gives experience if units are controlled by player 11 or player 12

JASS:
function Trig_Experience_System_Func005C takes nothing returns boolean
    // if you want to change the player who give experience edit this line
if ( ( GetOwningPlayer(GetDyingUnit()) == Player(10) ) ) then
        return true
    endif
    if ( ( GetOwningPlayer(GetDyingUnit()) == Player(11) ) ) then
        return true
    endif
    return false
endfunction

function Trig_Experience_System_Conditions takes nothing returns boolean
    if ( not Trig_Experience_System_Func005C() ) then
        return false
    endif
    return true
endfunction

function Trig_Experience_System_Func003Func001C takes nothing returns boolean
    if ( not ( IsUnitType(GetEnumUnit(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Experience_System_Func003A takes nothing returns nothing
    if ( Trig_Experience_System_Func003Func001C() ) then
        call AddHeroXPSwapped( udg_Experience, GetEnumUnit(), true )
        call CreateTextTagUnitBJ( ( "+" + ( I2S(udg_Experience) + " EXP" ) ), GetEnumUnit(), 30.00, 10, 70.00, 0.00, 70.00, 0 )
        call SetTextTagVelocityBJ( GetLastCreatedTextTag(), 60.00, 90.00 )
        call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
        call SetTextTagLifespanBJ( GetLastCreatedTextTag(), 1.00 )
        call SetTextTagFadepointBJ( GetLastCreatedTextTag(), 2.00 )
    else
        call DoNothing(  )
    endif
endfunction

function Trig_Experience_System_Actions takes nothing returns nothing
    set udg_Experience = GetUnitPointValue(GetDyingUnit())
// here you can set the range of the units around the dying unit who get exp, set to 750
    set udg_TEMP_UnitGroup = GetUnitsInRangeOfLocAll(750.00, GetUnitLoc(GetDyingUnit()))
    call ForGroupBJ( udg_TEMP_UnitGroup, function Trig_Experience_System_Func003A )
    call DestroyGroup(udg_TEMP_UnitGroup)
endfunction

//===========================================================================
function InitTrig_Experience_System takes nothing returns nothing
    set gg_trg_Experience_System = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Experience_System, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Experience_System, Condition( function Trig_Experience_System_Conditions ) )
    call TriggerAddAction( gg_trg_Experience_System, function Trig_Experience_System_Actions )
endfunction
 

Hotwer

New Member
Reaction score
0
@Glenph
Well, thanks for the Jass code, I really wanna it in GUI code. In jass I can't understand nothing, but, if you can't turn it into GUI, I mean, something is a custom script, I can use that way. And, the GUI version needs New Gen too?

@xAna
It's all the code? Thanks, your code needs NewGen?
 

Ayanami

칼리
Reaction score
288
Hotwer said:
Well, thanks for the Jass code, I really wanna it in GUI code. In jass I can't understand nothing, but, if you can't turn it into GUI, I mean, something is a custom script, I can use that way. And, the GUI version needs New Gen too?

Hmm, it is possible to code that in GUI. However, won't using custom scripts also be meaningless if you can't understand it?

Hotwer said:
@xAna
It's all the code? Thanks, your code needs NewGen?

No, her's doesn't need NewGen. She just used Vanllia JASS, while I used vJASS.

But I still suggest you download NewGen. It's great, even for GUI users.
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
as far as i know the experience a unit gives upon death
(in case it either is not a creep or the gameplay values have been changed so creeps give full exp regardless of the hero level)
is determined by the units level and can be calculated by yourself so you wouldnt even need to track the exp of the hero.
 

xAnaMorphine

Active Member
Reaction score
43
Hmm, it is possible to code that in GUI. However, won't using custom scripts also be meaningless if you can't understand it?



No, her's doesn't need NewGen. She just used Vanllia JASS, while I used vJASS.

But I still suggest you download NewGen. It's great, even for GUI users.

Yes I converted the GUI into Vanilla Jass because I got a German WE and the half of the script would be German.
Also if you plan to use my System you have to add this to map init:

Trigger:
  • For each (Integer A) from 1 to 16, do (Actions)
    • Loop - Action
      • Custom script: call SetPlayerHandicapXP(Player(bj_forLoopAIndex - 1), 0.)


Not sure for the others
 

Jedi

New Member
Reaction score
63
I found the GUI action :D

Trigger:
  • For each (Integer A) from 1 to 16, do (Actions)
    • Loop - Actions
      • Hero - Make (Player((Integer A))) Heroes gain 0.00% experience from future kills
 

xAnaMorphine

Active Member
Reaction score
43
I found the GUI action :D

Trigger:
  • For each (Integer A) from 1 to 16, do (Actions)
    • Loop - Actions
      • Hero - Make (Player((Integer A))) Heroes gain 0.00% experience from future kills

right, that would be simple :>
 
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