Jump to content


Photo

Just need help with damage reduction


  • Please log in to reply
2 replies to this topic

#1 CaptainDJ

CaptainDJ

    GMC Member

  • GMC Member
  • 60 posts
  • Version:GM:Studio

Posted 11 March 2012 - 08:32 PM

Hey I need a bit of help with my code. I basically have it set so when the monster deals damage to the player, he deals damage in a range from 20-50. I added armor now, so the more you have the less damage the monster deals, which is fine. Now, I noticed that when I have a lot of armor, the monster only deals 20's. Can someone teach me how to make the damage not capped at the minimum and make it as low as 1?
I found a similar topic on this forum, and applied it to my game, but it just made it worse. :(

Here is what I have:

//when the monster attacks the player
global.monsterdamage=(global.monsterdamagemin + random(global.monsterdamagemax - global.monsterdamagemin)/((100+global.armor)/100))

global.hp-=global.monsterdamage

  • 0

#2 Jakyl11

Jakyl11

    GMC Member

  • GMC Member
  • 3109 posts
  • Version:GM:Studio

Posted 11 March 2012 - 10:09 PM

d1=global.monsterdamagemin + irandom(global.monsterdamagemax);//calculate the damage

damage=max(1,d1-a1);//compare to armor value
global.hp-=damage;//deal the damage

d1 - is the damage being dealt
a1 - is the armor value
  • 1

#3 CaptainDJ

CaptainDJ

    GMC Member

  • GMC Member
  • 60 posts
  • Version:GM:Studio

Posted 12 March 2012 - 02:31 AM

d1=global.monsterdamagemin + irandom(global.monsterdamagemax);//calculate the damage

damage=max(1,d1-a1);//compare to armor value
global.hp-=damage;//deal the damage

d1 - is the damage being dealt
a1 - is the armor value


Awesome man, Thanks! :D
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users