H4 Displaying a message during AI turn when an object is taking

The old Heroes games developed by New World Computing. Please specify which game you are referring to in your post.
User avatar
Grythandril
Leprechaun
Leprechaun
Posts: 19
Joined: 06 Jan 2006
Location: Grythandril

H4 Displaying a message during AI turn when an object is taking

Unread postby Grythandril » 25 Aug 2019, 18:50

How do you create a script to display a message when object has been taken by the AI?

When the AI takes its turn and captures your castle a message is displayed stating that fact.

How do I create one when the AI take either a gold mine or another object e.g. Pandora's Box?

please advise
Last edited by Grythandril on 25 Aug 2019, 21:29, edited 1 time in total.

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 773
Joined: 21 Jul 2014

Re: H4 Displaying a message during AI turn when an object is taking

Unread postby iLiVeInAbOx05 » 26 Aug 2019, 16:06

I'll have to take a look later to verify, but don't mines have standard events? If they do, then you can simply use the captured event to place your scripting in.

Not sure on the pandora's box, I'll have to try to take a look at the editor later.

User avatar
Grythandril
Leprechaun
Leprechaun
Posts: 19
Joined: 06 Jan 2006
Location: Grythandril

Re: H4 Displaying a message during AI turn when an object is taking

Unread postby Grythandril » 29 Aug 2019, 19:31

I'm able to use the Pandora box (named Pandora 01) and the bomb object (named bomb1) to remove the box
Then create an placed event for the human player to be asked if they wish to open the box
If the answer is yes then the player will receive the contents which then delete the box and remove the script

Also so far I think the AI cannot do the above so have placed an event close to the box and create a script - placed event for the computer to automatically open the box and get the different contents when its cross the placed event.

But so far cannot produce a message for the human player (during the AI turn) to indicate that the Pandora's box has been opened

User avatar
Grythandril
Leprechaun
Leprechaun
Posts: 19
Joined: 06 Jan 2006
Location: Grythandril

Re: H4 Displaying a message during AI turn when an object is taking

Unread postby Grythandril » 29 Aug 2019, 19:37

Also noticed in the help page for scripting that its only for Quest huts, Quest gates, Quest Guards, Towns, armies, creatures and Heroes.

now the mines has the same facilities as the town but they I cannot find a way to display a message during the AI turn that your mine has been captured like that when your town is captured.

I have tried using these options at the start
Attacked: Allows you to script an event that will activate when an enemy army attacks the town.
Captured: Allows you to script an event that will activate after an enemy army conquers the town.
Victorious: Allows you to script an event that will activate after an enemy army attacks the town but loses the battle.
Encountered: Allows you to script an event that will activate when a friendly or allied army visits the town.

but none of these will display that message

User avatar
jeff
Moderator
Moderator
Posts: 3741
Joined: 06 Jan 2006

Re: H4 Displaying a message during AI turn when an object is taking

Unread postby jeff » 29 Aug 2019, 23:50

You can try a conditional that runs at the start of your turn each day, if green player has "artifact" then text Green player has "artifact", and have it step through all the colors. It would be tedious if you want this for more than a few artifacts. I used this whenever a critical artifact might be acquired or important hero was defeated by one of the AI players. It seems to work very well and I also have set variables that later help determine if victory conditions have been met. The script can also be written to account for neutral AI stacks defeating heroes.
Last edited by jeff on 29 Aug 2019, 23:50, edited 1 time in total.
Mala Ipsa Nova :bugsquash:

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 773
Joined: 21 Jul 2014

Re: H4 Displaying a message during AI turn when an object is taking

Unread postby iLiVeInAbOx05 » 30 Aug 2019, 15:12

The tedious aspect can be taken away if you use the H4 Advanced Options Editor. Then you only have to write the script once and you copy and paste and just change the artifact (or whatever you need to change) in the pasted script.

Still haven't had a chance to take a look, but I think Jeff has given you some good leads :D

User avatar
jeff
Moderator
Moderator
Posts: 3741
Joined: 06 Jan 2006

Re: H4 Displaying a message during AI turn when an object is taking

Unread postby jeff » 30 Aug 2019, 23:09

I had to add these scripts when the victory conditions dictated the player defeat certain heroes. If an AI army defeated them or they got defeated by a neutral stack, then that condition couldn't be met. Those scripts were added as a map script and I have tested them repeatedly and they work.

Now I did also added other scripts telling the player that it occurred, relieving them of the requirement; that script also set the necessary variables ensuring the player could complete the map.
Last edited by jeff on 30 Aug 2019, 23:11, edited 1 time in total.
Mala Ipsa Nova :bugsquash:

Accolon
Leprechaun
Leprechaun
Posts: 2
Joined: 11 Sep 2019

Re: H4 Displaying a message during AI turn when an object is taking

Unread postby Accolon » 11 Sep 2019, 10:37

How do you create a script to display a message when object has been taken by the AI?
1. Create time event (run every day if current player is human) "Check someone mines".
2. In "Check someone mines" place calling trigger event "My owner is"
3. Place trigger event "My owner is" at mine.
4. In "My owner is":

Code: Select all

if Owner is computer then
    Display "The mine has been captured by AI"
    Remove Script

User avatar
Grythandril
Leprechaun
Leprechaun
Posts: 19
Joined: 06 Jan 2006
Location: Grythandril

Re: H4 Displaying a message during AI turn when an object is taking

Unread postby Grythandril » 05 Oct 2019, 20:56

Thanks

I tried that and it worked only once but if i delete the remove the script then it displayed the message every day.

Is I will try this on a event next to the Pandora's box when the AI takes it.

Cheers

User avatar
jeff
Moderator
Moderator
Posts: 3741
Joined: 06 Jan 2006

Re: H4 Displaying a message during AI turn when an object is taking

Unread postby jeff » 07 Oct 2019, 21:24

There are ways to have the message occur again; so when do you want this to show and when would you want it to repeat.
Mala Ipsa Nova :bugsquash:


Return to “Heroes I-IV”

Who is online

Users browsing this forum: No registered users and 24 guests