Page 1 of 1

.IES Scripting - Solution for not working function HasTextBeenTyped( const char *in_szText)

Posted: 26 Nov 2020, 17:10
by Dr.MonaLisa
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:

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
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"
Zrzut ekranu 2020-11-26 164421.png
Zrzut ekranu 2020-11-26 164421.png (1.88 KiB) Viewed 3409 times

Instead of using "sex", we need to add some strange characters before the actual string:
Zrzut ekranu 2020-11-26 164458.png
Zrzut ekranu 2020-11-26 164458.png (2.8 KiB) Viewed 3409 times

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).
HasTextBeenTyped_Fixed_Example_26.11.2020.ies
(1.84 KiB) Downloaded 163 times

Proof:
EE2_ScreenShot_2020-11-26_16.58.12.376.jpg
EE2_ScreenShot_2020-11-26_16.58.12.376.jpg (275.63 KiB) Viewed 3409 times


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.

Re: .IES Scripting - Solution for not working function HasTextBeenTyped( const char *in_szText)

Posted: 26 Nov 2020, 17:27
by Loewenherz
Thanks for the work. Maybe we see interesting scenarios with multiple choice questions. I never thought that function would work. This strange scripting documentation with wrong examples. :D

Re: .IES Scripting - Solution for not working function HasTextBeenTyped( const char *in_szText)

Posted: 26 Nov 2020, 17:32
by Dr.MonaLisa
I think the example was correct, but maybe they added players colors in nicknames later... And didn't test how it behaves / works.

Those bugs are nothing bad. The bad thing is, EE2 had no official patches after .IES scripting was added, so problems like this existed forever...

Re: .IES Scripting - Solution for not working function HasTextBeenTyped( const char *in_szText)

Posted: 26 Nov 2020, 17:42
by Loewenherz
I think Sierra just finished development with the addon and gave mad doc no more money for more patches. So it was the last patch nad i have the feel, that the IES System was created to fast.

Re: .IES Scripting - Solution for not working function HasTextBeenTyped( const char *in_szText)

Posted: 26 Nov 2020, 18:20
by calsch03
Nice, now we van make text based minigames.

Re: .IES Scripting - Solution for not working function HasTextBeenTyped( const char *in_szText)

Posted: 26 Nov 2020, 18:24
by Dr.MonaLisa
I would make some kind of scenario-specific cheats. Like when game gets too hard, we could increase re-spawn periods, etc. For City-Building related games, there could be a cheat (not shared public) that would eliminate a player who becomes a "ruiner" (attacks during a CB mission). Many possibilities.

Re: .IES Scripting - Solution for not working function HasTextBeenTyped( const char *in_szText)

Posted: 26 Nov 2020, 19:09
by calsch03
Yeah your right, there are a lot of new possibilities now.

Re: .IES Scripting - Solution for not working function HasTextBeenTyped( const char *in_szText)

Posted: 26 Nov 2020, 20:57
by Sat42
Awesome, thanks Mona!

There's never been a better time to make scenarios for EEII + AoS!

Re: .IES Scripting - Solution for not working function HasTextBeenTyped( const char *in_szText)

Posted: 13 Dec 2020, 13:57
by Dr.MonaLisa
Hello there.

As Loew requested on private, I created an example script of a scenario cheat. The script can be downloaded here:
HasTextBeenTyped_CheatExample_13.12.2020.ies
(2.84 KiB) Downloaded 165 times
There are 3 cheats possibilities:
1. Toggle on/off cheat: long nose
2. Toggle on cheat: pigs rain enable
3. Toggle off cheat: pigs rain disable

The key to make our cheating system work instantly, without 20 seconds delays, was the following function:

Code: Select all

CallNamedEventHandler("ChatClearMessages", "");
I remembered that we have the CTRL + ENTER hotkey in EE2 to clear the current chat from the screen... And it worked!

Have fun.