Board index Programs with AI or Rules Enforcement Magic: The Gathering - Duels of the Planeswalkers New MTG Cards and Decks (2010, 2012, 2013, 2014, 2015, Magic Duels) 2014
Way to make yourself lose a fractional amount of life?
Moderator: CCGHQ Admins
Way to make yourself lose a fractional amount of life?
by fallenangle » 28 Aug 2014, 03:04
I've been trying to code Doomsday, and I can get it to do everything I want except make me lose half my life total when I cast it. I've tried using Blood Tribute and Pox as models to code this effect, but so far I've been unsuccessful. Can anyone show me what the code would look like for an RTA to make the caster of a spell lose half his or her life? Thanks in advance for all of your help and advice.
- fallenangle
- Posts: 319
- Joined: 20 Jul 2013, 02:31
- Has thanked: 73 times
- Been thanked: 41 times
Re: Way to make yourself lose a fractional amount of life?
by NeoAnderson » 28 Aug 2014, 04:26
Try with something like this: UNTESTEDfallenangle wrote:I've been trying to code Doomsday, and I can get it to do everything I want except make me lose half my life total when I cast it. I've tried using Blood Tribute and Pox as models to code this effect, but so far I've been unsuccessful. Can anyone show me what the code would look like for an RTA to make the caster of a spell lose half his or her life? Thanks in advance for all of your help and advice.
- Code: Select all
local value = math.ceil(EffectController():GetLifeTotal / 2)
EffectController():LoseLife(value)
- NeoAnderson
- Posts: 914
- Joined: 10 Sep 2013, 07:49
- Has thanked: 18 times
- Been thanked: 139 times
Re: Way to make yourself lose a fractional amount of life?
by thefiremind » 28 Aug 2014, 08:47
Yes, that should work, except for the missing parentheses after GetLifeTotal (I added them in the quoted message ).NeoAnderson wrote:Try with something like this: UNTESTED
- Code: Select all
local value = math.ceil(EffectController():GetLifeTotal() / 2)
EffectController():LoseLife(value)
This is an alternative that doesn't use Lua's math library, in case someone is interested:
- Code: Select all
local life = EffectController():GetLifeTotal()
local value = life / 2 + life % 2
EffectController():LoseLife(value)
< 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: Way to make yourself lose a fractional amount of life?
by NeoAnderson » 28 Aug 2014, 13:56
Ahahhaa sorry probably i was too tired when i posted the answer!!!!thefiremind wrote:Yes, that should work, except for the missing parentheses after GetLifeTotal (I added them in the quoted message ).NeoAnderson wrote:Try with something like this: UNTESTED
- Code: Select all
local value = math.ceil(EffectController():GetLifeTotal() / 2)
EffectController():LoseLife(value)
- NeoAnderson
- Posts: 914
- Joined: 10 Sep 2013, 07:49
- Has thanked: 18 times
- Been thanked: 139 times
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 59 guests