item
index
/home/achifaifa/git/kirino/source/item.py

#usr/bin/env python

 
Modules
       
common
copy
os
random

 
Classes
       
consumable
item

 
class consumable
    Potions, spells, items that can be eaten, drunk or consumed.
 
Default attributes
 
#Type
type=4
 
# 0 - Potion
#   01 - HP potion
#   02 - MP potion
#   03 - Recovery potion (HP&MP)
#   04 - Status potions
#   00 - Random (except status potions)
#
# Potions regenerate a certain amout of HP or MP in a single turn.
# The amout of points recovered depends on the type of potion. Each potion type has a fixed value that can vary in the -30% / +30% range with random modifiers.
# Recovery potions recover both HP and MP, and status potions stop damage over time (Poison, fire, bleeding, etc)
#
# 1 - Tome of knowledge
#
# Tomes of knowledge add one point to an attribute and decrease one point to another attribute.
#
# 2 - Attack items
#
# Attack items inflict extra damage. They can be direct things like bombs or extra strenght, or they can inflict extra damage over time.
#
# 3.- Unidentified potions
#
# Unidentified consumables can have totally random and unexpected effects. 
# Vendors can identify them. When this happens, they are converted to a random type 0, 1 or 2 item.
#
# 4.- Empty 
#
# Generates an object without propieties named "--EMPTY--" to be displayed in the crawl screen.
# This objects can not be consumend and are for display purposes only.
 
#General propieties
name="--EMPTY--"  #Name
price=0           #Price
 
#Potion propieties
hpr=0             #Maximum HP recovered
mpr=0             #Maximum MP recovered
statusr=0         #If 1, recovers status
subtype=0         #Potion subtype
 
#Tome propieties
intbst=0          #Intelligence modifier
dexbst=0          #Dexterity modifier
perbst=0          #Perception modifier
conbst=0          #Constitution modifier
wilbst=0          #Willpower modifier 
chabst=0          #Charisma modifier
strbst=0          #Strenght modifier
 
#Food propieties
hungrec=0         #Hunger recovery
chance=0          #Type of food (Good,risky,bad)
 
#Attack propieties
areatype=0        #Type of area affected
areasize=0        #Size of the area
damage=0          #Damage caused
dps=0             #Damage over time
 
  Methods defined here:
__init__(self, newtype, subtype)
Class constructor. Creates a consumable item of the specified type. Needs a subtype parameter for the potions, which is ignored in the rest of the items.
 
Consumable items can only be bought from vendors. They can't be found in the ground.
Requires type and subtype:
reset(self)
resets an item so all the attributes are set to zero.

 
class item
    Creates and manages items
 
#Item attributes
ID=0          #Identifier
name="_"      #Item name
type=00       #Item table. See any item_XX file or the table below
equip=0       #Equipped. 1=yes, 2=no
 
#Item bonuses
strbonus=0    #Intelligence boost
intbonus=0    #Dexterity boost
dexbonus=0    #Perception boost
perbonus=0    #Constitution boost
conbonus=0    #Willpower boost
wilbonus=0    #Charisma boost
chabonus=0    #Strenght boost
 
#Other
atk=0         #Attack power
defn=0        #Defense power
enchantlv=0   #Enchant level
 
  Methods defined here:
__init__(self, type)
Item constructor. 
 
Takes random data from the inventory data files and sets the attributes
Needs an integer (type) to determine the item type
 
#   01 - Head
#   02 - Face
#   03 - Neck
#   04 - Shoulders
#   05 - Chest
#   06 - One hand
#   07 - Two hands
#   08 - Ring
#   09 - Belt
#   10 - Legs
#   11 - Feet
#   00 - Empty (Item with all the attributes set to zero)
enchant(self, player)
Enchants the item 
 
Permanently adds attribute bonuses and increases either the attack or defense by 1.
Requires the player enchanting the object to be passed to alter the money balance.
Items can only be enchanted up to lv10.
 
Chances of attribute boosts:
  79.0% chance of one attribute boost
  15.0% chance of two attribute boost
  04.5% chance of three attribute boost
  00.5% chance of four attribute boost
  01.0% chances of the item being destroyed
 
Enchanting an item costs the current item price, and doubles its price.
If the player has no money to pay for the enchant or the item is lv10, enchant() returns a message and passes.
 
If the item is destroyed all its attributes are set to 0. 
Deleting the resetted item from the inventory is done in the player module after calling the enchant() function.
reset(self)
Sets all the attributes of the given item object to zero.