Making scripts multiplayer compatible
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins
18 posts
• Page 1 of 2 • 1, 2
Making scripts multiplayer compatible
by 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.
...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.
-

Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Making scripts multiplayer compatible
by 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
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
-

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
by Max mtg » 23 Oct 2012, 11:45
see r17671 for a good place to fire that trigger from.Hellfish wrote:I'll roll out a LosesGame trigger tonight hopefully.
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
by 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
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
-

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
by 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?
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
-

ArsenalNut - Posts: 512
- Joined: 08 Jul 2011, 03:49
- Has thanked: 27 times
- Been thanked: 121 times
Re: Making scripts multiplayer compatible
by Sloth » 23 Oct 2012, 14:17
Fixed! Thanks ArsenalNut.ArsenalNut wrote:Sloth,
Should the second trigger for flying creatures in Barbed Foilage also be changed?
You can search for cards with "each opponent": http://magiccards.info/query?q=o%3A%22e ... rd&s=cnameArsenalNut 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?
Most of these need to be updated.
-

Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Making scripts multiplayer compatible
by Max mtg » 23 Oct 2012, 18:48
That Combat.getDefendingPlayerRelatedTo - why is there
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
- 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
by 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!
Also, something amusing I found, The trigger goes off fine when I kill an AI, but the AI keeps playing!
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
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
-

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
by Max mtg » 23 Oct 2012, 19:22
Was it a multiplayer game? I'll have a lookHellfish wrote:Also, something amusing I found, The trigger goes off fine when I kill an AI, but the AI keeps playing!
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
by Hellfish » 23 Oct 2012, 19:25
Yeah, the Archenemy demo.Max mtg wrote:Was it a multiplayer game? I'll have a lookHellfish wrote:Also, something amusing I found, The trigger goes off fine when I kill an AI, but the AI keeps playing!
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
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
-

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
by friarsol » 23 Oct 2012, 19:28
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.Hellfish wrote:(Blood Tyrant's first trigger is not correct yet,.though)
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
by Sloth » 23 Oct 2012, 20:17
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.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
Feel free to fully implement Rule 802.2a which sucks big time, but there are much more pressing matters regarding multiplayer.
I've added it just recently for Blood Tribute. And yes it should be used on all these cards.friarsol wrote: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.Hellfish wrote:(Blood Tyrant's first trigger is not correct yet,.though)
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.
-

Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Making scripts multiplayer compatible
by 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
-

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
by Max mtg » 23 Oct 2012, 20:55
I can't say so.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?
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
by Max mtg » 23 Oct 2012, 21:03
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.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 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
18 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 6 guests