summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/items.xml148
-rw-r--r--data/items.xsd71
-rw-r--r--src/Makefile.am4
-rw-r--r--src/being.h92
-rw-r--r--src/dalstorage.cpp26
-rw-r--r--src/item.cpp22
-rw-r--r--src/item.h102
-rw-r--r--src/itemmanager.cpp193
-rw-r--r--src/itemmanager.h89
-rw-r--r--src/main.cpp47
-rw-r--r--src/player.cpp12
11 files changed, 721 insertions, 85 deletions
diff --git a/data/items.xml b/data/items.xml
new file mode 100644
index 00000000..ba524a93
--- /dev/null
+++ b/data/items.xml
@@ -0,0 +1,148 @@
+<?xml version="1.0"?>
+<items>
+<!-- id, weight, value, script_name, element, lifetime, -->
+<!-- strength, agility, vitality, intelligence, dexterity, luck -->
+<!-- heat, attack, defence, magic, accuracy, speed -->
+<!-- hp, mp -->
+ <!-- Equipment -->
+ <xsd:attribute name="range" type="xsd:integer" />
+ <!-- Status Effects Addition -->
+ <xsd:attribute name="status_normal" type="xsd:boolean" />
+ <xsd:attribute name="status_poisoned" type="xsd:boolean" />
+ <xsd:attribute name="status_stoned" type="xsd:boolean" />
+ <xsd:attribute name="status_stunned" type="xsd:boolean" />
+ <xsd:attribute name="status_slowed" type="xsd:boolean" />
+ <xsd:attribute name="status_tired" type="xsd:boolean" />
+ <xsd:attribute name="status_mad" type="xsd:boolean" />
+ <xsd:attribute name="status_berserk" type="xsd:boolean" />
+ <xsd:attribute name="status_hasted" type="xsd:boolean" />
+ <xsd:attribute name="status_floating" type="xsd:boolean" />
+ <!-- Status Effects Deletion -->
+ <xsd:attribute name="status_not_poisoned" type="xsd:boolean" />
+ <xsd:attribute name="status_not_stoned" type="xsd:boolean" />
+ <xsd:attribute name="status_not_stunned" type="xsd:boolean" />
+ <xsd:attribute name="status_not_slowed" type="xsd:boolean" />
+ <xsd:attribute name="status_not_tired" type="xsd:boolean" />
+ <xsd:attribute name="status_not_mad" type="xsd:boolean" />
+ <xsd:attribute name="status_not_berserk" type="xsd:boolean" />
+ <xsd:attribute name="status_not_hasted" type="xsd:boolean" />
+ <xsd:attribute name="status_not_floating" type="xsd:boolean" />
+ <item id="501" image="use-potion-cactusdrink.png" art="0" name="Cactus drink" description="A fresh drink" effect="+15 HP" type="0" weight="10" slot="0"/>
+ <item id="502" image="use-potion-cactuspotion.png" art="0" name="Cactus potion" description="A fresh potion" effect="+25 HP/+10 MP" type="0" weight="10" slot="0"/>
+ <item id="503" image="generic-casinocoins.png" art="0" name="Casino coins" description="Just some casino coins" effect="" type="0" weight="10" slot="0"/>
+ <item id="504" image="use-food-decorcandy.png" art="0" name="Decor candy" description="A leftover decor candy from last christmas" effect="" type="0" weight="10" slot="0"/>
+ <item id="505" image="generic-maggotslime.png" art="0" name="Maggot slime" description="Slimy Maggot slime" effect="" type="0" weight="10" slot="0"/>
+ <item id="506" image="use-food-candycane.png" art="0" name="Candy cane" description="Tasty candy cane" effect="+10 HP" type="0" weight="10" slot="0"/>
+ <item id="507" image="generic-scorpionstinger.png" art="0" name="Scorpion stinger" description="A poisoned scorpion stinger" effect="" type="0" weight="10" slot="0"/>
+ <item id="508" image="use-food-xmascake.png" art="0" name="Xmas cake" description="A sweet xmas cake" effect="+10 HP" type="0" weight="10" slot="0"/>
+ <item id="509" image="use-food-chocolatebar.png" art="0" name="Chocolate bar" description="A chocolate bar made of finest chocolate" effect="+20 HP" type="0" weight="10" slot="0"/>
+ <item id="510" image="use-food-candy.png" art="0" name="Candy" description="A sugar-free candy" effect="+ 5 HP" type="0" weight="10" slot="0"/>
+ <item id="511" image="armor-head-santahat.png" art="0" name="Santa hat" description="Ask Santa about this hat" effect="Defense: +2" type="0" weight="10" slot="0"/>
+ <item id="512" image="use-food-gingerbreadman.png" art="0" name="Ginger bread man" description="A tasty ginger bread man" effect="+25 HP" type="0" weight="10" slot="0"/>
+ <item id="513" image="use-food-cake.png" art="0" name="Cake" description="A slice of cake" effect="+15 HP" type="0" weight="10" slot="0"/>
+ <item id="514" image="use-food-xmascandycane.png" art="0" name="Xmas candy cane" description="A special xmas candy cane" effect="+10 HP" type="0" weight="10" slot="0"/>
+ <item id="515" image="generic-purplepresentbox.png" art="0" name="Purple present box" description="Something mysterious inside" effect="" type="0" weight="10" slot="0"/>
+ <item id="516" image="generic-bluepresentbox.png" art="0" name="Blue present box" description="Something mysterious inside" effect="" type="0" weight="10" slot="0"/>
+ <item id="517" image="generic-redscorpionstinger.png" art="0" name="Red scorpion stinger" description="A highly poisoned red scorpion stinger" effect="" type="0" weight="10" slot="0"/>
+ <item id="518" image="generic-bugleg.png" art="0" name="Bug leg" description="A bug's leg. Mostly used for alchemy" effect="" type="0" weight="10" slot="0"/>
+ <item id="519" image="use-food-cherrycake.png" art="0" name="Cherry cake" description="A nice cherry cake" effect="+35 HP" type="0" weight="10" slot="0"/>
+ <item id="520" image="use-food-easteregg.png" art="0" name="Easter egg" description="A surprise" effect="+100 HP" type="0" weight="10" slot="0"/>
+ <item id="521" image="weapon-dagger-dagger.png" art="0" name="Dagger" description="A simple Dagger" effect="Damage: +15 / Range: 1" type="0" weight="10" slot="0"/>
+ <item id="522" image="weapon-dagger-sharpknife.png" art="0" name="Sharp knife" description="A really sharp knife Don't hurt yourself!" effect="Damage: +10 / Range: 1" type="0" weight="10" slot="0"/>
+ <item id="523" image="armor-chest-leathershirt.png" art="0" name="Leather shirt" description="A shirt made of harded leather" effect="Defense: +4" type="0" weight="10" slot="0"/>
+ <item id="524" image="armor-head-fancyhat.png" art="0" name="Fancy hat" description="A fancy hat" effect="Defense: +5" type="0" weight="10" slot="0"/>
+ <item id="525" image="armor-head-minershat.png" art="0" name="Miners hat" description="A hat used by miners" effect="Defense: +4" type="0" weight="10" slot="0"/>
+ <item id="526" image="generic-coinbag.png" art="0" name="Coin bag" description="A bag used to transport coins in it If you own it you can take more coins with you" effect="" type="0" weight="10" slot="0"/>
+ <item id="527" image="use-food-milk.png" art="0" name="Milk" description="A fresh litre of ice cold milk Note: Cool people drink milk!" effect="+150 HP" type="0" weight="10" slot="0"/>
+ <item id="528" image="armor-feet-boots.png" art="0" name="Boots" description="Some robust boots, ideal for wandering" effect="Defense: +2" type="0" weight="10" slot="0"/>
+ <item id="529" image="weapon-arrow-iron.png" art="0" name="Iron arrow" description="A hard arrow made of iron" effect="Damage: +50" type="0" weight="10" slot="0"/>
+ <item id="530" image="weapon-bow-shortbow.png" art="0" name="Short bow" description="A bow for short distances" effect="Damage: +50 / Range: 5" type="0" weight="10" slot="0"/>
+ <item id="531" image="armor-hands-minergloves.png" art="0" name="Miner gloves" description="Gloves used by miners, very useful" effect="Defense: +2" type="0" weight="10" slot="0"/>
+ <item id="532" image="armor-hands-leathergloves.png" art="0" name="Leather gloves" description="Gloves made of harded leather" effect="Defense: +3" type="0" weight="10" slot="0"/>
+ <item id="533" image="use-food-roastedmaggot.png" art="0" name="Roasted maggot" description="Maggot roasted on fire" effect="+150 HP" type="0" weight="10" slot="0"/>
+ <item id="534" image="use-food-orangecupcake.png" art="0" name="Orange cupcake" description="A very soft orange cupcake" effect="+100 HP / +10 MP" type="0" weight="10" slot="0"/>
+ <item id="535" image="use-food-apple.png" art="0" name="Apple" description="A healthy apple" effect="+50 HP" type="0" weight="10" slot="0"/>
+ <item id="536" image="weapon-dagger-shortsword.png" art="0" name="Short sword" description="A small but sharp sword" effect="Damage: +100 / Range: 1" type="0" weight="10" slot ="0"/>
+ <item id="537" image="generic-treasurekey.png" art="0" name="Treasure key" description="A rusty key" effect="Opens Chests" type="0" weight="10" slot="0"/>
+ <item id="538" image="generic-greenpresentbox.png" art="0" name="Green present box" description="Something mysterious inside" effect="" type="0" weight="10" slot="0"/>
+ <item id="539" image="use-food-beer.png" art="0" name="Beer" description="A fresh beer" effect="+200 HP" type="0" weight="10" slot="0"/>
+ <item id="540" image="generic-emptybottle.png" art="0" name="Empty bottle" description="An empty bottle" effect="" type="0" weight="10" slot="0"/>
+ <item id="541" image="use-food-bottleofwater.png" art="0" name="Bottle of water" description="A bottle of water" effect="+250 HP" type="0" weight="10" slot="0"/>
+ <item id="542" image="generic-bottleofsand.png" art="0" name="Bottle of sand" description="A bottle with sand in it" effect="" type="0" weight="10" slot="0"/>
+ <item id="543" image="armor-head-standardheadband.png" art="0" name="Standard headband" description="Just a standard headband" effect="Defense: +1" type="0" weight="10" slot="0"/>
+ <item id="544" image="armor-head-silkheadband.png" art="0" name="Silk headband" description="A cool headband made of silk" effect="Defense: +3" type="0" weight="10" slot="0"/>
+ <item id="545" image="weapon-bow-forestbow.png" art="0" name="Forest bow" description="A bow usually used to hunt" effect="Damage: +65 / Range: 5" type="0" weight="10" slot="0"/>
+ <item id="546" image="armor-chest-desertshirt.png" art="0" name="Desert shirt" description="A shirt suitable for desert trips" effect="Defense: +6" type="0" weight="10" slot="0"/>
+ <item id="547" image="weapon-polearm-bardiche.png" art="0" name="Bardiche" description="A Bardiche" effect="Damage +100" type="0" weight="10" slot="0"/>
+ <item id="548" image="weapon-polearm-halberd.png" art="0" name="Halberd" description="A weapon usually carried by guards" effect="Damage +100" type="0" weight="10" slot="0"/>
+ <item id="549" image="weapon-axe-axe.png" art="0" name="Axe" description="An axe" effect="Damage +100" type="0" weight="10" slot="0"/>
+ <item id="550" image="weapon-axe-blacksmithsaxe.png" art="0" name="Blacksmith's axe" description="An axe usually used by blacksmiths" effect="Damage +100" type="0" weight="10" slot="0"/>
+ <item id="551" image="generic-bluehint.png" art="0" name="Hint" description="A hint" effect="" type="0" weight="10" slot="0"/>
+ <item id="552" image="generic-magentahint.png" art="0" name="Hint" description="A hint" effect="" type="0" weight="10" slot="0"/>
+ <item id="553" image="generic-yellowhint.png" art="0" name="Hint" description="A hint" effect="" type="0" weight="10" slot="0"/>
+ <item id="554" image="generic-greenhint.png" art="0" name="Hint" description="A hint" effect="" type="0" weight="10" slot="0"/>
+ <item id="555" image="generic-tealhint.png" art="0" name="Hint" description="A hint" effect="" type="0" weight="10" slot="0"/>
+ <item id="556" image="generic-purplehint.png" art="0" name="Hint" description="A hint" effect="" type="0" weight="10" slot="0"/>
+ <item id="557" image="generic-redhint.png" art="0" name="Hint" description="A hint" effect="" type="0" weight="10" slot="0"/>
+ <item id="558" image="generic-otherbluehint.png" art="0" name="Hint" description="A hint" effect="" type="0" weight="10" slot="0"/>
+ <item id="559" image="generic-orangehint.png" art="0" name="Hint" description="A hint" effect="" type="0" weight="10" slot="0"/>
+ <item id="560" image="generic-greyhint.png" art="0" name="Hint" description="A hint" effect="" type="0" weight="10" slot="0"/>
+ <item id="561" image="weapon-sword-sabre.png" art="0" name="Sabre" description="A sword with a very sharp, curved, single-edged blade" effect="" type="0" weight="10" slot="0"/>
+ <item id="562" image="use-food-chickenleg.png" art="0" name="Chicken leg" description="A well cooked chicken leg" effect="" type="0" weight="10" slot="0"/>
+ <item id="563" image="armor-hands-wintergloves.png" art="0" name="Winter gloves" description="Soft and warm gloves" effect="" type="0" weight="10" slot="0"/>
+ <item id="564" image="armor-chest-woolsweater.png" art="0" name="Wool sweater" description="Soft and warm sweater" effect="" type="0" weight="10" slot="0"/>
+ <item id="565" image="generic-petal.png" art="0" name="Petal" description="A petal from an evil flower" effect="" type="0" weight="10" slot="0"/>
+ <item id="566" image="generic-smallmushroom.png" art="0" name="Small mushroom" description="A mushroom" effect="" type="0" weight="10" slot="0"/>
+ <item id="567" image="use-potion-ironpotion.png" art="0" name="Iron potion" description="Increases your attack strenght" effect="" type="0" weight="10" slot="0"/>
+ <item id="568" image="use-potion-concentrationpotion.png" art="0" name="Concentration potion" description="Increases your attack speed" effect="" type="0" weight="10" slot="0"/>
+ <item id="569" image="generic-rawlog.png" art="0" name="Raw log" description="A raw log" effect="" type="0" weight="10" slot="0"/>
+ <item id="570" image="weapon-dagger-boneknife.png" art="0" name="Bone knife" description="A knife masterly carved out of a bone" effect="Damage: +50 " type="0" weight="10" slot="0"/>
+ <item id="571" image="weapon-dagger-setzer.png" art="0" name="Setzer" description="A knife named after a famous gambler" effect="Damage: +50 " type="0" weight="10" slot="0"/>
+ <item id="572" image="weapon-sword-scimitar.png" art="0" name="Scimitar" description="A sword with a heavy, curved, single-edged blade" effect="Damage: +50 " type="0" weight="10" slot="0"/>
+ <item id="573" image="weapon-sword-falchion.png" art="0" name="Falcion" description="A heavy one-handed, single-edged sword." effect="Damage: +50 " type="0" weight="10" slot="0"/>
+ <item id="574" image="weapon-polearm-scorpion.png" art="0" name="Scorpion" description="A well crafted glaive" effect="Damage: +50 " type="0" weight="10" slot="0"/>
+ <item id="575" image="weapon-bow-desertbow.png" art="0" name="Desert bow" description="A tonorian short bow" effect="Damage: +50 " type="0" weight="10" slot="0"/>
+ <item id="576" image="weapon-sword-beheader.png" art="0" name="Beheader" description="An oddly designed sword especially made for beheading enemies." effect="Damage: +50 " type="0" weight="10" slot="0"/>
+ <item id="577" image="weapon-thrown-bonedarts.png" art="0" name="Bone darts" description="Some darts made of bones" effect="Damage: +50 " type="0" weight="10" slot="0"/>
+ <item id="578" image="weapon-sword-sandcutter.png" art="0" name="Sand cutter" description="A sand cutter" effect="Damage: +50 " type="0" weight="10" slot="0"/>
+ <item id="579" image="weapon-dagger-rockknive.png" art="0" name="Rock knife" description="A knife made of stone" effect="Damage: +300 " type="0" weight="10" slot="0"/>
+ <item id="580" image="weapon-staff-staffoflife.png" art="0" name="Staff of life" description="A staff that increases healing magic." effect="Damage: +50 " type="0" weight="10" slot="0"/>
+ <item id="581" image="weapon-staff-crescentrod.png" art="0" name="Crescent rod" description="A crescent rod" effect="Damage: +50 " type="0" weight="10" slot="0"/>
+ <item id="582" image="weapon-staff-staffoffire.png" art="0" name="Staff of fire" description="A staff that increases fire magic." effect="Damage: +50 " type="0" weight="10" slot="0"/>
+ <item id="583" image="weapon-staff-staffofice.png" art="0" name="Staff of ice" description="A staff that increases ice magic." effect="Damage: +50 " type="0" weight="10" slot="0"/>
+ <item id="584" image="weapon-sword-jackal.png" art="0" name="Jackal" description="A jackal" effect="Damage: +50 " type="0" weight="10" slot="0"/>
+ <item id="585" image="armor-hands-scarabarmlet.png" art="0" name="Scarab Armlet" description="A scarab armlet" effect="Defense: +50 " type="0" weight="10" slot="0"/>
+ <item id="586" image="armor-legs-cottonshorts.png" art="0" name="Cotton shorts" description="Shorts made of 100% cotton" effect="Defense: +2" type="0" weight="10" slot="0"/>
+ <item id="587" image="weapon-sword-sword.png" art="0" name="Sword" description="A simple but reliable swor." effect="" type="0" weight="10" slot="0"/>
+ <item id="588" image="weapon-sword-bastardsword.png" art="0" name="Bastard Sword" description="A large two handed sword" effect="" type="0" weight="10" slot="0"/>
+ <item id="589" image="weapon-sword-broadsword.png" art="0" name="Broad Sword" description="A two handed sword with a very broad blade" effect="" type="0" weight="10" slot="0"/>
+ <item id="588" image="weapon-sword-baselard.png" art="0" name="Baselard" description="A short and powerful sword" effect="" type="0" weight="10" slot="0"/>
+ <item id="591" image="weapon-sword-longsword.png" art="0" name="Long Sword" description="A sword with a long and agile blade" effect="" type="0" weight="10" slot="0"/>
+ <item id="592" image="weapon-dagger-stiletto.png" art="0" name="Stiletto" description="A dagger with a long and thin blade" effect="" type="0" weight="10" slot="0"/>
+ <item id="593" image="weapon-sword-rapier.png" art="0" name="Rapier" description="A light sword made for duels" effect="" type="0" weight="10" slot="0"/>
+ <item id="594" image="weapon-polearm-spear.png" art="0" name="Spear" description="A light spear with a wooden pole" effect="" type="0" weight="10" slot="0"/>
+ <item id="595" image="weapon-polearm-heavyspear.png" art="0" name="Heavy Spear" description="A heavy spear with a wooden pole" effect="" type="0" weight="10" slot="0"/>
+ <item id="596" image="weapon-polearm-pike.png" art="0" name="" description="Pike" effect="A light spear with an iron pole" type="0" weight="10" slot="0"/>
+ <item id="597" image="weapon-polearm-heavypike.png" art="0" name="" description="Heavy Pike" effect="A heavy spear with an iron pole" type="0" weight="10" slot="0"/>
+ <item id="598" image="weapon-polearm-dualspear.png" art="0" name="Dual Spear" description="A spear with two tops" effect="" type="0" weight="10" slot="0"/>
+ <item id="599" image="weapon-sword-firesword.png" art="0" name="Fire Sword" description="A magical sword enchanted with the power of fire." effect="" type="0" weight="10" slot="0"/>
+ <item id="600" image="armor-shield-britshield.png" art="0" name="Brit Shield" description="Legendary shield that is said to save queens and rule waves" effect="Cooking: -50" type="0" weight="10" slot="0"/>
+ <item id="601" image="armor-shield-steelshield.png" art="0" name="Steel Shield" description="A shield made of steel" effect="" type="0" weight="10" slot="0"/>
+ <item id="602" image="armor-shield-woodenshield.png" art="0" name="Wooden Shield" description="A shield made of wood" effect="" type="0" weight="10" slot="0"/>
+ <item id="603" image="armor-shield-leathershield.png" art="0" name="Leather Shield" description="A shield made of leather on a wooden frame" effect="" type="0" weight="10" slot="0"/>
+ <item id="604" image="armor-shield-knightshield.png" art="0" name="Knight Shield" description="A high quality shield used by knights" effect="" type="0" weight="10" slot="0"/>
+ <item id="605" image="weapon-axe-meatcleaver.png" art="0" name="Meat Cleaver" description="A butchers tool that also makes a nice one handed battleaxe" effect="" type="0" weight="10" slot="0"/>
+ <item id="606" image="weapon-axe-hatchet.png" art="0" name="Hatchet" description="A short one handed axe" effect="" type="0" weight="10" slot="0"/>
+ <item id="607" image="weapon-polearm-trident.png" art="0" name="Trident" description="A spear with three heads" effect="" type="0" weight="10" slot="0"/>
+ <item id="608" image="armor-shield-bladeshield.png" art="0" name="A shield made of blades" description="" effect="" type="0" weight="10" slot="0"/>
+ <item id="609" image="weapon-mace-club.png" art="0" name="Club" description="A primitive wooden club" effect="" type="0" weight="10" slot="0"/>
+ <item id="610" image="armor-legs-jeanshorts.png" art="0" name="Jeans shorts" description="Shorts made of jeans" effect="Defense: +4" type="0" weight="10" slot="0"/>
+ <item id="611" image="generic-whitefur.png" art="0" name="White fur" description="A patch of white, fluffy fur." effect="" type="0" weight="10" slot="0"/>
+ <item id="612" image="generic-cavesnakelamp.png" art="0" name="Cave snake lamp" description="Feeler of a lamp snake that glows in the dark." effect="" type="0" weight="10" slot="0"/>
+ <item id="613" image="generic-hardspike.png" art="0" name="Hard spike" description="A hard spike of a slain monster" effect="" type="0" weight="10" slot="0"/>
+ <item id="614" image="generic-pinkantennae.png" art="0" name="Pink antennae" description="Noone knows why violets got these antennaes." effect="" type="0" weight="10" slot="0"/>
+ <item id="1199" image="weapon-arrow-arrow.png" art="0" name="Arrow" description="A standard arrow" effect="Damage: +25" type="0" weight="10" slot="0"/>
+ <item id="1200" image="weapon-bow-bow.png" art="0" name="Bow" description="A distance weapon" effect="Damage: +15 / Range: 5" type="0" weight="10" slot="0"/>
+ <item id="1201" image="weapon-dagger-knive.png" art="0" name="Knife" description="A small knife, the perfect weapon for a beginner" effect="Damage: 5 / Range: 1" type="0" weight="10" slot="0"/>
+ <item id="1202" image="armor-chest-cottonshirt.png" art="0" name="Cotton shirt" description="A shirt made of 100% cotton" effect="Defense: +2" type="0" weight="10" slot="0"/>
+</items> \ No newline at end of file
diff --git a/data/items.xsd b/data/items.xsd
new file mode 100644
index 00000000..e0bf4ed2
--- /dev/null
+++ b/data/items.xsd
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <!-- ITEMS LIST FILE SCHEMA -->
+
+ <xsd:element name="items">
+ <xsd:complexType>
+ <xsd:sequence>
+
+ <xsd:element name="item" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:positiveInteger">
+ <!-- General -->
+ <xsd:attribute name="id" type="xsd:positiveInteger" />
+ <xsd:attribute name="weight" type="xsd:integer" />
+ <xsd:attribute name="value" type="xsd:integer" />
+ <xsd:attribute name="script_name" type="xsd:string" />
+ <!-- Modifiers -->
+ <xsd:attribute name="element" type="xsd:integer" />
+ <xsd:attribute name="lifetime" type="xsd:positiveInteger" />
+ <!-- Raw Statistics -->
+ <xsd:attribute name="strength" type="xsd:integer" />
+ <xsd:attribute name="agility" type="xsd:integer" />
+ <xsd:attribute name="vitality" type="xsd:integer" />
+ <xsd:attribute name="intelligence" type="xsd:integer" />
+ <xsd:attribute name="dexterity" type="xsd:integer" />
+ <xsd:attribute name="luck" type="xsd:integer" />
+ <!-- Computed Statistics -->
+ <xsd:attribute name="heat" type="xsd:integer" />
+ <xsd:attribute name="attack" type="xsd:integer" />
+ <xsd:attribute name="defence" type="xsd:integer" />
+ <xsd:attribute name="magic" type="xsd:integer" />
+ <xsd:attribute name="accuracy" type="xsd:integer" />
+ <xsd:attribute name="speed" type="xsd:integer" />
+ <!-- Main Values -->
+ <xsd:attribute name="hp" type="xsd:integer" />
+ <xsd:attribute name="mp" type="xsd:integer" />
+ <!-- Equipment -->
+ <xsd:attribute name="range" type="xsd:integer" />
+ <!-- Status Effects Addition -->
+ <xsd:attribute name="status_normal" type="xsd:boolean" />
+ <xsd:attribute name="status_poisoned" type="xsd:boolean" />
+ <xsd:attribute name="status_stoned" type="xsd:boolean" />
+ <xsd:attribute name="status_stunned" type="xsd:boolean" />
+ <xsd:attribute name="status_slowed" type="xsd:boolean" />
+ <xsd:attribute name="status_tired" type="xsd:boolean" />
+ <xsd:attribute name="status_mad" type="xsd:boolean" />
+ <xsd:attribute name="status_berserk" type="xsd:boolean" />
+ <xsd:attribute name="status_hasted" type="xsd:boolean" />
+ <xsd:attribute name="status_floating" type="xsd:boolean" />
+ <!-- Status Effects Deletion -->
+ <xsd:attribute name="status_not_poisoned" type="xsd:boolean" />
+ <xsd:attribute name="status_not_stoned" type="xsd:boolean" />
+ <xsd:attribute name="status_not_stunned" type="xsd:boolean" />
+ <xsd:attribute name="status_not_slowed" type="xsd:boolean" />
+ <xsd:attribute name="status_not_tired" type="xsd:boolean" />
+ <xsd:attribute name="status_not_mad" type="xsd:boolean" />
+ <xsd:attribute name="status_not_berserk" type="xsd:boolean" />
+ <xsd:attribute name="status_not_hasted" type="xsd:boolean" />
+ <xsd:attribute name="status_not_floating" type="xsd:boolean" />
+ </xsd:extension>
+ </xsd:simpleContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+</xsd:schema>
diff --git a/src/Makefile.am b/src/Makefile.am
index 40631398..fbd3bd8b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -43,8 +43,8 @@ tmwserv_SOURCES = main.cpp \
inventory.cpp \
item.h \
item.cpp \
- itemhandler.h \
- itemhandler.cpp \
+ itemmanager.h \
+ itemmanager.cpp \
map.h \
map.cpp \
mapcomposite.h \
diff --git a/src/being.h b/src/being.h
index 2782a265..fb6e837a 100644
--- a/src/being.h
+++ b/src/being.h
@@ -33,15 +33,83 @@
class Controller;
/**
+ * Element attribute for beings, actors and items.
+ */
+typedef enum {
+ ELEMENT_NEUTRAL = 0,
+ ELEMENT_FIRE,
+ ELEMENT_WATER,
+ ELEMENT_EARTH,
+ ELEMENT_AIR,
+ ELEMENT_SACRED,
+ ELEMENT_DEATH
+} Element;
+
+/**
+ * States attribute for beings, and actors.
+ * States can be multiple for the same being.
+ */
+struct BeingState {
+ bool STATE_NORMAL;
+ bool STATE_POISONED;
+ bool STATE_STONED;
+ bool STATE_STUNNED;
+ bool STATE_SLOWED;
+ bool STATE_TIRED;
+ bool STATE_MAD;
+ bool STATE_BERSERK;
+ bool STATE_HASTED;
+ bool STATE_FLOATING;
+};
+
+/**
+ * Moves enum for beings and actors for others players vision.
+ */
+typedef enum {
+ ACTION_DEFAULT = 0,
+ ACTION_STAND,
+ ACTION_WALK,
+ ACTION_RUN,
+ ACTION_JUMP,
+ ACTION_CRAWL,
+ ACTION_ATTACK,
+ ACTION_ATTACK_SWING,
+ ACTION_ATTACK_STAB,
+ ACTION_ATTACK_BOW,
+ ACTION_ATTACK_THROW,
+ ACTION_CAST_MAGIC,
+ ACTION_USE_ITEM,
+ ACTION_SIT,
+ ACTION_SLEEP,
+ ACTION_HURT,
+ ACTION_DEAD,
+ ACTION_INVALID
+} SpriteAction;
+
+/**
+ * Beings and actors directions
+ */
+typedef enum {
+ DIRECTION_NORTH,
+ DIRECTION_NORTHWEST,
+ DIRECTION_NORTHEAST,
+ DIRECTION_WEST,
+ DIRECTION_EAST,
+ DIRECTION_SOUTH,
+ DIRECTION_SOUTHWEST,
+ DIRECTION_SOUTHEAST
+} SpriteDirection;
+
+/**
* Raw statistics of a Player.
*/
enum {
- STAT_STR = 0,
- STAT_AGI,
- STAT_VIT,
- STAT_INT,
- STAT_DEX,
- STAT_LUK,
+ STAT_STRENGTH = 0,
+ STAT_AGILITY,
+ STAT_VITALITY,
+ STAT_INTELLIGENCE,
+ STAT_DEXTERITY,
+ STAT_LUCK,
NB_RSTAT
};
@@ -57,12 +125,12 @@ struct RawStatistics
* Computed statistics of a Being.
*/
enum {
- STAT_HEA = 0,
- STAT_ATT,
- STAT_DEF,
- STAT_MAG,
- STAT_ACC,
- STAT_SPD,
+ STAT_HEAT = 0,
+ STAT_ATTACK,
+ STAT_DEFENCE,
+ STAT_MAGIC,
+ STAT_ACCURACY,
+ STAT_SPEED,
NB_CSTAT
};
diff --git a/src/dalstorage.cpp b/src/dalstorage.cpp
index 87387352..44e702ef 100644
--- a/src/dalstorage.cpp
+++ b/src/dalstorage.cpp
@@ -645,12 +645,12 @@ void DALStorage::flush(AccountPtr const &account)
<< (*it)->getPosition().x << ", "
<< (*it)->getPosition().y << ", "
<< (*it)->getMapId() << ", "
- << (*it)->getRawStat(STAT_STR) << ", "
- << (*it)->getRawStat(STAT_AGI) << ", "
- << (*it)->getRawStat(STAT_VIT) << ", "
- << (*it)->getRawStat(STAT_INT) << ", "
- << (*it)->getRawStat(STAT_DEX) << ", "
- << (*it)->getRawStat(STAT_LUK) << ");";
+ << (*it)->getRawStat(STAT_STRENGTH) << ", "
+ << (*it)->getRawStat(STAT_AGILITY) << ", "
+ << (*it)->getRawStat(STAT_VITALITY) << ", "
+ << (*it)->getRawStat(STAT_INTELLIGENCE) << ", "
+ << (*it)->getRawStat(STAT_DEXTERITY) << ", "
+ << (*it)->getRawStat(STAT_LUCK) << ");";
// get the character id
std::ostringstream sql2;
@@ -677,16 +677,16 @@ void DALStorage::flush(AccountPtr const &account)
<< " x = " << (*it)->getPosition().x << ", "
<< " y = " << (*it)->getPosition().y << ", "
<< " map_id = " << (*it)->getMapId() << ", "
- << " str = " << (*it)->getRawStat(STAT_STR) << ", "
- << " agi = " << (*it)->getRawStat(STAT_AGI) << ", "
- << " vit = " << (*it)->getRawStat(STAT_VIT) << ", "
+ << " str = " << (*it)->getRawStat(STAT_STRENGTH) << ", "
+ << " agi = " << (*it)->getRawStat(STAT_AGILITY) << ", "
+ << " vit = " << (*it)->getRawStat(STAT_VITALITY) << ", "
#if defined(MYSQL_SUPPORT) || defined(POSTGRESQL_SUPPORT)
- << " `int` = " << (*it)->getRawStat(STAT_INT) << ", "
+ << " `int` = " << (*it)->getRawStat(STAT_INTELLIGENCE) << ", "
#else
- << " int = " << (*it)->getRawStat(STAT_INT) << ", "
+ << " int = " << (*it)->getRawStat(STAT_INTELLIGENCE) << ", "
#endif
- << " dex = " << (*it)->getRawStat(STAT_DEX) << ", "
- << " luck = " << (*it)->getRawStat(STAT_LUK)
+ << " dex = " << (*it)->getRawStat(STAT_DEXTERITY) << ", "
+ << " luck = " << (*it)->getRawStat(STAT_LUCK)
<< " where id = " << (*it)->getDatabaseID() << ";";
}
mDb->execSql(sql3.str());
diff --git a/src/item.cpp b/src/item.cpp
index b0008134..660fa7b7 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -23,12 +23,26 @@
#include "item.h"
-void Item::use(BeingPtr itemUser)
+bool Item::use(BeingPtr itemUser)
{
- //
+ bool usedSuccessfully = true;
+ // Applying Modifiers for a given lifetime
+ // TODO
+
+ // Calling a script if scriptName != ""
+ if (mScriptName != "")
+ {
+ if(runScript(itemUser) && usedSuccessfully)
+ return true;
+ else
+ return false;
+ }
+ else
+ return usedSuccessfully;
}
-void Item::useWithScript(const std::string scriptFile)
+bool Item::runScript(BeingPtr itemUser)
{
- //
+ //TODO
+ return true;
}
diff --git a/src/item.h b/src/item.h
index 302c4f6a..2015a029 100644
--- a/src/item.h
+++ b/src/item.h
@@ -29,9 +29,12 @@
/**
* Enumeration of available Item types.
*/
-enum {
- ITEM_USABLE = 0,
- ITEM_EQUIPMENT_WEAPON,
+typedef enum {
+ ITEM_USABLE = 1,
+ ITEM_EQUIPMENT_ONE_HAND_WEAPON,
+ ITEM_EQUIPMENT_TWO_HANDS_WEAPON,
+ ITEM_EQUIPMENT_ONE_HAND_RANGED_WEAPON,
+ ITEM_EQUIPMENT_TWO_HANDS_RANGED_WEAPON,
ITEM_EQUIPMENT_BREST,
ITEM_EQUIPMENT_ARMS,
ITEM_EQUIPMENT_HEAD,
@@ -39,19 +42,57 @@ enum {
ITEM_EQUIPMENT_SHIELD,
ITEM_EQUIPMENT_RING,
ITEM_EQUIPMENT_NECKLACE
+} ItemType;
+
+/**
+ * States attribute effects to beings, and actors.
+ * States can be multiple for the same being.
+ */
+struct BeingStateEffects {
+ bool STATE_NORMAL;
+ bool STATE_POISONED;
+ bool STATE_STONED;
+ bool STATE_STUNNED;
+ bool STATE_SLOWED;
+ bool STATE_TIRED;
+ bool STATE_MAD;
+ bool STATE_BERSERK;
+ bool STATE_HASTED;
+ bool STATE_FLOATING;
+
+ bool STATE_NOT_POISONED;
+ bool STATE_NOT_STONED;
+ bool STATE_NOT_STUNNED;
+ bool STATE_NOT_SLOWED;
+ bool STATE_NOT_TIRED;
+ bool STATE_NOT_MAD;
+ bool STATE_NOT_BERSERK;
+ bool STATE_NOT_HASTED;
+ bool STATE_NOT_FLOATING;
};
+
/**
* statistics modifiers.
* once for usables.
* Permanent for equipment.
*/
-struct StatisticsModifiers
+struct Modifiers
{
- short rawStatsMod[NB_RSTAT]; /**< Raw Stats modifiers */
- short compStatsMod[NB_CSTAT]; /**< Computed Stats modifiers */
+ // General
+ Element element; /** Item Element */
+ BeingStateEffects beingStateEffects; /** Being State (dis)alteration */
+ unsigned short lifetime; /** Modifiers lifetime in seconds. */
+
+ // Caracteristics Modifiers
+ short rawStats[NB_RSTAT];
+ short computedStats[NB_CSTAT];
+
int hpMod; /**< HP modifier */
int mpMod; /**< MP Modifier */
+
+ // Equipment
+ unsigned short range; /** Weapon Item Range */
/**< More to come */
};
@@ -64,15 +105,16 @@ class Item
{
public:
- Item(StatisticsModifiers statsModifiers,
- unsigned short mItemType = 0,
+ Item(Modifiers modifiers,
+ unsigned short itemType = 0,
unsigned int weight = 0,
- unsigned short slot = 0,
- unsigned int value = 0):
+ unsigned int value = 0,
+ std::string scriptName = ""):
+ mModifiers(modifiers),
+ mItemType(itemType),
mWeight(weight),
- mSlot(slot),
mValue(value),
- mStatsModifiers(statsModifiers) {}
+ mScriptName(scriptName) {}
virtual ~Item() throw() { }
@@ -80,47 +122,43 @@ class Item
* The function called to use an item applying
* only the modifiers (for simple items...)
*/
- void use(BeingPtr itemUser);
-
- /**
- * The function called to use an item
- * using a script (for complex actions)
- */
- void useWithScript(const std::string scriptFile);
+ bool use(BeingPtr itemUser);
/**
* Return item Type
*/
- unsigned short getItemType() const { return mItemType; }
+ unsigned short getItemType() const { return mItemType; };
/**
* Return Weight of item
*/
- unsigned int getWeight() const { return mWeight; }
-
- /**
- * Return usual slot of item
- */
- unsigned short getSlot() const { return mSlot; }
+ unsigned int getWeight() const { return mWeight; };
/**
* Return gold value of item
*/
- unsigned int getGoldValue() const { return mValue; }
+ unsigned int getGoldValue() const { return mValue; };
/**
* Return item's modifiers
*/
- StatisticsModifiers
- getItemStatsModifiers() const { return mStatsModifiers; }
+ Modifiers
+ getItemModifiers() const { return mModifiers; };
private:
- //Item type
+
+ /**
+ * Runs the associated script when using the item, if any.
+ */
+ bool runScript(BeingPtr itemUser);
+
+ // Item reference information
unsigned short mItemType; /**< ItemType: Usable, equipment */
unsigned int mWeight; /**< Weight of the item */
- unsigned short mSlot; /**< Current slot of the item */
unsigned int mValue; /**< Gold value of the item */
- StatisticsModifiers mStatsModifiers; /**< Stats Mod of the items */
+ std::string mScriptName; /**< item's script. None if =="" */
+
+ Modifiers mModifiers; /**< Item's Modifiers */
};
/**
diff --git a/src/itemmanager.cpp b/src/itemmanager.cpp
new file mode 100644
index 00000000..2b480397
--- /dev/null
+++ b/src/itemmanager.cpp
@@ -0,0 +1,193 @@
+/*
+ * The Mana World
+ * Copyright 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id:$
+ */
+
+#include "itemmanager.h"
+
+#include "resourcemanager.h"
+#include "utils/logger.h"
+#include <libxml/tree.h>
+
+#define READ_PROP(node, prop, name, target, cast) \
+ prop = xmlGetProp(node, BAD_CAST name); \
+ if (prop) { \
+ target = cast((const char*)prop); \
+ xmlFree(prop); \
+ }
+
+ItemManager::ItemManager(std::string itemReferenceFile)
+{
+ ResourceManager *resman = ResourceManager::getInstance();
+ int size;
+ char *data = (char*)resman->loadFile(itemReferenceFile, size);
+
+ if (!data) {
+ LOG_ERROR("Item Manager: Could not find " << itemReferenceFile << "!", 0);
+ free(data);
+ }
+ else
+ {
+ xmlDocPtr doc = xmlParseMemory(data, size);
+ free(data);
+
+ if (!doc)
+ {
+ LOG_ERROR("Item Manager: Error while parsing item database ("
+ << itemReferenceFile << ")!", 0);
+ }
+ else
+ {
+ xmlNodePtr node = xmlDocGetRootElement(doc);
+ if (!node || !xmlStrEqual(node->name, BAD_CAST "items"))
+ {
+ LOG_ERROR("Item Manager: " << itemReferenceFile
+ << " is not a valid database file!", 0);
+ }
+
+ unsigned int nbItems = 0;
+ for (node = node->xmlChildrenNode; node != NULL; node = node->next)
+ {
+ // Properties
+ unsigned int id = 0;
+ unsigned short itemType = 0;
+ unsigned int weight = 0;
+ unsigned int value = 0;
+ std::string scriptName = "";
+ Modifiers modifiers;
+
+ if (!xmlStrEqual(node->name, BAD_CAST "item")) {
+ continue;
+ }
+
+ xmlChar *prop = NULL;
+ // Properties
+ READ_PROP(node, prop, "id", id, atoi);
+ READ_PROP(node, prop, "type", itemType, atoi);
+ READ_PROP(node, prop, "weight", weight, atoi);
+ READ_PROP(node, prop, "value", value, atoi);
+ READ_PROP(node, prop, "script_name", scriptName, );
+
+ // --- Modifiers
+ // General
+ READ_PROP(node, prop, "element", modifiers.element, (Element)atoi);
+ READ_PROP(node, prop, "lifetime", modifiers.lifetime, atoi);
+ // Raw Statistics
+ READ_PROP(node, prop, "strength", modifiers.rawStats[STAT_STRENGTH], atoi);
+ READ_PROP(node, prop, "agility", modifiers.rawStats[STAT_AGILITY], atoi);
+ READ_PROP(node, prop, "vitality", modifiers.rawStats[STAT_VITALITY], atoi);
+ READ_PROP(node, prop, "intelligence", modifiers.rawStats[STAT_INTELLIGENCE], atoi);
+ READ_PROP(node, prop, "dexterity", modifiers.rawStats[STAT_DEXTERITY], atoi);
+ READ_PROP(node, prop, "luck", modifiers.rawStats[STAT_LUCK], atoi);
+ // Computed Statistics
+ READ_PROP(node, prop, "heat", modifiers.computedStats[STAT_HEAT], atoi);
+ READ_PROP(node, prop, "attack", modifiers.computedStats[STAT_ATTACK], atoi);
+ READ_PROP(node, prop, "defence", modifiers.computedStats[STAT_DEFENCE], atoi);
+ READ_PROP(node, prop, "magic", modifiers.computedStats[STAT_MAGIC], atoi);
+ READ_PROP(node, prop, "accuracy", modifiers.computedStats[STAT_ACCURACY], atoi);
+ READ_PROP(node, prop, "speed", modifiers.computedStats[STAT_SPEED], atoi);
+ // Main Values
+ READ_PROP(node, prop, "hp", modifiers.hpMod, atoi);
+ READ_PROP(node, prop, "mp", modifiers.mpMod, atoi);
+ // Equipment
+ READ_PROP(node, prop, "range", modifiers.range, atoi);
+ // Status effects addition
+ READ_PROP(node, prop, "status_normal",
+ modifiers.beingStateEffects.STATE_NORMAL, (bool)atoi);
+ READ_PROP(node, prop, "status_poisoned",
+ modifiers.beingStateEffects.STATE_POISONED, (bool)atoi);
+ READ_PROP(node, prop, "status_stoned",
+ modifiers.beingStateEffects.STATE_STONED, (bool)atoi);
+ READ_PROP(node, prop, "status_stunned",
+ modifiers.beingStateEffects.STATE_STUNNED, (bool)atoi);
+ READ_PROP(node, prop, "status_slowed",
+ modifiers.beingStateEffects.STATE_SLOWED, (bool)atoi);
+ READ_PROP(node, prop, "status_tired",
+ modifiers.beingStateEffects.STATE_TIRED, (bool)atoi);
+ READ_PROP(node, prop, "status_mad",
+ modifiers.beingStateEffects.STATE_MAD, (bool)atoi);
+ READ_PROP(node, prop, "status_berserk",
+ modifiers.beingStateEffects.STATE_BERSERK, (bool)atoi);
+ READ_PROP(node, prop, "status_hasted",
+ modifiers.beingStateEffects.STATE_HASTED, (bool)atoi);
+ READ_PROP(node, prop, "status_floating",
+ modifiers.beingStateEffects.STATE_FLOATING, (bool)atoi);
+ // Status Effects deletion
+ READ_PROP(node, prop, "status_not_poisoned",
+ modifiers.beingStateEffects.STATE_NOT_POISONED, (bool)atoi);
+ READ_PROP(node, prop, "status_not_stoned",
+ modifiers.beingStateEffects.STATE_NOT_STONED, (bool)atoi);
+ READ_PROP(node, prop, "status_not_stunned",
+ modifiers.beingStateEffects.STATE_NOT_STUNNED, (bool)atoi);
+ READ_PROP(node, prop, "status_not_slowed",
+ modifiers.beingStateEffects.STATE_NOT_SLOWED, (bool)atoi);
+ READ_PROP(node, prop, "status_not_tired",
+ modifiers.beingStateEffects.STATE_NOT_TIRED, (bool)atoi);
+ READ_PROP(node, prop, "status_not_mad",
+ modifiers.beingStateEffects.STATE_NOT_MAD, (bool)atoi);
+ READ_PROP(node, prop, "status_not_berserk",
+ modifiers.beingStateEffects.STATE_NOT_BERSERK, (bool)atoi);
+ READ_PROP(node, prop, "status_not_hasted",
+ modifiers.beingStateEffects.STATE_NOT_HASTED, (bool)atoi);
+ READ_PROP(node, prop, "status_not_floating",
+ modifiers.beingStateEffects.STATE_NOT_FLOATING, (bool)atoi);
+
+ // Checks
+ if (id != 0)
+ {
+ ItemPtr item(new Item(modifiers, itemType, weight, value, scriptName));
+ mItemReference[id] = item;
+ nbItems++;
+ }
+
+ if (id == 0)
+ {
+ LOG_WARN("Item Manager: An (ignored) item has no ID in "
+ << itemReferenceFile << "!", 0);
+ }
+ if (itemType == 0)
+ {
+ LOG_WARN("Item Manager: Missing Item Type for item: "
+ << id << " in " << itemReferenceFile << ".", 0);
+ }
+ if (weight == 0)
+ {
+ LOG_WARN("Item Manager: Missing weight for item: "
+ << id << " in " << itemReferenceFile << ".", 0);
+ }
+
+ LOG_INFO("Item: ID: " << id << ", itemType: " << itemType
+ << ", weight: " << weight << ", value: " << value <<
+ ", scriptName: " << scriptName << ".", 3);
+ //TODO: Log level 5 with everything
+ }
+
+ LOG_INFO("Loaded " << nbItems << " items from " << itemReferenceFile << ".", 0);
+
+ xmlFreeDoc(doc);
+ } // End if doc?
+ } // End if data?
+}
+
+ItemManager::~ItemManager()
+{
+ mItemReference.clear();
+}
diff --git a/src/itemmanager.h b/src/itemmanager.h
new file mode 100644
index 00000000..3a80db40
--- /dev/null
+++ b/src/itemmanager.h
@@ -0,0 +1,89 @@
+/*
+ * The Mana World
+ * Copyright 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id: $
+ */
+
+#ifndef _TMW_ITEMMANAGER_H
+#define _TMW_ITEMMANAGER_H
+
+#include "item.h"
+
+#include <map>
+
+/**
+ * The Item Manager loads the item reference database
+ * and also offers an API to items information, and more.
+ * For item objects, see the WorldItem class.
+ */
+class ItemManager
+{
+ public:
+ /**
+ * Constructor (loads item reference file)
+ */
+ ItemManager(std::string itemReferenceFile);
+
+ /**
+ * Destructor
+ */
+ ~ItemManager();
+
+ /**
+ * Gives an Item having the demanded information.
+ */
+ ItemPtr getItem(const unsigned int itemId)
+ { return mItemReference[itemId]; };
+
+ bool use(BeingPtr beingPtr, const unsigned int itemId)
+ { return mItemReference[itemId].get()->use(beingPtr); };
+
+ /**
+ * Return item Type
+ */
+ unsigned short getItemType(const unsigned int itemId)
+ { return mItemReference[itemId].get()->getItemType(); };
+
+ /**
+ * Return Weight of item
+ */
+ unsigned int getWeight(const unsigned int itemId)
+ { return mItemReference[itemId].get()->getWeight(); };
+
+ /**
+ * Return gold value of item
+ */
+ unsigned int getGoldValue(const unsigned int itemId)
+ { return mItemReference[itemId].get()->getGoldValue(); };
+
+ /**
+ * Return item's modifiers
+ */
+ Modifiers
+ getItemModifiers(const unsigned int itemId)
+ { return mItemReference[itemId].get()->getItemModifiers(); };
+
+ private:
+ std::map<unsigned int, ItemPtr> mItemReference; /**< Item reference */
+};
+
+extern ItemManager *itemManager;
+
+#endif
diff --git a/src/main.cpp b/src/main.cpp
index 24bf79af..9516efbd 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -42,6 +42,7 @@
#include "gamehandler.h"
#include "messageout.h"
#include "resourcemanager.h"
+#include "itemmanager.h"
#include "skill.h"
#include "state.h"
#include "storage.h"
@@ -74,8 +75,14 @@ std::string scriptLanugage = "none";
// Default options that automake should be able to override.
#define DEFAULT_LOG_FILE "tmwserv.log"
#define DEFAULT_CONFIG_FILE "tmwserv.xml"
+#define DEFAULT_ITEMSDB_FILE "items.xml"
+#define DEFAULT_MAP_FOLDER "maps"
+#define DEFAULT_DATA_FOLDER "data"
#ifndef DEFAULT_SERVER_PORT
#define DEFAULT_SERVER_PORT 9601
+// Meaning Account Handler Port is 9601
+// Chat Handler Port is 9602 (9601 + 1)
+// and Game Handler Port is 9603...
#endif
utils::Timer worldTimer(100, false); /**< Timer for world tics set to 100 ms */
@@ -95,6 +102,8 @@ AccountHandler *accountHandler;
ChatHandler *chatHandler;
/** Chat Channels Manager */
ChatChannelManager *chatChannelManager;
+/** Item Manager */
+ItemManager *itemManager;
/** Core game message handler */
GameHandler *gameHandler;
@@ -107,6 +116,13 @@ State *gameState;
*/
void initialize()
{
+
+ // Reset to default segmentation fault handling for debugging purposes
+ signal(SIGSEGV, SIG_DFL);
+
+ // Set enet to quit on exit.
+ atexit(enet_deinitialize);
+
/*
* If the path values aren't defined, we set the default
* depending on the platform.
@@ -141,7 +157,10 @@ void initialize()
#endif // defined LOG_FILE
- // initialize the logger.
+ // Initialize PhysicsFS
+ PHYSFS_init("");
+
+ // Initialize the logger.
using namespace utils;
Logger::instance().setLogFile(logPath);
@@ -152,31 +171,28 @@ void initialize()
LOG_INFO("Using Config File: " << configPath, 0);
LOG_INFO("Using Log File: " << logPath, 0);
- // Initialize the slang's filter.
+ // --- Initialize the managers
+ // Initialize the slang's and double quotes filter.
stringFilter = new StringFilter(&config);
+ // Initialize the Chat channels manager
+ chatChannelManager = new ChatChannelManager();
+ // Initialize the Item Manager
+ itemManager = new ItemManager(DEFAULT_DATA_FOLDER"/"DEFAULT_ITEMSDB_FILE);
- // Initialize the global handlers
+ // --- Initialize the global handlers
// FIXME: Make the global handlers global vars or part of a bigger
// singleton or a local variable in the event-loop
- chatChannelManager = new ChatChannelManager();
-
chatHandler = new ChatHandler();
accountHandler = new AccountHandler();
gameHandler = new GameHandler();
- // Reset to default segmentation fault handling for debugging purposes
- signal(SIGSEGV, SIG_DFL);
-
- // Set enet to quit on exit.
- atexit(enet_deinitialize);
-
- // Initialize enet.
+ // --- Initialize enet.
if (enet_initialize() != 0) {
LOG_FATAL("An error occurred while initializing ENet", 0);
exit(2);
}
- // Initialize scripting subsystem.
+ // --- Initialize scripting subsystem.
#ifdef RUBY_SUPPORT
LOG_INFO("Script Language: " << scriptLanguage, 0);
@@ -209,9 +225,6 @@ void initialize()
config.setValue("dbuser", "");
config.setValue("dbpass", "");
config.setValue("dbhost", "");
-
- // Initialize PhysicsFS
- PHYSFS_init("");
}
@@ -241,7 +254,9 @@ void deinitialize()
delete chatHandler;
delete gameHandler;
+ // Destroy Managers
delete chatChannelManager;
+ delete itemManager;
// Get rid of persistent data storage
Storage::destroy();
diff --git a/src/player.cpp b/src/player.cpp
index 70659efc..0be018d6 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -36,12 +36,12 @@ void Player::setDatabaseID(int id)
void Player::update()
{
// computed stats.
- setStat(STAT_HEA, 20 + (20 * mRawStats.stats[STAT_VIT]));
- setStat(STAT_ATT, 10 + mRawStats.stats[STAT_STR]);
- setStat(STAT_DEF, 10 + mRawStats.stats[STAT_STR]);
- setStat(STAT_MAG, 10 + mRawStats.stats[STAT_INT]);
- setStat(STAT_ACC, 50 + mRawStats.stats[STAT_DEX]);
- setStat(STAT_SPD, mRawStats.stats[STAT_DEX]);
+ setStat(STAT_HEAT, 20 + (20 * mRawStats.stats[STAT_VITALITY]));
+ setStat(STAT_ATTACK, 10 + mRawStats.stats[STAT_STRENGTH]);
+ setStat(STAT_DEFENCE, 10 + mRawStats.stats[STAT_STRENGTH]);
+ setStat(STAT_MAGIC, 10 + mRawStats.stats[STAT_INTELLIGENCE]);
+ setStat(STAT_ACCURACY, 50 + mRawStats.stats[STAT_DEXTERITY]);
+ setStat(STAT_SPEED, mRawStats.stats[STAT_DEXTERITY]);
}
void Player::setInventory(const std::vector<unsigned int> &inven)