Page 1 of 2

Making scripts multiplayer compatible

PostPosted: 23 Oct 2012, 08:34
by Sloth
I've corrected a lot of scripts to make them compatible with multiplayer modes already.

...BUT, I guess there are a few hundred more. If someone has some time to spare, i would be glad for help.

Next on my list are cards with attacking restrictions like Armored Galleon. This needs some changes to CombatUtil functions so i will do this myself.

Here are some cards that need special fixes:
Blood Tyrant
Canker Abomination
Elbrus, the Binding Blade
Hydra Omnivore
Ruhan of the Fomori

If you want to claim some fixes or found other cards please post here.

Re: Making scripts multiplayer compatible

PostPosted: 23 Oct 2012, 10:55
by Hellfish
I'll roll out a LosesGame trigger tonight hopefully.

Re: Making scripts multiplayer compatible

PostPosted: 23 Oct 2012, 11:45
by Max mtg
Hellfish wrote:I'll roll out a LosesGame trigger tonight hopefully.
see r17671 for a good place to fire that trigger from.

Re: Making scripts multiplayer compatible

PostPosted: 23 Oct 2012, 11:50
by Hellfish
Heh, thanks. Looks like I might need to move the ReplacementEffect check for LoseGame too, then.

Re: Making scripts multiplayer compatible

PostPosted: 23 Oct 2012, 13:18
by ArsenalNut
Sloth,

Should the second trigger for flying creatures in Barbed Foilage also be changed? I started looking for at some of cards you've already fixed to figure what needs to be updated. Any pointers on what to to look for?

Re: Making scripts multiplayer compatible

PostPosted: 23 Oct 2012, 14:17
by Sloth
ArsenalNut wrote:Sloth,

Should the second trigger for flying creatures in Barbed Foilage also be changed?
Fixed! Thanks ArsenalNut.

ArsenalNut wrote: I started looking for at some of cards you've already fixed to figure what needs to be updated. Any pointers on what to to look for?
You can search for cards with "each opponent": http://magiccards.info/query?q=o%3A%22e ... rd&s=cname

Most of these need to be updated.

Re: Making scripts multiplayer compatible

PostPosted: 23 Oct 2012, 18:48
by Max mtg
That Combat.getDefendingPlayerRelatedTo - why is there
Code: Select all
        Player defender = Singletons.getModel().getGame().getPhaseHandler().getPlayerTurn().getOpponent();
?

The defending player is undefined in common case. A single attack may be targeted agains many players. Using getOpponent() of active player is incorrect here. As it is in CombatUtil.canAttack

Re: Making scripts multiplayer compatible

PostPosted: 23 Oct 2012, 19:18
by Hellfish
Alright, added the LosesGame trigger to Withengar and Blood Tyrant. (Blood Tyrant's first trigger is not correct yet,.though)

Also, something amusing I found, The trigger goes off fine when I kill an AI, but the AI keeps playing! :mrgreen:

Re: Making scripts multiplayer compatible

PostPosted: 23 Oct 2012, 19:22
by Max mtg
Hellfish wrote:Also, something amusing I found, The trigger goes off fine when I kill an AI, but the AI keeps playing! :mrgreen:
Was it a multiplayer game? I'll have a look

Re: Making scripts multiplayer compatible

PostPosted: 23 Oct 2012, 19:25
by Hellfish
Max mtg wrote:
Hellfish wrote:Also, something amusing I found, The trigger goes off fine when I kill an AI, but the AI keeps playing! :mrgreen:
Was it a multiplayer game? I'll have a look
Yeah, the Archenemy demo.

Re: Making scripts multiplayer compatible

PostPosted: 23 Oct 2012, 19:28
by friarsol
Hellfish wrote:(Blood Tyrant's first trigger is not correct yet,.though)
I bet there's a ton of cards that have a similar effect this. When I was poking around the LoseLife API the other day to update the Wiki, I found this interesting bit of info.

Part of resolving sets the SVar AFLifeLost to the amount of life lost by all players. You can probably just change the counters gained to the above SVar (or for anything that does similar). I'd assume since this variable gets a number assigned to it, there's at least one card that uses it our there. I just can't search cause I don't have the code base.

Re: Making scripts multiplayer compatible

PostPosted: 23 Oct 2012, 20:17
by Sloth
Max mtg wrote:That Combat.getDefendingPlayerRelatedTo - why is there
Code: Select all
        Player defender = Singletons.getModel().getGame().getPhaseHandler().getPlayerTurn().getOpponent();
?

The defending player is undefined in common case. A single attack may be targeted agains many players. Using getOpponent() of active player is incorrect here. As it is in CombatUtil.canAttack
In order not to break anything, this function has to return a player, so i've chosen what works in a single player game. The code below will switch to the right player in 90% of the cases.
Feel free to fully implement Rule 802.2a which sucks big time, but there are much more pressing matters regarding multiplayer.

friarsol wrote:
Hellfish wrote:(Blood Tyrant's first trigger is not correct yet,.though)
I bet there's a ton of cards that have a similar effect this. When I was poking around the LoseLife API the other day to update the Wiki, I found this interesting bit of info.

Part of resolving sets the SVar AFLifeLost to the amount of life lost by all players. You can probably just change the counters gained to the above SVar (or for anything that does similar). I'd assume since this variable gets a number assigned to it, there's at least one card that uses it our there. I just can't search cause I don't have the code base.
I've added it just recently for Blood Tribute. And yes it should be used on all these cards.

Re: Making scripts multiplayer compatible

PostPosted: 23 Oct 2012, 20:48
by moomarc
This migh not be the ideal place to post this, but close enough... I was just wondering whether the abstraction of players has brought us any closer to implementing Mindslaver or the original Sorin. In my mind you could now make the controller of player X human for the relevant turn (assuming the human controlled the Mindslaver). Is it actually any closer?

Re: Making scripts multiplayer compatible

PostPosted: 23 Oct 2012, 20:55
by Max mtg
moomarc wrote:This migh not be the ideal place to post this, but close enough... I was just wondering whether the abstraction of players has brought us any closer to implementing Mindslaver or the original Sorin. In my mind you could now make the controller of player X human for the relevant turn (assuming the human controlled the Mindslaver). Is it actually any closer?
I can't say so.
There was no abstraction set up yet. The what was made: removed hardcode for get(Specific)Player routines widely used by ai and all the rest, and phasehandler enchanced to deal with several players in a game. Thus we can have a number of ai players.
But.. there are still some awkward methods in Player class: isHuman or isComputer. These are checked to prodive a certain player reaction in each phase, trigger or other event.

Re: Making scripts multiplayer compatible

PostPosted: 23 Oct 2012, 21:03
by Max mtg
Sloth wrote:In order not to break anything, this function has to return a player, so i've chosen what works in a single player game. The code below will switch to the right player in 90% of the cases.
Feel free to fully implement Rule 802.2a which sucks big time, but there are much more pressing matters regarding multiplayer.
I have read the code for a second time and found out that combat variable is never null, otherwise there would have been an exception thrown at the very first line. So that default assignment was overwritten anyway.
I have commited an edition where there is no check for combat == null and defender player is calculated from the entity under attack. See lines 814-815 of http://svn.slightlymagic.net/websvn/dif ... &peg=17683

Was just upset to see player.getOpponent outside of AI code.