.IES Scripting - Solution for not working function HasTextBeenTyped( const char *in_szText)
Posted: 26 Nov 2020, 17:10
I'm happy to announce, that I found a solution for not working function HasTextBeenTyped( const char *in_szText) in .IES scripts for Empire Earth 2 and Empire Earth 2: The Art of Supremacy.
What is the problem?
The function HasTextBeenTyped defined in the EE2 Scripting.doc doesn't seem to work with the given example:
I was trying to use this function since my early-teens, but obviously had no knowledge about debugging the game. My tests ended after hundreds of tests with different RULES / ACTIONS in an .ies script. I came to a conclusion, that this function simply doesn't work, and stopped thinking about it. Thankfully, Loew reminded me from time to time that it doesn't work, so I finally decided to see what is going on...
Cause of the problem
In EE2, around address: "0079FFBD" it pushes a string that doesn't start with the actual message string, but has got the ending of the formatted player color...
Solution
I decided that it's not worth to fix this function with Unofficial Patch 1.5, as it requires assembling, and other things related to testing / documentation / update release.
It's already possible to use the following solution in order to be able to use this function.
For example, we want an action to be triggered on message: "sex"
Instead of using "sex", we need to add some strange characters before the actual string:
Download an .IES script:
I can't put those characters in the forum post, that's why I attached an example .IES file.
Please use Notepad++ (or some other text editor that supports displaying of control characters).
Proof:
Problems:
The PERIODICITY and INSTANT (without specified ONESHOT or PERIODICITY) are being executed multiple times, for a few seconds after message was sent.
To fix it, we would need to save the current elapsed game time to a variable, and check check if it's greater than variable + X seconds.
What is the problem?
The function HasTextBeenTyped defined in the EE2 Scripting.doc doesn't seem to work with the given example:
Code: Select all
// bool HasTextBeenTyped( const char *in_szText)
// Check and see if the specified text has been typed into
// the chat box during the current game. Note that this check
// is case insensitive. Therefore if you are checking for "BAR"
// and "bar" had been typed into the chat box, true would be
// returned.
// Example:
// is steve rocking?
if( HasTextBeenTyped("steve is rocking") )
then playSomeRockingMusic
Cause of the problem
In EE2, around address: "0079FFBD" it pushes a string that doesn't start with the actual message string, but has got the ending of the formatted player color...
Solution
I decided that it's not worth to fix this function with Unofficial Patch 1.5, as it requires assembling, and other things related to testing / documentation / update release.
It's already possible to use the following solution in order to be able to use this function.
For example, we want an action to be triggered on message: "sex"
Instead of using "sex", we need to add some strange characters before the actual string:
Download an .IES script:
I can't put those characters in the forum post, that's why I attached an example .IES file.
Please use Notepad++ (or some other text editor that supports displaying of control characters).
Proof:
Problems:
The PERIODICITY and INSTANT (without specified ONESHOT or PERIODICITY) are being executed multiple times, for a few seconds after message was sent.
To fix it, we would need to save the current elapsed game time to a variable, and check check if it's greater than variable + X seconds.