Checking to see if human or AI

Maps and the art of mapmaking.
JagoBC
Leprechaun
Leprechaun
Posts: 29
Joined: 29 May 2006

Checking to see if human or AI

Unread postby JagoBC » 07 May 2008, 23:41

Does anyone know how to do this? It seemed like there used to be something along the lines of IsHuman, but I stopped working with the editor for a long while and appear to have forgotten.

Any help would be greatly appreciated.

Thanks!

User avatar
rdeford
Assassin
Assassin
Posts: 299
Joined: 17 Apr 2007
Location: Sequim, USA
Contact:

Unread postby rdeford » 08 May 2008, 21:49

The Grumpy Old Wizard does it in his maps. Specifically I remember seeing it in his Seize The Throne map script and I'm pretty sure he did it in Shadow Dreams as well. Take a look at his scripts if he doesn't answer this post.
rdeford, Mage Of Soquim

“Forgiving and being forgiven, loving and being loved,
living and letting live, is the simple basis for it all."

Ernest Holmes 1984

User avatar
Grumpy Old Wizard
Round Table Knight
Round Table Knight
Posts: 2205
Joined: 06 Jan 2006
Location: Tower Grump

Unread postby Grumpy Old Wizard » 08 May 2008, 22:51

On the first day, before your next day script, you need something like this.
whoishuman = GetCurrentPlayer(); --determine human player, always goes first
humanheroelist = GetPlayerHeroes(whoishuman); --get human's heroe choice
humanmainheroe = humanheroelist[0]; --human heroe choice assigned as main heroe
whoishuman and humanherolist are variables. humanheroelist is an array.

I recommend that you have a look at the scripts the scripts of other map makers. You can learn a lot from looking at what other mapmakers have done.

My HOMM5 maps

rdeford's HOMM5 maps

GOW
Frodo: "I wish the ring had never come to me. I wish none of this had happened."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."

JagoBC
Leprechaun
Leprechaun
Posts: 29
Joined: 29 May 2006

Unread postby JagoBC » 09 May 2008, 03:13

thanks for the response. I will look at some scripts, I think I played seize the throne so should still have it.

However, in the example, that script would only work for a single player map. My map is multiplayer (up to 3 humans), so while the current player may indeed always be human, the others would not necessarily be AI.

User avatar
Grumpy Old Wizard
Round Table Knight
Round Table Knight
Posts: 2205
Joined: 06 Jan 2006
Location: Tower Grump

Unread postby Grumpy Old Wizard » 09 May 2008, 05:49

JagoBC wrote:thanks for the response. I will look at some scripts, I think I played seize the throne so should still have it.

However, in the example, that script would only work for a single player map. My map is multiplayer (up to 3 humans), so while the current player may indeed always be human, the others would not necessarily be AI.
In that case you would want to check each of the player positions on day 1 before your new day script. You'll need to use the below function.

IsHuman is described as being a combat script so I'm not sure if it works outside of a combat script but you can give it a try.
IsHuman
IsHuman – determine whether there is a human playing for the certain party
Syntax
IsHuman(side);
Description
This function returns not nil if the specified party that takes part in combat belongs to a human
(regardless of whether this human controls the party’s actions, or they are under auctomatic
control), and nil if not.
Assuming the positions that are playable by human players are players 1-3 you might try something like:
------------------------
--declare variables--
------------------------
player1human = 0;
player2human = 0;
player3human = 0;

---------------------------------------------
--determine which players are human--
---------------------------------------------
if IsHuman (PLAYER_1) then
player1human = 1;
end;

if IsHuman (PLAYER_2) then
player2human = 1;
end;

if IsHuman (PLAYER_3) then
player3human = 1;
end;
Now bear in mind I dindn't test this script out to make sure I didn't make an error.

GOW
Frodo: "I wish the ring had never come to me. I wish none of this had happened."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."

User avatar
Grumpy Old Wizard
Round Table Knight
Round Table Knight
Posts: 2205
Joined: 06 Jan 2006
Location: Tower Grump

Unread postby Grumpy Old Wizard » 09 May 2008, 06:43

Now, if the above doesn't work (since IsHeroe may only be a combat function) then check the gold resouce for each player and compare it to the gold that a human player would have at that difficulty level.

From the fan manual:
easy 50000 gold
normal 30000 gold
hard 20000 gold
heroic 10000 gold
Now for the first part of the script, assuming 7 possible human positions:

player1human = 0;
player2human = 0;
player3human =0;
player4human = 0;
player5human = 0;
player6human = 0;
player7human = 0;

----------------------------------------------------------------------------------------------------------------
--determine difficulty level and starting gold for human: easy(1), normal(2), hard(3) or heroic(4) --
-----------------------------------------------------------------------------------------------------------------
difficultylevel = 1;
humangold = 50000;
if GetDifficulty() == DIFFICULTY_HEROIC then
difficultylevel = 4;
humangold = 10000;
end;
if GetDifficulty() == DIFFICULTY_HARD then
difficultylevel = 3;
humangold = 20000;
end;
if GetDifficulty() == DIFFICULTY_NORMAL then
difficultylevel = 2;
humangold = 30000
end;
You might try something like this for the resource checking script (assuming 7 possible playable positions.) Assuming the above script was used to determine difficulty level:
-----------------------------------------------------------------------------------
--compare gold to what human gold should be to detect human players--
-----------------------------------------------------------------------------------

if GetPlayerResource(PLAYER_1 , 6) == humangold then --6 is gold
player1human = 1; --player is human
end;

if GetPlayerResource(PLAYER_2 , 6) == humangold then
player2human = 1; --player is human
end;

if GetPlayerResource(PLAYER_3 , 6) == humangold then
player3human = 1; --player is human
end;

if GetPlayerResource(PLAYER_4 , 6) == humangold then
player4human = 1; --player is human
end;

if GetPlayerResource(PLAYER_5 , 6) == humangold then
player5human = 1; --player is human
end;

if GetPlayerResource(PLAYER_6 , 6) == humangold then
player6human = 1; --player is human
end;

if GetPlayerResource(PLAYER_7 , 6) == humangold then
player7human = 1; --player is human
end;
GOW
Frodo: "I wish the ring had never come to me. I wish none of this had happened."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."

JagoBC
Leprechaun
Leprechaun
Posts: 29
Joined: 29 May 2006

Unread postby JagoBC » 09 May 2008, 19:30

Thanks, I did end up using a variation of your script (you did not take into account that players could choose extra gold as a start bonus, but I simply set the test parameters to a range for each difficulty and it seemed to solve the problem)... Except

On hard difficulty the computer appears to start off with 20,000 gold as well... So on hard, the script always returns that all players are human

User avatar
Grumpy Old Wizard
Round Table Knight
Round Table Knight
Posts: 2205
Joined: 06 Jan 2006
Location: Tower Grump

Unread postby Grumpy Old Wizard » 09 May 2008, 19:36

Ah, yes, hard difficulty is the setting where the computer and human are even in resources. Well, playtesting shows things that you forget to consider and errors in your logic.

However, if you designated only 3 positions playable on your map as you said, and have more than three positions total on the map you can see if the sum total of playable postions showing as human is 3 or greater. If it is then you know that each possible human position is filled.

If you don't have more than 3 positions on the map you can make a 4th position that is computer only and stick it in a small walled in area that the player can't get to and that computer can't leave. Or you could make that 4th computer only position a town that can be conquered to fulfil a quest.

Did you try the IsHuman function?

GOW
Frodo: "I wish the ring had never come to me. I wish none of this had happened."
Gandalf: "So do all who live to see such times but that is not for them to decide. All we have to decide is what to do with the time that is given to us."

Neckie
Peasant
Peasant
Posts: 67
Joined: 05 Oct 2006
Location: Quebec, Canada

Unread postby Neckie » 09 May 2008, 20:26

see http://heroescommunity.com/viewthread.php3?TID=25687

there are 2 methods there... my method is fine if you have an introduction messagebox while the other works for any situation.

JagoBC
Leprechaun
Leprechaun
Posts: 29
Joined: 29 May 2006

Unread postby JagoBC » 10 May 2008, 09:19

Wow, the one with the thread worked perfectly! Great stuff available on these boards!


Return to “Mapmaking Guild”

Who is online

Users browsing this forum: No registered users and 1 guest