It is currently 30 Oct 2025, 01:04
   
Text Size

Making scripts multiplayer compatible

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins

Making scripts multiplayer compatible

Postby Sloth » 23 Oct 2012, 08:34

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.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Making scripts multiplayer compatible

Postby Hellfish » 23 Oct 2012, 10:55

I'll roll out a LosesGame trigger tonight hopefully.
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
User avatar
Hellfish
Programmer
 
Posts: 1297
Joined: 07 Jun 2009, 10:41
Location: South of the Pumphouse
Has thanked: 110 times
Been thanked: 169 times

Re: Making scripts multiplayer compatible

Postby Max mtg » 23 Oct 2012, 11:45

Hellfish wrote:I'll roll out a LosesGame trigger tonight hopefully.
see r17671 for a good place to fire that trigger from.
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: Making scripts multiplayer compatible

Postby Hellfish » 23 Oct 2012, 11:50

Heh, thanks. Looks like I might need to move the ReplacementEffect check for LoseGame too, then.
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
User avatar
Hellfish
Programmer
 
Posts: 1297
Joined: 07 Jun 2009, 10:41
Location: South of the Pumphouse
Has thanked: 110 times
Been thanked: 169 times

Re: Making scripts multiplayer compatible

Postby ArsenalNut » 23 Oct 2012, 13:18

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?
So many cards, so little time
User avatar
ArsenalNut
 
Posts: 512
Joined: 08 Jul 2011, 03:49
Has thanked: 27 times
Been thanked: 121 times

Re: Making scripts multiplayer compatible

Postby Sloth » 23 Oct 2012, 14:17

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.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Making scripts multiplayer compatible

Postby Max mtg » 23 Oct 2012, 18:48

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
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: Making scripts multiplayer compatible

Postby Hellfish » 23 Oct 2012, 19:18

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:
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
User avatar
Hellfish
Programmer
 
Posts: 1297
Joined: 07 Jun 2009, 10:41
Location: South of the Pumphouse
Has thanked: 110 times
Been thanked: 169 times

Re: Making scripts multiplayer compatible

Postby Max mtg » 23 Oct 2012, 19:22

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
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: Making scripts multiplayer compatible

Postby Hellfish » 23 Oct 2012, 19:25

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.
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
User avatar
Hellfish
Programmer
 
Posts: 1297
Joined: 07 Jun 2009, 10:41
Location: South of the Pumphouse
Has thanked: 110 times
Been thanked: 169 times

Re: Making scripts multiplayer compatible

Postby friarsol » 23 Oct 2012, 19:28

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.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: Making scripts multiplayer compatible

Postby Sloth » 23 Oct 2012, 20:17

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.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: Making scripts multiplayer compatible

Postby moomarc » 23 Oct 2012, 20:48

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?
-Marc
User avatar
moomarc
Pixel Commander
 
Posts: 2091
Joined: 04 Jun 2010, 15:22
Location: Johannesburg, South Africa
Has thanked: 371 times
Been thanked: 372 times

Re: Making scripts multiplayer compatible

Postby Max mtg » 23 Oct 2012, 20:55

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.
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: Making scripts multiplayer compatible

Postby Max mtg » 23 Oct 2012, 21:03

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.
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Next

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 6 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 6 users online :: 0 registered, 0 hidden and 6 guests (based on users active over the past 10 minutes)
Most users ever online was 9298 on 10 Oct 2025, 12:54

Users browsing this forum: No registered users and 6 guests

Login Form