It is currently 23 Apr 2024, 15:25
   
Text Size

A function for the heroic keyword

Moderator: CCGHQ Admins

Re: A function for the heroic keyword

Postby thefiremind » 25 Sep 2013, 08:36

GrovyleXShinyCelebi wrote:what is an LUA table?
A table in Lua is similar to an array in other programming languages, but much more flexible.
http://lua-users.org/wiki/TablesTutorial

GrovyleXShinyCelebi wrote:What's practically different between a table and data chest?
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.
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.).

GrovyleXShinyCelebi wrote:And what basic functions (that work in Duels 2014) can interact with tables?
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.

----------------------------------------------

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...
User avatar
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

Postby 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>
Every heroic trigger ability will need to have its linked_ability_group attribute set to 1 for this to work, of course.
BlindWillow
 
Posts: 213
Joined: 19 Jul 2012, 00:26
Has thanked: 11 times
Been thanked: 46 times

Re: A function for the heroic keyword

Postby gorem2k » 25 Sep 2013, 21:16

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:
Yes! it works and you can even simplify a little more like this:
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>
gorem2k
 
Posts: 464
Joined: 01 Apr 2013, 04:21
Has thanked: 48 times
Been thanked: 33 times

Re: A function for the heroic keyword

Postby 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>
User avatar
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

Postby thefiremind » 10 Nov 2013, 09:46

Nice idea! =D> Unless I'm forgetting an important rule, it seems good to me.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 721 times

Previous

Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 8 guests


Who is online

In total there are 8 users online :: 0 registered, 0 hidden and 8 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 8 guests

Login Form