merge from develop

This commit is contained in:
Enno Rehling 2018-05-15 21:59:01 +02:00
commit 0a9f8bf662
58 changed files with 779 additions and 1718 deletions

View file

@ -6,15 +6,12 @@
"config://conf/e2/locales.json",
"config://conf/e2/terrains.json",
"config://conf/e2/items.json",
"config://conf/e2/rules.xml",
"config://res/core/ships.xml",
"config://res/core/common/buildings.xml",
"config://res/eressea/buildings.xml",
"config://res/buildings/castle.xml",
"config://res/eressea/races.xml",
"config://res/eressea/artrewards.xml",
"config://res/eressea/familiars.xml",
"config://res/eressea/equipment.xml",
"config://res/eressea/spells.xml",
"config://res/eressea/spellbooks/gray.xml",
"config://res/eressea/spellbooks/gwyrrd.xml",

View file

@ -1,27 +0,0 @@
<?xml version="1.0"?>
<eressea>
<equipment>
<set name="first_unit">
<item name="money" amount="2500"/>
<item name="log" amount="10"/>
<item name="stone" amount="4"/>
</set>
<set name="seed_unit">
<item name="log" amount="50"/>
<item name="stone" amount="50"/>
<item name="iron" amount="50"/>
<item name="laen" amount="10"/>
<item name="sword" amount="1"/>
<item name="mallorn" amount="10"/>
<item name="skillpotion" amount="5"/>
<item name="lifepotion" amount="5"/>
<item name="money" amount="20000"/>
<skill name="perception" level="30"/>
<skill name="melee" level="1"/>
</set>
<set name="seed_faction">
<item name="adamantium" amount="1"/>
</set>
</equipment>
</eressea>

View file

@ -7,8 +7,6 @@
"config://conf/e3/terrains.json",
"config://conf/e3/items.json",
"config://conf/e3/races.json",
"config://res/e3a/familiars.xml",
"config://res/e3a/equipment.xml",
"config://res/e3a/ships.xml",
"config://res/e3a/buildings.xml",
"config://res/e3a/spells.xml",

View file

@ -7100,112 +7100,6 @@
<text locale="en">Furious peasants</text>
</string>
<string name="random_plain_men">
<text locale="de">Söldner</text>
<text locale="en">Mercenaries</text>
</string>
<string name="random_swamp_men">
<text locale="de">Sumpfbewohner</text>
<text locale="en">Swamp people</text>
</string>
<string name="random_forest_men">
<text locale="de">Waldbewohner</text>
<text locale="en">Woodsmen</text>
</string>
<string name="random_desert_men">
<text locale="de">Nomaden</text>
<text locale="en">Nomads</text>
</string>
<string name="random_glacier_men">
<text locale="de">Eisleute</text>
<text locale="en">Ice people</text>
</string>
<string name="random_mountain_men">
<text locale="de">Bergbewohner</text>
<text locale="en">Mountain people</text>
</string>
<string name="manual_title_magic">
<text locale="de">Magie der Elemente</text>
<text locale="en">Magic of the Elements</text>
</string>
<string name="manual_title_weaponsmithing">
<text locale="de">Schwerter, Armbrüste, Langbögen</text>
<text locale="en">Swords, Crossbows and Longbows</text>
</string>
<string name="manual_title_tactics">
<text locale="de">Gorms Almanach der Rationellen Kriegsführung</text>
<text locale="en">Gorm's Almanach of Rational War</text>
</string>
<string name="manual_title_shipcraft">
<text locale="de">Katamarane, Koggen, Karavellen</text>
<text locale="en">The dragonship, the caravell and the longboat</text>
</string>
<string name="manual_title_sailing">
<text locale="de">Wege der Sterne</text>
<text locale="en">Ways of the Start</text>
</string>
<string name="manual_title_herbalism">
<text locale="de">Nadishahs Kleine Gift- und Kräuterkunde</text>
<text locale="en">Nadishah's collected lore on poisonous and beneficial herbs</text>
</string>
<string name="manual_title_alchemy">
<text locale="de">Mandricks Kompendium der Alchemie</text>
<text locale="en">Mandrick's alchemistic compendium</text>
</string>
<string name="manual_title_building">
<text locale="de">Die Konstruktion der Burgen und Schlösser von Zentralandune</text>
</string>
<string name="manual_title_armorer">
<text locale="de">Die Esse</text>
</string>
<string name="manual_title_mining">
<text locale="de">Über die Gewinnung von Erzen</text>
</string>
<string name="manual_title_entertainment">
<text locale="de">Barinions Lieder, eine Einführung für Unbedarfte</text>
</string>
<string name="manual_location_0">
<text locale="de">die Ruine eines alten Tempels</text>
<text locale="en">the ruins of an ancient temple</text>
</string>
<string name="manual_location_1">
<text locale="de">eine alte Burgruine</text>
<text locale="en">the ruins of a castle</text>
</string>
<string name="manual_location_2">
<text locale="de">ein zerfallenes Bauernhaus</text>
<text locale="en">a dilapitated farm</text>
</string>
<string name="manual_location_3">
<text locale="de">eine Leiche am Wegesrand</text>
<text locale="en">a corpse by the wayside</text>
</string>
<string name="manual_location_3">
<text locale="de">eine Leiche am Wegesrand</text>
<text locale="en">a corpse by the wayside</text>
</string>
<string name="firedragon">
<text locale="de">Feuerdrache</text>
<text locale="en">fire dragon</text>

View file

@ -7991,23 +7991,6 @@
<text locale="en">"A message from $unit($unit): '$message'"</text>
</message>
<message name="encounter_allies" section="events">
<type>
<arg name="unit" type="unit"/>
<arg name="name" type="string"/>
</type>
<text locale="de">"Plötzlich stolpert $unit($unit) über einige $localize($name). Nach kurzem Zögern entschließen die $localize($name), sich Deiner Partei anzuschließen."</text>
<text locale="en">"$unit($unit) stumbles upon $localize($name). After short hesitation, $localize($name) agrees to join your faction."</text>
</message>
<message name="encounter_villagers" section="events">
<type>
<arg name="unit" type="unit"/>
</type>
<text locale="de">"$unit($unit) entdeckt ein kleines Dorf. Die meisten Häuser wurden durch einen über die Ufer getretenen Fluß zerstört. Eine Gruppe der verzweifelten Menschen schließt sich deiner Partei an."</text>
<text locale="en">"$unit($unit) discovers a small village. Most of the houses have been destroyed by flooding, and a group of the distressed villagers join your faction."</text>
</message>
<message name="mob_warning" section="events">
<text locale="de">"Ein Bauernmob erhebt sich und macht Jagd auf Schwarzmagier."</text>
<text locale="en">"An angry mob forms and hunts practitioners of the dark arts."</text>
@ -8188,8 +8171,8 @@
<arg name="unit" type="unit"/>
<arg name="command" type="order"/>
</type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - In dieser Region gibt es keine Brücken und Straßen mehr zu bauen."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - The roads and bridges in this region are complete."</text>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - In dieser Richtung gibt es keine Brücken und Straßen mehr zu bauen."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - The roads and bridges in that direction are complete."</text>
</message>
<message name="error_build_skill_low" section="errors">

View file

@ -1,11 +0,0 @@
<?xml version="1.0"?>
<eressea>
<equipment>
<set name="spo_seaserpent">
<item name="dragonblood" amount="2"/>
<item name="seaserpenthead" amount="1"/>
</set>
</equipment>
</eressea>

View file

@ -1,105 +0,0 @@
<?xml version="1.0"?>
<eressea>
<equipment>
<!-- equipment given to familiars -->
<set name="fam_lynx">
<skill name="magic" level="1"/>
</set>
<set name="fam_tunnelworm">
<skill name="magic" level="1"/>
<skill name="mining" level="1"/>
<skill name="forestry" level="1"/>
<skill name="stamina" level="1"/>
</set>
<set name="fam_eagle">
<skill name="magic" level="1"/>
</set>
<set name="fam_rat">
<skill name="magic" level="1"/>
<skill name="stamina" level="6"/>
</set>
<set name="fam_songdragon">
<skill name="magic" level="1"/>
<!-- spells -->
<spell name="flee" level="2"/>
<spell name="sleep" level="7"/>
<spell name="frighten" level="8"/>
</set>
<set name="fam_nymph">
<skill name="magic" level="1"/>
<skill name="bow" level="1"/>
<skill name="training" level="1"/>
<skill name="riding" level="1"/>
<!-- spells -->
<spell name="seduction" level="6"/>
<spell name="calm_monster" level="6"/>
<spell name="song_of_confusion" level="4"/>
<spell name="appeasement" level="1"/>
</set>
<set name="fam_unicorn">
<skill name="magic" level="1"/>
<!-- spells -->
<spell name="resist_magic" level="3"/>
<spell name="song_of_peace" level="12"/>
<spell name="calm_monster" level="6"/>
<spell name="heroic_song" level="5"/>
<spell name="song_of_healing" level="2"/>
<spell name="appeasement" level="1"/>
</set>
<set name="fam_direwolf">
<skill name="magic" level="1"/>
</set>
<set name="fam_ghost">
<skill name="magic" level="1"/>
<!-- spells -->
<spell name="steal_aura" level="6"/>
<spell name="frighten" level="8"/>
<spell name="summonundead" level="6"/>
</set>
<set name="fam_imp">
<skill name="magic" level="1"/>
<!-- spells -->
<spell name="steal_aura" level="6"/>
<spell name="shapeshift" level="3"/>
<spell name="seduction" level="6"/>
</set>
<set name="fam_dreamcat">
<skill name="magic" level="1"/>
<!-- spells -->
<spell name="shapeshift" level="3"/>
<spell name="transferauratraum" level="3"/>
</set>
<set name="fam_fairy">
<skill name="magic" level="1"/>
<!-- spells -->
<spell name="appeasement" level="1"/>
<spell name="calm_monster" level="6"/>
<spell name="seduction" level="6"/>
</set>
<set name="fam_owl">
<skill name="magic" level="1"/>
</set>
<set name="fam_hellcat">
<skill name="magic" level="1"/>
</set>
<set name="fam_tiger">
<skill name="magic" level="1"/>
</set>
</equipment>
</eressea>

View file

@ -1,275 +0,0 @@
<?xml version="1.0"?>
<eressea><equipment>
<!-- one equipment-set per player-race for the first unit in a faction -->
<set name="seed_dwarf">
<item name="axe" amount="1"/>
<item name="chainmail" amount="1"/>
<skill name="melee" level="1"/>
</set>
<set name="seed_elf">
<item name="fairyboot" amount="1"/>
<callback name="equip_newunits"/>
</set>
<set name="seed_orc">
<skill name="polearm" level="4"/>
<skill name="melee" level="4"/>
<skill name="crossbow" level="4"/>
<skill name="catapult" level="4"/>
<skill name="bow" level="4"/>
</set>
<set name="seed_goblin">
<item name="roi" amount="1"/>
<callback name="equip_newunits"/>
</set>
<set name="seed_human">
<callback name="equip_newunits"/>
</set>
<set name="seed_troll">
<skill name="building" level="1"/>
<skill name="perception" level="3"/>
<item name="stone" amount="50"/>
</set>
<set name="seed_demon">
<skill name="stamina" level="15"/>
</set>
<set name="seed_insect">
<item name="nestwarmth" amount="9"/>
</set>
<set name="seed_halfling">
<skill name="trade" level="1"/>
<skill name="riding" level="2"/>
<item name="horse" amount="2"/>
<item name="cart" amount="1"/>
<item name="balm" amount="5"/>
<item name="spice" amount="5"/>
<item name="myrrh" amount="5"/>
<item name="jewel" amount="5"/>
<item name="oil" amount="5"/>
<item name="silk" amount="5"/>
<item name="incense" amount="5"/>
</set>
<set name="seed_cat">
<item name="roi" amount="1"/>
<callback name="equip_newunits"/>
</set>
<set name="seed_aquarian">
<skill name="sailing" level="1"/>
<callback name="equip_newunits"/>
</set>
<!-- equipment-sets for random encounters -->
<set name="rand_desert">
<skill name="melee" level="d2"/>
<skill name="trade" level="d3"/>
<skill name="riding" level="d2+1"/>
<skill name="training" level="d2+1"/>
<item name="horse" amount="1"/>
<item name="sword" amount="1"/>
<item name="money" amount="d30+19"/>
</set>
<set name="rand_swamp">
<skill name="stealth" level="d3+1"/>
<skill name="polearm" level="d3+1"/>
<item name="spear" amount="1"/>
<item name="money" amount="d20+9"/>
</set>
<set name="rand_glacier">
<skill name="armorer" level="d2+1"/>
<skill name="melee" level="d2+1"/>
<item name="sword" amount="1"/>
<item name="money" amount="d20+19"/>
</set>
<set name="rand_mountain">
<skill name="armorer" level="d2+1"/>
<skill name="melee" level="d2+1"/>
<skill name="trade" level="d3"/>
<item name="sword" amount="1"/>
<item name="money" amount="d40+59"/>
<subset chance="0.6">
<set name="i_plate"/>
</subset>
</set>
<set name="rand_highland">
<skill name="melee" level="d2"/>
<item name="sword" amount="1"/>
<item name="money" amount="d10+19"/>
</set>
<set name="rand_forest">
<skill name="stealth" level="d2"/>
<skill name="perception" level="d2+1"/>
<skill name="bow" level="d3+1"/>
<item name="bow" amount="1"/>
<item name="money" amount="d20+9"/>
<subset chance="0.2">
<set name="rand_herbalist"/>
</subset>
</set>
<set name="rand_herbalist">
<skill name="herbalism" level="d2"/>
</set>
<set name="rand_villagers">
<item name="money" amount="d80+19"/>
<skill name="cartmaking" level="d2-1"/>
<skill name="mining" level="d2-1"/>
<skill name="quarrying" level="d2-1"/>
<skill name="forestry" level="d2-1"/>
<item name="horse" amount="2"/>
<item name="wagon" amount="d2-1"/>
<item name="money" amount="d30+10"/>
</set>
<set name="rand_plain">
<item name="money" amount="d80+19"/>
<subset>
<set name="rand_sword" chance="0.25"/>
<set name="rand_spear" chance="0.25"/>
<set name="rand_crossbow" chance="0.25"/>
<set name="rand_bow" chance="0.25"/>
</subset>
<subset chance="0.4">
<set name="i_chain"/>
</subset>
<subset chance="0.3">
<set name="rand_rider"/>
</subset>
</set>
<set name="rand_spear">
<skill name="polearm" level="d3"/>
<item name="spear" amount="1"/>
</set>
<set name="rand_sword">
<skill name="melee" level="d3"/>
<item name="sword" amount="1"/>
</set>
<set name="rand_crossbow">
<skill name="crossbow" level="d3"/>
<item name="crossbow" amount="1"/>
</set>
<set name="rand_bow">
<skill name="bow" level="d3"/>
<item name="bow" amount="1"/>
</set>
<set name="rand_rider">
<item name="horse" amount="1"/>
<skill name="riding" level="d3"/>
</set>
<set name="new_dracoid">
<!-- dracoiden, von drachen rekrutiert -->
<skill name="polearm" level="d4+2"/>
<skill name="melee" level="d4+2"/>
<skill name="bow" level="d3+1"/>
<subset>
<!-- dracoiden haben immer eine von drei waffen -->
<set name="i_sword" chance="0.33"/>
<set name="i_spear" chance="0.33"/>
<set name="i_bow" chance="0.34"/>
</subset>
</set>
<set name="rising_undead">
<!-- untote, von den graebern auferstanden -->
<item name="rustysword" amount="1"/>
<item name="rustychainmail" amount="d2-1"/>
<subset chance="0.3">
<set name="i_rustyshield"/>
</subset>
</set>
<!-- single-item sets (that can be given a percentage-chance in a subset) -->
<set name="i_plate">
<item name="plate" amount="1"/>
</set>
<set name="i_spear">
<item name="spear" amount="1"/>
</set>
<set name="i_bow">
<item name="bow" amount="1"/>
</set>
<set name="i_sword">
<item name="sword" amount="1"/>
</set>
<set name="i_chain">
<item name="chainmail" amount="1"/>
</set>
<set name="i_rustyshield">
<item name="rustyshield" amount="1"/>
</set>
<set name="spo_dragon">
<item name="dragonblood" amount="4"/>
<item name="dragonhead" amount="1"/>
</set>
<set name="spo_youngdragon">
<item name="dragonblood" amount="1"/>
</set>
<set name="spo_wyrm">
<item name="dragonblood" amount="10"/>
<item name="dragonhead" amount="1"/>
</set>
<!-- sets that are used by the monster-spawning code -->
<set name="seed_dragon">
<skill name="magic" level="4"/>
<skill name="stealth" level="1"/>
<skill name="stamina" level="1"/>
<skill name="perception" level="d3"/>
<item name="money" amount="d500+99"/>
</set>
<set name="seed_braineater">
<skill name="stealth" level="1"/>
<skill name="perception" level="1"/>
</set>
<set name="seed_seaserpent">
<skill name="magic" level="4"/>
<skill name="stealth" level="2"/>
<skill name="stamina" level="1"/>
<skill name="perception" level="3"/>
</set>
<set name="new_orc">
<skill name="polearm" level="1"/>
<skill name="melee" level="1"/>
</set>
<set name="spo_seaserpent">
<item name="dragonblood" amount="6"/>
<item name="seaserpenthead" amount="1"/>
</set>
</equipment>
</eressea>

View file

@ -1,133 +0,0 @@
<?xml version="1.0"?>
<eressea>
<equipment>
<!-- equipment given to familiars -->
<set name="fam_lynx">
<skill name="espionage" level="1"/>
<skill name="magic" level="1"/>
<skill name="stealth" level="1"/>
<skill name="perception" level="1"/>
</set>
<set name="fam_tunnelworm">
<skill name="magic" level="1"/>
<skill name="mining" level="1"/>
<skill name="forestry" level="1"/>
<skill name="stamina" level="1"/>
</set>
<set name="fam_eagle">
<skill name="magic" level="1"/>
<skill name="perception" level="1"/>
</set>
<set name="fam_rat">
<skill name="magic" level="1"/>
<skill name="espionage" level="1"/>
<skill name="stealth" level="1"/>
<skill name="perception" level="1"/>
<skill name="stamina" level="6"/>
</set>
<set name="fam_songdragon">
<skill name="magic" level="1"/>
<!-- spells -->
<spell name="flee" level="2"/>
<spell name="sleep" level="7"/>
<spell name="frighten" level="8"/>
</set>
<set name="fam_nymph">
<skill name="magic" level="1"/>
<skill name="bow" level="1"/>
<skill name="herbalism" level="1"/>
<skill name="training" level="1"/>
<skill name="riding" level="1"/>
<skill name="espionage" level="1"/>
<skill name="stealth" level="1"/>
<skill name="entertainment" level="1"/>
<skill name="perception" level="1"/>
<!-- spells -->
<spell name="seduction" level="6"/>
<spell name="calm_monster" level="6"/>
<spell name="song_of_confusion" level="4"/>
<spell name="appeasement" level="1"/>
</set>
<set name="fam_unicorn">
<skill name="magic" level="1"/>
<skill name="stealth" level="1"/>
<skill name="perception" level="1"/>
<!-- spells -->
<spell name="resist_magic" level="3"/>
<spell name="song_of_peace" level="12"/>
<spell name="calm_monster" level="6"/>
<spell name="heroic_song" level="5"/>
<spell name="song_of_healing" level="2"/>
<spell name="appeasement" level="1"/>
</set>
<set name="fam_direwolf">
<skill name="magic" level="1"/>
<skill name="perception" level="1"/>
</set>
<set name="fam_ghost">
<skill name="magic" level="1"/>
<!-- spells -->
<spell name="steal_aura" level="6"/>
<spell name="frighten" level="8"/>
<spell name="summonundead" level="6"/>
</set>
<set name="fam_imp">
<skill name="magic" level="1"/>
<skill name="espionage" level="1"/>
<skill name="stealth" level="1"/>
<skill name="perception" level="1"/>
<skill name="taxation" level="1"/>
<!-- spells -->
<spell name="steal_aura" level="6"/>
<spell name="shapeshift" level="3"/>
<spell name="seduction" level="6"/>
</set>
<set name="fam_dreamcat">
<skill name="magic" level="1"/>
<skill name="espionage" level="1"/>
<skill name="stealth" level="1"/>
<skill name="perception" level="1"/>
<skill name="taxation" level="1"/>
<!-- spells -->
<spell name="shapeshift" level="3"/>
<spell name="transferauratraum" level="3"/>
</set>
<set name="fam_fairy">
<skill name="magic" level="1"/>
<!-- spells -->
<spell name="appeasement" level="1"/>
<spell name="calm_monster" level="6"/>
<spell name="seduction" level="6"/>
</set>
<set name="fam_owl">
<skill name="magic" level="1"/>
<skill name="espionage" level="1"/>
<skill name="stealth" level="1"/>
<skill name="perception" level="1"/>
</set>
<set name="fam_hellcat">
<skill name="magic" level="1"/>
<skill name="perception" level="1"/>
</set>
<set name="fam_tiger">
<skill name="magic" level="1"/>
<skill name="perception" level="1"/>
</set>
</equipment>
</eressea>

View file

@ -0,0 +1,153 @@
local sets = {
['fam_lynx'] = {
['skills'] = {
['espionage'] = 1,
['magic'] = 1,
['stealth'] = 1,
['perception'] = 1,
}
},
['fam_tunnelworm'] = {
['skills'] = {
['forestry'] = 1,
['magic'] = 1,
['mining'] = 1,
['stamina'] = 1,
}
},
['fam_eagle'] = {
['skills'] = {
['magic'] = 1,
['perception'] = 1,
}
},
['fam_rat'] = {
['skills'] = {
['magic'] = 1,
['espionage'] = 1,
['stealth'] = 1,
['perception'] = 1,
['stamina'] = 6,
}
},
['fam_owl'] = {
['skills'] = {
['magic'] = 1,
['espionage'] = 1,
['stealth'] = 1,
['perception'] = 1,
}
},
['fam_direwolf'] = {
['skills'] = {
['magic'] = 1,
['perception'] = 1,
}
},
['fam_hellcat'] = {
['skills'] = {
['magic'] = 1,
['perception'] = 1,
}
},
['fam_tiger'] = {
['skills'] = {
['magic'] = 1,
['perception'] = 1,
}
},
['fam_songdragon'] = {
['skills'] = {
['magic'] = 1,
},
['spells'] = {
['flee'] = 2,
['sleep'] = 7,
['frighten'] = 8,
},
},
['fam_ghost'] = {
['skills'] = {
['magic'] = 1,
},
['spells'] = {
['steal_aura'] = 6,
['summonundead'] = 6,
['frighten'] = 8,
},
},
['fam_fairy'] = {
['skills'] = {
['magic'] = 1,
},
['spells'] = {
['appeasement'] = 1,
['calm_monster'] = 6,
['seduction'] = 6,
},
},
['fam_unicorn'] = {
['skills'] = {
['magic'] = 1,
['stealth'] = 1,
['perception'] = 1,
},
['spells'] = {
['resist_magic'] = 3,
['song_of_peace'] = 12,
['calm_monster'] = 6,
['heroic_song'] = 5,
['song_of_healing'] = 3,
['appeasement'] = 2,
},
},
['fam_imp'] = {
['skills'] = {
['magic'] = 1,
['stealth'] = 1,
['perception'] = 1,
['espionage'] = 1,
['taxation'] = 1,
},
['spells'] = {
['steal_aura'] = 6,
['shapeshift'] = 3,
['seduction'] = 6,
},
},
['fam_dreamcat'] = {
['skills'] = {
['magic'] = 1,
['stealth'] = 1,
['perception'] = 1,
['espionage'] = 1,
['taxation'] = 1,
},
['spells'] = {
['shapeshift'] = 3,
['transferauratraum'] = 3,
},
},
['fam_nymph'] = {
['skills'] = {
['magic'] = 1,
['bow'] = 1,
['herbalism'] = 1,
['training'] = 1,
['riding'] = 1,
['espionage'] = 1,
['stealth'] = 1,
['entertainment'] = 1,
['perception'] = 1,
},
['spells'] = {
['seduction'] = 6,
['calm_monster'] = 3,
['song_of_confusion'] = 4,
['appeasement'] = 1,
},
},
}
local equipment = require('eressea.equipment')
equipment.add_multiple(sets)

View file

@ -1,5 +1,106 @@
require 'eressea.spells'
eressea.log.debug("rules for game E2")
eressea.log.debug('rules for game E2')
math.randomseed(rng.random())
local equipment = require('eressea.equipment')
local sets = {
['seed_faction'] = {
['items'] = {
['adamantium'] = 1
}
},
['new_orc'] = {
['skills'] = {
['polearm'] = 1,
['melee'] = 1
}
},
['spo_seaserpent'] = {
['items'] = {
['dragonblood'] = 6,
['seaserpenthead'] = 1
}
},
['spo_dragon'] = {
['items'] = {
['dragonblood'] = 4,
['seaserpenthead'] = 1
}
},
['spo_dragon'] = {
['items'] = {
['dragonblood'] = 4,
['dragonhead'] = 1
}
},
['spo_youngdragon'] = {
['items'] = {
['dragonblood'] = 1
}
},
['spo_wyrm'] = {
['items'] = {
['dragonblood'] = 10,
['dragonhead'] = 1
}
},
['seed_dragon'] = {
['skills'] = {
['magic'] = 4,
['stealth'] = 1,
['stamina'] = 1,
},
['callback'] = function(u)
u:add_item('money', u.number * (math.random(500)+99))
u:set_skill('perception', math.random(3))
end
},
['seed_braineater'] = {
['skills'] = {
['stealth'] = 1,
['perception'] = 1,
}
},
['seed_seaserpent'] = {
['skills'] = {
['magic'] = 4,
['stealth'] = 2,
['stamina'] = 1,
['perception'] = 3,
}
},
['rising_undead'] = {
['items'] = {
['rustysword'] = 1
},
['callback'] = function(u)
if (math.random(2)==1) then
u:add_item('rustychainmail', u.number)
end
if (math.random(3)==1) then
u:add_item('rustyshield', u.number)
end
end
},
['new_dracoid'] = {
['callback'] = function(u)
local pick = math.random(3)
if pick==1 then
u:set_skill('melee', math.random(4)+2)
u:add_item('sword', u.number)
elseif pick==2 then
u:set_skill('polearm', math.random(4)+2)
u:add_item('spear', u.number)
else
u:set_skill('bow', math.random(3)+1)
u:add_item('bow', u.number)
end
end
}
}
equipment.add_multiple(sets)
return {
require('eressea'),
@ -11,8 +112,8 @@ return {
require('eressea.tunnels'),
require('eressea.ponnuki'),
require('eressea.astral'),
-- require('eressea.locales'),
require('eressea.jsreport'),
require('eressea.ents'),
require('eressea.cursed')
require('eressea.cursed'),
require('eressea.e2.familiars')
}

View file

@ -0,0 +1,127 @@
eressea.log.debug("rules for game E3")
local equipment = require('eressea.equipment')
local sets = {
['fam_lynx'] = {
['skills'] = {
['magic'] = 1,
}
},
['fam_eagle'] = {
['skills'] = {
['magic'] = 1,
}
},
['fam_direwolf'] = {
['skills'] = {
['magic'] = 1,
}
},
['fam_owl'] = {
['skills'] = {
['magic'] = 1,
}
},
['fam_hellcat'] = {
['skills'] = {
['magic'] = 1,
}
},
['fam_tiger'] = {
['skills'] = {
['magic'] = 1,
}
},
['fam_rat'] = {
['skills'] = {
['magic'] = 1,
['stamina'] = 6,
}
},
['fam_tunnelworm'] = {
['skills'] = {
['magic'] = 1,
['mining'] = 1,
['forestry'] = 1,
['stamina'] = 1,
}
},
['fam_dreamcat'] = {
['skills'] = {
['magic'] = 1,
},
['spells'] = {
['shapeshift'] = 3,
['transferauratraum'] = 3,
}
},
['fam_imp'] = {
['skills'] = {
['magic'] = 1,
},
['spells'] = {
['shapeshift'] = 3,
['seduction'] = 6,
['steal_aura'] = 6,
}
},
['fam_ghost'] = {
['skills'] = {
['magic'] = 1,
},
['spells'] = {
['steal_aura'] = 6,
['summonundead'] = 6,
['frighten'] = 8,
}
},
['fam_fairy'] = {
['skills'] = {
['magic'] = 1,
},
['spells'] = {
['appeasement'] = 1,
['seduction'] = 6,
['calm_monster'] = 6,
}
},
['fam_songdragon'] = {
['skills'] = {
['magic'] = 1,
},
['spells'] = {
['flee'] = 2,
['sleep'] = 7,
['frighten'] = 8,
}
},
['fam_unicorn'] = {
['skills'] = {
['magic'] = 1,
},
['spells'] = {
['appeasement'] = 1,
['song_of_healing'] = 2,
['resist_magic'] = 3,
['heroic_song'] = 5,
['calm_monster'] = 6,
['song_of_peace'] = 12,
}
},
['fam_nymph'] = {
['skills'] = {
['magic'] = 1,
['bow'] = 1,
['training'] = 1,
['riding'] = 1,
},
['spells'] = {
['appeasement'] = 1,
['song_of_confusion'] = 4,
['calm_monster'] = 6,
['seduction'] = 6,
}
},
}
equipment.add_multiple(sets)

View file

@ -2,10 +2,21 @@ require 'eressea.spells'
eressea.log.debug("rules for game E3")
local equipment = require('eressea.equipment')
local sets = {
['spo_seaserpent'] = {
['items'] = {
['dragonblood'] = 2,
['seaserpenthead'] = 1
}
}
}
equipment.add_multiple(sets)
return {
require('eressea'),
require('eressea.xmasitems'),
-- require('eressea.markets'),
require('eressea.frost'),
require('eressea.ents')
require('eressea.ents'),
require('eressea.e3.familiars'),
}

View file

@ -0,0 +1,156 @@
-- forward declaration required:
local self = {}
local mysets = {
['first_unit'] = {
['items'] = {
['money'] = 2500,
['log'] = 10,
['stone'] = 4
}
},
['seed_unit'] = {
['items'] = {
['log'] = 50,
['stone'] = 50,
['iron'] = 50,
['laen'] = 10,
['sword'] = 1,
['mallorn'] = 10,
['skillpotion'] = 5,
['lifepotion'] = 5,
['money'] = 20000
},
['skills'] = {
['perception'] = 30,
['melee'] = 1
}
},
['seed_dwarf'] = {
['items'] = {
['axe'] = 1,
['chainmail'] = 1,
},
['skills'] = {
['melee'] = 1
}
},
['seed_elf'] = {
['items'] = {
['fairyboot'] = 1,
},
['callback'] = equip_newunits
},
['seed_orc'] = {
['skills'] = {
['polearm'] = 4,
['melee'] = 4,
['crossbow'] = 4,
['catapult'] = 4,
['bow'] = 4,
}
},
['seed_goblin'] = {
['items'] = {
['roi'] = 1
},
['callback'] = equip_newunits
},
['seed_human'] = {
['callback'] = equip_newunits
},
['seed_troll'] = {
['items'] = {
['stone'] = 50,
},
['skills'] = {
['building'] = 1,
['perception'] = 3,
}
},
['seed_demon'] = {
['skills'] = {
['stamina'] = 15
}
},
['seed_insect'] = {
['items'] = {
['nestwarmth'] =9
}
},
['seed_halfling'] = {
['items'] = {
['horse'] = 2,
['cart'] = 1,
['balm'] = 5,
['spice'] = 5,
['myrrh'] = 5,
['jewel'] = 5,
['oil'] = 5,
['silk'] = 5,
['incense'] = 5
},
['skills'] = {
['trade'] = 1,
['riding'] = 2
}
},
['seed_cat'] = {
['items'] = {
['roi'] = 1
},
['callback'] = equip_newunits
},
['seed_aquarian'] = {
['skills'] = {
['sailing'] = 1
},
['callback'] = equip_newunits
},
}
function equip_unit(u, name, flags)
local set = mysets[name]
if set then
local items = set['items']
if items then
for name, count in pairs(items) do
u:add_item(name, count * u.number)
end
end
local skills = set['skills']
if skills then
for name, level in pairs(skills) do
u:set_skill(name, level)
end
end
local spells = set['spells']
if spells then
for name, level in ipairs(spells) do
u:add_spell(name, level)
end
end
local callback = set['callback']
if callback and type(callback) == 'function' then
callback(u, flags)
end
return true
end
return false
end
self.add = function(name, set)
mysets[name] = set
end
self.add_multiple = function(sets)
for name, set in pairs(sets) do
mysets[name] = set
end
end
self.get = function(name)
return mysets[name]
end
return self

View file

@ -3,8 +3,6 @@ local rules = 'conf'
if config.rules then
rules = rules .. '/' .. config.rules
assert(0 == eressea.config.read(rules .. '/config.json', config.install), "could not read JSON data")
-- assert(0 == read_xml(confdir .. rules .. 'rules.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?")
-- assert(0 == read_xml(confdir .. rules .. 'locales.xml', confdir .. rules .. 'catalog.xml'), "could not load XML data, did you compile with LIBXML2 ?")
end
eressea.game.reset()

View file

@ -22,7 +22,6 @@ eressea.settings.set("rules.food.flags", "4")
eressea.settings.set("rules.ship.damage.nocrew", "0")
eressea.settings.set("rules.ship.drifting", "0")
eressea.settings.set("rules.ship.storms", "0")
eressea.settings.set("rules.encounters", "0")
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("NewbieImmunity", "0")
rules = require('eressea.' .. config.rules)

View file

@ -23,7 +23,6 @@ eressea.settings.set("rules.food.flags", "4")
eressea.settings.set("rules.ship.damage.nocrew", "0")
eressea.settings.set("rules.ship.drifting", "0")
eressea.settings.set("rules.ship.storms", "0")
eressea.settings.set("rules.encounters", "0")
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("NewbieImmunity", "0")
rules = require('eressea.' .. config.rules)

View file

@ -183,6 +183,8 @@ if file_exists('execute.lock') then
assert(false)
end
math.randomseed(rng.random())
local path = 'scripts'
if config.install then
path = config.install .. '/' .. path

View file

@ -33,7 +33,6 @@ function setup()
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("NewbieImmunity", "0")
eressea.settings.set("rules.food.flags", "4")
eressea.settings.set("rules.encounters", "0")
eressea.settings.set("rules.peasants.growth", "1")
eressea.settings.set("study.random_progress", "0")
end
@ -968,7 +967,6 @@ module("tests.parser", package.seeall, lunit.testcase)
function setup()
eressea.free_game()
eressea.settings.set("rules.food.flags", "4") -- FOOD_IS_FREE
eressea.settings.set("rules.encounters", "0")
eressea.settings.set("rules.move.owner_leave", "0")
end

View file

@ -8,27 +8,32 @@ end
function test_read_race()
local f
eressea.free_game()
assert_not_nil(eressea.config)
eressea.config.parse('{ "races": { "orc" : {}}}')
f = faction.create("orc", "orc@example.com", "en")
assert_not_nil(f)
end
function disable_test_read_ship()
local s
eressea.free_game()
assert_not_nil(eressea.config)
conf = [[{
"ships": {
"boat" : {
"construction" : {
"maxsize" : 20
}
}
}
}]]
eressea.config.parse(conf);
s = ship.create(nil, "boat")
assert_not_nil(s)
function test_seed_unit()
local r = region.create(0, 0, "plain")
local f = faction.create('human')
local u = unit.create(f, r, 1)
u:equip('seed_unit')
assert_equal(20000, u:get_item('money'))
assert_equal(50, u:get_item('log'))
assert_equal(50, u:get_item('stone'))
assert_equal(1, u:get_skill('melee'))
end
function test_seed_elf()
local r = region.create(0, 0, "plain")
local f = faction.create('human')
local u = unit.create(f, r, 1)
-- quirk: independent of the race, seed_elf contains a fairyboot
u:equip('seed_elf')
assert_equal(1, u:get_item('fairyboot'))
-- all humans start in a building:
assert_not_nil(u.building)
assert_equal('castle', u.building.type)
assert_equal(10, u.building.size)
end

View file

@ -7,7 +7,6 @@ function setup()
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("rules.food.flags", "4")
eressea.settings.set("rules.ship.storms", "0")
eressea.settings.set("rules.encounters", "0")
end
local function create_faction(race)

View file

@ -444,3 +444,45 @@ function test_faction_anonymous()
assert_equal(get_name(u) .. ", 1 Mensch, aggressiv.", u:show(f))
assert_equal(get_name(u) .. ", " .. get_name(f) .. ", 1 Mensch.", u:show(f2))
end
function test_new_orc_has_skills()
local f = faction.create('orc')
local r = region.create(0, 0, 'plain')
local u = unit.create(f, r)
u:add_item('money', 400)
u.number = 0
u:add_order("REKRUTIEREN 2")
process_orders()
assert_equal(2, u.number)
assert_equal(1, u:get_skill('polearm'))
assert_equal(1, u:get_skill('melee'))
end
function test_new_dracoid()
local f = faction.create('human')
local r = region.create(0, 0, 'plain')
local u = unit.create(f, r, 'dracoid')
u.number = 2
u:equip("new_dracoid")
assert_equal(2, u.number)
item = nil
if u:get_skill('bow') > 1 then
item = 'bow'
elseif u:get_skill('polearm') > 1 then
item = 'spear'
elseif u:get_skill('melee') > 1 then
item = 'sword'
end
assert_not_nil(item)
assert_equal(u.number, u:get_item(item))
end
function test_rising_undead()
local f = faction.create('human')
local r = region.create(0, 0, 'plain')
local u = unit.create(f, r, 'undead')
u.number = 2
u:equip("rising_undead")
assert_equal(2, u.number)
assert_equal(u.number, u:get_item('rustysword'))
end

View file

@ -13,6 +13,7 @@ require 'tests.e2.guard'
require 'tests.e2.stealth'
require 'tests.e2.items'
require 'tests.e2.ships'
require 'tests.config'
require 'tests.items'
require 'tests.economy'
require 'tests.orders'

View file

@ -7,7 +7,6 @@ function setup()
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("rules.food.flags", "4")
eressea.settings.set("rules.ship.storms", "0")
eressea.settings.set("rules.encounters", "0")
eressea.settings.set("magic.regeneration.enable", "0")
eressea.settings.set("rules.grow.formula", "0")
eressea.settings.set("study.random_progress", "0")

View file

@ -124,3 +124,15 @@ function test_familiar()
end
end
end
function test_familiar_lynx()
local r = region.create(0, 0, 'plain')
local f = faction.create('human')
local u = unit.create(f, r)
u.race = 'lynx'
u:equip('fam_lynx')
assert_equal(1, u:get_skill('stealth'))
assert_equal(1, u:get_skill('espionage'))
assert_equal(1, u:get_skill('magic'))
assert_equal(1, u:get_skill('perception'))
end

View file

@ -1026,3 +1026,17 @@ function test_demons_using_mallornlance()
end
assert_true(u.guard)
end
function test_new_orc_has_no_skills()
-- orcs in E2 get starting skills, but in E3 they do not
local f = faction.create('orc')
local r = region.create(0, 0, 'plain')
local u = unit.create(f, r)
u:add_item('money', 400)
u.number = 0
u:add_order("REKRUTIEREN 2")
process_orders()
assert_equal(2, u.number)
assert_equal(0, u:get_skill('polearm'))
assert_equal(0, u:get_skill('melee'))
end

View file

@ -1,5 +1,4 @@
-- new tests 2014-06-11
require 'tests.config'
require 'tests.faction'
require 'tests.locale'
require 'tests.movement'

View file

@ -8,7 +8,6 @@ function setup()
eressea.settings.set("NewbieImmunity", "0")
eressea.settings.set("rules.food.flags", "4")
eressea.settings.set("rules.ship.storms", "0")
eressea.settings.set("rules.encounters", "0")
eressea.settings.set("magic.regeneration.enable", "0")
end

View file

@ -36,7 +36,6 @@ function test_study_expensive()
local f = faction.create("human", "test@example.com", "de")
local u = unit.create(f, r, 1)
eressea.settings.set("skills.cost.alchemy", "50")
eressea.settings.set("rules.encounters", "0")
u:add_order("LERNEN Alchemie")
u:add_item("money", 50)
process_orders()

View file

@ -7,7 +7,6 @@ function setup()
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("NewbieImmunity", "0")
eressea.settings.set("rules.food.flags", "4")
eressea.settings.set("rules.encounters", "0")
eressea.settings.set("rules.peasants.growth", "1")
eressea.settings.set("study.random_progress", "0")
eressea.settings.set("GiveRestriction", "0")

View file

@ -916,17 +916,13 @@ void kill_troop(troop dt)
rmtroop(dt);
if (!df->alive) {
char eqname[64];
const struct equipment *eq;
const race *rc = u_race(du);
item *drops = item_spoil(rc, du->number - df->run.number);
if (drops != NULL) {
i_merge(&du->items, &drops);
}
sprintf(eqname, "spo_%s", rc->_name);
eq = get_equipment(eqname);
if (eq != NULL) {
equip_items(&du->items, eq);
}
equip_unit_mask(du, eqname, EQUIP_ITEMS);
}
}

View file

@ -7,7 +7,6 @@
#include <spells/flyingship.h>
#include <kernel/equipment.h>
#include <kernel/faction.h>
#include <kernel/race.h>
#include <kernel/ship.h>

View file

@ -17,6 +17,7 @@
#include <kernel/building.h>
#include <kernel/config.h>
#include <kernel/curse.h>
#include "kernel/equipment.h"
#include <kernel/faction.h>
#include <kernel/group.h>
#include <kernel/item.h>
@ -962,6 +963,16 @@ static int tolua_event_get(lua_State * L)
return 0;
}
static int tolua_equipunit(lua_State * L)
{
unit *u = (unit *)tolua_tousertype(L, 1, 0);
const char *eqname = tolua_tostring(L, 2, 0);
int mask = (int)tolua_tonumber(L, 3, EQUIP_ALL);
assert(u && mask > 0);
equip_unit_mask(u, eqname, mask);
return 0;
}
void tolua_unit_open(lua_State * L)
{
/* register user types */
@ -1062,6 +1073,7 @@ void tolua_unit_open(lua_State * L)
tolua_variable(L, TOLUA_CAST "hp_max", tolua_unit_get_hpmax, 0);
tolua_variable(L, TOLUA_CAST "aura_max", tolua_unit_get_auramax, 0);
tolua_function(L, TOLUA_CAST "equip", tolua_equipunit);
tolua_function(L, TOLUA_CAST "show", tolua_bufunit);
}
tolua_endmodule(L);

View file

@ -9,7 +9,6 @@
#include "kernel/alliance.h"
#include "kernel/building.h"
#include "kernel/curse.h"
#include "kernel/equipment.h"
#include "kernel/unit.h"
#include "kernel/terrain.h"
#include "kernel/messages.h"
@ -24,6 +23,7 @@
#include "kernel/save.h"
#include "kernel/spell.h"
#include "kernel/spellbook.h"
#include "races/races.h"
#include "bind_unit.h"
#include "bind_storage.h"
@ -47,7 +47,6 @@
#include "monsters.h"
#include "market.h"
#include <modules/autoseed.h>
#include <modules/score.h>
#include <attributes/key.h>
@ -154,25 +153,6 @@ int tolua_itemlist_next(lua_State * L)
return 0;
}
static int tolua_autoseed(lua_State * L)
{
const char *filename = tolua_tostring(L, 1, 0);
int new_island = tolua_toboolean(L, 2, 0);
newfaction *players = read_newfactions(filename);
if (players != NULL) {
while (players) {
int n = listlen(players);
int k = (n + ISLANDSIZE - 1) / ISLANDSIZE;
k = n / k;
n = autoseed(&players, k, new_island ? 0 : TURNS_PER_ISLAND);
if (n == 0) {
break;
}
}
}
return 0;
}
static int tolua_getkey(lua_State * L)
{
const char *name = tolua_tostring(L, 1, 0);
@ -413,33 +393,6 @@ static int tolua_get_nmrs(lua_State * L)
return 1;
}
static int tolua_equipunit(lua_State * L)
{
unit *u = (unit *)tolua_tousertype(L, 1, 0);
const char *eqname = tolua_tostring(L, 2, 0);
int mask = (int)tolua_tonumber(L, 3, EQUIP_ALL);
assert(u && mask > 0);
equip_unit_mask(u, get_equipment(eqname), mask);
return 0;
}
static int tolua_equipment_setitem(lua_State * L)
{
int result = -1;
const char *eqname = tolua_tostring(L, 1, 0);
const char *iname = tolua_tostring(L, 2, 0);
const char *value = tolua_tostring(L, 3, 0);
if (iname != NULL) {
const struct item_type *itype = it_find(iname);
if (itype != NULL) {
equipment_setitem(get_or_create_equipment(eqname), itype, value);
result = 0;
}
}
lua_pushinteger(L, result);
return 1;
}
static int tolua_spawn_braineaters(lua_State * L)
{
float chance = (float)tolua_tonumber(L, 1, 0);
@ -893,8 +846,13 @@ static int init_data(const char *filename)
return 0;
}
static int tolua_equip_newunits(lua_State * L) {
unit *u = (unit *)tolua_tousertype(L, 1, 0);
equip_newunits(u);
return 0;
}
int tolua_read_xml(lua_State * L)
static int tolua_read_xml(lua_State * L)
{
const char *filename = tolua_tostring(L, 1, "config.xml");
lua_pushinteger(L, init_data(filename));
@ -1056,8 +1014,6 @@ int tolua_bindings_open(lua_State * L, const dictionary *inifile)
tolua_function(L, TOLUA_CAST "set_turn", &tolua_set_turn);
tolua_function(L, TOLUA_CAST "get_turn", &tolua_get_turn);
tolua_function(L, TOLUA_CAST "get_season", tolua_get_season);
tolua_function(L, TOLUA_CAST "equipment_setitem", tolua_equipment_setitem);
tolua_function(L, TOLUA_CAST "equip_unit", tolua_equipunit);
tolua_function(L, TOLUA_CAST "atoi36", tolua_atoi36);
tolua_function(L, TOLUA_CAST "itoa36", tolua_itoa36);
tolua_function(L, TOLUA_CAST "dice_roll", tolua_dice_rand);
@ -1068,12 +1024,12 @@ int tolua_bindings_open(lua_State * L, const dictionary *inifile)
tolua_function(L, TOLUA_CAST "update_owners", tolua_update_owners);
tolua_function(L, TOLUA_CAST "learn_skill", tolua_learn_skill);
tolua_function(L, TOLUA_CAST "create_curse", tolua_create_curse);
tolua_function(L, TOLUA_CAST "autoseed", tolua_autoseed);
tolua_function(L, TOLUA_CAST "get_key", tolua_getkey);
tolua_function(L, TOLUA_CAST "set_key", tolua_setkey);
tolua_function(L, TOLUA_CAST "translate", &tolua_translate);
tolua_function(L, TOLUA_CAST "spells", tolua_get_spells);
tolua_function(L, TOLUA_CAST "read_xml", tolua_read_xml);
tolua_function(L, TOLUA_CAST "equip_newunits", tolua_equip_newunits);
} tolua_endmodule(L);
return 1;
}

View file

@ -263,7 +263,7 @@ void add_recruits(unit * u, int number, int wanted)
len = snprintf(equipment, sizeof(equipment), "new_%s", u_race(u)->_name);
if (len > 0 && (size_t)len < sizeof(equipment)) {
equip_unit(unew, get_equipment(equipment));
equip_unit(unew, equipment);
}
if (unew != u) {
transfermen(unew, u, unew->number);

View file

@ -31,7 +31,6 @@ without prior permission by the authors of Eressea.
#include <kernel/callbacks.h>
#include <kernel/config.h>
#include <kernel/callbacks.h>
#include <kernel/equipment.h>
#include <kernel/faction.h>
#include <kernel/spell.h>
#include <kernel/race.h>
@ -162,6 +161,36 @@ static void push_param(lua_State * L, char c, spllprm * param)
}
}
/** callback to use lua functions isntead of equipment */
static bool lua_equipunit(unit *u, const char *eqname, int mask) {
lua_State *L = (lua_State *)global.vm_state;
bool result = false;
static bool disabled = false;
if (disabled) {
return false;
}
lua_getglobal(L, "equip_unit");
if (lua_isfunction(L, -1)) {
tolua_pushusertype(L, u, TOLUA_CAST "unit");
lua_pushstring(L, eqname);
lua_pushinteger(L, mask);
if (lua_pcall(L, 3, 1, 0) != 0) {
const char *error = lua_tostring(L, -1);
log_error("equip(%s) with '%s/%d': %s.\n", unitname(u), eqname, mask, error);
lua_pop(L, 1);
}
else {
result = (bool)lua_toboolean(L, -1);
lua_pop(L, 1);
}
}
else {
disabled = true;
}
return result;
}
/** callback to use lua for spell functions */
static int lua_callspell(castorder * co, const char *fname)
{
@ -346,6 +375,7 @@ void register_tolua_helpers(void)
at_register(&at_direction);
at_deprecate("lcbuilding", building_action_read);
callbacks.equip_unit = lua_equipunit;
callbacks.cast_spell = lua_callspell;
callbacks.use_item = use_item_callback;
callbacks.produce_resource = produce_resource_lua;

View file

@ -47,7 +47,8 @@ const gamedate *get_gamedate(int turn_now, gamedate * gd)
assert(gd);
if (t<0) {
log_fatal("current turn %d is before first %d",
t = 0;
log_error("current turn %d is before first %d",
turn_now, first_turn());
}
assert(t>=0);

View file

@ -19,6 +19,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef H_KRNL_CALLBACKS_H
#define H_KRNL_CALLBACKS_H
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -31,6 +33,7 @@ extern "C" {
struct resource_type;
struct callback_struct {
bool (*equip_unit)(struct unit *u, const char *eqname, int mask);
int (*cast_spell)(struct castorder *co, const char *fname);
int (*use_item)(struct unit *u, const struct item_type *itype,
int amount, struct order *ord);

View file

@ -30,7 +30,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "connection.h"
#include "building.h"
#include "direction.h"
#include "equipment.h"
#include "faction.h"
#include "group.h"
#include "item.h"
@ -564,7 +563,6 @@ void kernel_done(void)
attrib_done();
item_done();
message_done();
equipment_done();
reports_done();
curses_done();
crmessage_done();

View file

@ -21,11 +21,12 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "equipment.h"
/* kernel includes */
#include "item.h"
#include "unit.h"
#include "callbacks.h"
#include "faction.h"
#include "item.h"
#include "race.h"
#include "spell.h"
#include "unit.h"
/* util includes */
#include <selist.h>
@ -40,278 +41,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <string.h>
#include <stdlib.h>
void equipment_setskill(equipment * eq, skill_t sk, const char *value)
bool equip_unit(struct unit *u, const char *eqname)
{
if (eq != NULL) {
if (value != NULL) {
eq->skills[sk] = str_strdup(value);
}
else if (eq->skills[sk]) {
free(eq->skills[sk]);
}
}
return equip_unit_mask(u, eqname, EQUIP_ALL);
}
typedef struct lazy_spell {
struct spellref *spref;
int level;
} lazy_spell;
void equipment_addspell(equipment * eq, const char * name, int level)
bool equip_unit_mask(struct unit *u, const char *eqname, int mask)
{
if (eq) {
lazy_spell *ls = malloc(sizeof(lazy_spell));
ls->spref = spellref_create(NULL, name);
ls->level = level;
selist_push(&eq->spells, ls);
if (callbacks.equip_unit) {
return callbacks.equip_unit(u, eqname, mask);
}
}
void
equipment_setitem(equipment * eq, const item_type * itype, const char *value)
{
if (eq != NULL) {
if (itype != NULL) {
itemdata *idata = eq->items;
while (idata && idata->itype != itype) {
idata = idata->next;
}
if (idata == NULL) {
idata = (itemdata *)malloc(sizeof(itemdata));
idata->itype = itype;
idata->value = str_strdup(value);
idata->next = eq->items;
eq->items = idata;
}
}
}
}
void
equipment_setcallback(struct equipment *eq,
void(*callback) (const struct equipment *, struct unit *))
{
eq->callback = callback;
}
void equip_unit(struct unit *u, const struct equipment *eq)
{
equip_unit_mask(u, eq, EQUIP_ALL);
}
void equip_unit_mask(struct unit *u, const struct equipment *eq, int mask)
{
if (eq) {
if (mask & EQUIP_SKILLS) {
int sk;
for (sk = 0; sk != MAXSKILLS; ++sk) {
if (eq->skills[sk] != NULL) {
int i = dice_rand(eq->skills[sk]);
if (i > 0) {
set_level(u, (skill_t)sk, i);
if (sk == SK_STAMINA) {
u->hp = unit_max_hp(u) * u->number;
}
}
}
}
}
if (mask & EQUIP_SPELLS) {
if (eq->spells) {
selist * ql = eq->spells;
int qi;
sc_mage * mage = get_mage_depr(u);
for (qi = 0; ql; selist_advance(&ql, &qi, 1)) {
lazy_spell *sbe = (lazy_spell *)selist_get(ql, qi);
spell *sp = spellref_get(sbe->spref);
unit_add_spell(u, mage, sp, sbe->level);
}
}
}
if (mask & EQUIP_ITEMS) {
itemdata *idata;
for (idata = eq->items; idata != NULL; idata = idata->next) {
int i = u->number * dice_rand(idata->value);
if (i > 0) {
i_add(&u->items, i_new(idata->itype, i));
}
}
}
if (eq->subsets) {
int i;
for (i = 0; eq->subsets[i].sets; ++i) {
if (chance(eq->subsets[i].chance)) {
double rnd = (1 + rng_int() % 1000) / 1000.0;
int k;
for (k = 0; eq->subsets[i].sets[k].set; ++k) {
if (rnd <= eq->subsets[i].sets[k].chance) {
equip_unit_mask(u, eq->subsets[i].sets[k].set, mask);
break;
}
rnd -= eq->subsets[i].sets[k].chance;
}
}
}
}
if (mask & EQUIP_SPECIAL) {
if (eq->callback)
eq->callback(eq, u);
}
}
}
void equip_items(struct item **items, const struct equipment *eq)
{
if (eq) {
itemdata *idata;
for (idata = eq->items; idata != NULL; idata = idata->next) {
int i = dice_rand(idata->value);
if (i > 0) {
i_add(items, i_new(idata->itype, i));
}
}
if (eq->subsets) {
int i;
for (i = 0; eq->subsets[i].sets; ++i) {
if (chance(eq->subsets[i].chance)) {
double rnd = (1 + rng_int() % 1000) / 1000.0;
int k;
for (k = 0; eq->subsets[i].sets[k].set; ++k) {
if (rnd <= eq->subsets[i].sets[k].chance) {
equip_items(items, eq->subsets[i].sets[k].set);
break;
}
rnd -= eq->subsets[i].sets[k].chance;
}
}
}
}
}
}
void free_ls(void *arg) {
lazy_spell *ls = (lazy_spell*)arg;
spellref_free(ls->spref);
free(ls);
}
static critbit_tree cb_equipments = { 0 };
#define EQNAMELEN 24
typedef struct eq_entry {
char key[EQNAMELEN];
equipment *value;
} eq_entry;
typedef struct name_cb_data {
const equipment *find;
const char *result;
} name_cb_data;
static int equipment_name_cb(const void * match, const void * key, size_t keylen, void *cbdata) {
const eq_entry *ent = (const eq_entry *)match;
name_cb_data *query = (name_cb_data *)cbdata;
if (ent->value == query->find) {
query->result = ent->key;
return 1;
}
return 0;
}
const char *equipment_name(const struct equipment *eq)
{
name_cb_data data;
data.find = eq;
data.result = NULL;
cb_foreach(&cb_equipments, "", 0, equipment_name_cb, &data);
return data.result;
}
equipment *get_equipment(const char *eqname)
{
const void *match;
if (strlen(eqname) >= EQNAMELEN) {
log_warning("equipment name is longer than %d bytes: %s", EQNAMELEN - 1, eqname);
return NULL;
}
match = cb_find_str(&cb_equipments, eqname);
if (match) {
const eq_entry *ent = (const eq_entry *)match;
return ent->value;
}
return NULL;
}
equipment *create_equipment(const char *eqname)
{
size_t len = strlen(eqname);
eq_entry ent;
if (len >= EQNAMELEN) {
log_error("equipment name is longer than %d bytes: %s", EQNAMELEN-1, eqname);
len = EQNAMELEN-1;
}
memset(ent.key, 0, EQNAMELEN);
memcpy(ent.key, eqname, len);
ent.value = (equipment *)calloc(1, sizeof(equipment));
cb_insert(&cb_equipments, &ent, sizeof(ent));
return ent.value;
}
equipment *get_or_create_equipment(const char *eqname)
{
equipment *eq = get_equipment(eqname);
if (!eq) {
return create_equipment(eqname);
}
return eq;
}
static void free_equipment(equipment *eq) {
int i;
if (eq->spells) {
selist_foreach(eq->spells, free_ls);
selist_free(eq->spells);
}
while (eq->items) {
itemdata *next = eq->items->next;
free(eq->items->value);
free(eq->items);
eq->items = next;
}
if (eq->subsets) {
for (i = 0; eq->subsets[i].sets; ++i) {
free(eq->subsets[i].sets);
}
free(eq->subsets);
}
for (i = 0; i != MAXSKILLS; ++i) {
free(eq->skills[i]);
}
}
static int free_equipment_cb(const void * match, const void * key, size_t keylen, void *cbdata) {
const eq_entry * ent = (const eq_entry *)match;
free_equipment(ent->value);
free(ent->value);
return 0;
}
void equipment_done(void) {
cb_foreach(&cb_equipments, "", 0, free_equipment_cb, 0);
cb_clear(&cb_equipments);
return false;
}

View file

@ -19,63 +19,20 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef H_KRNL_EQUIPMENT_H
#define H_KRNL_EQUIPMENT_H
#include "skill.h"
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
struct spell;
struct item;
struct unit;
typedef struct itemdata {
const struct item_type *itype;
char *value;
struct itemdata *next;
} itemdata;
typedef struct subsetitem {
struct equipment *set;
float chance;
} subsetitem;
typedef struct subset {
float chance;
subsetitem *sets;
} subset;
typedef struct equipment {
struct itemdata *items;
char *skills[MAXSKILLS];
struct selist *spells;
struct subset *subsets;
void(*callback) (const struct equipment *, struct unit *);
} equipment;
void equipment_done(void);
const char *equipment_name(const struct equipment *eq);
struct equipment *get_or_create_equipment(const char *eqname);
struct equipment *get_equipment(const char *eqname);
struct equipment *create_equipment(const char *eqname);
void equipment_setitem(struct equipment *eq,
const struct item_type *itype, const char *value);
void equipment_setskill(struct equipment *eq, skill_t sk,
const char *value);
void equipment_addspell(struct equipment *eq, const char *name, int level);
void equipment_setcallback(struct equipment *eq,
void(*callback) (const struct equipment *, struct unit *));
void equip_unit(struct unit *u, const struct equipment *eq);
#define EQUIP_SKILLS (1<<1)
#define EQUIP_SPELLS (1<<2)
#define EQUIP_ITEMS (1<<3)
#define EQUIP_SPECIAL (1<<4)
#define EQUIP_ALL (0xFF)
void equip_unit_mask(struct unit *u, const struct equipment *eq,
int mask);
void equip_items(struct item **items, const struct equipment *eq);
bool equip_unit_mask(struct unit *u, const char *eqname, int mask);
bool equip_unit(struct unit *u, const char *eqname);
#ifdef __cplusplus
}

View file

@ -2,6 +2,7 @@
#include "magic.h"
#include <kernel/callbacks.h>
#include <kernel/equipment.h>
#include <kernel/item.h>
#include <kernel/unit.h>
@ -10,62 +11,40 @@
#include <CuTest.h>
#include <tests.h>
static void test_equipment(CuTest * tc)
{
equipment * eq;
unit * u;
const item_type * it_horses;
spell *sp;
sc_mage * mage;
static unit *eq_unit;
static const char *eq_name;
static int eq_mask;
test_setup();
test_create_race("human");
enable_skill(SK_MAGIC, true);
it_horses = test_create_itemtype("horse");
CuAssertPtrNotNull(tc, it_horses);
sp = create_spell("testspell");
CuAssertPtrNotNull(tc, sp);
CuAssertPtrEquals(tc, 0, get_equipment("herpderp"));
eq = get_or_create_equipment("herpderp");
CuAssertPtrEquals(tc, eq, get_equipment("herpderp"));
equipment_setitem(eq, it_horses, "1");
equipment_setskill(eq, SK_MAGIC, "5");
equipment_addspell(eq, sp->sname, 1);
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
equip_unit_mask(u, eq, EQUIP_ALL);
CuAssertIntEquals(tc, 1, i_get(u->items, it_horses));
CuAssertIntEquals(tc, 5, get_level(u, SK_MAGIC));
mage = get_mage_depr(u);
CuAssertPtrNotNull(tc, mage);
CuAssertPtrNotNull(tc, mage->spellbook);
CuAssertTrue(tc, u_hasspell(u, sp));
test_teardown();
static bool equip_callback(unit *u, const char *eqname, int mask) {
eq_unit = u;
eq_name = eqname;
eq_mask = mask;
return true;
}
static void test_get_equipment(CuTest * tc)
static void test_equipment(CuTest * tc)
{
equipment * eq;
callbacks.equip_unit = equip_callback;
unit * u;
test_setup();
eq = create_equipment("catapultammo123");
CuAssertPtrNotNull(tc, eq);
CuAssertStrEquals(tc, "catapultammo123", equipment_name(eq));
eq = get_equipment("catapultammo123");
CuAssertPtrNotNull(tc, eq);
CuAssertStrEquals(tc, "catapultammo123", equipment_name(eq));
eq = get_equipment("catapult");
CuAssertPtrEquals(tc, NULL, eq);
eq = create_equipment("catapult");
CuAssertPtrNotNull(tc, eq);
CuAssertPtrEquals(tc, eq, get_equipment("catapult"));
CuAssertStrEquals(tc, "catapult", equipment_name(eq));
eq = get_equipment("catapultammo123");
CuAssertPtrNotNull(tc, eq);
CuAssertStrEquals(tc, "catapultammo123", equipment_name(eq));
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
CuAssertIntEquals(tc, true, equip_unit_mask(u, "hodor", EQUIP_ALL));
CuAssertIntEquals(tc, EQUIP_ALL, eq_mask);
CuAssertPtrEquals(tc, u, eq_unit);
CuAssertStrEquals(tc, "hodor", eq_name);
CuAssertIntEquals(tc, true, equip_unit_mask(u, "foobar", EQUIP_ITEMS));
CuAssertIntEquals(tc, EQUIP_ITEMS, eq_mask);
CuAssertPtrEquals(tc, u, eq_unit);
CuAssertStrEquals(tc, "foobar", eq_name);
CuAssertIntEquals(tc, true, equip_unit(u, "unknown"));
CuAssertIntEquals(tc, EQUIP_ALL, eq_mask);
CuAssertPtrEquals(tc, u, eq_unit);
CuAssertStrEquals(tc, "unknown", eq_name);
test_teardown();
}
@ -73,6 +52,5 @@ CuSuite *get_equipment_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_equipment);
SUITE_ADD_TEST(suite, test_get_equipment);
return suite;
}

View file

@ -285,7 +285,6 @@ unit *addplayer(region * r, faction * f)
{
unit *u;
const char * name;
const struct equipment* eq;
assert(r->land);
if (rpeasants(r) < PEASANT_MIN) {
@ -296,10 +295,7 @@ unit *addplayer(region * r, faction * f)
faction_setorigin(f, 0, r->x, r->y);
u = create_unit(r, f, 1, f->race, 0, NULL, NULL);
name = config_get("rules.equip_first");
eq = get_equipment(name ? name : "first_unit");
if (eq) {
equip_items(&u->items, eq);
}
equip_unit(u, name ? name : "first_unit");
u->hp = unit_max_hp(u) * u->number;
fset(u, UFL_ISNEW);
if (f->race == get_race(RC_DAEMON)) {

View file

@ -1091,7 +1091,6 @@ void terraform_region(region * r, const terrain_type * terrain)
rsethorses(r, 0);
rsetpeasants(r, 0);
rsetmoney(r, 0);
freset(r, RF_ENCOUNTER);
freset(r, RF_MALLORN);
return;
}
@ -1195,9 +1194,6 @@ void terraform_region(region * r, const terrain_type * terrain)
fset(r, RF_MALLORN);
else
freset(r, RF_MALLORN);
if (rng_int() % 100 < ENCCHANCE) {
fset(r, RF_ENCOUNTER);
}
}
}

View file

@ -42,7 +42,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define RF_UNUSED_7 (1<<7)
#define RF_UNUSED_8 (1<<8)
#define RF_ENCOUNTER (1<<9) /* persistent */
#define RF_MAPPER_HIGHLIGHT (1<<10)
#define RF_LIGHTHOUSE (1<<11) /* this region may contain a lighthouse */
#define RF_MIGRATION (1<<13)
@ -58,7 +57,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define RF_ALL 0xFFFFFF
#define RF_SAVEMASK (RF_CHAOTIC|RF_MALLORN|RF_BLOCKED|RF_ENCOUNTER|RF_GUARDED|RF_LIGHTHOUSE)
#define RF_SAVEMASK (RF_CHAOTIC|RF_MALLORN|RF_BLOCKED|RF_GUARDED|RF_LIGHTHOUSE)
struct message;
struct message_list;
struct rawmaterial;

View file

@ -27,7 +27,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "building.h"
#include "calendar.h"
#include "connection.h"
#include "equipment.h"
#include "faction.h"
#include "group.h"
#include "item.h"
@ -1331,29 +1330,7 @@ static void fix_familiars(void) {
/* unit is potentially a familiar */
attrib * a = a_find(u->attribs, &at_mage);
attrib * am = a_find(u->attribs, &at_familiarmage);
if (am) {
sc_mage *mage = a ? (sc_mage *)a->data.v : NULL;
/* a familiar */
if (!mage) {
log_error("%s seems to be a familiar with no magic.",
unitname(u));
mage = create_mage(u, M_GRAY);
}
if (!mage->spellbook) {
char eqname[32];
equipment *eq;
snprintf(eqname, sizeof(eqname), "fam_%s", u->_race->_name);
eq = get_equipment(eqname);
if (eq && eq->spells) {
log_error("%s seems to be a familiar with no spells.",
unitname(u));
/* magical familiar, no spells */
equip_unit_mask(u, eq, EQUIP_SPELLS);
}
}
}
else if (a) {
if (!am && a) {
/* not a familiar, but magical */
attrib * ae = a_find(u->attribs, &at_eventhandler);
if (ae) {

View file

@ -4040,11 +4040,6 @@ void init_processor(void)
p += 10;
add_proc_order(p, K_GUARD, guard_on_cmd, 0, "Bewache (an)");
if (config_get_int("rules.encounters", 0)) {
p += 10;
add_proc_global(p, encounters, "Zufallsbegegnungen");
}
p += 10;
add_proc_unit(p, monster_kills_peasants,
"Monster fressen und vertreiben Bauern");

View file

@ -2181,18 +2181,13 @@ void remove_familiar(unit * mage)
void create_newfamiliar(unit * mage, unit * fam)
{
/* skills and spells: */
const struct equipment *eq;
char eqname[64];
const race *rc = u_race(fam);
set_familiar(mage, fam);
snprintf(eqname, sizeof(eqname), "fam_%s", rc->_name);
eq = get_equipment(eqname);
if (eq != NULL) {
equip_unit(fam, eq);
}
else {
if (!equip_unit(fam, eqname)) {
log_info("could not perform initialization for familiar %s.\n", rc->_name);
}
/* TODO: Diese Attribute beim Tod des Familiars entfernen: */

View file

@ -4,6 +4,7 @@
#include "teleport.h"
#include "give.h"
#include <kernel/callbacks.h>
#include <kernel/building.h>
#include <kernel/race.h>
#include <kernel/equipment.h>
@ -556,39 +557,32 @@ static void test_familiar_age(CuTest *tc) {
test_teardown();
}
static unit *eq_unit;
static char *eq_name;
static int eq_mask;
static bool equip_callback(unit *u, const char *eqname, int mask) {
eq_unit = u;
eq_name = str_strdup(eqname);
eq_mask = mask;
return true;
}
static void test_familiar_equip(CuTest *tc) {
unit *mag, *u;
equipment *eq;
const item_type * itype;
spell *sp;
sc_mage * mage;
test_setup();
itype = test_create_itemtype("horse");
CuAssertPtrNotNull(tc, itype);
sp = create_spell("testspell");
CuAssertPtrNotNull(tc, sp);
eq = get_or_create_equipment("fam_human");
equipment_setitem(eq, itype, "1");
equipment_setskill(eq, SK_ENTERTAINMENT, "5");
equipment_addspell(eq, sp->sname, 1);
callbacks.equip_unit = equip_callback;
mag = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
u = test_create_unit(mag->faction, test_create_region(0, 0, NULL));
CuAssertStrEquals(tc, "human", u->_race->_name);
set_familiar(mag, u);
create_newfamiliar(mag, u);
CuAssertIntEquals(tc, 1, i_get(u->items, itype));
CuAssertIntEquals(tc, 5, get_level(u, SK_ENTERTAINMENT));
CuAssertIntEquals(tc, 0, get_level(u, SK_MAGIC));
mage = get_mage(u);
CuAssertPtrNotNull(tc, mage);
CuAssertPtrNotNull(tc, mage->spellbook);
set_level(u, SK_MAGIC, 1);
CuAssertPtrEquals(tc, mage, get_mage_depr(u));
CuAssertTrue(tc, u_hasspell(u, sp));
CuAssertIntEquals(tc, EQUIP_ALL, eq_mask);
CuAssertPtrEquals(tc, u, eq_unit);
CuAssertStrEquals(tc, "fam_human", eq_name);
free(eq_name);
test_teardown();
}

View file

@ -612,7 +612,7 @@ static void recruit_dracoids(unit * dragon, int size)
name_unit(un);
change_money(dragon, -un->number * 50);
equip_unit(un, get_equipment("new_dracoid"));
equip_unit(un, "new_dracoid");
unit_setstatus(un, ST_FIGHT);
for (weapon = un->items; weapon; weapon = weapon->next) {
@ -864,7 +864,7 @@ static int nrand(int handle_start, int sub)
unit *spawn_seaserpent(region *r, faction *f) {
unit *u = create_unit(r, f, 1, get_race(RC_SEASERPENT), 0, NULL, NULL);
fset(u, UFL_ISNEW | UFL_MOVED);
equip_unit(u, get_equipment("seed_seaserpent"));
equip_unit(u, "seed_seaserpent");
return u;
}
@ -903,7 +903,7 @@ void spawn_dragons(void)
u = create_unit(r, monsters, nrand(30, 20) + 1, get_race(RC_DRAGON), 0, NULL, NULL);
}
fset(u, UFL_ISNEW | UFL_MOVED);
equip_unit(u, get_equipment("seed_dragon"));
equip_unit(u, "seed_dragon");
log_debug("spawning %d %s in %s.\n", u->number,
LOC(default_locale,
@ -965,7 +965,7 @@ void spawn_undead(void)
fset(u, UFL_ISNEW | UFL_MOVED);
if ((rc == get_race(RC_SKELETON) || rc == get_race(RC_ZOMBIE))
&& rng_int() % 10 < 4) {
equip_unit(u, get_equipment("rising_undead"));
equip_unit(u, "rising_undead");
}
for (i = 0; i < MAXSKILLS; i++) {

View file

@ -12,7 +12,6 @@
#include "races.h"
#include <kernel/building.h>
#include <kernel/equipment.h>
#include <kernel/faction.h>
#include <kernel/item.h>
#include <kernel/pathfinder.h>
@ -36,7 +35,7 @@ void age_skeleton(struct unit *u);
void age_zombie(struct unit *u);
void age_ghoul(struct unit *u);
static void equip_newunits(const struct equipment *eq, struct unit *u)
void equip_newunits(struct unit *u)
{
struct region *r = u->region;
const struct resource_type *rtype;
@ -81,8 +80,6 @@ static void equip_newunits(const struct equipment *eq, struct unit *u)
* in die jeweilige Rassendefiniton eingebunden */
void register_races(void)
{
register_function((pf_generic)equip_newunits, "equip_newunits");
/* function age for race->age() */
register_function((pf_generic)age_undead, "age_undead");
register_function((pf_generic)age_skeleton, "age_skeleton");

View file

@ -18,6 +18,7 @@ extern "C" {
void register_races(void);
void make_undead_unit(struct unit *);
void equip_newunits(struct unit *u);
#ifdef __cplusplus
}

View file

@ -155,267 +155,6 @@ static void dissolve_units(void)
remove_empty_units();
}
static bool improve_all(faction * f, skill_t sk, int by_weeks)
{
unit *u;
bool result = false;
for (u = f->units; u; u = u->nextF) {
if (has_skill(u, sk)) {
increase_skill(u, sk, by_weeks);
result = true;
}
}
return result;
}
void find_manual(region * r, unit * u)
{
char zLocation[32];
char zBook[32];
skill_t skill = NOSKILL;
message *msg;
switch (rng_int() % 36) {
case 0:
skill = SK_MAGIC;
break;
case 1:
case 2:
case 3:
case 4:
skill = SK_WEAPONSMITH;
break;
case 5:
case 6:
skill = SK_TACTICS;
break;
case 7:
case 8:
case 9:
case 10:
skill = SK_SHIPBUILDING;
break;
case 11:
case 12:
case 13:
case 14:
skill = SK_SAILING;
break;
case 15:
case 16:
case 17:
skill = SK_HERBALISM;
break;
case 18:
case 19:
skill = SK_ALCHEMY;
break;
case 20:
case 21:
case 22:
case 23:
skill = SK_BUILDING;
break;
case 24:
case 25:
case 26:
case 27:
skill = SK_ARMORER;
break;
case 28:
case 29:
case 30:
case 31:
skill = SK_MINING;
break;
case 32:
case 33:
case 34:
case 35:
skill = SK_ENTERTAINMENT;
break;
}
snprintf(zLocation, sizeof(zLocation), "manual_location_%d",
(int)(rng_int() % 4));
snprintf(zBook, sizeof(zLocation), "manual_title_%s", skillnames[skill]);
msg = msg_message("find_manual", "unit location book", u, zLocation, zBook);
if (msg) {
r_addmessage(r, u->faction, msg);
msg_release(msg);
}
if (!improve_all(u->faction, skill, 3)) {
increase_skill(u, skill, 9);
}
}
static void get_villagers(region * r, unit * u)
{
unit *newunit;
message *msg = msg_message("encounter_villagers", "unit", u);
const char *name = LOC(u->faction->locale, "villagers");
r_addmessage(r, u->faction, msg);
msg_release(msg);
newunit =
create_unit(r, u->faction, rng_int() % 20 + 3, u->faction->race, 0, name,
u);
leave(newunit, true);
fset(newunit, UFL_ISNEW | UFL_MOVED);
equip_unit(newunit, get_equipment("rand_villagers"));
}
static void get_allies(region * r, unit * u)
{
unit *newunit = NULL;
const char *name;
const char *equip;
int number;
message *msg;
assert(u->number);
switch (rterrain(r)) {
case T_PLAIN:
if (!r_isforest(r)) {
if (get_money(u) / u->number < 100 + rng_int() % 200)
return;
name = "random_plain_men";
equip = "rand_plain";
number = rng_int() % 8 + 2;
break;
}
else {
if (effskill(u, SK_LONGBOW, r) < 3
&& effskill(u, SK_HERBALISM, r) < 2
&& effskill(u, SK_MAGIC, r) < 2) {
return;
}
name = "random_forest_men";
equip = "rand_forest";
number = rng_int() % 6 + 2;
}
break;
case T_SWAMP:
if (effskill(u, SK_MELEE, r) <= 1) {
return;
}
name = "random_swamp_men";
equip = "rand_swamp";
number = rng_int() % 6 + 2;
break;
case T_DESERT:
if (effskill(u, SK_RIDING, r) <= 2) {
return;
}
name = "random_desert_men";
equip = "rand_desert";
number = rng_int() % 12 + 2;
break;
case T_HIGHLAND:
if (effskill(u, SK_MELEE, r) <= 1) {
return;
}
name = "random_highland_men";
equip = "rand_highland";
number = rng_int() % 8 + 2;
break;
case T_MOUNTAIN:
if (effskill(u, SK_MELEE, r) <= 1 || effskill(u, SK_TRADE, r) <= 2) {
return;
}
name = "random_mountain_men";
equip = "rand_mountain";
number = rng_int() % 6 + 2;
break;
case T_GLACIER:
if (effskill(u, SK_MELEE, r) <= 1 || effskill(u, SK_TRADE, r) <= 1) {
return;
}
name = "random_glacier_men";
equip = "rand_glacier";
number = rng_int() % 4 + 2;
break;
default:
return;
}
newunit =
create_unit(r, u->faction, number, u->faction->race, 0,
LOC(u->faction->locale, name), u);
equip_unit(newunit, get_equipment(equip));
u_setfaction(newunit, u->faction);
set_racename(&newunit->attribs, get_racename(u->attribs));
if (u_race(u)->flags & RCF_SHAPESHIFT) {
newunit->irace = u->irace;
}
if (fval(u, UFL_ANON_FACTION))
fset(newunit, UFL_ANON_FACTION);
fset(newunit, UFL_ISNEW);
msg = msg_message("encounter_allies", "unit name", u, name);
r_addmessage(r, u->faction, msg);
msg_release(msg);
}
static void encounter(region * r, unit * u)
{
if (!fval(r, RF_ENCOUNTER))
return;
freset(r, RF_ENCOUNTER);
if (rng_int() % 100 >= ENCCHANCE)
return;
switch (rng_int() % 3) {
case 0:
find_manual(r, u);
break;
case 1:
get_villagers(r, u);
break;
case 2:
get_allies(r, u);
break;
}
}
void encounters(void)
{
region *r;
for (r = regions; r; r = r->next) {
if (fval(r->terrain, LAND_REGION) && fval(r, RF_ENCOUNTER)) {
int c = 0;
unit *u;
for (u = r->units; u; u = u->next) {
c += u->number;
}
if (c > 0) {
int i = 0;
int n = rng_int() % c;
for (u = r->units; u; u = u->next) {
if (i + u->number > n)
break;
i += u->number;
}
assert(u && u->number);
encounter(r, u);
}
}
}
}
void drown(region * r)
{
if (fval(r->terrain, SEA_REGION)) {
@ -611,7 +350,7 @@ static void move_icebergs(void)
}
}
void create_icebergs(void)
static void create_icebergs(void)
{
region *r;
const struct terrain_type *t_iceberg, *t_sleep;
@ -763,9 +502,8 @@ static void icebergs(void)
move_icebergs();
}
#define HERBS_ROT /* herbs owned by units have a chance to rot. */
#define HERBROTCHANCE 5 /* Verrottchance f<>r Kr<4B>uter (ifdef HERBS_ROT) */
#ifdef HERBS_ROT
static void rotting_herbs(void)
{
region *r;
@ -798,7 +536,6 @@ static void rotting_herbs(void)
}
}
}
#endif
void randomevents(void)
{
@ -842,9 +579,7 @@ void randomevents(void)
}
chaos_update();
#ifdef HERBS_ROT
rotting_herbs();
#endif
dissolve_units();
}

View file

@ -30,7 +30,6 @@ extern "C" {
#define PLAGUE_HEALCHANCE 0.25 /* Wahrscheinlichkeit Heilung */
#define PLAGUE_HEALCOST 30 /* Heilkosten */
void plagues(struct region *r);
void encounters(void);
void randomevents(void);
#ifdef __cplusplus

View file

@ -31,6 +31,5 @@
/* Gebaeudegroesse = Minimalbelagerer */
#define SIEGEFACTOR 2
#define ENCCHANCE 10 /* %-Chance fuer einmalige Zufallsbegegnung */
#define BAGCAPACITY 20000 /* soviel passt in einen Bag of Holding */
#define PERSON_WEIGHT 1000 /* weight of a "normal" human unit */

View file

@ -181,7 +181,7 @@ void spawn_braineaters(float chance)
if (next-- == 0) {
u = create_unit(r, f, 1 + rng_int() % 10 + rng_int() % 10,
rc_brain, 0, NULL, NULL);
equip_unit(u, get_equipment("seed_braineater"));
equip_unit(u, "seed_braineater");
next = rng_int() % (int)(chance * 100);
}

View file

@ -212,7 +212,6 @@ static void test_reset(void) {
free_config();
default_locale = 0;
calendar_cleanup();
equipment_done();
close_orders();
free_special_directions();
free_locales();
@ -257,6 +256,7 @@ void test_setup_test(CuTest *tc, const char *file, int line) {
else {
log_debug("start test in %s:%d", file, line);
}
errno = 0;
}
void test_teardown(void)

View file

@ -16,7 +16,6 @@ without prior permission by the authors of Eressea.
#include "xmlreader.h"
#include "kernel/building.h"
#include "kernel/equipment.h"
#include "kernel/item.h"
#include "kernel/messages.h"
#include "kernel/race.h"
@ -856,227 +855,6 @@ static int parse_resources(xmlDocPtr doc)
return results;
}
static void add_items(equipment * eq, xmlNodeSetPtr nsetItems)
{
if (nsetItems != NULL && nsetItems->nodeNr > 0) {
int i;
for (i = 0; i != nsetItems->nodeNr; ++i) {
xmlNodePtr node = nsetItems->nodeTab[i];
xmlChar *propValue;
const struct item_type *itype;
struct resource_type *rtype;
propValue = xmlGetProp(node, BAD_CAST "name");
assert(propValue != NULL);
rtype = rt_get_or_create((const char *)propValue);
itype = it_get_or_create(rtype);
xmlFree(propValue);
if (itype != NULL) {
propValue = xmlGetProp(node, BAD_CAST "amount");
if (propValue != NULL) {
equipment_setitem(eq, itype, (const char *)propValue);
xmlFree(propValue);
}
}
}
}
}
static void add_callbacks(equipment * eq, xmlNodeSetPtr nsetItems)
{
if (nsetItems != NULL && nsetItems->nodeNr > 0) {
int i;
for (i = 0; i != nsetItems->nodeNr; ++i) {
xmlNodePtr node = nsetItems->nodeTab[i];
xmlChar *propValue;
pf_generic fun;
propValue = xmlGetProp(node, BAD_CAST "name");
if (propValue != NULL) {
fun = get_function((const char *)propValue);
if (fun) {
equipment_setcallback(eq, (void(*)(const struct equipment *,
struct unit *))fun);
}
xmlFree(propValue);
}
}
}
}
static void add_spells(equipment * eq, xmlNodeSetPtr nsetItems)
{
if (nsetItems != NULL && nsetItems->nodeNr > 0) {
int i;
for (i = 0; i != nsetItems->nodeNr; ++i) {
xmlNodePtr node = nsetItems->nodeTab[i];
xmlChar *propValue;
int level;
const char *name;
propValue = xmlGetProp(node, BAD_CAST "name");
assert(propValue != NULL);
name = (const char *)propValue;
level = xml_ivalue(node, "level", 0);
if (level > 0) {
equipment_addspell(eq, name, level);
}
else {
log_error("spell '%s' for equipment-set '%s' has no level\n", name, equipment_name(eq));
}
xmlFree(propValue);
}
}
}
static void add_skills(equipment * eq, xmlNodeSetPtr nsetSkills)
{
if (nsetSkills != NULL && nsetSkills->nodeNr > 0) {
int i;
for (i = 0; i != nsetSkills->nodeNr; ++i) {
xmlNodePtr node = nsetSkills->nodeTab[i];
xmlChar *propValue;
skill_t sk;
propValue = xmlGetProp(node, BAD_CAST "name");
assert(propValue != NULL);
sk = findskill((const char *)propValue);
if (sk == NOSKILL) {
log_error("unknown skill '%s' in equipment-set %s\n", (const char *)propValue, equipment_name(eq));
xmlFree(propValue);
}
else {
xmlFree(propValue);
propValue = xmlGetProp(node, BAD_CAST "level");
if (propValue != NULL) {
equipment_setskill(eq, sk, (const char *)propValue);
xmlFree(propValue);
}
}
}
}
}
static void
add_subsets(xmlDocPtr doc, equipment * eq, xmlNodeSetPtr nsetSubsets)
{
xmlXPathContextPtr xpath = xmlXPathNewContext(doc);
if (nsetSubsets != NULL && nsetSubsets->nodeNr > 0) {
int i;
eq->subsets = calloc(nsetSubsets->nodeNr + 1, sizeof(subset));
for (i = 0; i != nsetSubsets->nodeNr; ++i) {
xmlXPathObjectPtr xpathResult;
xmlNodePtr node = nsetSubsets->nodeTab[i];
xmlChar *propValue;
eq->subsets[i].chance = 1.0f;
propValue = xmlGetProp(node, BAD_CAST "chance");
if (propValue != NULL) {
eq->subsets[i].chance = (float)atof((const char *)propValue);
xmlFree(propValue);
}
xpath->node = node;
xpathResult = xmlXPathEvalExpression(BAD_CAST "set", xpath);
if (xpathResult->nodesetval) {
xmlNodeSetPtr nsetSets = xpathResult->nodesetval;
float totalChance = 0.0f;
if (nsetSets->nodeNr > 0) {
int set;
eq->subsets[i].sets =
calloc(nsetSets->nodeNr + 1, sizeof(subsetitem));
for (set = 0; set != nsetSets->nodeNr; ++set) {
xmlNodePtr nodeSet = nsetSets->nodeTab[set];
float chance = 1.0f;
propValue = xmlGetProp(nodeSet, BAD_CAST "chance");
if (propValue != NULL) {
chance = (float)atof((const char *)propValue);
xmlFree(propValue);
}
totalChance += chance;
propValue = xmlGetProp(nodeSet, BAD_CAST "name");
assert(propValue != NULL);
eq->subsets[i].sets[set].chance = chance;
eq->subsets[i].sets[set].set =
get_or_create_equipment((const char *)propValue);
xmlFree(propValue);
}
}
if (totalChance > 1.0f) {
log_error("total chance exceeds 1.0: %f in equipment set %s.\n", totalChance, equipment_name(eq));
}
}
xmlXPathFreeObject(xpathResult);
}
}
xmlXPathFreeContext(xpath);
}
static int parse_equipment(xmlDocPtr doc)
{
xmlXPathContextPtr xpath = xmlXPathNewContext(doc);
xmlXPathObjectPtr xpathRaces;
int result = 0;
/* reading eressea/equipment/set */
xpathRaces = xmlXPathEvalExpression(BAD_CAST "/eressea/equipment/set", xpath);
if (xpathRaces->nodesetval) {
xmlNodeSetPtr nsetRaces = xpathRaces->nodesetval;
int i;
result += nsetRaces->nodeNr;
for (i = 0; i != nsetRaces->nodeNr; ++i) {
xmlNodePtr node = nsetRaces->nodeTab[i];
xmlChar *propName = xmlGetProp(node, BAD_CAST "name");
if (propName != NULL) {
equipment *eq = get_equipment((const char *)propName);
xmlXPathObjectPtr xpathResult;
if (!eq) {
eq = create_equipment((const char *)propName);
}
xpath->node = node;
xpathResult = xmlXPathEvalExpression(BAD_CAST "callback", xpath);
assert(!eq->callback);
add_callbacks(eq, xpathResult->nodesetval);
xmlXPathFreeObject(xpathResult);
xpathResult = xmlXPathEvalExpression(BAD_CAST "item", xpath);
assert(!eq->items);
add_items(eq, xpathResult->nodesetval);
xmlXPathFreeObject(xpathResult);
xpathResult = xmlXPathEvalExpression(BAD_CAST "spell", xpath);
assert(!eq->spells);
add_spells(eq, xpathResult->nodesetval);
xmlXPathFreeObject(xpathResult);
xpathResult = xmlXPathEvalExpression(BAD_CAST "skill", xpath);
add_skills(eq, xpathResult->nodesetval);
xmlXPathFreeObject(xpathResult);
xpathResult = xmlXPathEvalExpression(BAD_CAST "subset", xpath);
assert(!eq->subsets);
add_subsets(doc, eq, xpathResult->nodesetval);
xmlXPathFreeObject(xpathResult);
xmlFree(propName);
}
}
}
xmlXPathFreeObject(xpathRaces);
xmlXPathFreeContext(xpath);
return result;
}
static int parse_spellbooks(xmlDocPtr doc)
{
xmlXPathContextPtr xpath = xmlXPathNewContext(doc);
@ -1697,7 +1475,6 @@ void register_xmlreader(void)
xml_register_callback(parse_spells);
xml_register_callback(parse_races);
#endif
xml_register_callback(parse_equipment);
xml_register_callback(parse_strings);