HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Periodic Floating Text

12-17-2009, 04:57 AM#1
warbucket
Hey,

I'm wondering, is it possible to create floating text above a unit every t seconds after its construction? In my game, the player constructs Farms, which generate resources every 5 seconds. What I want to do is display the text '+25' (in green, doesn't really matter) after every 5 seconds of resource generation. It looks great and reminds the user where all his money is coming from. This effect can be seen in Battle for Middle Earth 2. In fact what I'm aiming for is an exact replication of that effect.

I honestly have no idea where to start. The event is what is troubling me. A periodic event wouldn't work because the text would appear regardless of whether or not a Farm has been constructed, and there is no unit for which the floating text may be given reference for its position. What should I do?

I would really appreciate some help on this as I am just thoroughly stumped,
Thanks!
12-17-2009, 08:04 AM#2
DioD
start from forum search may be?
12-17-2009, 09:49 AM#3
Newuser
Try something like this:

Trigger:
Floating Text 2
Collapse Events
Time - Every 5.00 seconds of game time
Conditions
Collapse Actions
Custom script: call DestroyGroup(udg_FarmGroup)
Set FarmGroup = (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Farm))
Collapse Unit Group - Pick every unit in FarmGroup and do (Actions)
Collapse Loop - Actions
Set Float_TextPoint = (Position of (Picked unit))
Player - Add 25 to (Owner of (Picked unit)) Current gold
Player - Add 25 to (Picked player) Current lumber
Floating Text - Create floating text that reads +25 at Float_TextPoint with Z offset 0.00, using font size 12.00, color (20.00%, 100.00%, 20.00%), and 0.00% transparency
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Set the velocity of (Last created floating text) to 80.00 towards 90.00 degrees
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 1.00 seconds
Custom script: call RemoveLocation(udg_Float_TextPoint)

If that doesn't work, try and see if the below works(the difference is, instead of using "Pick every unit in group", it loops through the group. Basically the same thing but there are some cases where "Pick every unit in group" might not work)
Hidden information:

Trigger:
Floating Text
Collapse Events
Time - Every 5.00 seconds of game time
Conditions
Collapse Actions
Custom script: call DestroyGroup(udg_FarmGroup)
Set FarmGroup = (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Farm))
Collapse For each (Integer A) from 1 to (Number of units in FarmGroup), do (Actions)
Collapse Loop - Actions
Custom script: call RemoveLocation(udg_Float_TextPoint)
Set FarmUnitPick = (Random unit from FarmGroup)
Set Float_TextPoint = (Position of FarmUnitPick)
Unit Group - Remove FarmUnitPick from FarmGroup
Player - Add 25 to (Owner of FarmUnitPick) Current gold
Player - Add 25 to (Owner of FarmUnitPick) Current lumber
Floating Text - Create floating text that reads +25 at Float_TextPoint with Z offset 0.00, using font size 12.00, color (20.00%, 100.00%, 20.00%), and 0.00% transparency
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Set the velocity of (Last created floating text) to 80.00 towards 90.00 degrees
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 1.00 seconds


Note about Floating Text:
Trigger:
Floating Text - Create floating text that reads +25 at Float_TextPoint with Z offset 0.00, using font size 12.00, color (20.00%, 100.00%, 20.00%), and 0.00% transparency
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Set the velocity of (Last created floating text) to 80.00 towards 90.00 degrees
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 1.00 seconds

"Change (Last Created floating text): Disable permanence: This needs to be done or else the floating text won't disappear. You should put that just after you put the trigger to create the floating text..
12-17-2009, 02:54 PM#4
warbucket
Thanks for the help and quick response. I tested it and it works perfectly.