• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Quick Question! +2 rep to all helpers!

Status
Not open for further replies.

Sverkerman

Hosted Project: BoW
Level 17
Joined
Feb 28, 2010
Messages
1,325
  • Actions
    • Floating Text - Create floating text that reads (String(DamageEventAmount)) at temp_point with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 50.00% transparency
    • Floating Text - Set the velocity of (Last created floating text) to 75.00 towards Real_FloatingTextDirection[(Player number of (Owner of DamageEventSource))] degrees
    • Floating Text - Change (Last created floating text): Disable permanence
    • Floating Text - Change the lifespan of (Last created floating text) to 3.50 seconds
    • Floating Text - Change the fading age of (Last created floating text) to 1.40 seconds
Alright, so I got this GUI code right here and I want to modify Transparity and Size every X seconds for each induvidual player for each induvidual floating text.

What is the best way to do this?
+2 rep to all helpers!
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
1. What differece will player make? I mean, what's the difference between Player 1 Size and Transperency and Player 2 Size and Transparency?

That would require creating 1 Floating Text for each player and handle each one of them individually, hiding it from all players except the one that floating text belongs to. That's done by hiding it inside a GetLocalPlayer() block.

2. To change it every X seconds you have to index the floating text, probably into a Hashtable or an Array, and turn on a periodic loop to make the size/transparency changes.

-- Maybe if you say exactly what you want to achieve we could suggest you some other and probably better ways to do it :) Because, so far, your trigger seems just as a simple Floating Damage amount over target --
 

Sverkerman

Hosted Project: BoW
Level 17
Joined
Feb 28, 2010
Messages
1,325
The question is:
How do I make the periodic trigger for the updates?

I use GetLocalPlayer to create the floating texts locally.

How should I save the floating texts in a hashtable? I guess ParentKey is PlayerNumber but what to use for child key?
How do I refer to them inside a new trigger?
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Floating Texts Handles goes from 100 to 0 again and again, so you can index them in a Single Array

FloatingText[GetHandleId(bj_lastCreatedTextTag)]

The TextTag should be binded to something (a unit, a building, a timer, etc.) so you can get the Handle Id from this other object, else, you would have to loop through the array.
 

Sverkerman

Hosted Project: BoW
Level 17
Joined
Feb 28, 2010
Messages
1,325
Give me an example, I cannot comprihend with the information unless i see it on paper.
The problem I'm having is indexing the Floating Texts and updating them each X second in another trigger due to not knowing how to refer to them.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
After creating each Floating Text
  • Custom script: set udg_FloatingTexts[GetHandleId(bj_lastCreatedTextTag)] = bj_lastCreatedTextTag
To modify them

  • Events
    • Time - Every 1.00 seconds of gametime
  • Actions
    • For each integer A from 0 to 100 do (Actions)
      • Loop - Actions
        • Floating Text - Do something with FloatingText[(Integer A)]
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
If you create the texts locally, you don't have to use an array (unless each player has multiple floating texts).
As you create them, save them in the same variable and just refer to that variable. Since every player has his own text in the variable, applying actions on it will apply them on the player corresponding floating text.
 

Sverkerman

Hosted Project: BoW
Level 17
Joined
Feb 28, 2010
Messages
1,325
There are several floating texts active at the same time for each induvidual player.
Each floating text needs to follow a certain pattern. The pattern is equal to all floating texts if that changes anything.

Every X seconds I need to change the transparity and size of each SPECIFIC floating text.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Here's what I think, this is my personal and subjective opinion:

The problem here relies on you thinking this is something "really hard". It's pretty easy, create 20293480342134 floating texts if you want, it's still easy to handle them all.

You want the number to become red as it moves up?
You want each damage type to move to a certain direction?
You want the number to become greater based on the damage dealt?
You want the text to be colored based on the player who did the damage?
What's each floating text supposed to say/show?

What floating texts you have? Why so many? Why several per player? What's the difference between one player floating text and another player floating text?

See.. we already answered your initial question: index the floating texts in a Hashtable or in An array as I show in a post above; the problem now relies on we all not knowing what do you want to achieve and why you need to do this, and how you want to do this.

"Change size and change transparency" you say... Change = increase? reduce? What's the basis of these changes? Is it a fixed change amount or depends on something?
 

Sverkerman

Hosted Project: BoW
Level 17
Joined
Feb 28, 2010
Messages
1,325
I want to create a floating text that displays damage done by each unit for allied players. Now, that is not the part that I don't know how to do. I know how to create floating texts and make them display damage taken.

What I do not get is how to modify up to 500 floating texts to have the same kind of "look" by changing the transparity and size INDUVIDUALLY for each SPECIFIC floating text each X seconds inside a other trigger.

Example:
I want to change the size of floating text (Load [Triggering Player] of [FloatingTextID] of Hashtable FloatingTextEditing to +1 it every 0.05 seconds for 1 second inside another trigger. Here is my problem, I cannot refer to TriggeringPlayer since it is inside another trigger (I can't set a variable to store TempPlayer either since the system has work for up to 12 players at all time) nor FloatingTextID since there will be up to around 200 floating texts active at all time which all needs induvidual timing.
 
Level 5
Joined
Aug 27, 2010
Messages
79
declare a floating text array, floatingTexts, size 15
an integer, top = 0,
a hash table,

whenever a floating text is created, do,
floatingTexts[top] = bj_lastCreatedFloatingText
top = top + 1
***save the player name/id in hash table, parent key is GetHandleId(floatingText), child key is 0...
store the duration (initially 0) in hash table with child key 1...

in the looping trigger (might have to convert to custom text)..
local integer i = 0
loop
exitwhen i == top
//*** get player by loading from hash table, parent key is GetHandleId(floatingText), child key is 0...
//change the floating text and increment duration
if duration is 1 sec
set floatingTexts = floatingTexts[top]
set top = top - 1;
else
set i = i + 1
endif
endloop
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Now I get it...

1. When Damage is Dealt create a timer
JASS:
local timer t = CreateTimer()
2. Get the handle id
JASS:
set id = GetHandleId(t)
3. Save the handle of the texttag (jass name of Floating Texts) in the timer id
JASS:
call SaveTextTagHandle(udg_TextHash, id, 0, bj_lastCreatedTextTag)
4. Save the initial transparency and size of that texttag, also the text in it
JASS:
local real transparency = 0
local real size = 12
local string str = "Damage"
call SaveReal(udg_TextHash, id, 1, transparency)
call SaveReal(udg_TextHash, id, 2, size)
call SaveStr(udg_TextHash, id, 3, str)
5. Start the timer as a periodic one that will last 0.5 and call another function (the one that will make the changes) when it expires. Every texttag will have it's own timer, and each timer will have it's own texttag.
JASS:
call TimerStart(t, 0.5, true, function TextTimerFunc)
6. Now create that TextTimerFunc to manipulate the values of the TextTags
JASS:
function TextTimerFunc takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer id = GetHandleId(t)
    local texttag tt = LoadTextTagHandle(udg_TextHash, id, 0)
    local real transparency = LoadReal(udg_TextHash, id, 1) + 8.4 // This "8.4" increases transparency by 3.3/second
    local real size = LoadReal(udg_TextHash, id, 2) + 0.00115 // This "0.00115" means increasing size by 0.5 
    local string str = LoadStr(udg_TextHash, id, 3)
    
    // Save new transparency value
        call SaveReal(udg_TextHash, id, 1, transparency) 
    // Save new size value
        call SaveReal(udg_TextHash, id, 1, size)

    // Update TextTag to new Size
        call SetTextTagText(tt, str, size) 
    // Update TextTag to new transparency (text is white)
        call SetTextTagColor(tt, 255 /*RED (0,255)*/, 255 /*GREEN (0,255)*/, 255 red /*BLUE (0,255)*/, 255-transparency)
    
    // Stop this process
    if transparency => 100
        call PauseTimer(t) // Pause the timer
        call DestroyTimer(t) // Destroy the timer
        call FlushChildHashtable(udg_TextHash, id) // Clear the Hashtable
        call DestroyTextTag(tt) // Destroy the TextTag
    endif
    
    // Clearing local Leaks
    set tt = null
    set t = null
    set str = null
endfunction
You don't need to set a fading age nor making the texttag permanent or not; this will handle the transparency and the color, and destroy the text when text becomes invisible.
 

Sverkerman

Hosted Project: BoW
Level 17
Joined
Feb 28, 2010
Messages
1,325
@Spartipilo
Thank you very much for writing the code! Altho, I have a few questions before implementing it.

How often is the floating text updated? The way I see it is that the floating text is being updated once a timer of 0.5 seconds runs out that is connected to the floating text and then destroys the floating text which is not what I want, I want it to be updated every X seconds until a certain value of seconds has been reached.

To clearify: I don't want to update the floating text 1 time during it's lifespan, I want to update it several times during it's lifespan.

Let me show you what I am trying to achieve:
[youtube]
http://www.youtube.com/watch?v=6dm6SL-XIJY&feature=relmfu
[/youtube]

I want to display damage dealt by any unit to the allies and the owner of the damage source unit by using floating texts which needs to be updated induvidually to have the same kind of movement pattern as seen in the video above.

I have one trigger where I have a event set up in a way that each time any unit takes damage this trigger will be runned. I can point towards the damage being dealt by using the variable EventDamageSource. I can also create the floating text inside this trigger and store it inside a hashtable for later use when I need to update it to make it have the same movement pattern as seen in the video above.

The way I read this movement pattern is that I need to update the size and the transparency of each floating text induvidually each X seconds. I'd need a hashtable for the size and the transparency to save the values by using parent key FloatingTextID and child key TransparencyID/SizeID.

If anyone could show to me how to create a code which updates this correctly then I could create the pattern on my own.

Otherwise if you are up for a challange you could create the pattern for me as well ;)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
How often is the floating text updated?
depends on the duration you place on the timer start. In my example i gave it 0.5s expiration time.

I want it to be updated every X seconds until a certain value of seconds has been reached.
I would suggest you to try calculating the seconds with the transparency. I destroyed the text when transparency => 100 wich would be in about 7.5 seconds; you could just change the "if transparency > 100" to the value you want. Else, you can save a "real" timer inside the timer ID (just as everything else is saved) and increase it by 0.5 on every interval, and replace the "transparency > 100" with "RealTimer = #"

I don't want to update the floating text 1 time during it's lifespan, I want to update it several times during it's lifespan.
Replace the "str" string with the text you want to display, the thing is, where are you going to get the string value from?

<< EDIT >>

So you basically want the text to start big then become smaller and fade away in some random direction, as the video shows

It also seems like the damage is stacked up when it's dealt in a row of hits.
 

Sverkerman

Hosted Project: BoW
Level 17
Joined
Feb 28, 2010
Messages
1,325
Spartipilo said:
So you basically want the text to start big then become smaller and fade away in some random direction, as the video shows

It also seems like the damage is stacked up when it's dealt in a row of hits.
The damage is not stacking. Each floating text in D3 displays each induvidual damage dealt.
It is the movement of the floating text that they have inside D3 that I want to achieve.

Could anyone create it for me?
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
I think you don't even need arrays and such for these kind of thing ?
  • Actions
    • Floating Text - Create floating text that reads DamageTaken above DamagedUnit with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
    • Set FloatingText = (Last created floating text)
    • Floating Text - Set the velocity of FloatingText to 64.00 towards 90.00 degrees
    • Floating Text - Change FloatingText: Disable permanence
    • Floating Text - Change the lifespan of FloatingText to 2.00 seconds
    • Floating Text - Change the fading age of FloatingText to 1.00 seconds
Of course you still should create all that function inside GetLocalPlayer() block.
Because the "transparency" per interval will be handled by default by that "fading age" function.

And it is always wise to set the value of Fading Age = (1 / 2) * Lifespan Age
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
For Transparency, I think we don't have problem because as I said, the Fading Age already does the Transparency per interval by default.

So, left now is size, okay I'll try something for you.

So, how does this "Size" affect one's Floating Text ?
 

Sverkerman

Hosted Project: BoW
Level 17
Joined
Feb 28, 2010
Messages
1,325
@defskull
Each time a unit takes damage I want to create a floating text with the same kind of look as that the floating texts that displays damage has inside Diablo3. In order to make a floating text look equal to the one in Diablo3 we need to change the size every X seconds. The problem is that we need to change the size for each floating text induvidually, not together, so we need some kind of indexing for each floating text so that we can refer to them inside another trigger with the event "every x seconds", I believe.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Not only size but apparently also position if you look closely ;)
You'll need a small algorithm to animate it "make it jump" like in the video.
Even though the position of the unit being hit is the same, the floating tekst appears at a slightly random position above the unit and jumps up while fading out and resizing.
This is a little bit harder to do.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
What's the difficulty? You just create the floating text towards a random direction and then just update the size and transparency. My trigger just modifies transparency and size, because direction and speed is done at the TextTag creation.
 

Sverkerman

Hosted Project: BoW
Level 17
Joined
Feb 28, 2010
Messages
1,325
EDIT: Could you make it so that depending on the player color of the owner of EventDamageSource it will display the damage dealt in a different color?

Example: Owner of EventDamageSource is Player1(Red) it will display in Red color.


I've made a condition in your code so that the floating text only is being displayed to allies of the owner of EventDamageSource.


EDIT2: Hold on a minute... I think I got this^
EDIT3: FIXED! Thread Status - Solved
 

Sverkerman

Hosted Project: BoW
Level 17
Joined
Feb 28, 2010
Messages
1,325
So wait, I do not know Vjass so this has to be optimized to my needs in order for me to be able to use it.

1: Is the text only being displayed to the owner of DamageSource and the allies of the owner of DamageSource?

2: Does this system show the correct damage if I modify it using
  • Events
    • Game - DamageModifierEvent becomes Equal to 1.00
??


EDIT: nevermind "2", It does display the correct damage after a DamageModifierEvent trigger has changed the damage, I just checked ;)








EDIT2:
I just tested and it seems like you didn't make players see the floating texts of allied damage. Could you change this for me? ;)
 
Status
Not open for further replies.
Top