How do you create floating text messages?

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

How do you create floating text messages?

Post by kurt751 »

I'd like to create floating messages like the ones telling you when you gain or lose hit points, or get affected by some status modification (like" slowed" or "poisoned").
Unfortunately I have no idea what they are called, so I can't search the WML reference; Could somebody please point me in the right direction?

What I want to do is to create a floating text just like the healing or wounding one, triggered by an event (moveto in this case).
User avatar
James_The_Invisible
Posts: 534
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces
Contact:

Re: How do you create floating text messages?

Post by James_The_Invisible »

It is called floating_text.
Another variation is using [unstore_unit] with attributes text and red, green, blue. The latter can be replaced by some {COLOR_*} macros (COLOR_HEAL, COLOR_HARM, COLOR_WHITE).
kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: How do you create floating text messages?

Post by kurt751 »

James_The_Invisible wrote:It is called floating_text.
Perfect, that's what I was looking for! Thank you.

James_The_Invisible wrote:Another variation is using [unstore_unit]
Why would I "[unstore_unit]"? I didn't store it... :shock: :?:

I'm not too clear about what [unstore_unit] does. I thought, as the Wiki says "Creates a unit from a game variable, and activates it on the playing field." I'm not creating units, I'm just modifying an existing unit's health and status...

More precisely, what is wrong with:

Code: Select all

[event]		# cursed hex
        name=moveto
        first_time_only=no
	[filter]
	   x,y=15,3
	   side=1
	[/filter]
	[modify_unit]
		[filter]
			x,y=15,3
		[/filter]
		hitpoints=$($unit.hitpoints - 5)
		status.poisoned=yes
		status.slowed=yes
	[/modify_unit]
[/event]
User avatar
Ravana
Forum Moderator
Posts: 3002
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: How do you create floating text messages?

Post by Ravana »

modify_unit uses storing and unstoring internally. So there is nothing wrong.

It works by storing unit, to that game variable, then changing values of that variable, and then unstoring, to update gamestate.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: How do you create floating text messages?

Post by zookeeper »

kurt751 wrote: status.poisoned=yes
status.slowed=yes
This isn't the way.
User avatar
ForestDragon
Posts: 1771
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: How do you create floating text messages?

Post by ForestDragon »

zookeeper wrote:
kurt751 wrote: status.poisoned=yes
status.slowed=yes
This isn't the way.
it's

Code: Select all

[status]
<insert status name here>=yes
[status]
to be precise
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: How do you create floating text messages?

Post by kurt751 »

Ravana wrote:modify_unit uses storing and unstoring internally. So there is nothing wrong.
Thank you, I'm relieved! :D
Jeez, I feel like I'm sleepwalking through a minefield... :roll:


General suggestion -
It would break with the monosyllabic trend of this site and look less "The Way you see is not the True Way", but I do think the "Building Scenarios" tutorial on the Wiki lacks a little section telling people how to do simple stuff, like (for instance, among others) harm or heal units, teleport, make multiple choice dialogues, and other stuff any scenario creator will most likely want to use sooner or later. With short examples to show what the syntax looks like. There is already some of that there, but the tutorial needs more.
Yes, I've read the opinion according to which making creation as difficult and tedious as possible will limit the amount of bad campaigns, but I don't subscribe to that point of view. It limits the overall amount of campaigns sure enough, but has no impact on quality. It only tests determination, not talent, and one can be determined and clueless at the same time. I'd even say those two fit quite well together.
Just my 2 cents worth.
kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: How do you create floating text messages?

Post by kurt751 »

ForestDragon wrote:it's

Code: Select all

[status]
<insert status name here>=yes
[status]
to be precise
Thank you for being precise... :)


I wonder where I found my "status.something=yes" syntax. I most certainly didn't invent it. :hmm:
kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: How do you create floating text messages?

Post by kurt751 »

(Sorry Ravana, new post because different topic)


Okay, everything works just fine, except that people apparently can't die this way. I had thought the game engine would automatically kill an unit if it drops below 0 hit points, but apparently it has to be done manually.
Is [kill] the right way to do this? Like [if] (<1hp) [then][kill] (location), animate=yes [/kill][/then][/if]?
User avatar
James_The_Invisible
Posts: 534
Joined: October 28th, 2012, 1:58 pm
Location: Somewhere in the Northlands, fighting dark forces
Contact:

Re: How do you create floating text messages?

Post by James_The_Invisible »

except that people apparently can't die this way.
You mean from poison? Well, its description says
This attack poisons living targets. Poisoned units lose 8 HP every turn until they are cured or are reduced to 1 HP. Poison can not, of itself, kill a unit.
That means that the poisoned unit's hp will not go below 1.
(A bit off topic: It is possible ,under some circumstances, to have a unit with 0 or less hp. E. g. if you set it via debug mode, or some event-driven abilities are in place. That unit will die next time it is attacked.)
User avatar
ForestDragon
Posts: 1771
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: How do you create floating text messages?

Post by ForestDragon »

also, if you want to harm a unit, just use this (the parts with '#' are comments):

Code: Select all

[harm_unit]
 [filter]
    x,y=$x1,$y1 #
 [/filter]
 amount=<insert amount>
 kill=yes #this is done to make sure that it will kill a unit if he/she has low enough hp
 animate=yes #to make sure the defend animation is triggered for the harmed unit
 damage_type=<insert damage type>
 poisoned=yes
 slowed=yes
[/harm_unit]
My active add-ons: The Great Steppe Era,XP Bank,Alliances Mod,Pestilence,GSE+EoMa,Ogre Crusaders,Battle Royale,EoMaifier,Steppeifier,Hardcoreifier
My inactive add-ons (1.12): Tale of Alan, The Golden Age
Co-creator of Era of Magic
kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: How do you create floating text messages?

Post by kurt751 »

James_The_Invisible wrote:You mean from poison?
No, from having hit points subtracted by aforementioned "cursed hex" trap. You can subtract as many hit points as you want, units remain alive even with negative hit point values.
kurt751
Posts: 232
Joined: June 4th, 2016, 11:17 pm

Re: How do you create floating text messages?

Post by kurt751 »

ForestDragon wrote:also, if you want to harm a unit, just use this (the parts with '#' are comments):
Great, that sounds simple and straightforward. Thanks a lot!
Post Reply