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

ImageImageTalking about Modding for EE2 and EE2 AOS. New maps, patches, programs and Multiplayer scenarios.
Post Reply
User avatar
Dr.MonaLisa
High Representative
Posts: 7951
Joined: 17 Jun 2010, 11:21
Location: Poland

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

Post 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 364 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 364 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 11 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 364 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.
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains

User avatar
Loewenherz
Posts: 174
Joined: 23 Sep 2017, 17:26

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

Post 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
List of tutorials, useful threads and utilities (look here before posting): Here

Add Pics to Map: viewtopic.php?f=54&p=25184#p25184

Loews Work: viewtopic.php?f=54&t=5160
User avatar
Dr.MonaLisa
High Representative
Posts: 7951
Joined: 17 Jun 2010, 11:21
Location: Poland

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

Post 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...
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains
User avatar
Loewenherz
Posts: 174
Joined: 23 Sep 2017, 17:26

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

Post 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.
List of tutorials, useful threads and utilities (look here before posting): Here

Add Pics to Map: viewtopic.php?f=54&p=25184#p25184

Loews Work: viewtopic.php?f=54&t=5160
User avatar
calsch03
Posts: 34
Joined: 04 Dec 2015, 11:24
Location: The Netherlands
Contact:

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

Post by calsch03 »

Nice, now we van make text based minigames.
User avatar
Dr.MonaLisa
High Representative
Posts: 7951
Joined: 17 Jun 2010, 11:21
Location: Poland

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

Post 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.
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains
User avatar
calsch03
Posts: 34
Joined: 04 Dec 2015, 11:24
Location: The Netherlands
Contact:

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

Post by calsch03 »

Yeah your right, there are a lot of new possibilities now.
Sat42
Posts: 100
Joined: 03 Dec 2018, 18:01

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

Post by Sat42 »

Awesome, thanks Mona!

There's never been a better time to make scenarios for EEII + AoS!
User avatar
Dr.MonaLisa
High Representative
Posts: 7951
Joined: 17 Jun 2010, 11:21
Location: Poland

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

Post 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 11 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.
Best regards,
Dr.MonaLisa
Ministry of Game Affairs
Department of Control and Complains
Post Reply

Return to “EE2 files, modding, maps, testing, etc.”