It is currently 24 Apr 2024, 23:22
   
Text Size

Gain or lose all creature types until end of turn. Help?

Moderator: CCGHQ Admins

Gain or lose all creature types until end of turn. Help?

Postby alexandreonly » 16 Oct 2012, 02:56

I want to code Amoeboid Changeling to include in my Mono Blue Allies deck (because there are no enough allies to fill the deck) but i don't know how to implement its active abilities.
alexandreonly
 
Posts: 145
Joined: 04 Jul 2011, 17:27
Has thanked: 0 time
Been thanked: 8 times

Re: Gain or lose all creature types until end of turn. Help?

Postby Persee » 16 Oct 2012, 08:24

Use CHARACTERISTIC_CHANGELING ^^
User avatar
Persee
 
Posts: 168
Joined: 02 Jun 2011, 08:33
Has thanked: 42 times
Been thanked: 24 times

Re: Gain or lose all creature types until end of turn. Help?

Postby thefiremind » 16 Oct 2012, 08:47

Persee wrote:Use CHARACTERISTIC_CHANGELING ^^
As I said here, it's not exactly how it should work, but it's as close as you can get.

About losing all creature types, I made the LoseCreatureTypes function (but never used it, so it's untested):
Code: Select all
LoseSubTypes = function(object)
-- makes object lose all sub-types
   object:GetCurrentCharacteristics():SubType_GetWritable(object):Clear()
end

LoseCreatureTypes = function(object)
-- makes object lose all creature sub-types (preserving the other ones, if any)
   local ncst_array = {}
   local ncst_count = 0
   for i=ARTIFACT_TYPE_CONTRAPTION,ARTIFACT_TYPE_FORTIFICATION do
      if object:GetSubType():Test(i) ~= 0 then
         ncst_array[ncst_count] = i
         ncst_count = ncst_count + 1
      end
   end
   for i=ENCHANTMENT_TYPE_AURA,ENCHANTMENT_TYPE_CURSE do
      if object:GetSubType():Test(i) ~= 0 then
         ncst_array[ncst_count] = i
         ncst_count = ncst_count + 1
      end
   end
   for i=LAND_TYPE_DESERT,LAND_TYPE_URZAS do
      if object:GetSubType():Test(i) ~= 0 then
         ncst_array[ncst_count] = i
         ncst_count = ncst_count + 1
      end
   end
   LoseSubTypes(object)
   if ncst_count > 0 then
      for i=0,ncst_count-1 do
         AddSubTypeTo(ncst_array[i], object)
      end
   end
end
It saves the noncreature sub-types, then it removes all sub-types, finally it gives the noncreature sub-types again. This would be perfect in a world where we can give all creature types without using CHARACTERISTIC_CHANGELING... but we can't, so you should also set that characteristic to 0.
< 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


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 12 guests


Who is online

In total there are 12 users online :: 0 registered, 0 hidden and 12 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 12 guests

Login Form