I'm trying to make equipable items with stat changes, but I want the stats to be affected by whatever clothes the player is wearing, so for instance HP+20 while wearing winter clothes, or MP+50 while wearing a magician's robe, but those stats are only relevent while wearing the clothing item itself.(so when the player changes clothes, they won't have the previous item's stats)
I copied and pasted the relevent bits of code here. (this is in the items class)
Code: Select all
def use(self):
if self.battleitem == False and in_battle == True:
renpy.show_screen("inventory_popup", message="This item cannot be used in battle.")
elif self.clothes == True:
if player.dress == self.clothestype:
renpy.show_screen("inventory_popup", message="You are already wearing this dress.")
else:
player.dress = self.clothestype
hptotal = player.hp+self.hp
renpy.show_screen("inventory_popup", message=self.usdesc)
renpy.jump("home")
elif self.battleitem == True and in_battle == False:
renpy.show_screen("inventory_popup", message="This item can only be used in battle")
elif self.name=="Book":
player.kno += 8
renpy.show_screen("inventory_popup", message=self.usdesc)
inventory.drop(self)
elif self.hp>0 and in_battle == True: #healing item
player.hp = player.hp+self.hp
if player.hp > player.max_hp: # can't heal beyond max HP
player.hp = player.max_hp
renpy.show_screen("inventory_popup", message=self.usdesc)
inventory.drop(self) # consumable item - drop after use
else:
renpy.show_screen("inventory_popup", message=self.usdesc)
Code: Select all
init python:
player = Player("Derp", 50, 10)
player.hp = 50
player.mp = 10
player.kno = 0
player.dress = "Normal"
hptotal = player.hp
book = Item("Book", image="gui/inv_book1.png", usdesc="You read the book and already feel smarter!", cost=120)
poetrybook = Item("Poetry Book", image="gui/inv_book2.png", usdesc="Read the book", cost=400)
doll = Item("Doll", image="gui/inv_doll.png", usdesc="Played with the doll", cost=120)
grenade = Item("Grenade", image="gui/inv_grenade.png", battleitem=True, usdesc="Used the Grenade", cost=100)
healingpill = Item("Healing Pill", hp=40, image="gui/inv_healing.png", battleitem=True, usdesc="Used the Healing pill", cost=30)
teacup = Item("Teacup", image="gui/inv_teacup.png", usdesc="Used the teacup", cost=500)
clothes_normal = Item("Normal Dress", image="gui/inv_dressnormal.png", hp=0, clothes=True, clothestype="Normal", usdesc="Put on the Normal Dress", cost=10)
clothes_summer = Item("Summer Dress", image="gui/inv_dresssummer.png", hp=10, clothes=True, clothestype="Summer", usdesc="Put on the Summer Dress", cost=70)
clothes_winter = Item("Winter Dress", image="gui/inv_dresswinter.png", hp=20, clothes=True, clothestype="Winter", usdesc="Put on the Winter Dress", cost=120)
inventory = Inventory()
#add items to the initial inventory:
inventory.add(clothes_normal)

