Board index Programs with AI or Rules Enforcement Magic: The Gathering - Duels of the Planeswalkers Programming Talk
A function for the heroic keyword
Moderator: CCGHQ Admins
Re: A function for the heroic keyword
by thefiremind » 25 Sep 2013, 08:36
A table in Lua is similar to an array in other programming languages, but much more flexible.GrovyleXShinyCelebi wrote:what is an LUA table?
http://lua-users.org/wiki/TablesTutorial
Warning: what I'm going to write might contain wrong information: I'm not a DotP developer, and I'm using reasonable guesses in order to "fill the holes" about what I don't know.GrovyleXShinyCelebi wrote:What's practically different between a table and data chest?
Lua is a scripting language that usually works side by side with the programming language used to code the executable, which is C++ for DotP (I think). Some structures belonging to the underlying programming language are exposed to Lua, so that you can manipulate them inside scripts. Data chests are examples of this. So the difference is that tables are Lua structures, while data chests are C++ objects, and they come with a set of methods (Get_Int, Make_Chest, etc.).
Since tables can contain everything, you can store specific data into them (objects, players...) and then call their methods by addressing the table. If you look at the tables from this point of view, the answer to your question is "all of them"... but you aren't really interacting with the tables, you are interacting with what they contain.GrovyleXShinyCelebi wrote:And what basic functions (that work in Duels 2014) can interact with tables?
----------------------------------------------
Back to the problem of BECAME_TARGET_OF_SPELL, my main concern about Common Bond and Seeds of Strength is what happens if I copy one of those spells choosing new targets. As we know now, the assignments among any number of targets let the original controller define the number of targets, and the controllers of the copies cannot change it. The number of targets in Common Bond and Seeds of Strength is defined by the card itself (2 and 3, respectively), so I think that using assignments would give problems with the copies.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 721 times
Re: A function for the heroic keyword
by BlindWillow » 25 Sep 2013, 16:53
For those who are worried about adding new functions and want something that will at least deal with the Common Bond issue, the following code should suffice:
- Code: Select all
<TRIGGER value="BECAME_TARGET_OF_SPELL" simple_qualifier="self">
if LinkedDC():Get_CardPtr(0) == nil then
if SecondaryObject():GetController() == EffectController() then
LinkedDC():Set_CardPtr( 0, SecondaryObject() )
return true
end
return false
end
return false
</TRIGGER>
<RESOLUTION_TIME_ACTION>
if LinkedDC():Get_CardPtr(0) ~= nil then
LinkedDC():Set_CardPtr(0, nil)
end
</RESOLUTION_TIME_ACTION>
- BlindWillow
- Posts: 213
- Joined: 19 Jul 2012, 00:26
- Has thanked: 11 times
- Been thanked: 46 times
Re: A function for the heroic keyword
by gorem2k » 25 Sep 2013, 21:16
Yes! it works and you can even simplify a little more like this:BlindWillow wrote:For those who are worried about adding new functions and want something that will at least deal with the Common Bond issue, the following code should suffice:
- Code: Select all
<TRIGGER value="BECAME_TARGET_OF_SPELL" simple_qualifier="self">
if LinkedDC():Get_CardPtr(0) == nil and SecondaryObject():GetController() == EffectController() then
LinkedDC():Set_CardPtr( 0, SecondaryObject() )
return true
end
return false
</TRIGGER>
<RESOLUTION_TIME_ACTION>
if LinkedDC():Get_CardPtr(0) ~= nil then LinkedDC():Set_CardPtr(0, nil) end
</RESOLUTION_TIME_ACTION>
Re: A function for the heroic keyword
by sumomole » 10 Nov 2013, 03:38
I try to do what you did to Sigarda, Host of Herons and Guile, it seems work, is there any bug?
- Code: Select all
<TRIGGERED_ABILITY linked_ability_group="1">
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[|Heroic| — Whenever you cast a spell that targets Tormented Hero, each opponent loses 1 life. You gain life equal to the life lost this way.]]></LOCALISED_TEXT>
<TRIGGER value="SPELL_PLAYED" simple_qualifier="objectyoucontrol">
if LinkedDC():Get_Int(0) == 1 then
LinkedDC():Set_Int(0, 0)
return true
end
return false
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local total = 0
local number = MTG():GetNumberOfPlayers()
for i = 0, (number-1) do
local player = MTG():GetNthPlayer(i)
if player:GetTeam() ~= EffectController():GetTeam() then
player:LoseLife( 1 )
total = total + 1
end
end
EffectController():GainLife( total )
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY linked_ability_group="1" replacement_effect="1">
<TRIGGER value="BECAME_TARGET_OF_SPELL" simple_qualifier="self">
if SecondaryPlayer() == EffectController() and SecondaryObject():WasCast() then
LinkedDC():Set_Int(0, 1)
end
return false
</TRIGGER>
</TRIGGERED_ABILITY>
-
sumomole - Programmer
- Posts: 611
- Joined: 07 Jun 2011, 08:34
- Has thanked: 51 times
- Been thanked: 234 times
Re: A function for the heroic keyword
by thefiremind » 10 Nov 2013, 09:46
Nice idea! Unless I'm forgetting an important rule, it seems good to me.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 721 times
20 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 8 guests