Page 1 of 1

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

PostPosted: 16 Oct 2012, 02:56
by alexandreonly
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.

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

PostPosted: 16 Oct 2012, 08:24
by Persee
Use CHARACTERISTIC_CHANGELING ^^

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

PostPosted: 16 Oct 2012, 08:47
by thefiremind
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.