Board index
Programs with AI or Rules Enforcement
Magic: The Gathering - Duels of the Planeswalkers
Programming Talk



Will of the Council
Moderator: CCGHQ Admins
Will of the Council
by volrathxp » 08 Aug 2014, 23:17
I know that we can do multiple choice questions, but is something like Will of the Council capable under Dotp 2014?
I thought about adding some of the more fun Council cards, but not really sure if the voting thing is possible. Especially something like Custodi Squire (voting for individual cards in a graveyard, etc).
I thought about adding some of the more fun Council cards, but not really sure if the voting thing is possible. Especially something like Custodi Squire (voting for individual cards in a graveyard, etc).
volrathxp
Re: Will of the Council
by sweetLu » 09 Aug 2014, 00:08
Sure. It wouldn't be a multiple choice question though. It would be like any other "choose a card" card. Just loop through all the players with the appropriate "choose a card" function and then simply evaluate the results.
For an example look at a card like Distress. It should do something like set up a filter for the target players hand then use ChooseItems() to get the chosen card. For will of the council you would have the filter be for permanents that aren't controlled by the casting player, then you'd have all players choose a card according to that filter.
For an example look at a card like Distress. It should do something like set up a filter for the target players hand then use ChooseItems() to get the chosen card. For will of the council you would have the filter be for permanents that aren't controlled by the casting player, then you'd have all players choose a card according to that filter.
Re: Will of the Council
by volrathxp » 09 Aug 2014, 00:21
Well, most Will of the Council cards have the players selecting a thing, not a card (like... Tyrant's Choice for example, has the players voting for "death" or "torture").sweetLu wrote:Sure. It wouldn't be a multiple choice question though. It would be like any other "choose a card" card. Just loop through all the players with the appropriate "choose a card" function and then simply evaluate the results.
For an example look at a card like Distress. It should do something like set up a filter for the target players hand then use ChooseItems() to get the chosen card. For will of the council you would have the filter be for permanents that aren't controlled by the casting player, then you'd have all players choose a card according to that filter.
Custodi Squire is the only one that really has a card selection.
volrathxp
Re: Will of the Council
by sweetLu » 09 Aug 2014, 00:47
Oh sorry I should have looked up some more. I've only seen Council's Judgment so I got confused.
You can set the multiple choice question up any way you want after you define the localized text files. You could do:
Question: Vote death or torture.
A1: Death - each opponent sacrifices a creature.
A2: Torture - each opponent losses 4 life.
You can set the multiple choice question up any way you want after you define the localized text files. You could do:
Question: Vote death or torture.
A1: Death - each opponent sacrifices a creature.
A2: Torture - each opponent losses 4 life.
Re: Will of the Council
by volrathxp » 09 Aug 2014, 01:13
That's kind of what I was thinking. Hmmph. I'll have to look at it some more when I have time. I don't have a whole lot of experience in multi-choice questions yet, so I'll have to see if I can't find a good card to work off of.sweetLu wrote:Oh sorry I should have looked up some more. I've only seen Council's Judgment so I got confused.
You can set the multiple choice question up any way you want after you define the localized text files. You could do:
Question: Vote death or torture.
A1: Death - each opponent sacrifices a creature.
A2: Torture - each opponent losses 4 life.
volrathxp
Re: Will of the Council
by RiiakShiNal » 09 Aug 2014, 01:50
It would even be possible to make Brago's Representative. You use a Player chest and do appropriate clearing (like I do for custom characteristics) then as a static ability you have Brago's Representative increment a register, for the "Vote" cards you have it check that register to see how many votes each player should get and give them the appropriate number of choices at the appropriate time. For example on a repeating action instead of using the number of repetitions to determine player number, you use it to determine a register index that gets the proper player pointer to ask. For example Player 1 has no representatives, Player 2 has two representatives, and player 3 has one representative the vote registers might look like this:
0 - Player 1
1 - Player 2
2 - Player 2
3 - Player 2
4 - Player 3
5 - Player 3
So the repeating action would repeat 7 or 12 times (depending on how implemented) to ask, get, and record all the votes.
The next action could tally them and do the appropriate action or store them so the action can be carried out later.
0 - Player 1
1 - Player 2
2 - Player 2
3 - Player 2
4 - Player 3
5 - Player 3
So the repeating action would repeat 7 or 12 times (depending on how implemented) to ask, get, and record all the votes.
The next action could tally them and do the appropriate action or store them so the action can be carried out later.
Just getting started: Xander9009's DotP 2014 Community Wad
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
- RiiakShiNal
- Programmer
- Posts: 2188
- Joined: 16 May 2011, 21:37
- Has thanked: 75 times
- Been thanked: 497 times
Re: Will of the Council
by volrathxp » 11 Aug 2014, 01:25
So I'm trying to get a good basis for this, wanting to know if I'm going into the right direction here, or I'm making this too hard on myself.
Working on setting up Bite of the Black Rose.
I don't have much experience with multi-choice questions and especially with effects that work off each player, so my brain is trying to wrap around it. Also, trying to understand how I tally the votes. I'm sure I can store those into Ints, but not sure how...
Working on setting up Bite of the Black Rose.
I don't have much experience with multi-choice questions and especially with effects that work off each player, so my brain is trying to wrap around it. Also, trying to understand how I tally the votes. I'm sure I can store those into Ints, but not sure how...
- Code Snippet - Bite of the Black Rose | Open
- Code: Select all
<RESOLUTION_TIME_ACTION>
for i=0,(MTG():GetNumberOfPlayers()-1) do
local player = MTG():GetNthPlayer(i)
if player ~= nil then
if player == EffectController() then
EffectDC():Set_Int(5, i)
end
end
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION repeating="1">
local n = MTG():GetActionRepCount()
local num_players = MTG():GetNumberOfPlayers()
local m = EffectDC():Get_Int(5)
local playerindex = ( n/2 + m ) % num_players
local parity = n % 2
local player = MTG():GetNthPlayer(playerindex)
local sickness = 0
local psychosis = 0
if player ~= nil and n < num_players*2 then
if parity == 0 then
player:AddMultipleChoiceAnswer( "CARD_QUERY_VOTE_SICKNESS" )
player:AddMultipleChoiceAnswer( "CARD_QUERY_VOTE_PSYCHOSIS" )
player:AskMultipleChoiceQuestion( "CARD_QUERY_BLACK_ROSE_QUESTION")
else
local result = player:GetMultipleChoiceResult()
if result == 0 then
sickness = sickness + 1
else
psychosis = psychosis + 1
end
if sickness > 0 or psychosis > 0 then
EffectDC():Set_Int(playerindex, EffectDC():Get_Int(playerindex) + result)
EffectDC():Set_Int(6, 0)
else
EffectDC():Int_Inc(6)
end
if EffectDC():Get_Int(6) == num_players then
return false
end
return true
end
return false
end
</RESOLUTION_TIME_ACTION>
volrathxp
Re: Will of the Council
by sweetLu » 11 Aug 2014, 01:50
That wouldn't work because each iteration you are resetting the sickness and psychosis vote back to 0. You'll have to save the vote count in a data chest. Try something like:
- | Open
- Code: Select all
<RESOLUTION_TIME_ACTION repeating="1">
local n = MTG():GetActionRepCount()
local parity = n%2
local index = n/2
if index < MTG():GetNumberOfStartingPlayers() then
local player = MTG():GetNthStartingPlayer(index)
if player ~= nil then
if parity == 0 then
player:BeginNewMultipleChoice()
player:AddMultipleChoiceAnswer("CARD_QUERY_VOTE_SICKNESS")
player:AddMultipleChoiceAnswer("CARD_QUERY_VOTE_PSYCHOSIS")
player:AskMultipleChoiceQuestion( "CARD_QUERY_BLACK_ROSE_QUESTION", EffectSource() )
else
-- The sickness vote should be stored in EffectDC():Get_Int(0)
-- The psychosis vote should be stored in EffectDC():Get_Int(1)
EffectDC():Int_Inc( player:GetMultipleChoiceResult() )
end
end
return true
end
return false
</RESOLUTION_TIME_ACTION>
Re: Will of the Council
by volrathxp » 11 Aug 2014, 02:41
Right. I'm not totally worried about Brago's Representative at this point in time. I kind of figured that was where I was going wrong I just couldn't see where to go with it. I will give that a shot. Thanks!
volrathxp
Re: Will of the Council
by RiiakShiNal » 11 Aug 2014, 10:58
To ask the questions and account for Brago's Representative you would do something along these lines (VOTE_MODIFIER would need to be defined as an unused register to hold the vote modifications, or 0 if no modifications):
This should also be able to handle things like getting card pointers or other things just by changing how the votes are tallied a bit.
- Code | Open
- Code: Select all
<RESOLUTION_TIME_ACTION>
-- Make a chest for the player pointers
local dcPlayers = EffectDC():Make_Chest(1)
local nPlayers = MTG():GetNumberOfPlayers()
local nVoteIndex = 0
-- Loop through all players in order
for nPlayer = 0, nPlayers-1 do
local oPlayer = MTG():GetNthPlayer(nPlayer)
-- Get additional votes (if any)
local nVotes = oPlayer:PlayerDataChest():Int_Get( VOTE_MODIFIER )
-- Loop through all votes (to setup voting queue).
for nVote = 0, nVotes do
-- Store the player that gets this vote.
dcPlayers:Set_PlayerPtr(nVoteIndex, oPlayer)
-- Increment vote index so we don't overwrite any.
nVoteIndex = nVoteIndex + 1
end
end
-- We have now cycled through all players and setup when
-- they are going to vote and how many votes they get so
-- now we need to store how many votes we need to conduct.
EffectDC():Int_Set(0, nVoteIndex)
-- Make our voting chest (we don't need the pointer now just need to create it)
EffectDC():Make_Chest(2)
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION repeating="1">
local n = MTG():GetActionRepCount()
local nNumVotes = EffectDC():Int_Get(0)
local dcPlayers = EffectDC():Get_Chest(1)
local dcVotes = EffectDC():Get_Chest(2)
-- If this is not the first rep then we need to record a vote
if (n > 0) then
local nVoteIndex = n - 1
local oVotePlayer = dcPlayers:Get_PlayerPtr(nVoteIndex)
dcVotes:Int_Set(nVoteIndex, oVotePlayer:GetMultipleChoiceResult())
end
-- Now we check to see if we should continue.
if (n >= nNumVotes) then
-- Nope, we already recorded our last vote so end.
return false
end
-- If we got to here then we need to ask a player a question.
local oPlayer = dcPlayers:Get_PlayerPtr(n)
oPlayer:BeginNewMultipleChoice()
oPlayer:AddMultipleChoiceAnswer("CARD_QUERY_VOTE_SICKNESS")
oPlayer:AddMultipleChoiceAnswer("CARD_QUERY_VOTE_PSYCHOSIS")
oPlayer:AskMultipleChoiceQuestion("CARD_QUERY_BLACK_ROSE_QUESTION", EffectSourceLKI())
-- We want to continue this repeating action.
return true
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
-- Count up the votes
local nNumVotes = EffectDC():Int_Get(0)
local dcVotes = EffectDC():Get_Chest(2)
local nSickness = 0
local nPsychosis = 0
for nVote = 0, nNumVotes-1 do
-- Check which option this is a vote for.
if (dcVotes:Int_Get(nVote) == 1) then
nPsychosis = nPsychosis + 1
else
nSickness = nSickness + 1
end
end
-- At this point the votes are tallied and can either be stored or used.
EffectDC():Int_Set(3, nSickness)
EffectDC():Int_Set(4, nPsychosis)
</RESOLUTION_TIME_ACTION>
This should also be able to handle things like getting card pointers or other things just by changing how the votes are tallied a bit.
Just getting started: Xander9009's DotP 2014 Community Wad
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
- RiiakShiNal
- Programmer
- Posts: 2188
- Joined: 16 May 2011, 21:37
- Has thanked: 75 times
- Been thanked: 497 times
Re: Will of the Council
by volrathxp » 11 Aug 2014, 11:28
Where would I set the VOTE_MODIFIER at? Would that be in one of the .LOL files?RiiakShiNal wrote:To ask the questions and account for Brago's Representative you would do something along these lines (VOTE_MODIFIER would need to be defined as an unused register to hold the vote modifications, or 0 if no modifications):Note that I have not added any checks for nil since EffectSourceLKI() should never be nil and there should be no change in the status of the players between our RESOLUTION_TIME_ACTIONs so nil checks should be unnecessary here. If, however, you start getting SCRIPT_LOG errors about referencing a nil value you can put in nil checks and it shouldn't really complicate things much.
- Code | Open
- Code: Select all
<RESOLUTION_TIME_ACTION>
-- Make a chest for the player pointers
local dcPlayers = EffectDC():Make_Chest(1)
local nPlayers = MTG():GetNumberOfPlayers()
local nVoteIndex = 0
-- Loop through all players in order
for nPlayer = 0, nPlayers-1 do
local oPlayer = MTG():GetNthPlayer(nPlayer)
-- Get additional votes (if any)
local nVotes = oPlayer:PlayerDataChest():Int_Get( VOTE_MODIFIER )
-- Loop through all votes (to setup voting queue).
for nVote = 0, nVotes do
-- Store the player that gets this vote.
dcPlayers:Set_PlayerPtr(nVoteIndex, oPlayer)
-- Increment vote index so we don't overwrite any.
nVoteIndex = nVoteIndex + 1
end
end
-- We have now cycled through all players and setup when
-- they are going to vote and how many votes they get so
-- now we need to store how many votes we need to conduct.
EffectDC():Int_Set(0, nVoteIndex)
-- Make our voting chest (we don't need the pointer now just need to create it)
EffectDC():Make_Chest(2)
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION repeating="1">
local n = MTG():GetActionRepCount()
local nNumVotes = EffectDC():Int_Get(0)
local dcPlayers = EffectDC():Get_Chest(1)
local dcVotes = EffectDC():Get_Chest(2)
-- If this is not the first rep then we need to record a vote
if (n > 0) then
local nVoteIndex = n - 1
local oVotePlayer = dcPlayers:Get_PlayerPtr(nVoteIndex)
dcVotes:Int_Set(nVoteIndex, oVotePlayer:GetMultipleChoiceResult())
end
-- Now we check to see if we should continue.
if (n >= nNumVotes) then
-- Nope, we already recorded our last vote so end.
return false
end
-- If we got to here then we need to ask a player a question.
local oPlayer = dcPlayers:Get_PlayerPtr(n)
oPlayer:BeginNewMultipleChoice()
oPlayer:AddMultipleChoiceAnswer("CARD_QUERY_VOTE_SICKNESS")
oPlayer:AddMultipleChoiceAnswer("CARD_QUERY_VOTE_PSYCHOSIS")
oPlayer:AskMultipleChoiceQuestion("CARD_QUERY_BLACK_ROSE_QUESTION", EffectSourceLKI())
-- We want to continue this repeating action.
return true
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
-- Count up the votes
local nNumVotes = EffectDC():Int_Get(0)
local dcVotes = EffectDC():Get_Chest(2)
local nSickness = 0
local nPsychosis = 0
for nVote = 0, nNumVotes-1 do
-- Check which option this is a vote for.
if (dcVotes:Int_Get(nVote) == 1) then
nPsychosis = nPsychosis + 1
else
nSickness = nSickness + 1
end
end
-- At this point the votes are tallied and can either be stored or used.
EffectDC():Int_Set(3, nSickness)
EffectDC():Int_Set(4, nPsychosis)
</RESOLUTION_TIME_ACTION>
This should also be able to handle things like getting card pointers or other things just by changing how the votes are tallied a bit.
volrathxp
Re: Will of the Council
by RiiakShiNal » 11 Aug 2014, 11:31
Yes, that would be set in a LOL file and the value assigned to that register would be increased by Brago's Representative and regularly cleared by an invisible token manager (so that it doesn't get artificially inflated by exchanging control of Brago's representative or flickering).
Remember it should be a register that is not used by anyone else or it could cause problems either with other cards or with voting.
Remember it should be a register that is not used by anyone else or it could cause problems either with other cards or with voting.
Just getting started: Xander9009's DotP 2014 Community Wad
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
- RiiakShiNal
- Programmer
- Posts: 2188
- Joined: 16 May 2011, 21:37
- Has thanked: 75 times
- Been thanked: 497 times
Re: Will of the Council
by volrathxp » 12 Aug 2014, 00:02
I've looked at a few of the constant files in other DLC's, but I can't seem to really figure this out. How do I know that I've picked a number or register that isn't used by anyone else?RiiakShiNal wrote:Yes, that would be set in a LOL file and the value assigned to that register would be increased by Brago's Representative and regularly cleared by an invisible token manager (so that it doesn't get artificially inflated by exchanging control of Brago's representative or flickering).
Remember it should be a register that is not used by anyone else or it could cause problems either with other cards or with voting.
I'm also a little fuzzy on the token manager.
volrathxp
Re: Will of the Council
by RiiakShiNal » 12 Aug 2014, 00:25
Constants are easy. You simply pick a name (usually all caps to indicate it's not going to change) and then equate it to something. As for picking the value usually you pick a pretty high value (but still less than 2 billion) usually starting with your reserved Id Block number and usually you're okay. For example since my Id Block is 8192 my constants for registers all start with 8192 (then I usually add a sequential number afterwards). Like my value for the target chest for Defending Player is 81920011. Most modders use low numbers for registers when creating cards (0, 1, 2, etc...), but for shared registers like the Duel Data Chest and the Player Data Chest use high numbers that are unlikely to be used by other people.volrathxp wrote:I've looked at a few of the constant files in other DLC's, but I can't seem to really figure this out. How do I know that I've picked a number or register that isn't used by anyone else?
Invisible managers get to be tricky, take a look at my custom Characteristics code for more information on how your manager would need to work. Your manager would not work quite the same as mine, but would need to be similar (you would be incrementing and clearing a value on the player instead of on a card). The good news is you would only need to worry about the manager for Brago's Representative and similar cards. If the card is only reading from the value and not modifying it then it doesn't have to worry about the manager.volrathxp wrote:I'm also a little fuzzy on the token manager.
Just getting started: Xander9009's DotP 2014 Community Wad
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
- RiiakShiNal
- Programmer
- Posts: 2188
- Joined: 16 May 2011, 21:37
- Has thanked: 75 times
- Been thanked: 497 times
Re: Will of the Council
by volrathxp » 12 Aug 2014, 00:32
So like I would just need something like this in a .LOL file?RiiakShiNal wrote:Constants are easy. You simply pick a name (usually all caps to indicate it's not going to change) and then equate it to something. As for picking the value usually you pick a pretty high value (but still less than 2 billion) usually starting with your reserved Id Block number and usually you're okay. For example since my Id Block is 8192 my constants for registers all start with 8192 (then I usually add a sequential number afterwards). Like my value for the target chest for Defending Player is 81920011. Most modders use low numbers for registers when creating cards (0, 1, 2, etc...), but for shared registers like the Duel Data Chest and the Player Data Chest use high numbers that are unlikely to be used by other people.volrathxp wrote:I've looked at a few of the constant files in other DLC's, but I can't seem to really figure this out. How do I know that I've picked a number or register that isn't used by anyone else?Invisible managers get to be tricky, take a look at my custom Characteristics code for more information on how your manager would need to work. Your manager would not work quite the same as mine, but would need to be similar (you would be incrementing and clearing a value on the player instead of on a card). The good news is you would only need to worry about the manager for Brago's Representative and similar cards. If the card is only reading from the value and not modifying it then it doesn't have to worry about the manager.volrathxp wrote:I'm also a little fuzzy on the token manager.
- CONSTANTS | Open
- Code: Select all
VOTE_MODIFIER = 100011
Edit: Of course... if I could *find* your token manager...
Edit: NVM Found it.
volrathxp
Who is online
Users browsing this forum: No registered users and 1 guest