So I made items that gives health/armor bonuses when equipped now I'm little bit lost here I made armor and necklace with defined stats problem is how do I make them to act independently? For example I have (100 HP) now I equip armor(50) and now I have (150 HP) but when I equip the necklace(20) my armor stats get lost and I have (120HP) instead of (170) . I understand that it happens because EXTRA_HP = item value but how do I make that it stack itself?
Here is my current code for this note that I removed unnecessary variables from Player class:
Code: Select all
init -1 python:
class Player(renpy.store.object):
def __init__(self,NAME, MAX_HP, CURRENT_HP, IMAGE = "NO IMAGE", ARMOR= None, EXTRA_HP=0, WEAPON=None, PLAYER_MAX_DAMAGE=0, PLAYER_MIN_DAMAGE=0, EXTRA_MAX_HP=0,
MAX_ARMOR_PROTECTION = 0,MIN_ARMOR_PROTECTION=0, NECKLACE=None, MAX_NECKLACE_PROTECTION=0, MIN_NECKLACE_PROTECTION=0):
self.NAME = NAME ### Player name
self.MAX_HP = MAX_HP ### Players max hp
self.CURRENT_HP = CURRENT_HP ### Players current hp
self.ARMOR = ARMOR ### Name of armor
self.EXTRA_HP = EXTRA_HP ### Used for the sum calculation with CURRENT_HP
self.EXTRA_MAX_HP = EXTRA_MAX_HP ### Used for the sum calculation with MAX_HP
self.MAX_ARMOR_PROTECTION = MAX_ARMOR_PROTECTION ### Highest roll on protection
self.MIN_ARMOR_PROTECTION = MIN_ARMOR_PROTECTION ### Lowest roll on protection
self.NECKLACE = NECKLACE ### Name of necklace
self.MAX_NECKLACE_PROTECTION= MAX_NECKLACE_PROTECTION ### Highest roll on protection
self.MIN_NECKLACE_PROTECTION = MIN_NECKLACE_PROTECTION ### Lowest roll on protection
@property
def TOTAL_MAX_HP(self): ### Used in battle engine just to display the max health
return self.MAX_HP + self.EXTRA_MAX_HP
@property
def TOTAL_CURRENT_HP(self): ### Used in battle engine when taking damage
return self.CURRENT_HP + self.EXTRA_HP
@TOTAL_CURRENT_HP.setter
def TOTAL_CURRENT_HP(self, value):
self.CURRENT_HP and self.EXTRA_HP - 0
def equip(self, item):
if item.PLAYER_EQ == "Bob" and item.EQUIPMENT_TYPE == "ARMOR":
self.ARMOR = item.NAME
self.EXTRA_HP = item.ARMOR_HP_BONUS
self.EXTRA_MAX_HP = item.ARMOR_HP_BONUS
bob.MAX_ARMOR_PROTECTION = item.MAX_ARMOR_PROTECTION
bob.MIN_ARMOR_PROTECTION = item.MIN_ARMOR_PROTECTION
renpy.show_screen("inventory_popup", message="You equiped [bob.ARMOR].")
elif item.PLAYER_EQ == "Bob" and item.EQUIPMENT_TYPE == "NECKLACE":
self.NECKLACE = item.NAME
self.EXTRA_HP = item.NECKLACE_HP_BONUS
self.EXTRA_MAX_HP = item.NECKLACE_HP_BONUS
bob.MAX_NECKLACE_PROTECTION = item.MAX_NECKLACE_PROTECTION
bob.MIN_NECKLACE_PROTECTION = item.MIN_NECKLACE_PROTECTION
renpy.show_screen("inventory_popup", message="You equiped [bob.NECKLACE].")
else:
renpy.show_screen("inventory_popup", message="You can't use this item!")
class Item(store.object):
def __init__(self, NAME, COST=0, KG=0, MAX_DAMAGE=0, MIN_DAMAGE=0, AMOUNT=0, DESC="No Desc", PICTURE = "", WEAPON_EQUIP="", PLAYER_EQ=None, ARMOR_EQUIP="",
ARMOR_HP_BONUS=0, TYPE=None,EQUIPMENT_TYPE=None, MAX_ARMOR_PROTECTION=0,MIN_ARMOR_PROTECTION=0, MAX_NECKLACE_PROTECTION=0, MIN_NECKLACE_PROTECTION=0, NECKLACE_HP_BONUS=0):
self.NAME = NAME ### Item name
self.COST = COST ### Item cost
self.KG = KG ### How heavy is item inside inventory?
self.MAX_DAMAGE = MAX_DAMAGE ### Highest damage roll
self.MIN_DAMAGE = MIN_DAMAGE ### Lowest damage roll
self.AMOUNT = AMOUNT ### Item amount
self.DESC = DESC ### Item description
self.PICTURE = PICTURE ### Item picture
self.PLAYER_EQ = PLAYER_EQ ### Which players can carry this tiem?
self.ARMOR_HP_BONUS = ARMOR_HP_BONUS ### How much extra HP does armor give when equipped?
self.ARMOR_NAME = TYPE ### Name of equippment that will be displayed on the screen
self.EQUIPMENT_TYPE = EQUIPMENT_TYPE ### Is the item weapon,armor or accessory?
self.MAX_ARMOR_PROTECTION = MAX_ARMOR_PROTECTION ### Highest armor prot roll
self.MIN_ARMOR_PROTECTION = MIN_ARMOR_PROTECTION ### Lowest armor prot roll
self.MAX_NECKLACE_PROTECTION= MAX_NECKLACE_PROTECTION ### Highest necklace prot roll
self.MIN_NECKLACE_PROTECTION = MIN_NECKLACE_PROTECTION ### Lowest necklace prot roll
self.NECKLACE_HP_BONUS = NECKLACE_HP_BONUS ### How much hp does necklace give? 