Announcement

Collapse
No announcement yet.

IsHumanPlayer() in Multiplayer

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • IsHumanPlayer() in Multiplayer

    The question has been raised before (here: http://apolyton.net/forums/showthrea...threadid=62653)

    Does the function IsHumanPlayer work properly in multiplayer games?

    I did some testing tonight and here's what I found... (warning bad news!)

    The one and only time the function would work in my setup was when it was a human player's turn (host or not) and the argument tested was his player number. No other player number would work when a human played and neither would it run on the AI's turns but there not even with the AI's player number as an argument.
    The error returned is always "_IsHumanPlayer: Wrong number of arguments"
    I can only think of some mistake in the code of the function itself which obviously renders it useless for any MP setup then...

  • #2
    What was the exact code mapfi and did you tested it with DebugSlic=Yes?

    -Martin
    Civ2 military advisor: "No complaints, Sir!"

    Comment


    • #3
      hm, that was a while ago already... I just wrote something for testing, like a BeginTurn handler that would give me the result of is humanplayer in a message box.

      Comment


      • #4
        So it would be something like this (if I use the information from your first post):

        Code:
        HandleEvent(BeginTurn)'Test_IsHumanPlayer'post{
            if(IsHumanPlayer(1)){
                 //Do something here
            }
        }
        This could be a little bit problematic, because players and ints are not the same thing, in the slic documentation you find this:

        player.owner - An integer version of the player.

        This is a hint that ints and players are not identical, but obviously we have a lot of implecit typecasts here in slic, but unfortunatly they fail sometimes. And other functions expects a integer representaion of the player as argument.

        I think something like this should work:

        Code:
        HandleEvent(BeginTurn)'Test_IsHumanPlayer'post{
            if(IsHumanPlayer(player[0])){
                 //Do something here
            }
        }
        Also this could work:

        Code:
        HandleEvent(BeginTurn)'Test_IsHumanPlayer'post{
            player[0] = 1;
            if(IsHumanPlayer(player[0])){
                 //Do something here
            }
        }
        And this should also work:

        Code:
        HandleEvent(BeginTurn)'Test_IsHumanPlayer'post{
            if(IsHumanPlayer(g.player)){
                 //Do something here
            }
        }
        In frenzy we have the problem that ints and players treated as the same thing. Most of the frenzy arguments for the IsHumanPlayer function are integers and not players.

        -Martin
        Civ2 military advisor: "No complaints, Sir!"

        Comment


        • #5
          I honestly can't remember - I would think I did something like
          Code:
          HandleEvent(BeginTurn) {
          for (i = 1; i <= Num; i = i + 1) {
          	player[0] = i;
          	result[i] = IsHumanPlayer(player[0]);
          	}
          message(g.player, 'test');
          }
          but I wouldn't be able to swear on this... someone will have to try again, sorry

          Comment


          • #6
            Well this code will work as you described. Whenever the BeginTurn event is called a message is send to the current player (that's g.player) and no other player will recieve the message. In theory the result array should contain a lot of zeros and ones, but so far I don't see what do you want to do with the result array.

            A code that could test it would be something like this:
            Code:
            HandleEvent(BeginTurn)'Test_IsHumanPlayer'post{
                 if(IsHumanPlayer(player[0])){
                       Message(1, 'Test_IsHumanPlayer');
                 }
                 else{
                       Message(1, 'Test_IsNotHumanPlayer');
                 }
            }
            So if you are player 1 then you will receive a buch of messages, as much as human players are in the game, and you should get as much messages as AI players are in the game.

            -Martin
            Civ2 military advisor: "No complaints, Sir!"

            Comment

            Working...
            X