From cd2435dbb070f45fabd529c243919a5b01eb0670 Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Sun, 6 May 2018 09:00:00 +0200
Subject: [PATCH 01/24] spell xml does not define an index attribute

---
 res/core/spells.xml    |  40 ++---
 res/e3a/spells.xml     | 270 ++++++++++++++++-----------------
 res/eressea/spells.xml | 330 ++++++++++++++++++++---------------------
 src/xmlreader.c        |   2 +-
 4 files changed, 321 insertions(+), 321 deletions(-)

diff --git a/res/core/spells.xml b/res/core/spells.xml
index fba087855..7a6d9a13e 100644
--- a/res/core/spells.xml
+++ b/res/core/spells.xml
@@ -2,115 +2,115 @@
 <spells>
 
   <!-- shared spells -->
-  <spell name="create_roi" ship="true" rank="5" index="130">
+  <spell name="create_roi" ship="true" rank="5">
     <resource name="aura" amount="50" cost="fixed"/>
     <resource name="money" amount="3000" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
 
-  <spell name="create_aots" ship="true" rank="5" index="125">
+  <spell name="create_aots" ship="true" rank="5">
     <resource name="aura" amount="50" cost="fixed"/>
     <resource name="money" amount="3000" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
 
   <!-- draig spells -->
-  <spell name="earn_silver#draig" ship="true" variable="true" rank="5" index="159">
+  <spell name="earn_silver#draig" ship="true" variable="true" rank="5">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
 
-  <spell name="create_firesword" ship="true" rank="5" index="148">
+  <spell name="create_firesword" ship="true" rank="5">
     <resource name="aura" amount="100" cost="fixed"/>
     <resource name="p10" amount="1" cost="fixed"/>
     <resource name="sword" amount="1" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
 
-  <spell name="create_trollbelt" ship="true" rank="5" index="48">
+  <spell name="create_trollbelt" ship="true" rank="5">
     <resource name="aura" amount="20" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
 
   <!-- gwyrrd spells -->
-  <spell name="earn_silver#gwyrrd" ship="true" variable="true" rank="5" index="159">
+  <spell name="earn_silver#gwyrrd" ship="true" variable="true" rank="5">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
 
-  <spell name="create_magicherbbag" ship="true" rank="5" index="165">
+  <spell name="create_magicherbbag" ship="true" rank="5">
     <resource name="aura" amount="30" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
     <resource name="lifepotion" amount="1" cost="fixed"/>
   </spell>
 
   <!-- illaun spells -->
-  <spell name="earn_silver#illaun" ship="true" variable="true" rank="5" index="159">
+  <spell name="earn_silver#illaun" ship="true" variable="true" rank="5">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
 
-  <spell name="create_dreameye" ship="true" rank="5" index="149">
+  <spell name="create_dreameye" ship="true" rank="5">
     <resource name="dragonhead" amount="1" cost="fixed"/>
     <resource name="permaura" amount="5" cost="fixed"/>
   </spell>
 
-  <spell name="create_invisibility_sphere" ship="true" rank="5" index="178">
+  <spell name="create_invisibility_sphere" ship="true" rank="5">
     <resource name="aura" amount="150" cost="fixed"/>
     <resource name="money" amount="30000" cost="fixed"/>
     <resource name="permaura" amount="3" cost="fixed"/>
   </spell>
 
   <!-- cerddor spells -->
-  <spell name="earn_silver#cerddor" ship="true" variable="true" rank="5" index="159">
+  <spell name="earn_silver#cerddor" ship="true" variable="true" rank="5">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
 
-  <spell name="create_roqf" ship="true" rank="5" index="63">
+  <spell name="create_roqf" ship="true" rank="5">
     <resource name="aura" amount="20" cost="fixed"/>
     <resource name="money" amount="1000" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
 
   <!-- tybied spells -->
-  <spell name="earn_silver#tybied" ship="true" variable="true" rank="5" index="159">
+  <spell name="earn_silver#tybied" ship="true" variable="true" rank="5">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
 
-  <spell name="create_antimagic" ship="true" rank="5" index="38">
+  <spell name="create_antimagic" ship="true" rank="5">
     <resource name="aura" amount="50" cost="fixed"/>
     <resource name="money" amount="3000" cost="fixed"/>
   </spell>
 
-  <spell name="create_rop" ship="true" rank="5" index="1">
+  <spell name="create_rop" ship="true" rank="5">
     <resource name="aura" amount="100" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
     <resource name="money" amount="4000" cost="fixed"/>
   </spell>
 
-  <spell name="create_bagofholding" ship="true" rank="5" index="155">
+  <spell name="create_bagofholding" ship="true" rank="5">
     <resource name="aura" amount="30" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
     <resource name="money" amount="5000" cost="fixed"/>
   </spell>
 
   <!-- gray magic -->
-  <spell name="create_runesword" ship="true" rank="5" index="135">
+  <spell name="create_runesword" ship="true" rank="5">
     <resource name="aura" amount="100" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
     <resource name="money" amount="1000" cost="fixed"/>
     <resource name="laensword" amount="1" cost="fixed"/>
   </spell>
 
-  <spell name="create_chastitybelt" ship="true" rank="5" index="134">
+  <spell name="create_chastitybelt" ship="true" rank="5">
     <resource name="aura" amount="50" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
     <resource name="money" amount="3000" cost="fixed"/>
   </spell>
 
-  <spell name="create_focus" ship="true" rank="5" index="2">
+  <spell name="create_focus" ship="true" rank="5">
     <resource name="aura" amount="100" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
 
-  <spell name="create_ror" ship="true" rank="5" index="3">
+  <spell name="create_ror" ship="true" rank="5">
     <resource name="aura" amount="100" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
diff --git a/res/e3a/spells.xml b/res/e3a/spells.xml
index f3edbd9f6..c6f466eb4 100644
--- a/res/e3a/spells.xml
+++ b/res/e3a/spells.xml
@@ -3,99 +3,99 @@
 <spells>
 
   <!-- shared spells -->
-  <spell name="create_roi" ship="true" rank="5" index="130">
+  <spell name="create_roi" ship="true" rank="5">
     <resource name="aura" amount="50" cost="fixed"/>
     <resource name="money" amount="3000" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
 
-  <spell name="create_aots" ship="true" rank="5" index="125">
+  <spell name="create_aots" ship="true" rank="5">
     <resource name="aura" amount="50" cost="fixed"/>
     <resource name="money" amount="3000" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
 
-  <spell name="disturbingdreams" rank="5" index="50" far="true">
+  <spell name="disturbingdreams" rank="5" far="true">
     <!-- Schlechter Schlaf -->
     <resource name="aura" amount="18" cost="fixed"/>
   </spell>
 
   <!-- new illaun -->
-  <spell name="shadowknights" rank="4" index="147" variable="true" combat="1">
+  <spell name="shadowknights" rank="4" variable="true" combat="1">
     <!-- Schattenritter -->
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="sparkledream" rank="5" index="154" parameters="u" los="true" ship="true" variable="true">
+  <spell name="sparkledream" rank="5" parameters="u" los="true" ship="true" variable="true">
     <!-- Traumsenden -->
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="earn_silver#illaun" ship="true" variable="true" rank="5" index="159">
+  <spell name="earn_silver#illaun" ship="true" variable="true" rank="5">
     <!-- Wahrsagen -->
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="flee" rank="5" index="20" variable="true" combat="1">
+  <spell name="flee" rank="5" variable="true" combat="1">
     <!-- Grauen der Schlacht -->
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="puttorest" rank="5" index="168" variable="true">
+  <spell name="puttorest" rank="5" variable="true">
     <!-- Seelenfrieden -->
     <resource name="aura" amount="3" cost="level"/>
     <resource name="balm" amount="10" cost="fixed"/>
   </spell>
-  <spell name="shapeshift" rank="5" index="93" syntax="race" parameters="uc" variable="true">
+  <spell name="shapeshift" rank="5" syntax="race" parameters="uc" variable="true">
     <!-- Gestaltwandlung -->
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="icastle" rank="5" index="137" syntax="buildingtype" parameters="c">
+  <spell name="icastle" rank="5" syntax="buildingtype" parameters="c">
     <!-- Traumschlößchen -->
     <resource name="aura" amount="3" cost="fixed"/>
   </spell>
-  <spell name="dreamreading" rank="5" index="13" parameters="u" far="true">
+  <spell name="dreamreading" rank="5" parameters="u" far="true">
     <!-- Traumlesen -->
     <resource name="aura" amount="8" cost="fixed"/>
   </spell>
-  <spell name="tiredsoldiers" rank="5" index="15" variable="true" combat="1">
+  <spell name="tiredsoldiers" rank="5" variable="true" combat="1">
     <!-- Schwere Glieder -->
     <resource name="aura" amount="4" cost="level"/>
   </spell>
-  <spell name="reanimate" rank="4" index="85" variable="true" combat="3">
+  <spell name="reanimate" rank="4" variable="true" combat="3">
     <!-- Wiederbelebung -->
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="sleep" rank="5" index="52" variable="true" combat="2">
+  <spell name="sleep" rank="5" variable="true" combat="2">
     <!-- Schlaf -->
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="readmind" parameters="u" rank="5" index="114">
+  <spell name="readmind" parameters="u" rank="5">
     <!-- Traumdeuten -->
     <function name="cast" value="cast_readmind"/>
     <resource name="aura" amount="20" cost="fixed"/>
     <!-- missing syntactical info: ONETARGET | UNITSPELL -->
   </spell>
-  <spell name="gooddreams" rank="5" index="12" far="true">
+  <spell name="gooddreams" rank="5" far="true">
     <!-- Schöne Träume -->
     <resource name="aura" amount="80" cost="fixed"/>
   </spell>
-  <spell name="illaundestroymagic" rank="2" index="140" parameters="kc+" los="true" ship="true" far="true" variable="true">
+  <spell name="illaundestroymagic" rank="2" parameters="kc+" los="true" ship="true" far="true" variable="true">
     <!-- Traumbilder entwirren -->
     <resource name="aura" amount="6" cost="level"/>
   </spell>
-  <spell name="clone" rank="5" index="173">
+  <spell name="clone" rank="5">
     <!-- Seelenkopie -->
     <resource name="aura" amount="100" cost="fixed"/>
     <resource name="permaura" amount="20" cost="fixed"/>
     <resource name="dragonblood" amount="5" cost="fixed"/>
     <resource name="silk" amount="20" cost="fixed"/>
   </spell>
-  <spell name="bad_dreams" rank="5" index="11" far="true">
+  <spell name="bad_dreams" rank="5" far="true">
     <!-- Schlechte Träume -->
     <resource name="aura" amount="90" cost="fixed"/>
   </spell>
-  <spell name="mindblast" rank="5" index="78" variable="true" combat="1">
+  <spell name="mindblast" rank="5" variable="true" combat="1">
     <!-- Tod des Geistes -->
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="create_dreameye" ship="true" rank="5" index="149">
+  <spell name="create_dreameye" ship="true" rank="5">
     <!-- Erschaffe ein Traumauge -->
     <resource name="dragonhead" amount="1" cost="fixed"/>
     <resource name="permaura" amount="5" cost="fixed"/>
@@ -103,87 +103,87 @@
   <!-- end illaun -->
 
   <!-- new draig -->
-  <spell name="sparklechaos" rank="5" index="153" parameters="u" los="true" variable="true">
+  <spell name="sparklechaos" rank="5" parameters="u" los="true" variable="true">
     <!-- Verwünschung -->
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="earn_silver#draig" ship="true" variable="true" rank="5" index="159">
+  <spell name="earn_silver#draig" ship="true" variable="true" rank="5">
     <!-- Kleine Flüche -->
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="fireball" rank="5" index="4" variable="true" combat="2">
+  <spell name="fireball" rank="5" variable="true" combat="2">
     <!-- Feuerball -->
     <function name="cast" value="combat_spell"/>
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="magicboost" rank="3" index="17" ship="true">
+  <spell name="magicboost" rank="3" ship="true">
     <!-- Gabe des Chaos -->
     <resource name="aura" amount="6" cost="fixed"/>
   </spell>
-  <spell name="bloodsacrifice" rank="1" index="171" ship="true">
+  <spell name="bloodsacrifice" rank="1" ship="true">
     <!-- Kleines Blutopfer -->
     <resource name="hp" amount="16" cost="fixed"/>
   </spell>
-  <spell name="berserk" rank="4" index="22" variable="true" combat="1">
+  <spell name="berserk" rank="4" variable="true" combat="1">
     <!-- Blutrausch -->
     <resource name="aura" amount="5" cost="level"/>
     <resource name="peasant" amount="1" cost="fixed"/>
   </spell>
-  <spell name="fumblecurse" rank="4" index="136" parameters="u" los="true" variable="true">
+  <spell name="fumblecurse" rank="4" parameters="u" los="true" variable="true">
     <!-- Chaosfluch -->
     <resource name="aura" amount="4" cost="level"/>
   </spell>
-  <spell name="combatrust" rank="5" index="7" variable="true" combat="2">
+  <spell name="combatrust" rank="5" variable="true" combat="2">
     <!-- Rosthauch -->
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="summonundead" rank="5" index="41" ship="true" far="true" variable="true">
+  <spell name="summonundead" rank="5" ship="true" far="true" variable="true">
     <!-- Mächte des Todes -->
     <resource name="aura" amount="5" cost="level"/>
   </spell>
-  <spell name="firewall" rank="4" index="151" syntax="direction" parameters="c" variable="true">
+  <spell name="firewall" rank="4" syntax="direction" parameters="c" variable="true">
     <!-- Feuerwand -->
     <resource name="aura" amount="6" cost="level"/>
   </spell>
-  <spell name="chaosrow" rank="5" index="18" variable="true" combat="1">
+  <spell name="chaosrow" rank="5" variable="true" combat="1">
     <!-- Wahnsinn des Krieges -->
     <resource name="aura" amount="3" cost="level"/>
     <resource name="peasant" amount="10" cost="fixed"/>
   </spell>
-  <spell name="summonshadow" rank="5" index="34" variable="true">
+  <spell name="summonshadow" rank="5" variable="true">
     <!-- Beschwöre Schattendämonen -->
     <resource name="aura" amount="3" cost="level"/>
   </spell>
-  <spell name="undeadhero" rank="5" index="164" variable="true" combat="3">
+  <spell name="undeadhero" rank="5" variable="true" combat="3">
     <!-- Untote Helden -->
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="draigdestroymagic" rank="2" index="139" parameters="kc+" los="true" ship="true" far="true" variable="true">
+  <spell name="draigdestroymagic" rank="2" parameters="kc+" los="true" ship="true" far="true" variable="true">
     <!-- Pentagramm -->
     <resource name="aura" amount="10" cost="level"/>
   </spell>
-  <spell name="deathcloud" rank="5" index="111" far="true">
+  <spell name="deathcloud" rank="5" far="true">
     <!-- Todeswolke -->
     <resource name="aura" amount="40" cost="fixed"/>
     <resource name="hp" amount="15" cost="fixed"/>
   </spell>
-  <spell name="summondragon" rank="5" index="113" far="true">
+  <spell name="summondragon" rank="5" far="true">
     <!-- Drachenruf -->
     <resource name="aura" amount="80" cost="fixed"/>
     <resource name="dragonhead" amount="1" cost="fixed"/>
   </spell>
-  <spell name="summonshadowlords" rank="5" index="35" variable="true">
+  <spell name="summonshadowlords" rank="5" variable="true">
     <!-- Beschwöre Schattenmeister -->
     <resource name="aura" amount="7" cost="level"/>
   </spell>
-  <spell name="create_firesword" ship="true" rank="5" index="148">
+  <spell name="create_firesword" ship="true" rank="5">
     <!-- Erschaffe ein Flammenschwert -->
     <resource name="aura" amount="100" cost="fixed"/>
     <resource name="oil" amount="10" cost="fixed"/>
     <resource name="sword" amount="1" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
-  <spell name="unholypower" rank="5" index="169" parameters="u+" los="true" variable="true">
+  <spell name="unholypower" rank="5" parameters="u+" los="true" variable="true">
     <!-- Unheilige Kraft -->
     <resource name="aura" amount="10" cost="level"/>
     <resource name="peasant" amount="5" cost="level"/>
@@ -191,185 +191,185 @@
   <!-- end draig -->
 
   <!-- new cerddor -->
-  <spell name="earn_silver#cerddor" ship="true" variable="true" rank="5" index="159">
+  <spell name="earn_silver#cerddor" ship="true" variable="true" rank="5">
     <!-- Gaukeleien -->
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="song_of_healing" rank="5" index="10" variable="true" combat="3">
+  <spell name="song_of_healing" rank="5" variable="true" combat="3">
     <!-- Lied der Heilung -->
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="generous" rank="5" index="87" ship="true" far="true" variable="true">
+  <spell name="generous" rank="5" ship="true" far="true" variable="true">
     <!-- Hohes Lied der Gaukelei -->
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="song_of_fear" rank="5" index="21" variable="true" combat="2">
+  <spell name="song_of_fear" rank="5" variable="true" combat="2">
     <!-- Gesang der Furcht -->
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="song_of_confusion" rank="5" index="19" variable="true" combat="1">
+  <spell name="song_of_confusion" rank="5" variable="true" combat="1">
     <!-- Gesang der Verwirrung -->
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="blabbermouth" parameters="u" los="true" rank="5" index="115">
+  <spell name="blabbermouth" parameters="u" los="true" rank="5">
     <!-- Plappermaul -->
     <function name="cast" value="cast_babbler"/>
     <resource name="aura" amount="10" cost="fixed"/>
     <!-- missing syntactical info: ONETARGET | UNITSPELL -->
   </spell>
-  <spell name="heroic_song" rank="4" index="76" variable="true" combat="1">
+  <spell name="heroic_song" rank="4" variable="true" combat="1">
     <!-- Heldengesang -->
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="seduction" rank="5" index="73" parameters="u" los="true">
+  <spell name="seduction" rank="5" parameters="u" los="true">
     <!-- Lied der Verführung -->
     <resource name="aura" amount="12" cost="fixed"/>
   </spell>
-  <spell name="calm_monster" rank="5" index="75" parameters="u" los="true" ship="true">
+  <spell name="calm_monster" rank="5" parameters="u" los="true" ship="true">
     <!-- Monster friedlich stimmen -->
     <resource name="aura" amount="15" cost="fixed"/>
   </spell>
-  <spell name="bloodthirst" rank="4" index="23" variable="true" combat="1">
+  <spell name="bloodthirst" rank="4" variable="true" combat="1">
     <!-- Kriegsgesang -->
     <resource name="aura" amount="5" cost="level"/>
   </spell>
-  <spell name="frighten" rank="5" index="77" variable="true" combat="1">
+  <spell name="frighten" rank="5" variable="true" combat="1">
     <!-- Gesang der Angst -->
     <resource name="aura" amount="5" cost="level"/>
   </spell>
-  <spell name="cerddor_destroymagic" rank="2" index="141" parameters="kc+" los="true" ship="true" far="true" variable="true">
+  <spell name="cerddor_destroymagic" rank="2" parameters="kc+" los="true" ship="true" far="true" variable="true">
     <!-- Lebenslied festigen -->
     <resource name="aura" amount="5" cost="level"/>
   </spell>
-  <spell name="migration" rank="5" index="90" parameters="u" los="true" variable="true">
+  <spell name="migration" rank="5" parameters="u" los="true" variable="true">
     <!-- Ritual der Aufnahme -->
     <resource name="aura" amount="3" cost="level"/>
     <resource name="permaura" amount="1" cost="level"/>
   </spell>
-  <spell name="raise_mob" rank="5" index="60" variable="true">
+  <spell name="raise_mob" rank="5" variable="true">
     <!-- Mob aufwiegeln -->
     <resource name="aura" amount="4" cost="level"/>
   </spell>
-  <spell name="song_resist_magic" rank="2" index="100" far="true" variable="true">
+  <spell name="song_resist_magic" rank="2" far="true" variable="true">
     <!-- Gesang des wachen Geistes -->
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="create_roqf" ship="true" rank="5" index="63">
+  <spell name="create_roqf" ship="true" rank="5">
     <!-- Miriams flinke Finger -->
     <resource name="aura" amount="20" cost="fixed"/>
     <resource name="money" amount="1000" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
-  <spell name="song_of_peace" rank="5" index="89" variable="true">
+  <spell name="song_of_peace" rank="5" variable="true">
     <!-- Gesang der Friedfertigkeit -->
     <resource name="aura" amount="20" cost="level"/>
   </spell>
-  <spell name="song_suscept_magic" rank="2" index="101" far="true" variable="true">
+  <spell name="song_suscept_magic" rank="2" far="true" variable="true">
     <!-- Gesang des schwachen Geistes -->
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="song_of_slavery" rank="5" index="123" parameters="u" los="true">
+  <spell name="song_of_slavery" rank="5" parameters="u" los="true">
     <!-- Gesang der Versklavung -->
     <resource name="aura" amount="40" cost="fixed"/>
   </spell>
 <!-- TODO: exploitable (transfers items) -->
-  <spell name="big_recruit" rank="5" index="179" variable="true">
+  <spell name="big_recruit" rank="5" variable="true">
     <!-- Hohe Kunst der Überzeugung -->
     <resource name="aura" amount="20" cost="level"/>
   </spell>
-  <spell name="calm_riot" rank="5" index="91" far="true">
+  <spell name="calm_riot" rank="5" far="true">
     <!-- Aufruhr beschwichtigen -->
     <resource name="aura" amount="30" cost="fixed"/>
   </spell>
-  <spell name="incite_riot" rank="5" index="92" far="true">
+  <spell name="incite_riot" rank="5" far="true">
     <!-- Aufruhr verursachen -->
     <resource name="aura" amount="40" cost="fixed"/>
   </spell>
   <!-- end cerddor -->
 
   <!-- new gwyrrd -->
-  <spell name="blessedharvest" rank="5" index="25" ship="true" far="true" variable="true">
+  <spell name="blessedharvest" rank="5" ship="true" far="true" variable="true">
     <!-- Segen der Erde -->
     <function name="cast" value="cast_blessedharvest"/>
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="earn_silver#gwyrrd" ship="true" variable="true" rank="5" index="159">
+  <spell name="earn_silver#gwyrrd" ship="true" variable="true" rank="5">
     <!-- Viehheilung -->
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="stonegolem" rank="4" index="32" variable="true">
+  <spell name="stonegolem" rank="4" variable="true">
     <!-- Erschaffe Steingolems -->
     <resource name="aura" amount="2" cost="level"/>
     <resource name="stone" amount="1" cost="level"/>
     <resource name="jewel" amount="10" cost="fixed"/>
   </spell>
-  <spell name="treegrow" rank="5" index="8" far="true" variable="true">
+  <spell name="treegrow" rank="5" far="true" variable="true">
     <!-- Hainzauber -->
     <resource name="aura" amount="4" cost="level"/>
     <resource name="log" amount="1" cost="level"/>
     <resource name="myrrh" amount="10" cost="fixed"/>
   </spell>
-  <spell name="hail" rank="5" index="5" variable="true" combat="2">
+  <spell name="hail" rank="5" variable="true" combat="2">
     <!-- Hagel -->
     <function name="cast" value="combat_spell"/>
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="goodwinds" rank="5" index="56" parameters="s" ship="true" variable="true">
+  <spell name="goodwinds" rank="5" parameters="s" ship="true" variable="true">
     <!-- Beschwörung eines Wasserelementares -->
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="windshield" rank="5" index="59" variable="true" combat="1">
+  <spell name="windshield" rank="5" variable="true" combat="1">
     <!-- Windschild -->
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="healing" rank="5" index="9" variable="true" combat="3">
+  <spell name="healing" rank="5" variable="true" combat="3">
     <!-- Heilung -->
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="earthquake" rank="5" index="53" far="true">
+  <spell name="earthquake" rank="5" far="true">
     <!-- Beschwöre einen Erdelementar -->
     <resource name="aura" amount="25" cost="fixed"/>
     <resource name="laen" amount="2" cost="fixed"/>
   </spell>
-  <spell name="stormwinds" rank="5" index="55" parameters="s+" ship="true" ocean="true" variable="true">
+  <spell name="stormwinds" rank="5" parameters="s+" ship="true" ocean="true" variable="true">
     <!-- Beschwöre einen Sturmelementar -->
     <resource name="aura" amount="6" cost="level"/>
   </spell>
-  <spell name="wolfhowl" rank="5" index="94" variable="true" combat="1">
+  <spell name="wolfhowl" rank="5" variable="true" combat="1">
     <!-- Wolfsgeheul -->
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="versteinern" rank="5" index="67" variable="true" combat="2">
+  <spell name="versteinern" rank="5" variable="true" combat="2">
     <!-- Blick des Basilisken -->
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="gwyrrddestroymagic" rank="2" index="138" parameters="kc+" los="true" ship="true" far="true" variable="true">
+  <spell name="gwyrrddestroymagic" rank="2" parameters="kc+" los="true" ship="true" far="true" variable="true">
     <!-- Geister bannen -->
     <resource name="aura" amount="6" cost="level"/>
   </spell>
-  <spell name="holyground" rank="5" index="170">
+  <spell name="holyground" rank="5">
     <!-- Heiliger Boden -->
     <resource name="aura" amount="80" cost="fixed"/>
     <resource name="permaura" amount="3" cost="fixed"/>
   </spell>
-  <spell name="summonent" rank="5" index="49" variable="true">
+  <spell name="summonent" rank="5" variable="true">
     <!-- Erwecke Ents -->
     <resource name="aura" amount="6" cost="level"/>
   </spell>
-  <spell name="blessstonecircle" rank="5" index="117" parameters="b">
+  <spell name="blessstonecircle" rank="5" parameters="b">
     <!-- Segne Steinkreis -->
     <resource name="aura" amount="350" cost="fixed"/>
     <resource name="permaura" amount="5" cost="fixed"/>
   </spell>
-  <spell name="barkskin" rank="2" index="142" variable="true" combat="1">
+  <spell name="barkskin" rank="2" variable="true" combat="1">
     <!-- Rindenhaut -->
     <resource name="aura" amount="4" cost="level"/>
   </spell>
-  <spell name="summonfireelemental" rank="5" index="46" far="true">
+  <spell name="summonfireelemental" rank="5" far="true">
     <!-- Beschwörung eines Hitzeelementar -->
     <resource name="aura" amount="600" cost="fixed"/>
   </spell>
-  <spell name="maelstrom" rank="5" index="24" ship="true" ocean="true">
+  <spell name="maelstrom" rank="5" ship="true" ocean="true">
     <!-- Mahlstrom -->
     <resource name="aura" amount="200" cost="fixed"/>
     <resource name="seaserpenthead" amount="1" cost="fixed"/>
@@ -441,211 +441,211 @@
     <resource name="dragonblood" amount="1" cost="fixed"/><!-- Drachenblut -->
   </spell>
 
-  <spell name="auratransfer" rank="1" index="31" syntax="aura" parameters="ui" ship="true">
+  <spell name="auratransfer" rank="1" syntax="aura" parameters="ui" ship="true">
     <!-- Auratransfer -->
     <resource name="aura" amount="1" cost="fixed"/>
   </spell>
   <!-- end tybied -->
 
   <!-- common spells: randomly given, one per level -->
-  <spell name="create_trollbelt" ship="true" rank="5" index="48">
+  <spell name="create_trollbelt" ship="true" rank="5">
     <resource name="aura" amount="20" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
 
-  <spell name="create_antimagic" ship="true" rank="5" index="38">
+  <spell name="create_antimagic" ship="true" rank="5">
     <resource name="aura" amount="50" cost="fixed"/>
     <resource name="money" amount="3000" cost="fixed"/>
   </spell>
 
-  <spell name="create_rop" ship="true" rank="5" index="1">
+  <spell name="create_rop" ship="true" rank="5">
     <resource name="aura" amount="100" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
     <resource name="money" amount="4000" cost="fixed"/>
   </spell>
 
-  <spell name="create_bagofholding" ship="true" rank="5" index="155">
+  <spell name="create_bagofholding" ship="true" rank="5">
     <resource name="aura" amount="30" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
     <resource name="money" amount="5000" cost="fixed"/>
   </spell>
 
-  <spell name="create_focus" ship="true" rank="5" index="2">
+  <spell name="create_focus" ship="true" rank="5">
     <resource name="aura" amount="100" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
 
-  <spell name="create_ror" ship="true" rank="5" index="3">
+  <spell name="create_ror" ship="true" rank="5">
     <resource name="aura" amount="100" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
 
-  <spell name="rustweapon" rank="5" index="6" parameters="u+" los="true" far="true" variable="true">
+  <spell name="rustweapon" rank="5" parameters="u+" los="true" far="true" variable="true">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="plague" rank="5" index="16" far="true">
+  <spell name="plague" rank="5" far="true">
     <resource name="aura" amount="30" cost="fixed"/>
     <resource name="peasant" amount="50" cost="fixed"/>
   </spell>
-  <spell name="raindance" rank="5" index="26" ship="true" far="true" variable="true">
+  <spell name="raindance" rank="5" ship="true" far="true" variable="true">
     <!-- Regentanz -->
     <function name="cast" value="cast_blessedharvest"/>
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="irongolem" rank="4" index="33" variable="true">
+  <spell name="irongolem" rank="4" variable="true">
     <!-- Eisengolem -->
     <resource name="aura" amount="2" cost="level"/>
     <resource name="iron" amount="1" cost="level"/>
     <resource name="incense" amount="1" cost="fixed"/>
   </spell>
-  <spell name="reelingarrows" rank="5" index="36" variable="true" combat="1">
+  <spell name="reelingarrows" rank="5" variable="true" combat="1">
     <!-- Wirbelwind -->
     <resource name="aura" amount="15" cost="fixed"/>
   </spell>
-  <spell name="antimagiczone" rank="2" index="37" far="true" variable="true">
+  <spell name="antimagiczone" rank="2" far="true" variable="true">
     <resource name="aura" amount="3" cost="level"/>
   </spell>
-  <spell name="steal_aura" rank="3" index="40" parameters="u" los="true" far="true" variable="true">
+  <spell name="steal_aura" rank="3" parameters="u" los="true" far="true" variable="true">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="auraleak" rank="3" index="42">
+  <spell name="auraleak" rank="3">
     <resource name="aura" amount="35" cost="fixed"/>
     <resource name="dragonblood" amount="1" cost="fixed"/>
   </spell>
-  <spell name="strongwall" rank="5" index="44" variable="true" combat="1">
+  <spell name="strongwall" rank="5" variable="true" combat="1">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="homestone" rank="5" index="45">
+  <spell name="homestone" rank="5">
     <resource name="aura" amount="50" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
-  <spell name="forestfire" rank="5" index="47" far="true">
+  <spell name="forestfire" rank="5" far="true">
     <resource name="aura" amount="50" cost="fixed"/>
     <resource name="oil" amount="5" cost="fixed"/>
   </spell>
-  <spell name="appeasement" rank="5" index="51" variable="true" combat="1">
+  <spell name="appeasement" rank="5" variable="true" combat="1">
     <resource name="aura" amount="2" cost="fixed"/>
   </spell>
-  <spell name="ironkeeper" rank="5" index="54" far="true" variable="true">
+  <spell name="ironkeeper" rank="5" far="true" variable="true">
     <resource name="aura" amount="3" cost="level"/>
   </spell>
-  <spell name="airship" rank="5" index="57" parameters="s" ship="true">
+  <spell name="airship" rank="5" parameters="s" ship="true">
     <resource name="aura" amount="10" cost="fixed"/>
     <resource name="h12" amount="1" cost="fixed"/>
     <resource name="h20" amount="1" cost="fixed"/>
   </spell>
-  <spell name="sound_out" rank="5" index="74" parameters="ur" los="true">
+  <spell name="sound_out" rank="5" parameters="ur" los="true">
     <resource name="aura" amount="4" cost="fixed"/>
     <resource name="money" amount="100" cost="fixed"/>
   </spell>
-  <spell name="combat_speed" rank="5" index="79" variable="true" combat="1">
+  <spell name="combat_speed" rank="5" variable="true" combat="1">
     <resource name="aura" amount="5" cost="level"/>
   </spell>
-  <spell name="double_time" rank="5" index="80" parameters="u+" los="true" ship="true" variable="true">
+  <spell name="double_time" rank="5" parameters="u+" los="true" ship="true" variable="true">
     <resource name="aura" amount="5" cost="level"/>
   </spell>
-  <spell name="magicstreet" rank="5" index="84" ship="true" far="true" variable="true">
+  <spell name="magicstreet" rank="5" ship="true" far="true" variable="true">
     <resource name="aura" amount="1" cost="level"/>
     <resource name="stone" amount="1" cost="fixed"/>
     <resource name="log" amount="1" cost="fixed"/>
   </spell>
-  <spell name="sacrifice_strength" rank="1" index="88" syntax="aura" parameters="ui">
+  <spell name="sacrifice_strength" rank="1" syntax="aura" parameters="ui">
     <resource name="aura" amount="100" cost="fixed"/>
   </spell>
-  <spell name="resist_magic" rank="2" index="97" parameters="u+" los="true" ship="true" variable="true">
+  <spell name="resist_magic" rank="2" parameters="u+" los="true" ship="true" variable="true">
     <!-- Schutzzauber -->
     <resource name="aura" amount="5" cost="level"/>
   </spell>
-  <spell name="protective_runes" rank="2" index="99" parameters="kc" regiontarget="false" unittarget="false" buildingtarget="true" shiptarget="true" ship="true">
+  <spell name="protective_runes" rank="2" parameters="kc" regiontarget="false" unittarget="false" buildingtarget="true" shiptarget="true" ship="true">
     <resource name="aura" amount="20" cost="fixed"/>
   </spell>
-  <spell name="analyze_magic" rank="5" index="102" parameters="kc+" los="true" ship="true" variable="true">
+  <spell name="analyze_magic" rank="5" parameters="kc+" los="true" ship="true" variable="true">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="destroy_magic" rank="2" index="106" parameters="kc+" los="true" ship="true" far="true" variable="true">
+  <spell name="destroy_magic" rank="2" parameters="kc+" los="true" ship="true" far="true" variable="true">
     <resource name="aura" amount="4" cost="level"/>
   </spell>
-  <spell name="break_curse" rank="3" index="107" syntax="spellid" parameters="kcc" los="true" ship="true" far="true" variable="true">
+  <spell name="break_curse" rank="3" syntax="spellid" parameters="kcc" los="true" ship="true" far="true" variable="true">
     <resource name="aura" amount="3" cost="level"/>
   </spell>
-  <spell name="fish_shield" rank="2" index="109" variable="true" combat="1">
+  <spell name="fish_shield" rank="2" variable="true" combat="1">
     <resource name="aura" amount="4" cost="level"/>
   </spell>
-  <spell name="armor_shield" rank="2" index="110" variable="true" combat="1">
+  <spell name="armor_shield" rank="2" variable="true" combat="1">
     <resource name="aura" amount="4" cost="level"/>
   </spell>
-  <spell name="living_rock" rank="5" index="116" syntax="direction" parameters="bc" variable="true">
+  <spell name="living_rock" rank="5" syntax="direction" parameters="bc" variable="true">
     <resource name="aura" amount="10" cost="level"/>
     <resource name="permaura" amount="1" cost="fixed"/>
     <resource name="laen" amount="5" cost="fixed"/>
   </spell>
-  <spell name="summon_familiar" rank="5" index="118">
+  <spell name="summon_familiar" rank="5">
     <function name="cast" value="cast_familiar"/>
     <resource name="aura" amount="100" cost="fixed"/>
     <resource name="permaura" amount="5" cost="fixed"/>
   </spell>
-  <spell name="draigfumbleshield" rank="2" index="143" variable="true" combat="1">
+  <spell name="draigfumbleshield" rank="2" variable="true" combat="1">
     <resource name="aura" amount="6" cost="level"/>
   </spell>
-  <spell name="gwyrrdfumbleshield" rank="2" index="144" variable="true" combat="1">
+  <spell name="gwyrrdfumbleshield" rank="2" variable="true" combat="1">
     <resource name="aura" amount="5" cost="level"/>
   </spell>
-  <spell name="cerddorfumbleshield" rank="2" index="145" variable="true" combat="1">
+  <spell name="cerddorfumbleshield" rank="2" variable="true" combat="1">
     <resource name="aura" amount="5" cost="level"/>
   </spell>
-  <spell name="tybiedfumbleshield" rank="2" index="146" variable="true" combat="1">
+  <spell name="tybiedfumbleshield" rank="2" variable="true" combat="1">
     <resource name="aura" amount="3" cost="level"/>
   </spell>
-  <spell name="concealing_aura" rank="5" index="150" parameters="u" ship="true" variable="true">
+  <spell name="concealing_aura" rank="5" parameters="u" ship="true" variable="true">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="shockwave" rank="5" index="163" variable="true" combat="2">
+  <spell name="shockwave" rank="5" variable="true" combat="2">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="eternal_walls" rank="5" index="167" parameters="b" ship="true" variable="true">
+  <spell name="eternal_walls" rank="5" parameters="b" ship="true" variable="true">
     <resource name="aura" amount="50" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
   <!-- end common spells -->
 
   <!-- gray spells: given to individuals or monsters -->
-  <spell name="fiery_dragonbreath" rank="5" index="81" combat="2">
+  <spell name="fiery_dragonbreath" rank="5" combat="2">
     <resource name="aura" amount="1" cost="fixed"/>
   </spell>
-  <spell name="icy_dragonbreath" rank="5" index="82" combat="2">
+  <spell name="icy_dragonbreath" rank="5" combat="2">
     <resource name="aura" amount="2" cost="fixed"/>
   </spell>
-  <spell name="powerful_dragonbreath" rank="5" index="83" combat="2">
+  <spell name="powerful_dragonbreath" rank="5" combat="2">
     <resource name="aura" amount="3" cost="fixed"/>
   </spell>
-  <spell name="meteor_rain" rank="5" index="108" variable="true" combat="2">
+  <spell name="meteor_rain" rank="5" variable="true" combat="2">
     <function name="cast" value="combat_spell"/>
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="wyrm_transformation" rank="5" index="166">
+  <spell name="wyrm_transformation" rank="5">
     <resource name="aura" amount="1" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
-  <spell name="transferauratraum" rank="1" index="30" syntax="aura" parameters="ui" ship="true">
+  <spell name="transferauratraum" rank="1" syntax="aura" parameters="ui" ship="true">
     <!-- Traum der Magie -->
     <resource name="aura" amount="2" cost="fixed"/>
   </spell>
-  <spell name="drain_skills" rank="5" index="174" combat="2">
+  <spell name="drain_skills" rank="5" combat="2">
     <resource name="aura" amount="4" cost="fixed"/>
   </spell>
-  <spell name="aura_of_fear" rank="5" index="175" combat="2">
+  <spell name="aura_of_fear" rank="5" combat="2">
     <resource name="aura" amount="12" cost="fixed"/>
   </spell>
-  <spell name="immolation" rank="5" index="180" combat="2">
+  <spell name="immolation" rank="5" combat="2">
     <resource name="aura" amount="24" cost="fixed"/>
   </spell>
-  <spell name="firestorm" rank="5" index="181" combat="2">
+  <spell name="firestorm" rank="5" combat="2">
     <resource name="aura" amount="2" cost="fixed"/>
   </spell>
-  <spell name="coldfront" rank="5" index="182" combat="2">
+  <spell name="coldfront" rank="5" combat="2">
     <resource name="aura" amount="2" cost="fixed"/>
   </spell>
-  <spell name="acidrain" rank="5" index="183" combat="2">
+  <spell name="acidrain" rank="5" combat="2">
     <resource name="aura" amount="2" cost="fixed"/>
   </spell>
   <!-- end gray spells -->
diff --git a/res/eressea/spells.xml b/res/eressea/spells.xml
index 7680f2f3b..2adc132e5 100644
--- a/res/eressea/spells.xml
+++ b/res/eressea/spells.xml
@@ -3,608 +3,608 @@
 <spells>
 
   <!-- shared spells -->
-  <spell name="create_roi" ship="true" rank="5" index="130">
+  <spell name="create_roi" ship="true" rank="5">
     <resource name="aura" amount="50" cost="fixed"/>
     <resource name="money" amount="3000" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
 
-  <spell name="create_aots" ship="true" rank="5" index="125">
+  <spell name="create_aots" ship="true" rank="5">
     <resource name="aura" amount="50" cost="fixed"/>
     <resource name="money" amount="3000" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
 
-  <spell name="fireball" rank="5" index="4" variable="true" combat="2">
+  <spell name="fireball" rank="5" variable="true" combat="2">
     <function name="cast" value="combat_spell"/>
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="hail" rank="5" index="5" variable="true" combat="2">
+  <spell name="hail" rank="5" variable="true" combat="2">
     <function name="cast" value="combat_spell"/>
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="rustweapon" rank="5" index="6" parameters="u+" los="true" far="true" variable="true">
+  <spell name="rustweapon" rank="5" parameters="u+" los="true" far="true" variable="true">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="combatrust" rank="5" index="7" variable="true" combat="2">
+  <spell name="combatrust" rank="5" variable="true" combat="2">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="treegrow" rank="5" index="8" far="true" variable="true">
+  <spell name="treegrow" rank="5" far="true" variable="true">
     <resource name="aura" amount="4" cost="level"/>
     <resource name="log" amount="1" cost="level"/>
     <resource name="lifepotion" amount="1" cost="fixed"/>
   </spell>
-  <spell name="healing" rank="5" index="9" variable="true" combat="3">
+  <spell name="healing" rank="5" variable="true" combat="3">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="song_of_healing" rank="5" index="10" variable="true" combat="3">
+  <spell name="song_of_healing" rank="5" variable="true" combat="3">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="bad_dreams" rank="5" index="11" far="true">
+  <spell name="bad_dreams" rank="5" far="true">
     <resource name="aura" amount="90" cost="fixed"/>
   </spell>
-  <spell name="gooddreams" rank="5" index="12" far="true">
+  <spell name="gooddreams" rank="5" far="true">
     <resource name="aura" amount="80" cost="fixed"/>
   </spell>
-  <spell name="dreamreading" rank="5" index="13" parameters="u" far="true">
+  <spell name="dreamreading" rank="5" parameters="u" far="true">
     <resource name="aura" amount="8" cost="fixed"/>
   </spell>
-  <spell name="tiredsoldiers" rank="5" index="15" variable="true" combat="1">
+  <spell name="tiredsoldiers" rank="5" variable="true" combat="1">
     <resource name="aura" amount="4" cost="level"/>
   </spell>
-  <spell name="plague" rank="5" index="16" far="true">
+  <spell name="plague" rank="5" far="true">
     <resource name="aura" amount="30" cost="fixed"/>
     <resource name="peasant" amount="50" cost="fixed"/>
   </spell>
-  <spell name="magicboost" rank="3" index="17" ship="true">
+  <spell name="magicboost" rank="3" ship="true">
     <resource name="aura" amount="6" cost="fixed"/>
   </spell>
-  <spell name="chaosrow" rank="5" index="18" variable="true" combat="1">
+  <spell name="chaosrow" rank="5" variable="true" combat="1">
     <resource name="aura" amount="3" cost="level"/>
     <resource name="peasant" amount="10" cost="fixed"/>
   </spell>
-  <spell name="song_of_confusion" rank="5" index="19" variable="true" combat="1">
+  <spell name="song_of_confusion" rank="5" variable="true" combat="1">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="flee" rank="5" index="20" variable="true" combat="1">
+  <spell name="flee" rank="5" variable="true" combat="1">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="song_of_fear" rank="5" index="21" variable="true" combat="2">
+  <spell name="song_of_fear" rank="5" variable="true" combat="2">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="berserk" rank="4" index="22" variable="true" combat="1">
+  <spell name="berserk" rank="4" variable="true" combat="1">
     <resource name="aura" amount="5" cost="level"/>
     <resource name="peasant" amount="1" cost="fixed"/>
   </spell>
-  <spell name="bloodthirst" rank="4" index="23" variable="true" combat="1">
+  <spell name="bloodthirst" rank="4" variable="true" combat="1">
     <resource name="aura" amount="5" cost="level"/>
   </spell>
-  <spell name="maelstrom" rank="5" index="24" ship="true" ocean="true">
+  <spell name="maelstrom" rank="5" ship="true" ocean="true">
     <resource name="aura" amount="200" cost="fixed"/>
     <resource name="seaserpenthead" amount="1" cost="fixed"/>
   </spell>
-  <spell name="transferauradruide" rank="1" index="27" syntax="aura" parameters="ui" ship="true">
+  <spell name="transferauradruide" rank="1" syntax="aura" parameters="ui" ship="true">
     <resource name="aura" amount="2" cost="fixed"/>
   </spell>
-  <spell name="transfer_aura_song" rank="1" index="28" syntax="aura" parameters="ui" ship="true">
+  <spell name="transfer_aura_song" rank="1" syntax="aura" parameters="ui" ship="true">
     <resource name="aura" amount="2" cost="fixed"/>
   </spell>
-  <spell name="transferaurachaos" rank="1" index="29" syntax="aura" parameters="ui" ship="true">
+  <spell name="transferaurachaos" rank="1" syntax="aura" parameters="ui" ship="true">
     <resource name="aura" amount="2" cost="fixed"/>
   </spell>
-  <spell name="transferauratraum" rank="1" index="30" syntax="aura" parameters="ui" ship="true">
+  <spell name="transferauratraum" rank="1" syntax="aura" parameters="ui" ship="true">
     <resource name="aura" amount="2" cost="fixed"/>
   </spell>
-  <spell name="auratransfer" rank="1" index="31" syntax="aura" parameters="ui" ship="true">
+  <spell name="auratransfer" rank="1" syntax="aura" parameters="ui" ship="true">
     <resource name="aura" amount="1" cost="fixed"/>
   </spell>
-  <spell name="stonegolem" rank="4" index="32" variable="true">
+  <spell name="stonegolem" rank="4" variable="true">
     <resource name="aura" amount="2" cost="level"/>
     <resource name="stone" amount="1" cost="level"/>
     <resource name="lifepotion" amount="1" cost="fixed"/>
   </spell>
-  <spell name="irongolem" rank="4" index="33" variable="true">
+  <spell name="irongolem" rank="4" variable="true">
     <resource name="aura" amount="2" cost="level"/>
     <resource name="iron" amount="1" cost="level"/>
     <resource name="lifepotion" amount="1" cost="fixed"/>
   </spell>
-  <spell name="summonshadow" rank="5" index="34" variable="true">
+  <spell name="summonshadow" rank="5" variable="true">
     <resource name="aura" amount="3" cost="level"/>
   </spell>
-  <spell name="summonshadowlords" rank="5" index="35" variable="true">
+  <spell name="summonshadowlords" rank="5" variable="true">
     <resource name="aura" amount="7" cost="level"/>
   </spell>
-  <spell name="reelingarrows" rank="5" index="36" variable="true" combat="1">
+  <spell name="reelingarrows" rank="5" variable="true" combat="1">
     <resource name="aura" amount="15" cost="fixed"/>
   </spell>
-  <spell name="antimagiczone" rank="2" index="37" far="true" variable="true">
+  <spell name="antimagiczone" rank="2" far="true" variable="true">
     <resource name="aura" amount="3" cost="level"/>
   </spell>
-  <spell name="cold_protection" rank="5" index="39" parameters="u+" los="true" ship="true" variable="true">
+  <spell name="cold_protection" rank="5" parameters="u+" los="true" ship="true" variable="true">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="steal_aura" rank="3" index="40" parameters="u" los="true" far="true" variable="true">
+  <spell name="steal_aura" rank="3" parameters="u" los="true" far="true" variable="true">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="summonundead" rank="5" index="41" ship="true" far="true" variable="true">
+  <spell name="summonundead" rank="5" ship="true" far="true" variable="true">
     <resource name="aura" amount="5" cost="level"/>
   </spell>
-  <spell name="auraleak" rank="3" index="42">
+  <spell name="auraleak" rank="3">
     <resource name="aura" amount="35" cost="fixed"/>
     <resource name="dragonblood" amount="1" cost="fixed"/>
   </spell>
-  <spell name="great_drought" rank="5" index="43" far="true">
+  <spell name="great_drought" rank="5" far="true">
     <resource name="aura" amount="800" cost="fixed"/>
   </spell>
-  <spell name="strongwall" rank="5" index="44" variable="true" combat="1">
+  <spell name="strongwall" rank="5" variable="true" combat="1">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="homestone" rank="5" index="45">
+  <spell name="homestone" rank="5">
     <resource name="aura" amount="50" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
-  <spell name="summonfireelemental" rank="5" index="46" far="true">
+  <spell name="summonfireelemental" rank="5" far="true">
     <resource name="aura" amount="600" cost="fixed"/>
   </spell>
-  <spell name="forestfire" rank="5" index="47" far="true">
+  <spell name="forestfire" rank="5" far="true">
     <resource name="aura" amount="50" cost="fixed"/>
     <resource name="oil" amount="1" cost="fixed"/>
   </spell>
-  <spell name="summonent" rank="5" index="49" variable="true">
+  <spell name="summonent" rank="5" variable="true">
     <resource name="aura" amount="6" cost="level"/>
   </spell>
-  <spell name="disturbingdreams" rank="5" index="50" far="true">
+  <spell name="disturbingdreams" rank="5" far="true">
     <resource name="aura" amount="18" cost="fixed"/>
   </spell>
-  <spell name="appeasement" rank="5" index="51" variable="true" combat="1">
+  <spell name="appeasement" rank="5" variable="true" combat="1">
     <resource name="aura" amount="2" cost="fixed"/>
   </spell>
-  <spell name="sleep" rank="5" index="52" variable="true" combat="2">
+  <spell name="sleep" rank="5" variable="true" combat="2">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="earthquake" rank="5" index="53" far="true">
+  <spell name="earthquake" rank="5" far="true">
     <resource name="aura" amount="25" cost="fixed"/>
     <resource name="laen" amount="2" cost="fixed"/>
   </spell>
-  <spell name="ironkeeper" rank="5" index="54" far="true" variable="true">
+  <spell name="ironkeeper" rank="5" far="true" variable="true">
     <resource name="aura" amount="3" cost="level"/>
   </spell>
-  <spell name="stormwinds" rank="5" index="55" parameters="s+" ship="true" ocean="true" variable="true">
+  <spell name="stormwinds" rank="5" parameters="s+" ship="true" ocean="true" variable="true">
     <resource name="aura" amount="6" cost="level"/>
   </spell>
-  <spell name="goodwinds" rank="5" index="56" parameters="s" ship="true" variable="true">
+  <spell name="goodwinds" rank="5" parameters="s" ship="true" variable="true">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="airship" rank="5" index="57" parameters="s" ship="true">
+  <spell name="airship" rank="5" parameters="s" ship="true">
     <resource name="aura" amount="10" cost="fixed"/>
     <resource name="h12" amount="1" cost="fixed"/>
     <resource name="h20" amount="1" cost="fixed"/>
   </spell>
-  <spell name="windshield" rank="5" index="59" variable="true" combat="1">
+  <spell name="windshield" rank="5" variable="true" combat="1">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="raise_mob" rank="5" index="60" variable="true">
+  <spell name="raise_mob" rank="5" variable="true">
     <resource name="aura" amount="4" cost="level"/>
   </spell>
-  <spell name="melancholy" rank="5" index="61" far="true">
+  <spell name="melancholy" rank="5" far="true">
     <resource name="aura" amount="40" cost="fixed"/>
   </spell>
-  <spell name="headache" rank="5" index="62" parameters="u" los="true">
+  <spell name="headache" rank="5" parameters="u" los="true">
     <resource name="aura" amount="28" cost="fixed"/>
     <resource name="h7" amount="3" cost="fixed"/>
     <resource name="money" amount="50" cost="fixed"/>
   </spell>
-  <spell name="enterastral" rank="7" index="64" parameters="u+" variable="true">
+  <spell name="enterastral" rank="7" parameters="u+" variable="true">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="leaveastral" rank="7" index="65" parameters="ru+" variable="true">
+  <spell name="leaveastral" rank="7" parameters="ru+" variable="true">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="versteinern" rank="5" index="67" variable="true" combat="2">
+  <spell name="versteinern" rank="5" variable="true" combat="2">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="treewalkenter" rank="7" index="68" parameters="u+" los="true" variable="true">
+  <spell name="treewalkenter" rank="7" parameters="u+" los="true" variable="true">
     <resource name="aura" amount="3" cost="level"/>
   </spell>
-  <spell name="treewalkexit" rank="7" index="69" parameters="ru+" los="true" variable="true">
+  <spell name="treewalkexit" rank="7" parameters="ru+" los="true" variable="true">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="chaossuction" rank="5" index="70">
+  <spell name="chaossuction" rank="5">
     <resource name="aura" amount="150" cost="fixed"/>
     <resource name="peasant" amount="200" cost="fixed"/>
   </spell>
-  <spell name="view_reality" rank="5" index="71">
+  <spell name="view_reality" rank="5">
     <resource name="aura" amount="40" cost="fixed"/>
   </spell>
-  <spell name="astral_disruption" rank="4" index="72" variable="true">
+  <spell name="astral_disruption" rank="4" variable="true">
     <resource name="aura" amount="140" cost="fixed"/>
   </spell>
-  <spell name="seduction" rank="5" index="73" parameters="u" los="true">
+  <spell name="seduction" rank="5" parameters="u" los="true">
     <resource name="aura" amount="12" cost="fixed"/>
   </spell>
-  <spell name="sound_out" rank="5" index="74" parameters="ur" los="true">
+  <spell name="sound_out" rank="5" parameters="ur" los="true">
     <resource name="aura" amount="4" cost="fixed"/>
     <resource name="money" amount="100" cost="fixed"/>
   </spell>
-  <spell name="calm_monster" rank="5" index="75" parameters="u" los="true" ship="true">
+  <spell name="calm_monster" rank="5" parameters="u" los="true" ship="true">
     <resource name="aura" amount="15" cost="fixed"/>
   </spell>
-  <spell name="heroic_song" rank="4" index="76" variable="true" combat="1">
+  <spell name="heroic_song" rank="4" variable="true" combat="1">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="frighten" rank="5" index="77" variable="true" combat="1">
+  <spell name="frighten" rank="5" variable="true" combat="1">
     <resource name="aura" amount="5" cost="level"/>
   </spell>
-  <spell name="mindblast" rank="5" index="78" variable="true" combat="1">
+  <spell name="mindblast" rank="5" variable="true" combat="1">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="combat_speed" rank="5" index="79" variable="true" combat="1">
+  <spell name="combat_speed" rank="5" variable="true" combat="1">
     <resource name="aura" amount="5" cost="level"/>
   </spell>
-  <spell name="double_time" rank="5" index="80" parameters="u+" los="true" ship="true" variable="true">
+  <spell name="double_time" rank="5" parameters="u+" los="true" ship="true" variable="true">
     <resource name="aura" amount="5" cost="level"/>
   </spell>
-  <spell name="fiery_dragonbreath" rank="5" index="81" combat="2">
+  <spell name="fiery_dragonbreath" rank="5" combat="2">
     <resource name="aura" amount="1" cost="fixed"/>
   </spell>
-  <spell name="icy_dragonbreath" rank="5" index="82" combat="2">
+  <spell name="icy_dragonbreath" rank="5" combat="2">
     <resource name="aura" amount="2" cost="fixed"/>
   </spell>
-  <spell name="powerful_dragonbreath" rank="5" index="83" combat="2">
+  <spell name="powerful_dragonbreath" rank="5" combat="2">
     <resource name="aura" amount="3" cost="fixed"/>
   </spell>
-  <spell name="magicstreet" rank="5" index="84" ship="true" far="true" variable="true">
+  <spell name="magicstreet" rank="5" ship="true" far="true" variable="true">
     <resource name="aura" amount="1" cost="level"/>
     <resource name="stone" amount="1" cost="fixed"/>
     <resource name="log" amount="1" cost="fixed"/>
   </spell>
-  <spell name="reanimate" rank="4" index="85" variable="true" combat="3">
+  <spell name="reanimate" rank="4" variable="true" combat="3">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="courting" rank="5" index="86" variable="true">
+  <spell name="courting" rank="5" variable="true">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="generous" rank="5" index="87" ship="true" far="true" variable="true">
+  <spell name="generous" rank="5" ship="true" far="true" variable="true">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="sacrifice_strength" rank="1" index="88" syntax="aura" parameters="ui">
+  <spell name="sacrifice_strength" rank="1" syntax="aura" parameters="ui">
     <resource name="aura" amount="100" cost="fixed"/>
   </spell>
-  <spell name="song_of_peace" rank="5" index="89" variable="true">
+  <spell name="song_of_peace" rank="5" variable="true">
     <resource name="aura" amount="20" cost="level"/>
   </spell>
-  <spell name="migration" rank="5" index="90" parameters="u" los="true" variable="true">
+  <spell name="migration" rank="5" parameters="u" los="true" variable="true">
     <resource name="aura" amount="3" cost="level"/>
     <resource name="permaura" amount="1" cost="level"/>
   </spell>
-  <spell name="calm_riot" rank="5" index="91" far="true">
+  <spell name="calm_riot" rank="5" far="true">
     <resource name="aura" amount="30" cost="fixed"/>
   </spell>
-  <spell name="incite_riot" rank="5" index="92" far="true">
+  <spell name="incite_riot" rank="5" far="true">
     <resource name="aura" amount="40" cost="fixed"/>
   </spell>
-  <spell name="shapeshift" rank="5" index="93" syntax="race" parameters="uc" variable="true">
+  <spell name="shapeshift" rank="5" syntax="race" parameters="uc" variable="true">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="wolfhowl" rank="5" index="94" variable="true" combat="1">
+  <spell name="wolfhowl" rank="5" variable="true" combat="1">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="igjarjuk" rank="5" index="94" variable="true" combat="1">
+  <spell name="igjarjuk" rank="5" variable="true" combat="1">
     <function name="cast" value="igjarjuk"/>
   </spell>
-  <spell name="resist_magic" rank="2" index="97" parameters="u+" los="true" ship="true" variable="true">
+  <spell name="resist_magic" rank="2" parameters="u+" los="true" ship="true" variable="true">
     <resource name="aura" amount="5" cost="level"/>
   </spell>
-  <spell name="keeploot" rank="5" index="98" variable="true" combat="3">
+  <spell name="keeploot" rank="5" variable="true" combat="3">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="protective_runes" rank="2" index="99" parameters="kc" regiontarget="false" unittarget="false" buildingtarget="true" shiptarget="true" ship="true">
+  <spell name="protective_runes" rank="2" parameters="kc" regiontarget="false" unittarget="false" buildingtarget="true" shiptarget="true" ship="true">
     <resource name="aura" amount="20" cost="fixed"/>
   </spell>
-  <spell name="song_resist_magic" rank="2" index="100" far="true" variable="true">
+  <spell name="song_resist_magic" rank="2" far="true" variable="true">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="song_suscept_magic" rank="2" index="101" far="true" variable="true">
+  <spell name="song_suscept_magic" rank="2" far="true" variable="true">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="analyze_magic" rank="5" index="102" parameters="kc+" los="true" ship="true" variable="true">
+  <spell name="analyze_magic" rank="5" parameters="kc+" los="true" ship="true" variable="true">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="analysedream" rank="5" index="103" parameters="u" los="true" ship="true">
+  <spell name="analysedream" rank="5" parameters="u" los="true" ship="true">
     <resource name="aura" amount="25" cost="fixed"/>
   </spell>
-  <spell name="analysesong_unit" rank="5" index="104" parameters="u" los="true" ship="true">
+  <spell name="analysesong_unit" rank="5" parameters="u" los="true" ship="true">
     <resource name="aura" amount="10" cost="fixed"/>
   </spell>
-  <spell name="analyse_object" rank="5" index="105" parameters="kc+" ship="true" variable="true">
+  <spell name="analyse_object" rank="5" parameters="kc+" ship="true" variable="true">
     <resource name="aura" amount="3" cost="level" regiontarget="true" unittarget="false" buildingtarget="true" shiptarget="true"/>
   </spell>
-  <spell name="destroy_magic" rank="2" index="106" parameters="kc+" los="true" ship="true" far="true" variable="true">
+  <spell name="destroy_magic" rank="2" parameters="kc+" los="true" ship="true" far="true" variable="true">
     <resource name="aura" amount="4" cost="level"/>
   </spell>
-  <spell name="break_curse" rank="3" index="107" syntax="spellid" parameters="kcc" los="true" ship="true" far="true" variable="true">
+  <spell name="break_curse" rank="3" syntax="spellid" parameters="kcc" los="true" ship="true" far="true" variable="true">
     <resource name="aura" amount="3" cost="level"/>
   </spell>
-  <spell name="meteor_rain" rank="5" index="108" variable="true" combat="2">
+  <spell name="meteor_rain" rank="5" variable="true" combat="2">
     <function name="cast" value="combat_spell"/>
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="fish_shield" rank="2" index="109" variable="true" combat="1">
+  <spell name="fish_shield" rank="2" variable="true" combat="1">
     <resource name="aura" amount="4" cost="level"/>
   </spell>
-  <spell name="armor_shield" rank="2" index="110" variable="true" combat="1">
+  <spell name="armor_shield" rank="2" variable="true" combat="1">
     <resource name="aura" amount="4" cost="level"/>
   </spell>
-  <spell name="deathcloud" rank="5" index="111" far="true">
+  <spell name="deathcloud" rank="5" far="true">
     <resource name="aura" amount="40" cost="fixed"/>
     <resource name="hp" amount="15" cost="fixed"/>
   </spell>
-  <spell name="orkdream" rank="5" index="112" parameters="u+" los="true" variable="true">
+  <spell name="orkdream" rank="5" parameters="u+" los="true" variable="true">
     <resource name="aura" amount="5" cost="level"/>
   </spell>
-  <spell name="summondragon" rank="5" index="113" far="true">
+  <spell name="summondragon" rank="5" far="true">
     <resource name="aura" amount="80" cost="fixed"/>
     <resource name="dragonhead" amount="1" cost="fixed"/>
   </spell>
-  <spell name="living_rock" rank="5" index="116" syntax="direction" parameters="bc" variable="true">
+  <spell name="living_rock" rank="5" syntax="direction" parameters="bc" variable="true">
     <resource name="aura" amount="10" cost="level"/>
     <resource name="permaura" amount="1" cost="fixed"/>
     <resource name="laen" amount="5" cost="fixed"/>
   </spell>
-  <spell name="blessstonecircle" rank="5" index="117" parameters="b">
+  <spell name="blessstonecircle" rank="5" parameters="b">
     <resource name="aura" amount="350" cost="fixed"/>
     <resource name="permaura" amount="5" cost="fixed"/>
   </spell>
-  <spell name="summon_familiar" rank="5" index="122">
+  <spell name="summon_familiar" rank="5">
     <function name="cast" value="cast_familiar"/>
     <resource name="aura" amount="100" cost="fixed"/>
     <resource name="permaura" amount="5" cost="fixed"/>
   </spell>
-  <spell name="song_of_slavery" rank="5" index="123" parameters="u" los="true">
+  <spell name="song_of_slavery" rank="5" parameters="u" los="true">
     <resource name="aura" amount="40" cost="fixed"/>
   </spell>
-  <spell name="fumblecurse" rank="4" index="136" parameters="u" los="true" variable="true">
+  <spell name="fumblecurse" rank="4" parameters="u" los="true" variable="true">
     <resource name="aura" amount="4" cost="level"/>
   </spell>
-  <spell name="icastle" rank="5" index="137" syntax="buildingtype" parameters="c">
+  <spell name="icastle" rank="5" syntax="buildingtype" parameters="c">
     <resource name="aura" amount="3" cost="fixed"/>
   </spell>
-  <spell name="gwyrrddestroymagic" rank="2" index="138" parameters="kc+" los="true" ship="true" far="true" variable="true">
+  <spell name="gwyrrddestroymagic" rank="2" parameters="kc+" los="true" ship="true" far="true" variable="true">
     <resource name="aura" amount="6" cost="level"/>
   </spell>
-  <spell name="draigdestroymagic" rank="2" index="139" parameters="kc+" los="true" ship="true" far="true" variable="true">
+  <spell name="draigdestroymagic" rank="2" parameters="kc+" los="true" ship="true" far="true" variable="true">
     <resource name="aura" amount="10" cost="level"/>
   </spell>
-  <spell name="illaundestroymagic" rank="2" index="140" parameters="kc+" los="true" ship="true" far="true" variable="true">
+  <spell name="illaundestroymagic" rank="2" parameters="kc+" los="true" ship="true" far="true" variable="true">
     <resource name="aura" amount="6" cost="level"/>
   </spell>
-  <spell name="cerddor_destroymagic" rank="2" index="141" parameters="kc+" los="true" ship="true" far="true" variable="true">
+  <spell name="cerddor_destroymagic" rank="2" parameters="kc+" los="true" ship="true" far="true" variable="true">
     <resource name="aura" amount="5" cost="level"/>
   </spell>
-  <spell name="barkskin" rank="2" index="142" variable="true" combat="1">
+  <spell name="barkskin" rank="2" variable="true" combat="1">
     <resource name="aura" amount="4" cost="level"/>
   </spell>
-  <spell name="draigfumbleshield" rank="2" index="143" variable="true" combat="1">
+  <spell name="draigfumbleshield" rank="2" variable="true" combat="1">
     <resource name="aura" amount="6" cost="level"/>
   </spell>
-  <spell name="gwyrrdfumbleshield" rank="2" index="144" variable="true" combat="1">
+  <spell name="gwyrrdfumbleshield" rank="2" variable="true" combat="1">
     <resource name="aura" amount="5" cost="level"/>
   </spell>
-  <spell name="cerddorfumbleshield" rank="2" index="145" variable="true" combat="1">
+  <spell name="cerddorfumbleshield" rank="2" variable="true" combat="1">
     <resource name="aura" amount="5" cost="level"/>
   </spell>
-  <spell name="tybiedfumbleshield" rank="2" index="146" variable="true" combat="1">
+  <spell name="tybiedfumbleshield" rank="2" variable="true" combat="1">
     <resource name="aura" amount="3" cost="level"/>
   </spell>
-  <spell name="shadowknights" rank="4" index="147" variable="true" combat="1">
+  <spell name="shadowknights" rank="4" variable="true" combat="1">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="concealing_aura" rank="5" index="150" parameters="u" ship="true" variable="true">
+  <spell name="concealing_aura" rank="5" parameters="u" ship="true" variable="true">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="firewall" rank="4" index="151" syntax="direction" parameters="c" variable="true">
+  <spell name="firewall" rank="4" syntax="direction" parameters="c" variable="true">
     <resource name="aura" amount="6" cost="level"/>
   </spell>
-  <spell name="sparklechaos" rank="5" index="153" parameters="u" los="true" variable="true">
+  <spell name="sparklechaos" rank="5" parameters="u" los="true" variable="true">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="sparkledream" rank="5" index="154" parameters="u" los="true" ship="true" variable="true">
+  <spell name="sparkledream" rank="5" parameters="u" los="true" ship="true" variable="true">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="pull_astral" rank="7" index="156" parameters="ru+" variable="true" target_global="true">
+  <spell name="pull_astral" rank="7" parameters="ru+" variable="true" target_global="true">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="fetch_astral" rank="7" index="157" parameters="u+" variable="true" target_global="true">
+  <spell name="fetch_astral" rank="7" parameters="u+" variable="true" target_global="true">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="shockwave" rank="5" index="163" variable="true" combat="2">
+  <spell name="shockwave" rank="5" variable="true" combat="2">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="undeadhero" rank="5" index="164" variable="true" combat="3">
+  <spell name="undeadhero" rank="5" variable="true" combat="3">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="wyrm_transformation" rank="5" index="166">
+  <spell name="wyrm_transformation" rank="5">
     <resource name="aura" amount="1" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
-  <spell name="eternal_walls" rank="5" index="167" parameters="b" ship="true" variable="true">
+  <spell name="eternal_walls" rank="5" parameters="b" ship="true" variable="true">
     <resource name="aura" amount="50" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
-  <spell name="puttorest" rank="5" index="168" variable="true">
+  <spell name="puttorest" rank="5" variable="true">
     <resource name="aura" amount="3" cost="level"/>
     <resource name="lifepotion" amount="1" cost="fixed"/>
   </spell>
-  <spell name="unholypower" rank="5" index="169" parameters="u+" los="true" variable="true">
+  <spell name="unholypower" rank="5" parameters="u+" los="true" variable="true">
     <resource name="aura" amount="10" cost="level"/>
     <resource name="peasant" amount="5" cost="level"/>
   </spell>
-  <spell name="holyground" rank="5" index="170">
+  <spell name="holyground" rank="5">
     <resource name="aura" amount="80" cost="fixed"/>
     <resource name="permaura" amount="3" cost="fixed"/>
   </spell>
-  <spell name="bloodsacrifice" rank="1" index="171" ship="true">
+  <spell name="bloodsacrifice" rank="1" ship="true">
     <resource name="hp" amount="16" cost="fixed"/>
   </spell>
-  <spell name="magic_roots" rank="5" index="172" far="true">
+  <spell name="magic_roots" rank="5" far="true">
     <resource name="aura" amount="250" cost="fixed"/>
     <resource name="permaura" amount="10" cost="fixed"/>
     <resource name="toadslime" amount="1" cost="fixed"/>
   </spell>
-  <spell name="clone" rank="5" index="173">
+  <spell name="clone" rank="5">
     <resource name="aura" amount="100" cost="fixed"/>
     <resource name="permaura" amount="20" cost="fixed"/>
     <resource name="dragonblood" amount="5" cost="fixed"/>
     <resource name="lifepotion" amount="5" cost="fixed"/>
   </spell>
-  <spell name="drain_skills" rank="5" index="174" combat="2">
+  <spell name="drain_skills" rank="5" combat="2">
     <resource name="aura" amount="4" cost="fixed"/>
   </spell>
-  <spell name="aura_of_fear" rank="5" index="175" combat="2">
+  <spell name="aura_of_fear" rank="5" combat="2">
     <resource name="aura" amount="12" cost="fixed"/>
   </spell>
-  <spell name="mallorntreegrow" rank="5" index="177" far="true" variable="true">
+  <spell name="mallorntreegrow" rank="5" far="true" variable="true">
     <resource name="aura" amount="6" cost="level"/>
     <resource name="mallorn" amount="1" cost="level"/>
     <resource name="lifepotion" amount="1" cost="fixed"/>
   </spell>
-  <spell name="big_recruit" rank="5" index="179" variable="true">
+  <spell name="big_recruit" rank="5" variable="true">
     <resource name="aura" amount="20" cost="level"/>
   </spell>
-  <spell name="immolation" rank="5" index="180" combat="2">
+  <spell name="immolation" rank="5" combat="2">
     <resource name="aura" amount="24" cost="fixed"/>
   </spell>
-  <spell name="firestorm" rank="5" index="181" combat="2">
+  <spell name="firestorm" rank="5" combat="2">
     <resource name="aura" amount="2" cost="fixed"/>
   </spell>
-  <spell name="coldfront" rank="5" index="182" combat="2">
+  <spell name="coldfront" rank="5" combat="2">
     <resource name="aura" amount="2" cost="fixed"/>
   </spell>
-  <spell name="acidrain" rank="5" index="183" combat="2">
+  <spell name="acidrain" rank="5" combat="2">
     <resource name="aura" amount="2" cost="fixed"/>
   </spell>
 
   <!-- draig spells -->
-  <spell name="earn_silver#draig" ship="true" variable="true" rank="5" index="159">
+  <spell name="earn_silver#draig" ship="true" variable="true" rank="5">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
 
-  <spell name="create_firesword" ship="true" rank="5" index="148">
+  <spell name="create_firesword" ship="true" rank="5">
     <resource name="aura" amount="100" cost="fixed"/>
     <resource name="p10" amount="1" cost="fixed"/>
     <resource name="sword" amount="1" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
 
-  <spell name="create_trollbelt" ship="true" rank="5" index="48">
+  <spell name="create_trollbelt" ship="true" rank="5">
     <resource name="aura" amount="20" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
 
   <!-- gwyrrd spells -->
-  <spell name="blessedharvest" rank="5" index="25" ship="true" far="true" variable="true">
+  <spell name="blessedharvest" rank="5" ship="true" far="true" variable="true">
     <!-- Segen der Erde -->
     <function name="cast" value="cast_blessedharvest"/>
     <resource name="aura" amount="1" cost="level"/>
   </spell>
 
-  <spell name="earn_silver#gwyrrd" ship="true" variable="true" rank="5" index="159">
+  <spell name="earn_silver#gwyrrd" ship="true" variable="true" rank="5">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
 
-  <spell name="create_magicherbbag" ship="true" rank="5" index="165">
+  <spell name="create_magicherbbag" ship="true" rank="5">
     <resource name="aura" amount="30" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
     <resource name="lifepotion" amount="1" cost="fixed"/>
   </spell>
 
   <!-- illaun spells -->
-  <spell name="earn_silver#illaun" ship="true" variable="true" rank="5" index="159">
+  <spell name="earn_silver#illaun" ship="true" variable="true" rank="5">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
 
-  <spell name="create_dreameye" ship="true" rank="5" index="149">
+  <spell name="create_dreameye" ship="true" rank="5">
     <resource name="dragonhead" amount="1" cost="fixed"/>
     <resource name="permaura" amount="5" cost="fixed"/>
   </spell>
 
-  <spell name="create_invisibility_sphere" ship="true" rank="5" index="178">
+  <spell name="create_invisibility_sphere" ship="true" rank="5">
     <resource name="aura" amount="150" cost="fixed"/>
     <resource name="money" amount="30000" cost="fixed"/>
     <resource name="permaura" amount="3" cost="fixed"/>
   </spell>
 
   <!-- cerddor spells -->
-  <spell name="raindance" rank="5" index="26" ship="true" far="true" variable="true">
+  <spell name="raindance" rank="5" ship="true" far="true" variable="true">
     <!-- Segen der Erde -->
     <function name="cast" value="cast_blessedharvest"/>
     <resource name="aura" amount="1" cost="level"/>
   </spell>
 
-  <spell name="earn_silver#cerddor" ship="true" variable="true" rank="5" index="159">
+  <spell name="earn_silver#cerddor" ship="true" variable="true" rank="5">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
 
-  <spell name="create_roqf" ship="true" rank="5" index="63">
+  <spell name="create_roqf" ship="true" rank="5">
     <resource name="aura" amount="20" cost="fixed"/>
     <resource name="money" amount="1000" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
 
-  <spell name="blabbermouth" parameters="u" los="true" rank="5" index="115">
+  <spell name="blabbermouth" parameters="u" los="true" rank="5">
     <function name="cast" value="cast_babbler"/>
     <resource name="aura" amount="10" cost="fixed"/>
     <!-- missing syntactical info: ONETARGET | UNITSPELL -->
   </spell>
 
-  <spell name="readmind" parameters="u" rank="5" index="114">
+  <spell name="readmind" parameters="u" rank="5">
     <function name="cast" value="cast_readmind"/>
     <resource name="aura" amount="20" cost="fixed"/>
     <!-- missing syntactical info: ONETARGET | UNITSPELL -->
   </spell>
 
   <!-- tybied spells -->
-  <spell name="earn_silver#tybied" ship="true" variable="true" rank="5" index="159">
+  <spell name="earn_silver#tybied" ship="true" variable="true" rank="5">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
 
-  <spell name="create_antimagic" ship="true" rank="5" index="38">
+  <spell name="create_antimagic" ship="true" rank="5">
     <resource name="aura" amount="50" cost="fixed"/>
     <resource name="money" amount="3000" cost="fixed"/>
   </spell>
 
-  <spell name="create_rop" ship="true" rank="5" index="1">
+  <spell name="create_rop" ship="true" rank="5">
     <resource name="aura" amount="100" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
     <resource name="money" amount="4000" cost="fixed"/>
   </spell>
 
-  <spell name="create_bagofholding" ship="true" rank="5" index="155">
+  <spell name="create_bagofholding" ship="true" rank="5">
     <resource name="aura" amount="30" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
     <resource name="money" amount="5000" cost="fixed"/>
   </spell>
 
   <!-- gray magic -->
-  <spell name="create_runesword" ship="true" rank="5" index="135">
+  <spell name="create_runesword" ship="true" rank="5">
     <resource name="aura" amount="100" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
     <resource name="money" amount="1000" cost="fixed"/>
     <resource name="laensword" amount="1" cost="fixed"/>
   </spell>
 
-  <spell name="create_chastitybelt" ship="true" rank="5" index="134">
+  <spell name="create_chastitybelt" ship="true" rank="5">
     <resource name="aura" amount="50" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
     <resource name="money" amount="3000" cost="fixed"/>
   </spell>
 
-  <spell name="create_focus" ship="true" rank="5" index="2">
+  <spell name="create_focus" ship="true" rank="5">
     <resource name="aura" amount="100" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
 
-  <spell name="create_ror" ship="true" rank="5" index="3">
+  <spell name="create_ror" ship="true" rank="5">
     <resource name="aura" amount="100" cost="fixed"/>
     <resource name="permaura" amount="1" cost="fixed"/>
   </spell>
diff --git a/src/xmlreader.c b/src/xmlreader.c
index cdaf6b809..dcf51707b 100644
--- a/src/xmlreader.c
+++ b/src/xmlreader.c
@@ -1166,7 +1166,7 @@ static int parse_spells(xmlDocPtr doc)
             xmlFree(propValue);
             /* level, rank and flags */
 #endif
-            sp->rank = (char)xml_ivalue(node, "rank", -1);
+            sp->rank = (char)xml_ivalue(node, "rank", 0);
             if (xml_bvalue(node, "los", false))
                 sp->sptyp |= TESTCANSEE;        /* must see or have contact */
             if (!xml_bvalue(node, "target_global", false))

From cd2624de8acfa430f44ee5d4ecd78a27a1e77bd3 Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Sun, 6 May 2018 15:49:34 +0200
Subject: [PATCH 02/24] stop reallocation spell parameters. fix involuntary
 tree growth in test, message check.

---
 scripts/tests/e2/init.lua   |  2 +-
 scripts/tests/e2/items.lua  |  1 +
 scripts/tests/e2/spells.lua | 33 +++++++++++++++++++++++++++++++++
 scripts/tests/spells.lua    |  2 +-
 src/bind_faction.c          |  1 +
 src/bindings.c              | 29 ++++++++++++++++-------------
 src/laws.c                  |  7 -------
 src/laws.h                  |  1 -
 src/magic.c                 | 32 +++++++++++---------------------
 9 files changed, 64 insertions(+), 44 deletions(-)

diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua
index 9dd507671..e9c14ec61 100644
--- a/scripts/tests/e2/init.lua
+++ b/scripts/tests/e2/init.lua
@@ -1,6 +1,6 @@
+require 'tests.e2.spells'
 require 'tests.e2.e2features'
 require 'tests.e2.insects'
-require 'tests.e2.spells'
 require 'tests.e2.buildings'
 require 'tests.e2.production'
 require 'tests.e2.adamantium'
diff --git a/scripts/tests/e2/items.lua b/scripts/tests/e2/items.lua
index e444a9c73..456262342 100644
--- a/scripts/tests/e2/items.lua
+++ b/scripts/tests/e2/items.lua
@@ -9,6 +9,7 @@ function setup()
     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")
 end
 
diff --git a/scripts/tests/e2/spells.lua b/scripts/tests/e2/spells.lua
index deeb2798c..53c86d413 100644
--- a/scripts/tests/e2/spells.lua
+++ b/scripts/tests/e2/spells.lua
@@ -12,6 +12,39 @@ function setup()
     eressea.settings.set("magic.fumble.enable", "0")
 end
 
+function disable_pull_astral()
+    local r = region.create(0, 0, "plain")
+    local f = faction.create("human")
+    local u1 = unit.create(f, r, 1)
+    local u2 = unit.create(f, r, 1)
+    u1.magic = "gray"
+    u1:set_skill("magic", 6)
+    u1.aura = 1
+    u1:add_spell("pull_astral")
+    u1:clear_orders()
+    u1:add_order("ZAUBERE Astraler~Ruf " .. itoa36(u2.id))
+    -- process_orders()
+    -- assert_equal(1, f:count_msg_type('error194'), 'no target region')
+    -- assert_equal(1, f:count_msg_type('error209'), 'bad arguments')
+    u1:clear_orders()
+
+    u1:add_order("ZAUBERE Astraler~Ruf 1 0 " .. itoa36(u2.id))
+    process_orders()
+    assert_equal(1, f:count_msg_type('error194'), 'no target region')
+    assert_equal(0, f:count_msg_type('error209'), 'bad arguments')
+    assert_equal(1, f:count_msg_type('spellregionresists'), 'no such region')
+
+    u1:add_order("ZAUBERE Astraler~Ruf 0 0 " .. itoa36(u2.id))
+    process_orders()
+    assert_equal(0, f:count_msg_type('error194'), 'no target region')
+    assert_equal(0, f:count_msg_type('error209'), 'bad arguments')
+    assert_equal(0, f:count_msg_type('spellregionresists'), 'no such region')
+    for k, v in ipairs(f.messages) do
+        print(v)
+    end
+    assert_equal(u1, u2)
+end
+
 function test_shapeshift()
     local r = region.create(42, 0, "plain")
     local f = faction.create("demon", "noreply@eressea.de", "de")
diff --git a/scripts/tests/spells.lua b/scripts/tests/spells.lua
index de56472c3..28efb936a 100644
--- a/scripts/tests/spells.lua
+++ b/scripts/tests/spells.lua
@@ -21,7 +21,7 @@ function test_create_bogus()
     u:clear_orders()
     u:add_order("ZAUBERE 'Erschaffe Katastrophe'")
     process_orders()
-    assert_equal(f.messages[3], 'error173') -- HACKity HACK
+    assert_equal(1, f:count_msg_type('error173'), 'spell not found')
 end
 
 function test_create_roi()
diff --git a/src/bind_faction.c b/src/bind_faction.c
index c0875aae2..ac797093d 100644
--- a/src/bind_faction.c
+++ b/src/bind_faction.c
@@ -39,6 +39,7 @@ without prior permission by the authors of Eressea.
 
 #include <tolua.h>
 #include <string.h>
+#include <stdlib.h>
 #include <stdbool.h>
 
 typedef struct helpmode {
diff --git a/src/bindings.c b/src/bindings.c
index f9f51ded3..3fda9b844 100755
--- a/src/bindings.c
+++ b/src/bindings.c
@@ -476,22 +476,17 @@ static int tolua_write_reports(lua_State * L)
     return 1;
 }
 
-static int tolua_process_orders(lua_State * L)
-{
-    UNUSED_ARG(L);
-#if 0
-    order * ord = parse_order("@GIB xmis ALLES Gurgelkraut", default_locale);
-    assert(ord);
-    free_order(ord);
-    return 0;
-#endif
-    processorders();
-    return 0;
-}
-
 static int tolua_turn_begin(lua_State * L)
 {
+    faction *f;
     UNUSED_ARG(L);
+    for (f = factions; f; f = f->next) {
+        if (f->msgs) {
+            free_messagelist(f->msgs->begin);
+            free(f->msgs);
+            f->msgs = NULL;
+        }
+    }
     turn_begin();
     return 0;
 }
@@ -510,6 +505,14 @@ static int tolua_turn_end(lua_State * L)
     return 0;
 }
 
+static int tolua_process_orders(lua_State * L)
+{
+    UNUSED_ARG(L);
+    tolua_turn_begin(L);
+    tolua_turn_process(L);
+    return tolua_turn_end(L);
+}
+
 static int tolua_write_passwords(lua_State * L)
 {
     int result = writepasswd();
diff --git a/src/laws.c b/src/laws.c
index b24fa5b3b..9eb3795c6 100644
--- a/src/laws.c
+++ b/src/laws.c
@@ -4140,13 +4140,6 @@ void turn_end(void)
     update_spells();
 }
 
-void processorders(void)
-{
-    turn_begin();
-    turn_process();
-    turn_end();
-}
-
 void update_subscriptions(void)
 {
     FILE *F;
diff --git a/src/laws.h b/src/laws.h
index 56ed9623b..ae2c712ca 100755
--- a/src/laws.h
+++ b/src/laws.h
@@ -53,7 +53,6 @@ extern "C" {
     int enter_building(struct unit *u, struct order *ord, int id, bool report);
     int enter_ship(struct unit *u, struct order *ord, int id, bool report);
 
-    void processorders(void);
     void turn_begin(void);
     void turn_process(void);
     void turn_end(void);
diff --git a/src/magic.c b/src/magic.c
index a00a29527..4c2df4023 100644
--- a/src/magic.c
+++ b/src/magic.c
@@ -1822,7 +1822,7 @@ addparam_region(const char *const param[], spllprm ** spobjp, const unit * u,
     order * ord)
 {
     assert(param[0]);
-    if (param[1] == 0) {
+    if (param[1] == NULL) {
         /* Fehler: Zielregion vergessen */
         cmistake(u, ord, 194, MSG_MAGIC);
         return -1;
@@ -2014,13 +2014,13 @@ static spellparameter *add_spellparameter(region * target_r, unit * u,
 
     /* im Endeffekt waren es evtl. nur p parameter (wegen TEMP) */
     par->length = p;
-    if (fail || par->length < minlen) {
+    if (par->length < minlen) {
         cmistake(u, ord, 209, MSG_MAGIC);
         free_spellparameter(par);
         return NULL;
     }
 
-    return par;
+    return fail ? NULL : par;
 }
 
 struct unit * co_get_caster(const struct castorder * co) {
@@ -2412,6 +2412,7 @@ static bool is_moving_ship(ship * sh)
     return false;
 }
 
+#define MAX_PARAMETERS 8
 static castorder *cast_cmd(unit * u, order * ord)
 {
     char token[128];
@@ -2612,33 +2613,22 @@ static castorder *cast_cmd(unit * u, order * ord)
     }
     /* Weitere Argumente zusammenbasteln */
     if (sp->parameter) {
-        char **params = (char**)malloc(2 * sizeof(char *));
-        int p = 0, size = 2;
+        char *params[MAX_PARAMETERS];
+        int i, p = 0;
         for (;;) {
             s = gettoken(token, sizeof(token));
-            if (!s || *s == 0)
+            if (!s || *s == 0) {
                 break;
-            if (p + 1 >= size) {
-                char ** tmp;
-                tmp = (char**)realloc(params, sizeof(char *) * size * 2);
-                if (tmp) {
-                    size *= 2;
-                    params = tmp;
-                }
-                else {
-                    log_error("error allocationg %d bytes: %s", size * 2, strerror(errno));
-                    break;
-                }
             }
+            assert(p + 1 < MAX_PARAMETERS);
             params[p++] = str_strdup(s);
         }
-        params[p] = 0;
         args =
             add_spellparameter(target_r, caster, sp->parameter,
             (const char *const *)params, p, ord);
-        for (p = 0; params[p]; ++p)
-            free(params[p]);
-        free(params);
+        for (i = 0; i != p; ++i) {
+            free(params[i]);
+        }
         if (args == NULL) {
             /* Syntax war falsch */
             return 0;

From 088747ea817bb04fc77916cf4504c3dbf1baa570 Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Sun, 6 May 2018 15:50:32 +0200
Subject: [PATCH 03/24] code style

---
 src/magic.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/magic.c b/src/magic.c
index 4c2df4023..a8190dfa8 100644
--- a/src/magic.c
+++ b/src/magic.c
@@ -2390,8 +2390,9 @@ unit *get_clone(const unit * u)
     attrib *a = a_find(u->attribs, &at_clone);
     if (a != NULL) {
         unit *uc = (unit *)a->data.v;
-        if (uc->number > 0)
+        if (uc->number > 0) {
             return uc;
+        }
     }
     return NULL;
 }
@@ -2400,7 +2401,7 @@ static bool is_moving_ship(ship * sh)
 {
     const unit *u = ship_owner(sh);
 
-    if (u)
+    if (u) {
         switch (getkeyword(u->thisorder)) {
         case K_ROUTE:
         case K_MOVE:
@@ -2409,6 +2410,7 @@ static bool is_moving_ship(ship * sh)
         default:
             return false;
         }
+    }
     return false;
 }
 

From 5af775ba8799e323b04353323afcdbe76a049e7d Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Sun, 6 May 2018 16:35:23 +0200
Subject: [PATCH 04/24] prevent out-of-bounds read.

---
 src/magic.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/magic.c b/src/magic.c
index a8190dfa8..80f528de8 100644
--- a/src/magic.c
+++ b/src/magic.c
@@ -1943,7 +1943,9 @@ static spellparameter *add_spellparameter(region * target_r, unit * u,
             break;
         case 'r':
             /* Parameter sind zwei Regionskoordinaten innerhalb der "normalen" Plane */
-            j = addparam_region(param + i, &spobj, u, ord);
+            if (i + 1 < size) {
+                j = addparam_region(param + i, &spobj, u, ord);
+            }
             ++c;
             break;
         case 'b':

From 4d3718bab996ec5693bf7a9b0affe18c80f9d273 Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Sun, 6 May 2018 18:05:35 +0200
Subject: [PATCH 05/24] find out why t<=0 assert happens sometimes

---
 src/kernel/calendar.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/kernel/calendar.c b/src/kernel/calendar.c
index df9f6c204..93722b5bc 100644
--- a/src/kernel/calendar.c
+++ b/src/kernel/calendar.c
@@ -4,7 +4,8 @@
 #include "calendar.h"
 #include "move.h" /* storms */
 
-#include <kernel/config.h>
+#include "kernel/config.h"
+#include "util/log.h"
 
 #include <assert.h>
 #include <stdlib.h>
@@ -45,6 +46,10 @@ const gamedate *get_gamedate(int turn_now, gamedate * gd)
     int t = turn_now - first_turn();
 
     assert(gd);
+    if (t<0) {
+        log_fatal("current turn %d is before first %d",
+                turn_now, first_turn());
+    }
     assert(t>=0);
 
     gd->turn = turn_now;

From 14f59e4bfe205cc254db59a5ca2502a3704ae022 Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Sun, 6 May 2018 19:02:47 +0200
Subject: [PATCH 06/24] functional tests for pull_astral spell.

---
 scripts/tests/e2/astral.lua | 63 +++++++++++++++++++++++++++++++++++++
 scripts/tests/e2/init.lua   | 53 ++++++++++++++++---------------
 scripts/tests/e2/spells.lua | 33 -------------------
 scripts/tests/spells.lua    |  1 +
 src/bind_region.c           | 21 +++++++++++++
 src/magic.c                 | 44 +++++++++++++++-----------
 6 files changed, 137 insertions(+), 78 deletions(-)
 create mode 100644 scripts/tests/e2/astral.lua

diff --git a/scripts/tests/e2/astral.lua b/scripts/tests/e2/astral.lua
new file mode 100644
index 000000000..d798767c2
--- /dev/null
+++ b/scripts/tests/e2/astral.lua
@@ -0,0 +1,63 @@
+require "lunit"
+
+module("tests.e2.astral", package.seeall, lunit.testcase)
+
+function setup()
+    eressea.free_game()
+    eressea.settings.set("nmr.removenewbie", "0")
+    eressea.settings.set("nmr.timeout", "0")
+    eressea.settings.set("NewbieImmunity", "0")
+    eressea.settings.set("rules.food.flags", "4")
+    eressea.settings.set("rules.peasants.growth.factor", "0")
+    eressea.settings.set("magic.fumble.enable", "0")
+    eressea.settings.set("magic.regeneration.enable", "0")
+end
+
+local function dump_messages(f)
+    for k, v in ipairs(f.messages) do
+        print(v)
+    end
+end
+
+function test_pull_astral()
+    local r = region.create(0, 0, "plain")
+    local f = faction.create("human")
+    local u1 = unit.create(f, r, 1)
+    local u2 = unit.create(f, r, 1)
+    u1.magic = "gray"
+    u1:set_skill("magic", 6)
+    u1.aura = 0
+    u1:add_spell("pull_astral")
+
+    u1:clear_orders()
+    u1:add_order("ZAUBERE Astraler~Ruf " .. itoa36(u2.id))
+    process_orders()
+    assert_equal(1, f:count_msg_type('error209'), 'syntax error')
+    u1:clear_orders()
+
+    u1:clear_orders()
+    u1:add_order("ZAUBERE Astraler~Ruf 1 0 " .. itoa36(u2.id))
+    process_orders()
+    assert_equal(0, f:count_msg_type('error209'), 'syntax error')
+    assert_equal(1, f:count_msg_type('error194'), 'target region')
+
+    u1:clear_orders()
+    u1:add_order("ZAUBERE Astraler~Ruf 0 0 " .. itoa36(u2.id))
+    u1.aura = 0 -- missing components
+    process_orders()
+    assert_equal(0, f:count_msg_type('error194'), 'target region')
+    assert_equal(1, f:count_msg_type('missing_components_list'), 'no components')
+
+    u1.aura = 12 -- 2 Aura pro Stufe
+    process_orders()
+    assert_equal(1, f:count_msg_type('spellfail_astralonly'), 'astral space')
+
+    u1.region = u1.region:get_astral('fog')
+    assert_equal('fog', u1.region.terrain)
+    process_orders()
+    assert_equal(0, f:count_msg_type('spellfail_astralonly'), 'astral space')
+    assert_equal(1, f:count_msg_type('send_astral'), 'astral space')
+
+    assert_equal(u1.region, u2.region)
+end
+
diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua
index e9c14ec61..59cb705e4 100644
--- a/scripts/tests/e2/init.lua
+++ b/scripts/tests/e2/init.lua
@@ -1,26 +1,27 @@
-require 'tests.e2.spells'
-require 'tests.e2.e2features'
-require 'tests.e2.insects'
-require 'tests.e2.buildings'
-require 'tests.e2.production'
-require 'tests.e2.adamantium'
-require 'tests.e2.undead'
-require 'tests.e2.shiplanding'
-require 'tests.e2.movement'
-require 'tests.e2.destroy'
-require 'tests.e2.guard'
-require 'tests.e2.stealth'
-require 'tests.e2.items'
-require 'tests.e2.ships'
-require 'tests.items'
-require 'tests.economy'
-require 'tests.orders'
-require 'tests.common'
-require 'tests.report'
-require 'tests.storage'
-require 'tests.magicbag'
-require 'tests.process'
-require 'tests.xmas'
-require 'tests.production'
-require 'tests.spells'
-require 'tests.undead'
+require 'tests.e2.astral'
+-- require 'tests.e2.spells'
+-- require 'tests.e2.e2features'
+-- require 'tests.e2.insects'
+-- require 'tests.e2.buildings'
+-- require 'tests.e2.production'
+-- require 'tests.e2.adamantium'
+-- require 'tests.e2.undead'
+-- require 'tests.e2.shiplanding'
+-- require 'tests.e2.movement'
+-- require 'tests.e2.destroy'
+-- require 'tests.e2.guard'
+-- require 'tests.e2.stealth'
+-- require 'tests.e2.items'
+-- require 'tests.e2.ships'
+-- require 'tests.items'
+-- require 'tests.economy'
+-- require 'tests.orders'
+-- require 'tests.common'
+-- require 'tests.report'
+-- require 'tests.storage'
+-- require 'tests.magicbag'
+-- require 'tests.process'
+-- require 'tests.xmas'
+-- require 'tests.production'
+-- require 'tests.spells'
+-- require 'tests.undead'
diff --git a/scripts/tests/e2/spells.lua b/scripts/tests/e2/spells.lua
index 53c86d413..deeb2798c 100644
--- a/scripts/tests/e2/spells.lua
+++ b/scripts/tests/e2/spells.lua
@@ -12,39 +12,6 @@ function setup()
     eressea.settings.set("magic.fumble.enable", "0")
 end
 
-function disable_pull_astral()
-    local r = region.create(0, 0, "plain")
-    local f = faction.create("human")
-    local u1 = unit.create(f, r, 1)
-    local u2 = unit.create(f, r, 1)
-    u1.magic = "gray"
-    u1:set_skill("magic", 6)
-    u1.aura = 1
-    u1:add_spell("pull_astral")
-    u1:clear_orders()
-    u1:add_order("ZAUBERE Astraler~Ruf " .. itoa36(u2.id))
-    -- process_orders()
-    -- assert_equal(1, f:count_msg_type('error194'), 'no target region')
-    -- assert_equal(1, f:count_msg_type('error209'), 'bad arguments')
-    u1:clear_orders()
-
-    u1:add_order("ZAUBERE Astraler~Ruf 1 0 " .. itoa36(u2.id))
-    process_orders()
-    assert_equal(1, f:count_msg_type('error194'), 'no target region')
-    assert_equal(0, f:count_msg_type('error209'), 'bad arguments')
-    assert_equal(1, f:count_msg_type('spellregionresists'), 'no such region')
-
-    u1:add_order("ZAUBERE Astraler~Ruf 0 0 " .. itoa36(u2.id))
-    process_orders()
-    assert_equal(0, f:count_msg_type('error194'), 'no target region')
-    assert_equal(0, f:count_msg_type('error209'), 'bad arguments')
-    assert_equal(0, f:count_msg_type('spellregionresists'), 'no such region')
-    for k, v in ipairs(f.messages) do
-        print(v)
-    end
-    assert_equal(u1, u2)
-end
-
 function test_shapeshift()
     local r = region.create(42, 0, "plain")
     local f = faction.create("demon", "noreply@eressea.de", "de")
diff --git a/scripts/tests/spells.lua b/scripts/tests/spells.lua
index 28efb936a..27a5424f7 100644
--- a/scripts/tests/spells.lua
+++ b/scripts/tests/spells.lua
@@ -8,6 +8,7 @@ function setup()
     eressea.settings.set("NewbieImmunity", "0")
     eressea.settings.set("rules.food.flags", "4")
     eressea.settings.set("rules.encounters", "0")
+    eressea.settings.set("magic.fumble.enable", "0")
     eressea.settings.set("magic.regeneration.enable", "0")
 end
 
diff --git a/src/bind_region.c b/src/bind_region.c
index a87b6f856..e041fba77 100644
--- a/src/bind_region.c
+++ b/src/bind_region.c
@@ -8,6 +8,7 @@
 #include "bind_building.h"
 
 #include "chaos.h"
+#include "teleport.h"
 
 #include <kernel/calendar.h>
 #include <kernel/config.h>
@@ -561,6 +562,24 @@ static int tolua_region_getkey(lua_State * L)
     return 1;
 }
 
+static int tolua_region_getastral(lua_State * L)
+{
+    region *r = (region *)tolua_tousertype(L, 1, 0);
+    region *rt = r_standard_to_astral(r);
+
+    if (!rt) {
+        const char *tname = tolua_tostring(L, 2, 0);
+        plane *pl = get_astralplane();
+        rt = new_region(real2tp(r->x), real2tp(r->y), pl, 0);
+        if (tname) {
+            const terrain_type *terrain = get_terrain(tname);
+            terraform_region(rt, terrain);
+        }
+    }
+    tolua_pushusertype(L, rt, TOLUA_CAST "region");
+    return 1;
+}
+
 static int tolua_region_setkey(lua_State * L)
 {
     region *self = (region *)tolua_tousertype(L, 1, 0);
@@ -772,6 +791,8 @@ void tolua_region_open(lua_State * L)
             tolua_variable(L, TOLUA_CAST "owner", &tolua_region_get_owner,
                 &tolua_region_set_owner);
 
+            tolua_function(L, TOLUA_CAST "get_astral", tolua_region_getastral);
+
             tolua_function(L, TOLUA_CAST "get_key", tolua_region_getkey);
             tolua_function(L, TOLUA_CAST "set_key", tolua_region_setkey);
         }
diff --git a/src/magic.c b/src/magic.c
index 80f528de8..f95a6a2a3 100644
--- a/src/magic.c
+++ b/src/magic.c
@@ -1819,12 +1819,12 @@ static int addparam_building(const char *const param[], spllprm ** spobjp)
 
 static int
 addparam_region(const char *const param[], spllprm ** spobjp, const unit * u,
-    order * ord)
+    order * ord, message **err)
 {
     assert(param[0]);
     if (param[1] == NULL) {
         /* Fehler: Zielregion vergessen */
-        cmistake(u, ord, 194, MSG_MAGIC);
+        *err = msg_error(u, ord, 194);
         return -1;
     }
     else {
@@ -1846,7 +1846,7 @@ addparam_region(const char *const param[], spllprm ** spobjp, const unit * u,
         }
         else {
             /* Fehler: Zielregion vergessen */
-            cmistake(u, ord, 194, MSG_MAGIC);
+            *err = msg_error(u, ord, 194);
             return -1;
         }
         return 2;
@@ -1855,7 +1855,7 @@ addparam_region(const char *const param[], spllprm ** spobjp, const unit * u,
 
 static int
 addparam_unit(const char *const param[], spllprm ** spobjp, const unit * u,
-    order * ord)
+    order * ord, message **err)
 {
     spllprm *spobj;
     int i = 0;
@@ -1865,7 +1865,7 @@ addparam_unit(const char *const param[], spllprm ** spobjp, const unit * u,
     if (isparam(param[0], u->faction->locale, P_TEMP)) {
         if (param[1] == NULL) {
             /* Fehler: Ziel vergessen */
-            cmistake(u, ord, 203, MSG_MAGIC);
+            *err = msg_error(u, ord, 203);
             return -1;
         }
         ++i;
@@ -1883,7 +1883,7 @@ addparam_unit(const char *const param[], spllprm ** spobjp, const unit * u,
 static spellparameter *add_spellparameter(region * target_r, unit * u,
     const char *syntax, const char *const param[], int size, struct order *ord)
 {
-    bool fail = false;
+    struct message *err = NULL;
     int i = 0;
     int p = 0;
     const char *c;
@@ -1919,7 +1919,7 @@ static spellparameter *add_spellparameter(region * target_r, unit * u,
     }
     par->param = malloc(size * sizeof(spllprm *));
 
-    while (!fail && *c && i < size && param[i] != NULL) {
+    while (!err && *c && i < size && param[i] != NULL) {
         spllprm *spobj = NULL;
         int j = -1;
         switch (*c) {
@@ -1938,13 +1938,13 @@ static spellparameter *add_spellparameter(region * target_r, unit * u,
             break;
         case 'u':
             /* Parameter ist eine Einheit, evtl. TEMP */
-            j = addparam_unit(param + i, &spobj, u, ord);
+            j = addparam_unit(param + i, &spobj, u, ord, &err);
             ++c;
             break;
         case 'r':
             /* Parameter sind zwei Regionskoordinaten innerhalb der "normalen" Plane */
             if (i + 1 < size) {
-                j = addparam_region(param + i, &spobj, u, ord);
+                j = addparam_region(param + i, &spobj, u, ord, &err);
             }
             ++c;
             break;
@@ -1979,7 +1979,7 @@ static spellparameter *add_spellparameter(region * target_r, unit * u,
                 break;
             case P_UNIT:
                 if (i < size) {
-                    j = addparam_unit(param + i, &spobj, u, ord);
+                    j = addparam_unit(param + i, &spobj, u, ord, &err);
                     ++c;
                 }
                 break;
@@ -2005,8 +2005,10 @@ static spellparameter *add_spellparameter(region * target_r, unit * u,
             j = -1;
             break;
         }
-        if (j < 0)
-            fail = true;
+        if (j < 0 && !err) {
+            /* syntax error */
+            err = msg_error(u, ord, 209);
+        }
         else {
             if (spobj != NULL)
                 par->param[p++] = spobj;
@@ -2014,15 +2016,19 @@ static spellparameter *add_spellparameter(region * target_r, unit * u,
         }
     }
 
-    /* im Endeffekt waren es evtl. nur p parameter (wegen TEMP) */
+    /* im Endeffekt waren es evtl. nur p parameter (weniger weil TEMP nicht gilt) */
     par->length = p;
-    if (par->length < minlen) {
-        cmistake(u, ord, 209, MSG_MAGIC);
-        free_spellparameter(par);
-        return NULL;
-    }
 
-    return fail ? NULL : par;
+    if (!err && p < minlen) {
+        /* syntax error */
+        err = msg_error(u, ord, 209);
+    }
+    if (err) {
+        ADDMSG(&u->faction->msgs, err);
+        free_spellparameter(par);
+        par = NULL;
+    }
+    return par;
 }
 
 struct unit * co_get_caster(const struct castorder * co) {

From cfe21e7e1d23a813763e8fddd1dc30e356b15169 Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Sun, 6 May 2018 19:07:20 +0200
Subject: [PATCH 07/24] re-enable tests, allow more spell arguments. a list of
 ships, units, etc can be long!

---
 scripts/tests/e2/init.lua | 52 +++++++++++++++++++--------------------
 src/magic.c               |  2 +-
 2 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua
index 59cb705e4..22195a1f4 100644
--- a/scripts/tests/e2/init.lua
+++ b/scripts/tests/e2/init.lua
@@ -1,27 +1,27 @@
 require 'tests.e2.astral'
--- require 'tests.e2.spells'
--- require 'tests.e2.e2features'
--- require 'tests.e2.insects'
--- require 'tests.e2.buildings'
--- require 'tests.e2.production'
--- require 'tests.e2.adamantium'
--- require 'tests.e2.undead'
--- require 'tests.e2.shiplanding'
--- require 'tests.e2.movement'
--- require 'tests.e2.destroy'
--- require 'tests.e2.guard'
--- require 'tests.e2.stealth'
--- require 'tests.e2.items'
--- require 'tests.e2.ships'
--- require 'tests.items'
--- require 'tests.economy'
--- require 'tests.orders'
--- require 'tests.common'
--- require 'tests.report'
--- require 'tests.storage'
--- require 'tests.magicbag'
--- require 'tests.process'
--- require 'tests.xmas'
--- require 'tests.production'
--- require 'tests.spells'
--- require 'tests.undead'
+require 'tests.e2.spells'
+require 'tests.e2.e2features'
+require 'tests.e2.insects'
+require 'tests.e2.buildings'
+require 'tests.e2.production'
+require 'tests.e2.adamantium'
+require 'tests.e2.undead'
+require 'tests.e2.shiplanding'
+require 'tests.e2.movement'
+require 'tests.e2.destroy'
+require 'tests.e2.guard'
+require 'tests.e2.stealth'
+require 'tests.e2.items'
+require 'tests.e2.ships'
+require 'tests.items'
+require 'tests.economy'
+require 'tests.orders'
+require 'tests.common'
+require 'tests.report'
+require 'tests.storage'
+require 'tests.magicbag'
+require 'tests.process'
+require 'tests.xmas'
+require 'tests.production'
+require 'tests.spells'
+require 'tests.undead'
diff --git a/src/magic.c b/src/magic.c
index f95a6a2a3..892c78e68 100644
--- a/src/magic.c
+++ b/src/magic.c
@@ -2422,7 +2422,7 @@ static bool is_moving_ship(ship * sh)
     return false;
 }
 
-#define MAX_PARAMETERS 8
+#define MAX_PARAMETERS 32
 static castorder *cast_cmd(unit * u, order * ord)
 {
     char token[128];

From 68de367a98e97c2a2756f762c0c6c4abf0cfb231 Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Sun, 6 May 2018 19:27:22 +0200
Subject: [PATCH 08/24] print an error instead of asserting.

---
 src/magic.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/magic.c b/src/magic.c
index 892c78e68..e6bb36002 100644
--- a/src/magic.c
+++ b/src/magic.c
@@ -2624,14 +2624,17 @@ static castorder *cast_cmd(unit * u, order * ord)
     /* Weitere Argumente zusammenbasteln */
     if (sp->parameter) {
         char *params[MAX_PARAMETERS];
-        int i, p = 0;
-        for (;;) {
+        int i, p;
+        for (p = 0; p != MAX_PARAMETERS; ++p) {
             s = gettoken(token, sizeof(token));
             if (!s || *s == 0) {
                 break;
             }
-            assert(p + 1 < MAX_PARAMETERS);
-            params[p++] = str_strdup(s);
+            params[p] = str_strdup(s);
+        }
+        if (p == MAX_PARAMETERS) {
+            log_error("%s: MAX_PARAMETERS (%d) too small to CAST %s, parsing stopped early.",
+                unitname(u), MAX_PARAMETERS, sp->sname);
         }
         args =
             add_spellparameter(target_r, caster, sp->parameter,

From 674640133066ddbe466098d1f57c30dafb84f774 Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Mon, 7 May 2018 20:22:02 +0200
Subject: [PATCH 09/24] BUG 2437: fetch_astral should have no aura cost when
 given bad units.

---
 scripts/tests/e2/astral.lua | 28 ++++++++++++++++++++++++++++
 src/spells.c                |  4 +++-
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/scripts/tests/e2/astral.lua b/scripts/tests/e2/astral.lua
index d798767c2..0764f6c56 100644
--- a/scripts/tests/e2/astral.lua
+++ b/scripts/tests/e2/astral.lua
@@ -19,6 +19,34 @@ local function dump_messages(f)
     end
 end
 
+function test_fetch_astral()
+    local r = region.create(0, 0, "plain")
+    local f = faction.create("human")
+    local u1 = unit.create(f, r, 1)
+    local u2 = unit.create(f, r, 1)
+    u1.magic = "gray"
+    u1:set_skill("magic", 6)
+    u1.aura = 0
+    u1:add_spell("fetch_astral")
+
+    u1:clear_orders()
+    u1:add_order("ZAUBERE Ruf~der~Realitaet " .. itoa36(u2.id))
+    process_orders()
+    assert_equal(1, f:count_msg_type('missing_components_list'), 'no components')
+
+    u1.aura = 12 -- 2 Aura pro Stufe
+    process_orders()
+    assert_equal(12, u1.aura)
+    assert_equal(1, f:count_msg_type('spellfail_astralonly'), 'astral space')
+
+    u1.name = 'Xolgrim'
+    u1.aura = 12 -- 2 Aura pro Stufe
+    u2.region = u2.region:get_astral('fog')
+    process_orders()
+    assert_equal(0, u1.aura)
+    assert_equal(u1.region, u2.region)
+end
+
 function test_pull_astral()
     local r = region.create(0, 0, "plain")
     local f = faction.create("human")
diff --git a/src/spells.c b/src/spells.c
index 57807ae83..bd2c8ea1a 100644
--- a/src/spells.c
+++ b/src/spells.c
@@ -5311,7 +5311,7 @@ int sp_fetchastral(castorder * co)
 {
     int n;
     unit *mage = co->magician.u;
-    int cast_level = co->level;
+    int cast_level = 0;
     spellparameter *pa = co->par;
     double power = co->force;
     int remaining_cap = (int)((power - 3) * 1500);
@@ -5343,6 +5343,7 @@ int sp_fetchastral(castorder * co)
                     "spellfail_astralonly", ""));
                 continue;
             }
+
             if (rtl != NULL)
                 free_regionlist(rtl);
             rtl = astralregions(u->region, NULL);
@@ -5359,6 +5360,7 @@ int sp_fetchastral(castorder * co)
             ro = u->region;
         }
 
+        cast_level = co->level; /* at least one unit could have been teleported */
         if (is_cursed(ro->attribs, &ct_astralblock)) {
             ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order,
                 "spellfail_astralblock", ""));

From 4bcaaa5f793899bf0f20998bd17893a8c5e69083 Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Mon, 7 May 2018 20:24:59 +0200
Subject: [PATCH 10/24] remove debug code

---
 scripts/tests/e2/astral.lua | 2 --
 1 file changed, 2 deletions(-)

diff --git a/scripts/tests/e2/astral.lua b/scripts/tests/e2/astral.lua
index 0764f6c56..efed6345f 100644
--- a/scripts/tests/e2/astral.lua
+++ b/scripts/tests/e2/astral.lua
@@ -39,8 +39,6 @@ function test_fetch_astral()
     assert_equal(12, u1.aura)
     assert_equal(1, f:count_msg_type('spellfail_astralonly'), 'astral space')
 
-    u1.name = 'Xolgrim'
-    u1.aura = 12 -- 2 Aura pro Stufe
     u2.region = u2.region:get_astral('fog')
     process_orders()
     assert_equal(0, u1.aura)

From ccf09770e3018c5ecc694c1aaf47be5de99092ee Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Tue, 8 May 2018 21:43:13 +0200
Subject: [PATCH 11/24] rename global target flag, invert logic

---
 res/eressea/spells.xml |  4 ++--
 src/magic.c            | 13 +++++++------
 src/magic.h            |  2 +-
 src/xmlreader.c        |  4 ++--
 4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/res/eressea/spells.xml b/res/eressea/spells.xml
index 2adc132e5..859dea5bb 100644
--- a/res/eressea/spells.xml
+++ b/res/eressea/spells.xml
@@ -411,10 +411,10 @@
   <spell name="sparkledream" rank="5" parameters="u" los="true" ship="true" variable="true">
     <resource name="aura" amount="1" cost="level"/>
   </spell>
-  <spell name="pull_astral" rank="7" parameters="ru+" variable="true" target_global="true">
+  <spell name="pull_astral" rank="7" parameters="ru+" variable="true" globaltarget="true">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
-  <spell name="fetch_astral" rank="7" parameters="u+" variable="true" target_global="true">
+  <spell name="fetch_astral" rank="7" parameters="u+" variable="true" globaltarget="true">
     <resource name="aura" amount="2" cost="level"/>
   </spell>
   <spell name="shockwave" rank="5" variable="true" combat="2">
diff --git a/src/magic.c b/src/magic.c
index e6bb36002..1b41b87af 100644
--- a/src/magic.c
+++ b/src/magic.c
@@ -1475,7 +1475,7 @@ verify_ship(region * r, unit * mage, const spell * sp, spllprm * spobj,
 {
     ship *sh = findship(spobj->data.i);
 
-    if (sh != NULL && sh->region != r && (sp->sptyp & SEARCHLOCAL)) {
+    if (sh != NULL && sh->region != r && (sp->sptyp & GLOBALTARGET) == 0) {
         /* Burg muss in gleicher Region sein */
         sh = NULL;
     }
@@ -1498,7 +1498,7 @@ verify_building(region * r, unit * mage, const spell * sp, spllprm * spobj,
 {
     building *b = findbuilding(spobj->data.i);
 
-    if (b != NULL && b->region != r && (sp->sptyp & SEARCHLOCAL)) {
+    if (b != NULL && b->region != r && (sp->sptyp & GLOBALTARGET) == 0) {
         /* Burg muss in gleicher Region sein */
         b = NULL;
     }
@@ -1552,14 +1552,15 @@ verify_unit(region * r, unit * mage, const spell * sp, spllprm * spobj,
     default:
         assert(!"shouldn't happen, this");
     }
-    if (u != NULL && (sp->sptyp & SEARCHLOCAL)) {
-        if (u->region != r)
-            u = NULL;
-        else if (sp->sptyp & TESTCANSEE) {
+    if (u != NULL) {
+        if (u->region == r) {
             if (!cansee(mage->faction, r, u, 0) && !ucontact(u, mage)) {
                 u = NULL;
             }
         }
+        else if ((sp->sptyp & GLOBALTARGET) == 0) {
+            u = NULL;
+        }
     }
 
     if (u == NULL) {
diff --git a/src/magic.h b/src/magic.h
index ae43fd5af..9118a546b 100644
--- a/src/magic.h
+++ b/src/magic.h
@@ -174,7 +174,7 @@ extern "C" {
 #define NOTFAMILIARCAST (1<<12)
 #define TESTRESISTANCE  (1<<13) /* alle Zielobjekte (u, s, b, r) auf
                                        Magieresistenz pr�fen */
-#define SEARCHLOCAL     (1<<14) /* Ziel muss in der target_region sein */
+#define GLOBALTARGET    (1<<14) /* Ziel muss in der target_region sein */
 #define TESTCANSEE      (1<<15) /* alle Zielunits auf cansee pr�fen */
 #define ANYTARGET       (UNITSPELL|REGIONSPELL|BUILDINGSPELL|SHIPSPELL) /* wirkt auf alle objekttypen (unit, ship, building, region) */
 
diff --git a/src/xmlreader.c b/src/xmlreader.c
index dcf51707b..35b4b328e 100644
--- a/src/xmlreader.c
+++ b/src/xmlreader.c
@@ -1169,8 +1169,6 @@ static int parse_spells(xmlDocPtr doc)
             sp->rank = (char)xml_ivalue(node, "rank", 0);
             if (xml_bvalue(node, "los", false))
                 sp->sptyp |= TESTCANSEE;        /* must see or have contact */
-            if (!xml_bvalue(node, "target_global", false))
-                sp->sptyp |= SEARCHLOCAL;       /* must be in same region */
             if (xml_bvalue(node, "ship", false))
                 sp->sptyp |= ONSHIPCAST;
             if (xml_bvalue(node, "ocean", false))
@@ -1180,6 +1178,8 @@ static int parse_spells(xmlDocPtr doc)
             if (xml_bvalue(node, "variable", false))
                 sp->sptyp |= SPELLLEVEL;
 
+            if (xml_bvalue(node, "globaltarget", false))
+                sp->sptyp |= GLOBALTARGET;       /* target need not be in same region */
             if (xml_bvalue(node, "buildingtarget", false))
                 sp->sptyp |= BUILDINGSPELL;
             if (xml_bvalue(node, "shiptarget", false))

From ae3c0b099f85e1cbb6ea2c32214570545461707d Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Tue, 8 May 2018 23:10:51 +0200
Subject: [PATCH 12/24] spells do not have a function element in XML

---
 conf/e2/config.json    | 1 +
 conf/e3/config.json    | 1 +
 res/e3a/spells.xml     | 8 --------
 res/eressea/spells.xml | 9 ---------
 src/kernel/faction.c   | 2 +-
 5 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/conf/e2/config.json b/conf/e2/config.json
index 6450e9d54..b5ed2e68c 100644
--- a/conf/e2/config.json
+++ b/conf/e2/config.json
@@ -28,6 +28,7 @@
     ],
     "settings": {
         "game.name" : "Eressea",
+        "game.mailcmd" : "ERESSEA",
         "game.id" : 2,
         "orders.default": "work",
         "NewbieImmunity": 8,
diff --git a/conf/e3/config.json b/conf/e3/config.json
index b5f9aed5c..ad7a44b2f 100644
--- a/conf/e3/config.json
+++ b/conf/e3/config.json
@@ -43,6 +43,7 @@
     ],
     "settings": {
         "game.name" : "Eressea",
+        "game.mailcmd" : "ERESSEA",
         "game.id" : 3,
         "orders.default": "work",
         "database.gameid": 7,
diff --git a/res/e3a/spells.xml b/res/e3a/spells.xml
index c6f466eb4..94d7cbc08 100644
--- a/res/e3a/spells.xml
+++ b/res/e3a/spells.xml
@@ -68,7 +68,6 @@
   </spell>
   <spell name="readmind" parameters="u" rank="5">
     <!-- Traumdeuten -->
-    <function name="cast" value="cast_readmind"/>
     <resource name="aura" amount="20" cost="fixed"/>
     <!-- missing syntactical info: ONETARGET | UNITSPELL -->
   </spell>
@@ -113,7 +112,6 @@
   </spell>
   <spell name="fireball" rank="5" variable="true" combat="2">
     <!-- Feuerball -->
-    <function name="cast" value="combat_spell"/>
     <resource name="aura" amount="1" cost="level"/>
   </spell>
   <spell name="magicboost" rank="3" ship="true">
@@ -213,7 +211,6 @@
   </spell>
   <spell name="blabbermouth" parameters="u" los="true" rank="5">
     <!-- Plappermaul -->
-    <function name="cast" value="cast_babbler"/>
     <resource name="aura" amount="10" cost="fixed"/>
     <!-- missing syntactical info: ONETARGET | UNITSPELL -->
   </spell>
@@ -290,7 +287,6 @@
   <!-- new gwyrrd -->
   <spell name="blessedharvest" rank="5" ship="true" far="true" variable="true">
     <!-- Segen der Erde -->
-    <function name="cast" value="cast_blessedharvest"/>
     <resource name="aura" amount="1" cost="level"/>
   </spell>
   <spell name="earn_silver#gwyrrd" ship="true" variable="true" rank="5">
@@ -311,7 +307,6 @@
   </spell>
   <spell name="hail" rank="5" variable="true" combat="2">
     <!-- Hagel -->
-    <function name="cast" value="combat_spell"/>
     <resource name="aura" amount="1" cost="level"/>
   </spell>
   <spell name="goodwinds" rank="5" parameters="s" ship="true" variable="true">
@@ -489,7 +484,6 @@
   </spell>
   <spell name="raindance" rank="5" ship="true" far="true" variable="true">
     <!-- Regentanz -->
-    <function name="cast" value="cast_blessedharvest"/>
     <resource name="aura" amount="1" cost="level"/>
   </spell>
   <spell name="irongolem" rank="4" variable="true">
@@ -580,7 +574,6 @@
     <resource name="laen" amount="5" cost="fixed"/>
   </spell>
   <spell name="summon_familiar" rank="5">
-    <function name="cast" value="cast_familiar"/>
     <resource name="aura" amount="100" cost="fixed"/>
     <resource name="permaura" amount="5" cost="fixed"/>
   </spell>
@@ -619,7 +612,6 @@
     <resource name="aura" amount="3" cost="fixed"/>
   </spell>
   <spell name="meteor_rain" rank="5" variable="true" combat="2">
-    <function name="cast" value="combat_spell"/>
     <resource name="aura" amount="1" cost="level"/>
   </spell>
   <spell name="wyrm_transformation" rank="5">
diff --git a/res/eressea/spells.xml b/res/eressea/spells.xml
index 859dea5bb..4b9251691 100644
--- a/res/eressea/spells.xml
+++ b/res/eressea/spells.xml
@@ -16,11 +16,9 @@
   </spell>
 
   <spell name="fireball" rank="5" variable="true" combat="2">
-    <function name="cast" value="combat_spell"/>
     <resource name="aura" amount="1" cost="level"/>
   </spell>
   <spell name="hail" rank="5" variable="true" combat="2">
-    <function name="cast" value="combat_spell"/>
     <resource name="aura" amount="1" cost="level"/>
   </spell>
   <spell name="rustweapon" rank="5" parameters="u+" los="true" far="true" variable="true">
@@ -290,7 +288,6 @@
     <resource name="aura" amount="2" cost="level"/>
   </spell>
   <spell name="igjarjuk" rank="5" variable="true" combat="1">
-    <function name="cast" value="igjarjuk"/>
   </spell>
   <spell name="resist_magic" rank="2" parameters="u+" los="true" ship="true" variable="true">
     <resource name="aura" amount="5" cost="level"/>
@@ -326,7 +323,6 @@
     <resource name="aura" amount="3" cost="level"/>
   </spell>
   <spell name="meteor_rain" rank="5" variable="true" combat="2">
-    <function name="cast" value="combat_spell"/>
     <resource name="aura" amount="1" cost="level"/>
   </spell>
   <spell name="fish_shield" rank="2" variable="true" combat="1">
@@ -356,7 +352,6 @@
     <resource name="permaura" amount="5" cost="fixed"/>
   </spell>
   <spell name="summon_familiar" rank="5">
-    <function name="cast" value="cast_familiar"/>
     <resource name="aura" amount="100" cost="fixed"/>
     <resource name="permaura" amount="5" cost="fixed"/>
   </spell>
@@ -504,7 +499,6 @@
   <!-- gwyrrd spells -->
   <spell name="blessedharvest" rank="5" ship="true" far="true" variable="true">
     <!-- Segen der Erde -->
-    <function name="cast" value="cast_blessedharvest"/>
     <resource name="aura" amount="1" cost="level"/>
   </spell>
 
@@ -537,7 +531,6 @@
   <!-- cerddor spells -->
   <spell name="raindance" rank="5" ship="true" far="true" variable="true">
     <!-- Segen der Erde -->
-    <function name="cast" value="cast_blessedharvest"/>
     <resource name="aura" amount="1" cost="level"/>
   </spell>
 
@@ -552,13 +545,11 @@
   </spell>
 
   <spell name="blabbermouth" parameters="u" los="true" rank="5">
-    <function name="cast" value="cast_babbler"/>
     <resource name="aura" amount="10" cost="fixed"/>
     <!-- missing syntactical info: ONETARGET | UNITSPELL -->
   </spell>
 
   <spell name="readmind" parameters="u" rank="5">
-    <function name="cast" value="cast_readmind"/>
     <resource name="aura" amount="20" cost="fixed"/>
     <!-- missing syntactical info: ONETARGET | UNITSPELL -->
   </spell>
diff --git a/src/kernel/faction.c b/src/kernel/faction.c
index 865d0f2a9..43c25d440 100755
--- a/src/kernel/faction.c
+++ b/src/kernel/faction.c
@@ -237,7 +237,7 @@ faction *addfaction(const char *email, const char *password,
     if (check_email(email) == 0) {
         faction_setemail(f, email);
     } else {
-        log_warning("Invalid email address for faction %s: %s\n", itoa36(f->no), email?email:"");
+        log_info("Invalid email address for faction %s: %s\n", itoa36(f->no), email?email:"");
         faction_setemail(f, NULL);
     }
 

From 3f9b3219fef0b5bf565561bd33ce61571306b403 Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Tue, 8 May 2018 23:22:05 +0200
Subject: [PATCH 13/24] BUG 2348: bad XML

---
 res/eressea/spells.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/res/eressea/spells.xml b/res/eressea/spells.xml
index 4b9251691..1931a4c74 100644
--- a/res/eressea/spells.xml
+++ b/res/eressea/spells.xml
@@ -313,8 +313,8 @@
   <spell name="analysesong_unit" rank="5" parameters="u" los="true" ship="true">
     <resource name="aura" amount="10" cost="fixed"/>
   </spell>
-  <spell name="analyse_object" rank="5" parameters="kc+" ship="true" variable="true">
-    <resource name="aura" amount="3" cost="level" regiontarget="true" unittarget="false" buildingtarget="true" shiptarget="true"/>
+  <spell name="analyse_object" rank="5" parameters="kc+" ship="true" variable="true" regiontarget="true" unittarget="false" buildingtarget="true" shiptarget="true">
+	  <resource name="aura" amount="3" cost="level"/>
   </spell>
   <spell name="destroy_magic" rank="2" parameters="kc+" los="true" ship="true" far="true" variable="true">
     <resource name="aura" amount="4" cost="level"/>

From 8c7b890f3e5e9a10a18362d3d8d304441c91c645 Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Wed, 9 May 2018 20:56:38 +0200
Subject: [PATCH 14/24] set the default unarmed modifiers for races.

---
 res/e3a/races.xml      |  98 +++++++++++++++---------------
 res/eressea/races.xml  | 134 ++++++++++++++++++++---------------------
 src/kernel/race.c      |   2 +
 src/kernel/race.test.c |   2 +
 src/xmlreader.c        |   4 +-
 5 files changed, 122 insertions(+), 118 deletions(-)

diff --git a/res/e3a/races.xml b/res/e3a/races.xml
index bb70fa3df..7bb80edc0 100644
--- a/res/e3a/races.xml
+++ b/res/e3a/races.xml
@@ -4,11 +4,11 @@
 
   <!-- begin main races -->
 
-  <race name="template" maintenance="0" magres="100" maxaura="0.000000" regaura="0.000000" weight="0" capacity="1000" speed="10.000000" hp="10" damage="1d4" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" fly="yes" swim="yes" walk="yes" shapeshift="yes" shapeshiftany="yes" giveperson="yes" giveunit="yes" getitem="yes" recruitethereal="yes" recruitunlimited="yes" equipment="yes">
+  <race name="template" maintenance="0" magres="100" maxaura="0" regaura="0" weight="0" capacity="1000" speed="10.000000" hp="10" damage="1d4" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" fly="yes" swim="yes" walk="yes" shapeshift="yes" shapeshiftany="yes" giveperson="yes" giveunit="yes" getitem="yes" recruitethereal="yes" recruitunlimited="yes" equipment="yes">
     <ai splitsize="10000" moverandom="yes" learn="yes"/>
     <attack type="1" damage="1d4"/>
   </race>
-  <race name="lynx" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="1.0" hp="20" damage="2d3" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="5" walk="yes" teach="no" getitem="yes">
+  <race name="lynx" maxaura="0" regaura="0" weight="500" capacity="540" speed="1.0" hp="20" damage="2d3" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="5" walk="yes" teach="no" getitem="yes">
     <ai splitsize="99999"/>
     <skill name="crossbow" modifier="-99"/>
     <skill name="mining" modifier="-99"/>
@@ -31,7 +31,7 @@
     <attack type="4" damage="2d3"/>
   </race>
 
-  <race name="human" maxaura="1.0" regaura="1.0" recruitcost="100" maintenance="10" weight="1000" capacity="540" speed="1.0" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
+  <race name="human" maxaura="1" regaura="1" recruitcost="100" maintenance="10" weight="1000" capacity="540" speed="1.0" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
     <ai splitsize="10000" moverandom="yes" learn="yes"/>
     <param name="other_race" value="elf"/>
     <skill name="riding" modifier="+1"/>
@@ -44,7 +44,7 @@
     <familiar race="giantturtle"/>
   </race>
 
-  <race name="orc" studyspeed="-5" magres="-5" maxaura="1.0" regaura="1.0" recruitcost="100" maintenance="10" weight="1000" capacity="540" speed="1.0" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
+  <race name="orc" studyspeed="-5" magres="-5" maxaura="1" regaura="1" recruitcost="100" maintenance="10" weight="1000" capacity="540" speed="1.0" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
     <ai splitsize="10000" moverandom="yes" learn="yes"/>
     <param name="other_race" value="troll"/>
 
@@ -71,8 +71,8 @@
     <familiar race="ghost"/>
   </race>
 
-  <race name="halfling" defensemodifier="1" magres="5" maxaura="1.0"
-  regaura="1.0" recruitcost="100" maintenance="10" weight="1000"
+  <race name="halfling" defensemodifier="1" magres="5" maxaura="1"
+  regaura="1" recruitcost="100" maintenance="10" weight="1000"
   capacity="540" speed="1.0" hp="20" damage="1d5" unarmedattack="-2"
   unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes"
   giveunit="yes" getitem="yes" equipment="yes">
@@ -101,7 +101,7 @@
   
   <!-- begin secondary races -->
 
-  <race name="demon" magres="15" maxaura="1.0" regaura="1.1" recruitcost="360" maintenance="10" weight="1000" capacity="540" speed="1.0" hp="30" ac="2" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" shapeshift="yes" giveperson="yes" giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes">
+  <race name="demon" magres="15" maxaura="1" regaura="1.1" recruitcost="360" maintenance="10" weight="1000" capacity="540" speed="1.0" hp="30" ac="2" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" shapeshift="yes" giveperson="yes" giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes">
     <ai splitsize="10000" moverandom="yes" learn="yes"/>
     <skill name="cartmaking" modifier="-2"/>
     <skill name="forestry" modifier="1"/>
@@ -120,7 +120,7 @@
     <familiar race="ghost"/>
   </race>
 
-  <race name="elf" magres="10" maxaura="1.0" regaura="1.1"
+  <race name="elf" magres="10" maxaura="1" regaura="1.1"
   recruitcost="200" maintenance="10" weight="1000" capacity="540"
   speed="1.0" hp="20" damage="1d5" unarmedattack="-2"
   unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes"
@@ -142,7 +142,7 @@
     <familiar race="unicorn"/>
   </race>
 
-  <race name="troll" magres="10" maxaura="1.0" regaura="1.0" recruitcost="260" maintenance="10" weight="2000" capacity="1080" speed="1.0" hp="20" ac="1" damage="1d5+3" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
+  <race name="troll" magres="10" maxaura="1" regaura="1" recruitcost="260" maintenance="10" weight="2000" capacity="1080" speed="1.0" hp="20" ac="1" damage="1d5+3" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
     <ai splitsize="10000" moverandom="yes" learn="yes"/>
     <param name="armor.stamina" value="4"/> <!-- +1 natural armor per X levels stamina -->
     <skill name="armorer" modifier="2"/>
@@ -164,7 +164,7 @@
     <familiar race="rat"/>
   </race>
 
-  <race name="dwarf" magres="5" maxaura="1.0" regaura="0.9"
+  <race name="dwarf" magres="5" maxaura="1" regaura="0.9"
   recruitcost="240" maintenance="10" weight="1000" capacity="540"
   speed="1.0" hp="20" damage="1d5" unarmedattack="-2"
   unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes"
@@ -192,7 +192,7 @@
 
   <!-- end player races -->
 
-  <race name="kraken" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="2.000000" hp="300" damage="2d10" unarmedattack="0" unarmeddefense="0" attackmodifier="7" defensemodifier="7" coastal="yes" swim="yes" teach="no" getitem="yes">
+  <race name="kraken" maxaura="0" regaura="0" weight="500" capacity="540" speed="2.000000" hp="300" damage="2d10" unarmedattack="0" unarmeddefense="0" attackmodifier="7" defensemodifier="7" coastal="yes" swim="yes" teach="no" getitem="yes">
     <ai splitsize="5000"/>
     <skill name="crossbow" modifier="-99"/>
     <skill name="mining" modifier="-99"/>
@@ -218,7 +218,7 @@
     <attack type="4" damage="1d10"/>
     <attack type="4" damage="1d10"/>
   </race>
-  <race name="giantturtle" maxaura="0.000000" regaura="0.000000" weight="1600" capacity="600" speed="1.0" hp="900" ac="7" damage="2d50" unarmedattack="0" unarmeddefense="0" attackmodifier="10" defensemodifier="5" coastal="yes" swim="yes" walk="yes" teach="no" getitem="yes">
+  <race name="giantturtle" maxaura="0" regaura="0" weight="1600" capacity="600" speed="1.0" hp="900" ac="7" damage="2d50" unarmedattack="0" unarmeddefense="0" attackmodifier="10" defensemodifier="5" coastal="yes" swim="yes" walk="yes" teach="no" getitem="yes">
     <ai splitsize="5000"/>
     <skill name="crossbow" modifier="-99"/>
     <skill name="mining" modifier="-99"/>
@@ -239,7 +239,7 @@
     <skill name="cartmaking" modifier="-99"/>
     <attack type="4" damage="2d50"/>
   </race>
-  <race name="dolphin" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="2.000000" hp="24" damage="1d6" unarmedattack="0" unarmeddefense="0" attackmodifier="5" defensemodifier="5" coastal="yes" swim="yes" teach="no" getitem="yes">
+  <race name="dolphin" maxaura="0" regaura="0" weight="500" capacity="540" speed="2.000000" hp="24" damage="1d6" unarmedattack="0" unarmeddefense="0" attackmodifier="5" defensemodifier="5" coastal="yes" swim="yes" teach="no" getitem="yes">
     <ai splitsize="5000"/>
     <skill name="crossbow" modifier="-99"/>
     <skill name="mining" modifier="-99"/>
@@ -260,7 +260,7 @@
     <skill name="cartmaking" modifier="-99"/>
     <attack type="4" damage="1d6"/>
   </race>
-  <race name="tiger" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="1.0" hp="30" damage="2d6" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="3" walk="yes" teach="no" getitem="yes">
+  <race name="tiger" maxaura="0" regaura="0" weight="500" capacity="540" speed="1.0" hp="30" damage="2d6" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="3" walk="yes" teach="no" getitem="yes">
     <ai splitsize="5000"/>
     <skill name="crossbow" modifier="-99"/>
     <skill name="mining" modifier="-99"/>
@@ -283,7 +283,7 @@
     <attack type="4" damage="1d6"/>
     <attack type="4" damage="1d6"/>
   </race>
-  <race name="hellcat" magres="50" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="1.0" hp="40" damage="2d6" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="4" walk="yes" teach="no" getitem="yes" resistpierce="yes">
+  <race name="hellcat" magres="50" maxaura="0" regaura="0" weight="500" capacity="540" speed="1.0" hp="40" damage="2d6" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="4" walk="yes" teach="no" getitem="yes" resistpierce="yes">
     <ai splitsize="5000"/>
     <skill name="crossbow" modifier="-99"/>
     <skill name="mining" modifier="-99"/>
@@ -306,7 +306,7 @@
     <attack type="4" damage="1d6"/>
     <attack type="4" damage="1d6"/>
   </race>
-  <race name="owl" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="1.0" hp="9" damage="1d4" unarmedattack="0" unarmeddefense="0" attackmodifier="2" defensemodifier="4" fly="yes" walk="yes" teach="no" getitem="yes">
+  <race name="owl" maxaura="0" regaura="0" weight="500" capacity="540" speed="1.0" hp="9" damage="1d4" unarmedattack="0" unarmeddefense="0" attackmodifier="2" defensemodifier="4" fly="yes" walk="yes" teach="no" getitem="yes">
     <ai splitsize="5000"/>
     <skill name="crossbow" modifier="-99"/>
     <skill name="mining" modifier="-99"/>
@@ -328,7 +328,7 @@
     <skill name="cartmaking" modifier="-99"/>
     <attack type="4" damage="1d4"/>
   </race>
-  <race name="fairy" magres="80" maxaura="1.0" regaura="1.500000" weight="200" capacity="540" speed="1.0" hp="6" damage="1d3" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="14" fly="yes" walk="yes" teach="no" getitem="yes" equipment="yes">
+  <race name="fairy" magres="80" maxaura="1" regaura="1.5" weight="200" capacity="540" speed="1.0" hp="6" damage="1d3" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="14" fly="yes" walk="yes" teach="no" getitem="yes" equipment="yes">
     <ai splitsize="5000"/>
     <skill name="magic" modifier="1"/>
     <skill name="riding" modifier="-1"/>
@@ -354,7 +354,7 @@
     <attack type="4" damage="1d3"/>
     <attack type="4" damage="1d3"/>
   </race>
-  <race name="dreamcat" magres="50" maxaura="1.0" regaura="1.0" weight="500" capacity="540" speed="1.0" hp="10" damage="1d5" unarmedattack="0" unarmeddefense="0" attackmodifier="5" defensemodifier="6" fly="yes" walk="yes" teach="no" getitem="yes" invinciblenonmagic="yes">
+  <race name="dreamcat" magres="50" maxaura="1" regaura="1" weight="500" capacity="540" speed="1.0" hp="10" damage="1d5" unarmedattack="0" unarmeddefense="0" attackmodifier="5" defensemodifier="6" fly="yes" walk="yes" teach="no" getitem="yes" invinciblenonmagic="yes">
     <ai splitsize="5000"/>
     <skill name="magic" modifier="1"/>
     <skill name="crossbow" modifier="-99"/>
@@ -376,7 +376,7 @@
     <attack type="4" damage="1d5"/>
     <attack type="4" damage="1d5"/>
   </race>
-  <race name="imp" magres="50" maxaura="1.0" regaura="1.0" weight="500" capacity="540" speed="1.0" hp="10" ac="1" damage="1d4" unarmedattack="0" unarmeddefense="0" attackmodifier="5" defensemodifier="4" fly="yes" walk="yes" teach="no" getitem="yes" equipment="yes">
+  <race name="imp" magres="50" maxaura="1" regaura="1" weight="500" capacity="540" speed="1.0" hp="10" ac="1" damage="1d4" unarmedattack="0" unarmeddefense="0" attackmodifier="5" defensemodifier="4" fly="yes" walk="yes" teach="no" getitem="yes" equipment="yes">
     <ai splitsize="5000"/>
     <skill name="crossbow" modifier="-99"/>
     <skill name="mining" modifier="-99"/>
@@ -400,7 +400,7 @@
     <attack type="1" damage="1d4"/>
     <attack type="6" spell="fiery_dragonbreath" level="3" />
   </race>
-  <race name="ghost" magres="80" maxaura="0.500000" regaura="0.100000" weight="500" capacity="540" speed="1.0" hp="30" ac="5" damage="2d6" unarmedattack="0" unarmeddefense="0" attackmodifier="5" defensemodifier="8" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" equipment="yes" invinciblenonmagic="yes">
+  <race name="ghost" magres="80" maxaura="0.5" regaura="0.1" weight="500" capacity="540" speed="1.0" hp="30" ac="5" damage="2d6" unarmedattack="0" unarmeddefense="0" attackmodifier="5" defensemodifier="8" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" equipment="yes" invinciblenonmagic="yes">
     <ai splitsize="5000"/>
     <skill name="crossbow" modifier="-99"/>
     <skill name="mining" modifier="-99"/>
@@ -425,7 +425,7 @@
     <attack type="2" damage="2d30"/>
     <attack type="3" damage="1d1"/>
   </race>
-  <race name="wolf" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="1.0" hp="25" damage="2d6" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="3" scarepeasants="yes" walk="yes" teach="no" getitem="yes">
+  <race name="wolf" maxaura="0" regaura="0" weight="500" capacity="540" speed="1.0" hp="25" damage="2d6" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="3" scarepeasants="yes" walk="yes" teach="no" getitem="yes">
     <ai splitsize="5000"/>
     <skill name="crossbow" modifier="-99"/>
     <skill name="mining" modifier="-99"/>
@@ -471,7 +471,7 @@
     <attack type="4" damage="3d12"/>
     <attack type="4" damage="2d4"/>
   </race>
-  <race name="nymph" magres="90" maxaura="1.0" regaura="1.500000" weight="1000" capacity="540" speed="1.0" hp="15" damage="1d4" unarmedattack="0" unarmeddefense="0" attackmodifier="3" defensemodifier="1" walk="yes" teach="no" getitem="yes" equipment="yes">
+  <race name="nymph" magres="90" maxaura="1" regaura="1.500000" weight="1000" capacity="540" speed="1.0" hp="15" damage="1d4" unarmedattack="0" unarmeddefense="0" attackmodifier="3" defensemodifier="1" walk="yes" teach="no" getitem="yes" equipment="yes">
     <ai splitsize="9999"/>
     <skill name="mining" modifier="-99"/>
     <skill name="bow" modifier="2"/>
@@ -493,7 +493,7 @@
     <attack type="1" damage="1d4"/>
     <attack type="2" damage="2d20"/>
   </race>
-  <race name="songdragon" magres="99" maxaura="1.0" regaura="1.0" weight="1000" capacity="600" speed="1.500000" hp="40" ac="1" damage="2d4" unarmedattack="0" unarmeddefense="0" attackmodifier="3" defensemodifier="1" fly="yes" walk="yes" teach="no" getitem="yes">
+  <race name="songdragon" magres="99" maxaura="1" regaura="1" weight="1000" capacity="600" speed="1.500000" hp="40" ac="1" damage="2d4" unarmedattack="0" unarmeddefense="0" attackmodifier="3" defensemodifier="1" fly="yes" walk="yes" teach="no" getitem="yes">
     <ai splitsize="9999"/>
     <skill name="crossbow" modifier="-99"/>
     <skill name="mining" modifier="-99"/>
@@ -520,7 +520,7 @@
     <attack type="6" spell="fiery_dragonbreath" level="3" />
   </race>
 
-  <race name="rat" maxaura="0.000000" regaura="0.000000" weight="100" capacity="540" speed="1.0" hp="10" damage="1d4" unarmedattack="0" unarmeddefense="0" attackmodifier="1" defensemodifier="1" walk="yes" teach="no" getitem="yes">
+  <race name="rat" maxaura="0" regaura="0" weight="100" capacity="540" speed="1.0" hp="10" damage="1d4" unarmedattack="0" unarmeddefense="0" attackmodifier="1" defensemodifier="1" walk="yes" teach="no" getitem="yes">
     <ai splitsize="9999"/>
     <skill name="crossbow" modifier="-99"/>
     <skill name="mining" modifier="-99"/>
@@ -543,7 +543,7 @@
     <attack type="4" damage="1d4"/>
     <attack type="4" damage="1d4"/>
   </race>
-  <race name="eagle" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="1.500000" hp="15" damage="2d3" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="2" fly="yes" walk="yes" teach="no" getitem="yes">
+  <race name="eagle" maxaura="0" regaura="0" weight="500" capacity="540" speed="1.500000" hp="15" damage="2d3" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="2" fly="yes" walk="yes" teach="no" getitem="yes">
     <ai splitsize="9999"/>
     <skill name="crossbow" modifier="-99"/>
     <skill name="mining" modifier="-99"/>
@@ -565,7 +565,7 @@
     <skill name="cartmaking" modifier="-99"/>
     <attack type="4" damage="2d3"/>
   </race>
-  <race name="tunnelworm" magres="80" maxaura="0.000000" regaura="0.000000" weight="30000" capacity="10000" speed="1.0" hp="300" ac="6" damage="3d20" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="1" scarepeasants="yes" walk="yes" teach="no" getitem="yes">
+  <race name="tunnelworm" magres="80" maxaura="0" regaura="0" weight="30000" capacity="10000" speed="1.0" hp="300" ac="6" damage="3d20" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="1" scarepeasants="yes" walk="yes" teach="no" getitem="yes">
     <ai splitsize="99999"/>
     <skill name="crossbow" modifier="-99"/>
     <skill name="mining" modifier="10"/>
@@ -589,21 +589,21 @@
     <attack type="4" damage="3d20"/>
     <attack type="8" damage="1d10"/>
   </race>
-  <race name="direwolf" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="1.0" hp="20" damage="2d4" unarmedattack="0" unarmeddefense="0" attackmodifier="3" defensemodifier="1" walk="yes" teach="no" giveperson="yes">
+  <race name="direwolf" maxaura="0" regaura="0" weight="500" capacity="540" speed="1.0" hp="20" damage="2d4" unarmedattack="0" unarmeddefense="0" attackmodifier="3" defensemodifier="1" walk="yes" teach="no" giveperson="yes">
     <ai splitsize="5000"/>
     <attack type="4" damage="2d4"/>
   </race>
-  <race name="peasant" maxaura="1.0" regaura="1.0" weight="1000" capacity="540" speed="1.0" hp="20" damage="1d6" unarmedattack="0" unarmeddefense="0" cannotmove="yes" teach="no">
+  <race name="peasant" maxaura="1" regaura="1" weight="1000" capacity="540" speed="1.0" hp="20" damage="1d6" unarmedattack="0" unarmeddefense="0" cannotmove="yes" teach="no">
     <ai splitsize="10000"/>
     <attack type="1" damage="1d6"/>
   </race>
-  <race name="braineater" magres="90" maxaura="1.0" regaura="1.0" weight="100" capacity="540" speed="1.0" hp="20" damage="0d0" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="10" scarepeasants="yes" fly="yes" walk="yes" teach="no" invinciblenonmagic="yes">
+  <race name="braineater" magres="90" maxaura="1" regaura="1" weight="100" capacity="540" speed="1.0" hp="20" damage="0d0" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="10" scarepeasants="yes" fly="yes" walk="yes" teach="no" invinciblenonmagic="yes">
     <ai splitsize="500" killpeasants="yes" moverandom="yes" learn="yes"/>
     <attack type="2" damage="3d15"/>
     <attack type="3" damage="1d1"/>
     <attack type="4" damage="1d1"/>
   </race>
-  <race name="toad" magres="20" maxaura="1.0" regaura="1.0" maintenance="10" weight="100" capacity="540" speed="1.0" hp="10" damage="1d2" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" giveperson="yes" giveunit="yes" getitem="yes" walk="yes">
+  <race name="toad" magres="20" maxaura="1" regaura="1" maintenance="10" weight="100" capacity="540" speed="1.0" hp="10" damage="1d2" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" giveperson="yes" giveunit="yes" getitem="yes" walk="yes">
     <ai splitsize="1" learn="yes"/>
     <skill name="crossbow" modifier="-10"/>
     <skill name="mining" modifier="-10"/>
@@ -651,56 +651,56 @@
     <skill name="stamina" modifier="-10"/>
     <attack type="4" damage="1d2"/>
   </race>
-  <race name="mountainguard" unarmedguard="yes" magres="50" maxaura="1.0" regaura="0.500000" weight="10000" capacity="2000" speed="0.000000" hp="1000" ac="12" damage="2d40" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="8" cannotmove="yes" canlearn="no" teach="no" noweapons="yes">
+  <race name="mountainguard" unarmedguard="yes" magres="50" maxaura="1" regaura="0.500000" weight="10000" capacity="2000" speed="0.000000" hp="1000" ac="12" damage="2d40" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="8" cannotmove="yes" canlearn="no" teach="no" noweapons="yes">
     <ai splitsize="1"/>
     <attack type="4" damage="2d40"/>
   </race>
-  <race name="shadowmaster" cansail="no" cansteal="no" canlearn="no" magres="75" maxaura="1.0" regaura="2.000000" weight="500" capacity="540" speed="1.0" hp="150" ac="4" damage="2d5" unarmedattack="0" unarmeddefense="0" attackmodifier="11" defensemodifier="13" scarepeasants="yes" walk="yes" teach="no" desert="yes">
+  <race name="shadowmaster" cansail="no" cansteal="no" canlearn="no" magres="75" maxaura="1" regaura="2.000000" weight="500" capacity="540" speed="1.0" hp="150" ac="4" damage="2d5" unarmedattack="0" unarmeddefense="0" attackmodifier="11" defensemodifier="13" scarepeasants="yes" walk="yes" teach="no" desert="yes">
     <ai splitsize="50" killpeasants="yes" moverandom="yes" learn="yes"/>
     <attack type="4" damage="2d4"/>
     <attack type="2" damage="2d30"/>
     <attack type="3" damage="1d2"/>
   </race>
-  <race name="shadowdemon" cansail="no" cansteal="no" canlearn="no" magres="75" maxaura="1.0" regaura="1.0" weight="500" capacity="540" speed="1.0" hp="50" ac="3" damage="2d4" unarmedattack="0" unarmeddefense="0" attackmodifier="8" defensemodifier="11" scarepeasants="yes" walk="yes" teach="no" desert="yes" recruitethereal="yes">
+  <race name="shadowdemon" cansail="no" cansteal="no" canlearn="no" magres="75" maxaura="1" regaura="1" weight="500" capacity="540" speed="1.0" hp="50" ac="3" damage="2d4" unarmedattack="0" unarmeddefense="0" attackmodifier="8" defensemodifier="11" scarepeasants="yes" walk="yes" teach="no" desert="yes" recruitethereal="yes">
     <ai splitsize="1000" killpeasants="yes" moverandom="yes" learn="yes"/>
     <attack type="4" damage="2d3"/>
     <attack type="3" damage="1d1"/>
   </race>
-  <race name="stonegolem" stonegolem="true" magres="25" maxaura="1.0" regaura="0.100000" weight="10000" capacity="2000" speed="1.0" hp="60" ac="4" damage="2d12+6" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="2" walk="yes" canlearn="no" teach="no">
+  <race name="stonegolem" stonegolem="true" magres="25" maxaura="1" regaura="0.100000" weight="10000" capacity="2000" speed="1.0" hp="60" ac="4" damage="2d12+6" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="2" walk="yes" canlearn="no" teach="no">
     <ai splitsize="50"/>
     <skill name="building" modifier="14"/>
     <skill name="roadwork" modifier="14"/>
     <attack type="4" damage="2d10+4"/>
   </race>
-  <race name="irongolem" irongolem="true" magres="25" maxaura="1.0" regaura="0.100000" weight="10000" capacity="2000" speed="1.0" hp="50" ac="2" damage="2d10+4" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="2" walk="yes" canlearn="no" teach="no">
+  <race name="irongolem" irongolem="true" magres="25" maxaura="1" regaura="0.100000" weight="10000" capacity="2000" speed="1.0" hp="50" ac="2" damage="2d10+4" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="2" walk="yes" canlearn="no" teach="no">
     <ai splitsize="50"/>
     <skill name="armorer" modifier="14"/>
     <skill name="weaponsmithing" modifier="14"/>
     <attack type="4" damage="2d8+4"/>
   </race>
-  <race name="spell" maxaura="1.0" regaura="0.100000" weight="0" capacity="0" speed="0.000000" hp="1" damage="1d4" unarmedattack="-2" unarmeddefense="-2" canlearn="no" noheal="yes" noweapons="yes" illusionary="yes" invisible="yes" fly="yes" swim="yes" walk="yes">
+  <race name="spell" maxaura="1" regaura="0.100000" weight="0" capacity="0" speed="0.000000" hp="1" damage="1d4" unarmedattack="-2" unarmeddefense="-2" canlearn="no" noheal="yes" noweapons="yes" illusionary="yes" invisible="yes" fly="yes" swim="yes" walk="yes">
     <ai splitsize="1"/>
     <attack type="1" damage="1d4"/>
   </race>
-  <race name="special" maxaura="0.000000" regaura="0.000000" weight="0" capacity="0" speed="0.000000" hp="1" damage="1d4" unarmedattack="-2" unarmeddefense="-2">
+  <race name="special" maxaura="0" regaura="0" weight="0" capacity="0" speed="0.000000" hp="1" damage="1d4" unarmedattack="-2" unarmeddefense="-2">
     <ai splitsize="1"/>
     <attack type="1" damage="1d4"/>
   </race>
 
-  <race name="dracoid" maxaura="1.0" regaura="1.0" weight="1000" capacity="540" speed="1.0" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" walk="yes" teach="no" giveperson="yes" getitem="yes" equipment="yes">
+  <race name="dracoid" maxaura="1" regaura="1" weight="1000" capacity="540" speed="1.0" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" walk="yes" teach="no" giveperson="yes" getitem="yes" equipment="yes">
     <ai splitsize="10000" moverandom="yes" learn="yes"/>
     <attack type="4" damage="1d6"/>
     <attack type="4" damage="1d6"/>
     <attack type="1" damage="1d5"/>
   </race>
 
-  <race name="ent" magres="25" maxaura="1.0" regaura="0.500000" weight="5000" capacity="2500" speed="1.0" hp="50" ac="4" damage="2d4+12" unarmedattack="0" unarmeddefense="0" attackmodifier="9" defensemodifier="7" scarepeasants="yes" walk="yes" teach="no">
+  <race name="ent" magres="25" maxaura="1" regaura="0.500000" weight="5000" capacity="2500" speed="1.0" hp="50" ac="4" damage="2d4+12" unarmedattack="0" unarmeddefense="0" attackmodifier="9" defensemodifier="7" scarepeasants="yes" walk="yes" teach="no">
     <ai splitsize="1000" moverandom="yes" learn="yes"/>
     <attack type="4" damage="2d12"/>
     <attack type="4" damage="2d12"/>
   </race>
 
-  <race name="undead" maxaura="1.0" regaura="1.0" weight="1000"
+  <race name="undead" maxaura="1" regaura="1" weight="1000"
   capacity="540" speed="1.0" hp="20" damage="1d7" unarmedattack="0"
   unarmeddefense="0" attackmodifier="1" defensemodifier="1"
   scarepeasants="yes" walk="yes" canlearn="no" teach="no" noheal="yes"
@@ -710,7 +710,7 @@
     <attack type="5"/>
   </race>
 
-  <race name="clone" magres="90" maxaura="0.000000" regaura="0.000000" weight="1000" capacity="540" speed="1.0" hp="40" damage="0d0" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" canlearn="no" teach="no" noheal="yes">
+  <race name="clone" magres="90" maxaura="0" regaura="0" weight="1000" capacity="540" speed="1.0" hp="40" damage="0d0" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" canlearn="no" teach="no" noheal="yes">
     <ai splitsize="10000"/>
     <skill name="crossbow" modifier="-99"/>
     <skill name="mining" modifier="-99"/>
@@ -736,7 +736,7 @@
     <attack type="1" damage="0d0"/>
   </race>
 
-  <race name="ghast" magres="60" maxaura="1.0" regaura="1.0" weight="1000" capacity="540" speed="1.0" hp="60" ac="2" damage="1d7" unarmedattack="6" unarmeddefense="6" attackmodifier="6" defensemodifier="6" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes" giveperson="yes">
+  <race name="ghast" magres="60" maxaura="1" regaura="1" weight="1000" capacity="540" speed="1.0" hp="60" ac="2" damage="1d7" unarmedattack="6" unarmeddefense="6" attackmodifier="6" defensemodifier="6" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes" giveperson="yes">
     <ai splitsize="2000" killpeasants="yes" moverandom="yes"/>
     <skill name="crossbow" modifier="1"/>
     <skill name="bow" modifier="1"/>
@@ -754,7 +754,7 @@
     <attack type="2" damage="1d30"/>
   </race>
 
-  <race name="ghoul" magres="30" maxaura="1.0" regaura="1.0" weight="1000" capacity="540" speed="1.0" hp="30" ac="1" damage="1d7" unarmedattack="3" unarmeddefense="3" attackmodifier="3" defensemodifier="3" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes" giveperson="yes">
+  <race name="ghoul" magres="30" maxaura="1" regaura="1" weight="1000" capacity="540" speed="1.0" hp="30" ac="1" damage="1d7" unarmedattack="3" unarmeddefense="3" attackmodifier="3" defensemodifier="3" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes" giveperson="yes">
     <ai splitsize="10000" killpeasants="yes" moverandom="yes"/>
     <skill name="crossbow" modifier="1"/>
     <skill name="bow" modifier="1"/>
@@ -771,7 +771,7 @@
     <attack type="2" damage="1d30"/>
   </race>
 
-  <race name="juju" magres="50" maxaura="1.0" regaura="1.0" weight="1000" capacity="540" speed="1.0" hp="80" ac="2" damage="1d7" unarmedattack="6" unarmeddefense="6" attackmodifier="8" defensemodifier="8" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes" resistbash="yes" resistcut="yes" resistpierce="yes" giveperson="yes">
+  <race name="juju" magres="50" maxaura="1" regaura="1" weight="1000" capacity="540" speed="1.0" hp="80" ac="2" damage="1d7" unarmedattack="6" unarmeddefense="6" attackmodifier="8" defensemodifier="8" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes" resistbash="yes" resistcut="yes" resistpierce="yes" giveperson="yes">
     <ai splitsize="2000" killpeasants="yes" moverandom="yes"/>
     <skill name="crossbow" modifier="1"/>
     <skill name="bow" modifier="1"/>
@@ -787,7 +787,7 @@
     <attack type="3" damage="1d1"/>
   </race>
 
-  <race name="zombie" magres="20" maxaura="1.0" regaura="1.0" weight="1000" capacity="540" speed="1.0" hp="40" ac="1" damage="1d7" unarmedattack="2" unarmeddefense="2" attackmodifier="5" defensemodifier="5" scarepeasants="yes" walk="yes" canlearn="no" teach="no" noheal="yes" undead="yes" equipment="yes" resistcut="yes" resistpierce="yes" giveperson="yes">
+  <race name="zombie" magres="20" maxaura="1" regaura="1" weight="1000" capacity="540" speed="1.0" hp="40" ac="1" damage="1d7" unarmedattack="2" unarmeddefense="2" attackmodifier="5" defensemodifier="5" scarepeasants="yes" walk="yes" canlearn="no" teach="no" noheal="yes" undead="yes" equipment="yes" resistcut="yes" resistpierce="yes" giveperson="yes">
     <ai splitsize="10000" killpeasants="yes" moverandom="yes"/>
     <skill name="crossbow" modifier="1"/>
     <skill name="bow" modifier="1"/>
@@ -801,7 +801,7 @@
     <attack type="1" damage="1d7"/>
   </race>
 
-  <race name="skeletonlord" magres="30" maxaura="1.0" regaura="1.0" weight="1000" capacity="540" speed="1.0" hp="60" ac="4" damage="1d7" unarmedattack="6" unarmeddefense="6" attackmodifier="8" defensemodifier="8" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes" resistcut="yes" resistpierce="yes" giveperson="yes">
+  <race name="skeletonlord" magres="30" maxaura="1" regaura="1" weight="1000" capacity="540" speed="1.0" hp="60" ac="4" damage="1d7" unarmedattack="6" unarmeddefense="6" attackmodifier="8" defensemodifier="8" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes" resistcut="yes" resistpierce="yes" giveperson="yes">
     <ai splitsize="2000" killpeasants="yes" moverandom="yes"/>
     <skill name="crossbow" modifier="1"/>
     <skill name="bow" modifier="1"/>
@@ -816,7 +816,7 @@
     <attack type="1" damage="1d7"/>
   </race>
 
-  <race name="skeleton" magres="10" maxaura="1.0" regaura="1.0" weight="500" capacity="540" speed="1.0" hp="20" ac="1" damage="1d7" unarmedattack="1" unarmeddefense="1" attackmodifier="6" defensemodifier="6" scarepeasants="yes" walk="yes" canlearn="no" teach="no" noheal="yes" undead="yes" equipment="yes" resistcut="yes" resistpierce="yes" giveperson="yes">
+  <race name="skeleton" magres="10" maxaura="1" regaura="1" weight="500" capacity="540" speed="1.0" hp="20" ac="1" damage="1d7" unarmedattack="1" unarmeddefense="1" attackmodifier="6" defensemodifier="6" scarepeasants="yes" walk="yes" canlearn="no" teach="no" noheal="yes" undead="yes" equipment="yes" resistcut="yes" resistpierce="yes" giveperson="yes">
     <ai splitsize="10000" killpeasants="yes" moverandom="yes"/>
     <skill name="crossbow" modifier="1"/>
     <skill name="bow" modifier="1"/>
@@ -830,12 +830,12 @@
     <attack type="1" damage="1d7"/>
   </race>
 
-  <race name="shadowknight" maxaura="0.000000" regaura="0.000000" weight="0" capacity="540" speed="1.0" hp="1" damage="1d1" unarmedattack="0" unarmeddefense="0" attackmodifier="1" defensemodifier="1" scarepeasants="yes" walk="yes" canlearn="no" teach="no" noblock="yes">
+  <race name="shadowknight" maxaura="0" regaura="0" weight="0" capacity="540" speed="1.0" hp="1" damage="1d1" unarmedattack="0" unarmeddefense="0" attackmodifier="1" defensemodifier="1" scarepeasants="yes" walk="yes" canlearn="no" teach="no" noblock="yes">
     <ai splitsize="20000" moverandom="yes"/>
     <attack type="1" damage="1d1"/>
   </race>
 
-  <race name="seaserpent" magres="50" maxaura="1.0" regaura="1.0" weight="20000" capacity="5000" speed="1.0" hp="600" ac="3" damage="2d15" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="4" scarepeasants="yes" swim="yes" teach="no" getitem="yes" resistbash="yes">
+  <race name="seaserpent" magres="50" maxaura="1" regaura="1" weight="20000" capacity="5000" speed="1.0" hp="600" ac="3" damage="2d15" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="4" scarepeasants="yes" swim="yes" teach="no" getitem="yes" resistbash="yes">
     <ai splitsize="6" killpeasants="yes" moverandom="yes" learn="yes" moveattack="yes"/>
     <skill name="tactics" modifier="4"/>
     <attack type="4" damage="1d30"/>
diff --git a/res/eressea/races.xml b/res/eressea/races.xml
index 21ff5b028..b1f105f98 100644
--- a/res/eressea/races.xml
+++ b/res/eressea/races.xml
@@ -2,16 +2,16 @@
 <eressea>
 <races>
 
-  <race name="snowman" magres="80" maxaura="0.000000"
-        regaura="0.000000" weight="500" capacity="200" equipment="no"
-        speed="1.000000" hp="1000" ac="4" damage="2d4" unarmedattack="10"
+  <race name="snowman" magres="80" maxaura="0"
+        regaura="0" weight="500" capacity="200" equipment="no"
+        speed="1" hp="1000" ac="4" damage="2d4" unarmedattack="10"
         unarmeddefense="10" attackmodifier="8" defensemodifier="8"
         fly="no" walk="no" canteach="no" getitem="yes">
     <attack type="4" damage="2d6+2"/>
     <attack type="3" damage="2d6+2"/>
   </race>
 
-  <race name="human" maxaura="1.000000" regaura="1.000000" recruitcost="75" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
+  <race name="human" maxaura="1" regaura="1" recruitcost="75" maintenance="10" weight="1000" capacity="540" speed="1" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
     <ai splitsize="10000" moverandom="yes" learn="yes"/>
     <param name="migrants.formula" value="1"/>
     <skill name="trade" modifier="1"/>
@@ -27,7 +27,7 @@
     <familiar race="eagle"/>
     <familiar race="imp"/>
   </race>
-  <race name="kraken" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="2.000000" hp="300" damage="2d10" unarmedattack="0" unarmeddefense="0" attackmodifier="7" defensemodifier="7" coastal="yes" swim="yes" teach="no" getitem="yes">
+  <race name="kraken" maxaura="0" regaura="0" weight="500" capacity="540" speed="2" hp="300" damage="2d10" unarmedattack="0" unarmeddefense="0" attackmodifier="7" defensemodifier="7" coastal="yes" swim="yes" teach="no" getitem="yes">
     <ai splitsize="5000"/>
     <skill name="perception" modifier="1"/>
     <skill name="alchemy" modifier="-99"/>
@@ -60,7 +60,7 @@
     <attack type="4" damage="1d10"/>
     <attack type="4" damage="1d10"/>
   </race>
-  <race name="giantturtle" maxaura="0.000000" regaura="0.000000" weight="1600" capacity="600" speed="1.000000" hp="900" ac="7" damage="2d50" unarmedattack="0" unarmeddefense="0" attackmodifier="10" defensemodifier="5" coastal="yes" swim="yes" walk="yes" teach="no" getitem="yes">
+  <race name="giantturtle" maxaura="0" regaura="0" weight="1600" capacity="600" speed="1" hp="900" ac="7" damage="2d50" unarmedattack="0" unarmeddefense="0" attackmodifier="10" defensemodifier="5" coastal="yes" swim="yes" walk="yes" teach="no" getitem="yes">
     <ai splitsize="5000"/>
     <skill name="perception" modifier="1"/>
     <skill name="alchemy" modifier="-99"/>
@@ -88,7 +88,7 @@
     <skill name="taxation" modifier="-99"/>
     <attack type="4" damage="2d50"/>
   </race>
-  <race name="dolphin" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="2.000000" hp="24" damage="1d6" unarmedattack="0" unarmeddefense="0" attackmodifier="5" defensemodifier="5" coastal="yes" swim="yes" teach="no" getitem="yes">
+  <race name="dolphin" maxaura="0" regaura="0" weight="500" capacity="540" speed="2" hp="24" damage="1d6" unarmedattack="0" unarmeddefense="0" attackmodifier="5" defensemodifier="5" coastal="yes" swim="yes" teach="no" getitem="yes">
     <ai splitsize="5000"/>
     <skill name="alchemy" modifier="-99"/>
     <skill name="crossbow" modifier="-99"/>
@@ -115,7 +115,7 @@
     <skill name="taxation" modifier="-99"/>
     <attack type="4" damage="1d6"/>
   </race>
-  <race name="tiger" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="1.000000" hp="30" damage="2d6" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="3" walk="yes" teach="no" getitem="yes">
+  <race name="tiger" maxaura="0" regaura="0" weight="500" capacity="540" speed="1" hp="30" damage="2d6" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="3" walk="yes" teach="no" getitem="yes">
     <ai splitsize="5000"/>
     <skill name="alchemy" modifier="-99"/>
     <skill name="crossbow" modifier="-99"/>
@@ -144,7 +144,7 @@
     <attack type="4" damage="1d6"/>
     <attack type="4" damage="1d6"/>
   </race>
-  <race name="hellcat" magres="50" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="1.000000" hp="40" damage="2d6" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="4" walk="yes" teach="no" getitem="yes" resistpierce="yes">
+  <race name="hellcat" magres="50" maxaura="0" regaura="0" weight="500" capacity="540" speed="1" hp="40" damage="2d6" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="4" walk="yes" teach="no" getitem="yes" resistpierce="yes">
     <ai splitsize="5000"/>
     <skill name="perception" modifier="1"/>
     <skill name="alchemy" modifier="-99"/>
@@ -173,7 +173,7 @@
     <attack type="4" damage="1d6"/>
     <attack type="4" damage="1d6"/>
   </race>
-  <race name="owl" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="1.000000" hp="9" damage="1d4" unarmedattack="0" unarmeddefense="0" attackmodifier="2" defensemodifier="4" fly="yes" walk="yes" teach="no" getitem="yes">
+  <race name="owl" maxaura="0" regaura="0" weight="500" capacity="540" speed="1" hp="9" damage="1d4" unarmedattack="0" unarmeddefense="0" attackmodifier="2" defensemodifier="4" fly="yes" walk="yes" teach="no" getitem="yes">
     <ai splitsize="5000"/>
     <skill name="espionage" modifier="1"/>
     <skill name="stealth" modifier="1"/>
@@ -203,7 +203,7 @@
     <skill name="taxation" modifier="-99"/>
     <attack type="4" damage="1d4"/>
   </race>
-  <race name="fairy" magres="80" maxaura="1.000000" regaura="1.500000" weight="200" capacity="540" speed="1.000000" hp="6" damage="1d3" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="14" fly="yes" walk="yes" teach="no" getitem="yes" equipment="yes">
+  <race name="fairy" magres="80" maxaura="1" regaura="1.5" weight="200" capacity="540" speed="1" hp="6" damage="1d3" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="14" fly="yes" walk="yes" teach="no" getitem="yes" equipment="yes">
     <ai splitsize="5000"/>
     <skill name="stealth" modifier="5"/>
     <skill name="espionage" modifier="2"/>
@@ -237,7 +237,7 @@
     <attack type="4" damage="1d3"/>
     <attack type="4" damage="1d3"/>
   </race>
-  <race name="dreamcat" magres="50" maxaura="1.000000" regaura="1.000000" weight="500" capacity="540" speed="1.000000" hp="10" damage="1d5" unarmedattack="0" unarmeddefense="0" attackmodifier="5" defensemodifier="6" fly="yes" walk="yes" teach="no" getitem="yes" invinciblenonmagic="yes">
+  <race name="dreamcat" magres="50" maxaura="1" regaura="1" weight="500" capacity="540" speed="1" hp="10" damage="1d5" unarmedattack="0" unarmeddefense="0" attackmodifier="5" defensemodifier="6" fly="yes" walk="yes" teach="no" getitem="yes" invinciblenonmagic="yes">
     <ai splitsize="5000"/>
     <skill name="magic" modifier="1"/>
     <skill name="espionage" modifier="1"/>
@@ -267,7 +267,7 @@
     <attack type="4" damage="1d5"/>
     <attack type="4" damage="1d5"/>
   </race>
-  <race name="imp" magres="50" maxaura="1.000000" regaura="1.000000" weight="500" capacity="540" speed="1.000000" hp="10" ac="1" damage="1d4" unarmedattack="0" unarmeddefense="0" attackmodifier="5" defensemodifier="4" fly="yes" walk="yes" teach="no" getitem="yes" equipment="yes">
+  <race name="imp" magres="50" maxaura="1" regaura="1" weight="500" capacity="540" speed="1" hp="10" ac="1" damage="1d4" unarmedattack="0" unarmeddefense="0" attackmodifier="5" defensemodifier="4" fly="yes" walk="yes" teach="no" getitem="yes" equipment="yes">
     <ai splitsize="5000"/>
     <skill name="alchemy" modifier="-99"/>
     <skill name="crossbow" modifier="-99"/>
@@ -299,7 +299,7 @@
     <attack type="1" damage="1d4"/>
     <attack type="6" spell="fiery_dragonbreath" level="3" />
   </race>
-  <race name="ghost" magres="80" maxaura="0.500000" regaura="0.100000" weight="500" capacity="540" speed="1.000000" hp="30" ac="5" damage="2d6" unarmedattack="0" unarmeddefense="0" attackmodifier="5" defensemodifier="8" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" equipment="yes" invinciblenonmagic="yes">
+  <race name="ghost" magres="80" maxaura="0.5" regaura="0.1" weight="500" capacity="540" speed="1" hp="30" ac="5" damage="2d6" unarmedattack="0" unarmeddefense="0" attackmodifier="5" defensemodifier="8" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" equipment="yes" invinciblenonmagic="yes">
     <ai splitsize="5000"/>
     <skill name="alchemy" modifier="-99"/>
     <skill name="crossbow" modifier="-99"/>
@@ -329,7 +329,7 @@
     <attack type="2" damage="2d30"/>
     <attack type="3" damage="1d1"/>
   </race>
-  <race name="wolf" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="1.000000" hp="25" damage="2d6" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="3" scarepeasants="yes" walk="yes" teach="no" getitem="yes">
+  <race name="wolf" maxaura="0" regaura="0" weight="500" capacity="540" speed="1" hp="25" damage="2d6" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="3" scarepeasants="yes" walk="yes" teach="no" getitem="yes">
     <ai splitsize="5000"/>
     <skill name="alchemy" modifier="-99"/>
     <skill name="crossbow" modifier="-99"/>
@@ -358,7 +358,7 @@
     <attack type="4" damage="1d4"/>
     <attack type="4" damage="1d4"/>
   </race>
-  <race name="unicorn" magres="90" maxaura="1.500000" regaura="1.500000" weight="5000" capacity="2000" speed="2.000000" hp="40" damage="2d4" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="4" walk="yes" teach="no" getitem="yes">
+  <race name="unicorn" magres="90" maxaura="1.5" regaura="1.5" weight="5000" capacity="2000" speed="2" hp="40" damage="2d4" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="4" walk="yes" teach="no" getitem="yes">
     <ai splitsize="9999"/>
     <skill name="alchemy" modifier="-99"/>
     <skill name="crossbow" modifier="-99"/>
@@ -388,7 +388,7 @@
     <attack type="4" damage="3d12"/>
     <attack type="4" damage="2d4"/>
   </race>
-  <race name="nymph" magres="90" maxaura="1.000000" regaura="1.500000" weight="1000" capacity="540" speed="1.000000" hp="15" damage="1d4" unarmedattack="0" unarmeddefense="0" attackmodifier="3" defensemodifier="1" walk="yes" teach="no" getitem="yes" equipment="yes">
+  <race name="nymph" magres="90" maxaura="1" regaura="1.5" weight="1000" capacity="540" speed="1" hp="15" damage="1d4" unarmedattack="0" unarmeddefense="0" attackmodifier="3" defensemodifier="1" walk="yes" teach="no" getitem="yes" equipment="yes">
     <ai splitsize="9999"/>
     <skill name="mining" modifier="-99"/>
     <skill name="bow" modifier="2"/>
@@ -417,7 +417,7 @@
     <attack type="1" damage="1d4"/>
     <attack type="2" damage="2d20"/>
   </race>
-  <race name="songdragon" magres="99" maxaura="1.000000" regaura="1.000000" weight="1000" capacity="600" speed="1.500000" hp="40" ac="1" damage="2d4" unarmedattack="0" unarmeddefense="0" attackmodifier="3" defensemodifier="1" fly="yes" walk="yes" teach="no" getitem="yes" unarmedguard="yes">
+  <race name="songdragon" magres="99" maxaura="1" regaura="1" weight="1000" capacity="600" speed="1.5" hp="40" ac="1" damage="2d4" unarmedattack="0" unarmeddefense="0" attackmodifier="3" defensemodifier="1" fly="yes" walk="yes" teach="no" getitem="yes" unarmedguard="yes">
     <ai splitsize="9999"/>
     <skill name="alchemy" modifier="-99"/>
     <skill name="crossbow" modifier="-99"/>
@@ -448,7 +448,7 @@
     <attack type="4" damage="2d4"/>
     <attack type="6" spell="fiery_dragonbreath" level="3" />
   </race>
-  <race name="rat" maxaura="0.000000" regaura="0.000000" weight="100" capacity="540" speed="1.000000" hp="10" damage="1d4" unarmedattack="0" unarmeddefense="0" attackmodifier="1" defensemodifier="1" walk="yes" teach="no" getitem="yes">
+  <race name="rat" maxaura="0" regaura="0" weight="100" capacity="540" speed="1" hp="10" damage="1d4" unarmedattack="0" unarmeddefense="0" attackmodifier="1" defensemodifier="1" walk="yes" teach="no" getitem="yes">
     <ai splitsize="9999"/>
     <skill name="espionage" modifier="5"/>
     <skill name="stealth" modifier="4"/>
@@ -479,7 +479,7 @@
     <attack type="4" damage="1d4"/>
     <attack type="4" damage="1d4"/>
   </race>
-  <race name="eagle" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="1.500000" hp="15" damage="2d3" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="2" fly="yes" walk="yes" teach="no" getitem="yes">
+  <race name="eagle" maxaura="0" regaura="0" weight="500" capacity="540" speed="1.5" hp="15" damage="2d3" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="2" fly="yes" walk="yes" teach="no" getitem="yes">
     <ai splitsize="9999"/>
     <skill name="alchemy" modifier="-99"/>
     <skill name="crossbow" modifier="-99"/>
@@ -508,7 +508,7 @@
     <skill name="taxation" modifier="-99"/>
     <attack type="4" damage="2d3"/>
   </race>
-  <race name="tunnelworm" magres="80" maxaura="0.000000" regaura="0.000000" weight="30000" capacity="10000" speed="1.000000" hp="300" ac="6" damage="3d20" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="1" scarepeasants="yes" walk="yes" teach="no" getitem="yes">
+  <race name="tunnelworm" magres="80" maxaura="0" regaura="0" weight="30000" capacity="10000" speed="1" hp="300" ac="6" damage="3d20" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="1" scarepeasants="yes" walk="yes" teach="no" getitem="yes">
     <ai splitsize="99999"/>
     <skill name="alchemy" modifier="-99"/>
     <skill name="crossbow" modifier="-99"/>
@@ -540,7 +540,7 @@
     <attack type="4" damage="3d20"/>
     <attack type="8" damage="1d10"/>
   </race>
-  <race name="lynx" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="1.000000" hp="20" damage="2d3" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="5" walk="yes" teach="no" getitem="yes">
+  <race name="lynx" maxaura="0" regaura="0" weight="500" capacity="540" speed="1" hp="20" damage="2d3" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="5" walk="yes" teach="no" getitem="yes">
     <ai splitsize="99999"/>
     <skill name="alchemy" modifier="-99"/>
     <skill name="crossbow" modifier="-99"/>
@@ -570,22 +570,22 @@
     <skill name="taxation" modifier="-99"/>
     <attack type="4" damage="2d3"/>
   </race>
-  <race name="direwolf" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="1.000000" hp="20" damage="2d4" unarmedattack="0" unarmeddefense="0" attackmodifier="3" defensemodifier="1" walk="yes" teach="no" giveperson="yes">
+  <race name="direwolf" maxaura="0" regaura="0" weight="500" capacity="540" speed="1" hp="20" damage="2d4" unarmedattack="0" unarmeddefense="0" attackmodifier="3" defensemodifier="1" walk="yes" teach="no" giveperson="yes">
     <ai splitsize="5000"/>
     <attack type="4" damage="2d4"/>
   </race>
-  <race name="peasant" maxaura="1.000000" regaura="1.000000" weight="1000" capacity="540" speed="1.000000" hp="20" damage="1d6" unarmedattack="0" unarmeddefense="0" cannotmove="yes" teach="no">
+  <race name="peasant" maxaura="1" regaura="1" weight="1000" capacity="540" speed="1" hp="20" damage="1d6" unarmedattack="0" unarmeddefense="0" cannotmove="yes" teach="no">
     <ai splitsize="10000"/>
     <attack type="1" damage="1d6"/>
   </race>
-  <race name="braineater" magres="90" maxaura="1.000000"
-  regaura="1.000000" weight="100" capacity="540" speed="1.000000" hp="20" damage="0d0" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="10" scarepeasants="yes" fly="yes" walk="yes" teach="no" invinciblenonmagic="yes">
+  <race name="braineater" magres="90" maxaura="1"
+  regaura="1" weight="100" capacity="540" speed="1" hp="20" damage="0d0" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="10" scarepeasants="yes" fly="yes" walk="yes" teach="no" invinciblenonmagic="yes">
     <ai splitsize="500" killpeasants="yes" moverandom="yes" learn="yes"/>
     <attack type="2" damage="3d15"/>
     <attack type="3" damage="1d1"/>
     <attack type="4" damage="1d1"/>
   </race>
-  <race name="toad" magres="20" maxaura="1.000000" regaura="1.000000" maintenance="10" weight="100" capacity="540" speed="1.000000" hp="10" damage="1d2" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" giveperson="yes" giveunit="yes" getitem="yes" walk="yes">
+  <race name="toad" magres="20" maxaura="1" regaura="1" maintenance="10" weight="100" capacity="540" speed="1" hp="10" damage="1d2" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" giveperson="yes" giveunit="yes" getitem="yes" walk="yes">
     <ai splitsize="1" learn="yes"/>
     <skill name="alchemy" modifier="-10"/>
     <skill name="crossbow" modifier="-10"/>
@@ -617,7 +617,7 @@
     <skill name="stamina" modifier="-10"/>
     <attack type="4" damage="1d2"/>
   </race>
-  <race name="smurf" weight="1000" capacity="540" speed="1.000000" hp="10" damage="1d2" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" giveperson="yes" giveunit="yes" getitem="yes" walk="yes">
+  <race name="smurf" weight="1000" capacity="540" speed="1" hp="10" damage="1d2" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" giveperson="yes" giveunit="yes" getitem="yes" walk="yes">
     <ai splitsize="1" learn="yes"/>
     <skill name="alchemy" modifier="-10"/>
     <skill name="crossbow" modifier="-10"/>
@@ -649,60 +649,60 @@
     <skill name="stamina" modifier="-10"/>
     <attack type="4" damage="1d2"/>
   </race>
-  <race name="mountainguard" unarmedguard="yes" magres="50" maxaura="1.000000" regaura="0.500000" weight="10000" capacity="2000" speed="0.000000" hp="1000" ac="12" damage="2d40" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="8" cannotmove="yes" canlearn="no" teach="no" noweapons="yes">
+  <race name="mountainguard" unarmedguard="yes" magres="50" maxaura="1" regaura="0.5" weight="10000" capacity="2000" speed="0" hp="1000" ac="12" damage="2d40" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="8" cannotmove="yes" canlearn="no" teach="no" noweapons="yes">
     <ai splitsize="1"/>
     <attack type="4" damage="2d40"/>
   </race>
-  <race name="shadowmaster" cansail="no" cansteal="no" canlearn="no" magres="75" maxaura="1.000000" regaura="2.000000" weight="500" capacity="540" speed="1.000000" hp="150" ac="4" damage="2d5" unarmedattack="0" unarmeddefense="0" attackmodifier="11" defensemodifier="13" scarepeasants="yes" walk="yes" teach="no" desert="yes">
+  <race name="shadowmaster" cansail="no" cansteal="no" canlearn="no" magres="75" maxaura="1" regaura="2" weight="500" capacity="540" speed="1" hp="150" ac="4" damage="2d5" unarmedattack="0" unarmeddefense="0" attackmodifier="11" defensemodifier="13" scarepeasants="yes" walk="yes" teach="no" desert="yes">
     <ai splitsize="50" killpeasants="yes" moverandom="yes" learn="yes"/>
     <attack type="4" damage="2d4"/>
     <attack type="2" damage="2d30"/>
     <attack type="3" damage="1d2"/>
   </race>
-  <race name="shadowdemon" cansail="no" cansteal="no" canlearn="no" magres="75" maxaura="1.000000" regaura="1.000000" weight="500" capacity="540" speed="1.000000" hp="50" ac="3" damage="2d4" unarmedattack="0" unarmeddefense="0" attackmodifier="8" defensemodifier="11" scarepeasants="yes" walk="yes" teach="no" desert="yes" recruitethereal="yes">
+  <race name="shadowdemon" cansail="no" cansteal="no" canlearn="no" magres="75" maxaura="1" regaura="1" weight="500" capacity="540" speed="1" hp="50" ac="3" damage="2d4" unarmedattack="0" unarmeddefense="0" attackmodifier="8" defensemodifier="11" scarepeasants="yes" walk="yes" teach="no" desert="yes" recruitethereal="yes">
     <ai splitsize="1000" killpeasants="yes" moverandom="yes" learn="yes"/>
     <attack type="4" damage="2d3"/>
     <attack type="3" damage="1d1"/>
   </race>
-  <race name="stonegolem" stonegolem="true" magres="25" maxaura="1.000000" regaura="0.100000" weight="10000" capacity="2000" speed="1.000000" hp="60" ac="4" damage="2d12+6" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="2" walk="yes" canlearn="no" teach="no">
+  <race name="stonegolem" stonegolem="true" magres="25" maxaura="1" regaura="0.100000" weight="10000" capacity="2000" speed="1" hp="60" ac="4" damage="2d12+6" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="2" walk="yes" canlearn="no" teach="no">
     <ai splitsize="50"/>
     <skill name="building" modifier="14"/>
     <skill name="roadwork" modifier="14"/>
     <attack type="4" damage="2d10+4"/>
   </race>
-  <race name="irongolem" irongolem="true" magres="25" maxaura="1.000000" regaura="0.100000" weight="10000" capacity="2000" speed="1.000000" hp="50" ac="2" damage="2d10+4" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="2" walk="yes" canlearn="no" teach="no">
+  <race name="irongolem" irongolem="true" magres="25" maxaura="1" regaura="0.100000" weight="10000" capacity="2000" speed="1" hp="50" ac="2" damage="2d10+4" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="2" walk="yes" canlearn="no" teach="no">
     <ai splitsize="50"/>
     <skill name="armorer" modifier="14"/>
     <skill name="weaponsmithing" modifier="14"/>
     <attack type="4" damage="2d8+4"/>
   </race>
-  <race name="spell" maxaura="1.000000" regaura="0.100000" weight="0" capacity="0" speed="0.000000" hp="1" damage="1d4" unarmedattack="-2" unarmeddefense="-2" canlearn="no" noheal="yes" noweapons="yes" illusionary="yes" invisible="yes" fly="yes" swim="yes" walk="yes">
+  <race name="spell" maxaura="1" regaura="0.100000" weight="0" capacity="0" speed="0" hp="1" damage="1d4" unarmedattack="-2" unarmeddefense="-2" canlearn="no" noheal="yes" noweapons="yes" illusionary="yes" invisible="yes" fly="yes" swim="yes" walk="yes">
     <ai splitsize="1"/>
     <attack type="1" damage="1d4"/>
   </race>
-  <race name="special" maxaura="0.000000" regaura="0.000000" weight="0" capacity="0" speed="0.000000" hp="1" damage="1d4" unarmedattack="-2" unarmeddefense="-2">
+  <race name="special" maxaura="0" regaura="0" weight="0" capacity="0" speed="0" hp="1" damage="1d4" unarmedattack="-2" unarmeddefense="-2">
     <ai splitsize="1"/>
     <attack type="1" damage="1d4"/>
   </race>
-  <race name="dracoid" maxaura="1.000000" regaura="1.000000" weight="1000" capacity="540" speed="1.000000" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" walk="yes" teach="no" giveperson="yes" getitem="yes" equipment="yes">
+  <race name="dracoid" maxaura="1" regaura="1" weight="1000" capacity="540" speed="1" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" walk="yes" teach="no" giveperson="yes" getitem="yes" equipment="yes">
     <ai splitsize="10000" moverandom="yes" learn="yes"/>
     <attack type="4" damage="1d6"/>
     <attack type="4" damage="1d6"/>
     <attack type="1" damage="1d5"/>
   </race>
-  <race name="catdragon" magres="90" maxaura="1.000000" regaura="1.000000" weight="20000" capacity="10000" speed="1.000000" hp="20" damage="2d40" unarmedattack="0" unarmeddefense="0" defensemodifier="50" fly="yes" walk="yes" teach="no" shapeshift="yes" giveperson="yes" getitem="yes" dragon="yes">
+  <race name="catdragon" magres="90" maxaura="1" regaura="1" weight="20000" capacity="10000" speed="1" hp="20" damage="2d40" unarmedattack="0" unarmeddefense="0" defensemodifier="50" fly="yes" walk="yes" teach="no" shapeshift="yes" giveperson="yes" getitem="yes" dragon="yes">
     <ai splitsize="1"/>
     <attack type="4" damage="2d40"/>
     <attack type="4" damage="2d40"/>
     <attack type="4" damage="2d40"/>
     <attack type="4" damage="2d40"/>
   </race>
-  <race name="ent" magres="25" maxaura="1.000000" regaura="0.500000" weight="5000" capacity="2500" speed="1.000000" hp="50" ac="4" damage="2d4+12" unarmedattack="0" unarmeddefense="0" attackmodifier="9" defensemodifier="7" scarepeasants="yes" walk="yes" teach="no">
+  <race name="ent" magres="25" maxaura="1" regaura="0.5" weight="5000" capacity="2500" speed="1" hp="50" ac="4" damage="2d4+12" unarmedattack="0" unarmeddefense="0" attackmodifier="9" defensemodifier="7" scarepeasants="yes" walk="yes" teach="no">
     <ai splitsize="1000" moverandom="yes" learn="yes"/>
     <attack type="4" damage="2d12"/>
     <attack type="4" damage="2d12"/>
   </race>
-  <race name="wyrm" magres="90" maxaura="1.000000" regaura="3.000000" weight="18000" capacity="1000000" speed="1.000000" hp="2700" ac="8" damage="2d60" unarmedattack="0" unarmeddefense="0" attackmodifier="10" defensemodifier="10" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes" dragon="yes" unarmedguard="yes">
+  <race name="wyrm" magres="90" maxaura="1" regaura="3" weight="18000" capacity="1000000" speed="1" hp="2700" ac="8" damage="2d60" unarmedattack="0" unarmeddefense="0" attackmodifier="10" defensemodifier="10" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes" dragon="yes" unarmedguard="yes">
     <ai splitsize="1" killpeasants="yes" learn="yes"/>
     <skill name="magic" modifier="12"/>
     <skill name="tactics" modifier="12"/>
@@ -712,7 +712,7 @@
     <attack type="4" damage="5d30"/>
     <attack type="6" spell="powerful_dragonbreath" level="12" />
   </race>
-  <race name="dragon" magres="70" maxaura="1.000000" regaura="2.000000" weight="10000" capacity="1000000" speed="1.500000" hp="900" ac="6" damage="2d30" unarmedattack="0" unarmeddefense="0" attackmodifier="7" defensemodifier="7" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes" unarmedguard="yes" dragon="yes">
+  <race name="dragon" magres="70" maxaura="1" regaura="2" weight="10000" capacity="1000000" speed="1.5" hp="900" ac="6" damage="2d30" unarmedattack="0" unarmeddefense="0" attackmodifier="7" defensemodifier="7" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes" unarmedguard="yes" dragon="yes">
     <ai splitsize="2" killpeasants="yes" learn="yes"/>
     <skill name="magic" modifier="8"/>
     <skill name="tactics" modifier="8"/>
@@ -722,7 +722,7 @@
     <attack type="4" damage="3d30"/>
     <attack type="6" spell="icy_dragonbreath" level="6" />
   </race>
-  <race name="youngdragon" magres="50" maxaura="1.000000" regaura="1.000000" weight="20000" capacity="10000" speed="1.000000" hp="300" ac="4" damage="2d15" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="4" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes" unarmedguard="yes">
+  <race name="youngdragon" magres="50" maxaura="1" regaura="1" weight="20000" capacity="10000" speed="1" hp="300" ac="4" damage="2d15" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="4" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes" unarmedguard="yes">
     <ai splitsize="6" killpeasants="yes" learn="yes"/>
     <skill name="magic" modifier="4"/>
     <skill name="tactics" modifier="4"/>
@@ -733,12 +733,12 @@
     <attack type="4" damage="1d30"/>
     <attack type="6" spell="fiery_dragonbreath" level="3" />
   </race>
-  <race name="undead" maxaura="1.000000" regaura="1.000000" weight="1000" capacity="540" speed="1.000000" hp="20" damage="1d7" unarmedattack="0" unarmeddefense="0" attackmodifier="1" defensemodifier="1" scarepeasants="yes" walk="yes" canlearn="no" teach="no" noheal="yes" undead="yes" equipment="yes" giveperson="yes">
+  <race name="undead" maxaura="1" regaura="1" weight="1000" capacity="540" speed="1" hp="20" damage="1d7" unarmedattack="0" unarmeddefense="0" attackmodifier="1" defensemodifier="1" scarepeasants="yes" walk="yes" canlearn="no" teach="no" noheal="yes" undead="yes" equipment="yes" giveperson="yes">
     <ai splitsize="20000" moverandom="yes"/>
     <attack type="4" damage="1d7"/>
     <attack type="5"/>
   </race>
-  <race name="aquarian" maxaura="1.000000" regaura="1.000000" recruitcost="80" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" shipspeed="yes" playerrace="yes" coastal="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
+  <race name="aquarian" maxaura="1" regaura="1" recruitcost="80" maintenance="10" weight="1000" capacity="540" speed="1" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" shipspeed="yes" playerrace="yes" coastal="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
     <ai splitsize="10000" moverandom="yes" learn="yes"/>
     <skill name="mining" modifier="-2"/>
     <skill name="building" modifier="-1"/>
@@ -756,7 +756,7 @@
     <familiar race="dolphin"/>
     <familiar race="kraken"/>
   </race>
-  <race name="cat" maxaura="1.000000" regaura="1.000000" recruitcost="90" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" defensemodifier="1" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
+  <race name="cat" maxaura="1" regaura="1" recruitcost="90" maintenance="10" weight="1000" capacity="540" speed="1" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" defensemodifier="1" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
     <ai splitsize="10000" moverandom="yes" learn="yes"/>
     <skill name="alchemy" modifier="-1"/>
     <skill name="mining" modifier="-2"/>
@@ -781,7 +781,7 @@
     <familiar race="tiger"/>
     <familiar race="hellcat"/>
   </race>
-  <race name="halfling" magres="5" maxaura="1.000000" regaura="1.000000" recruitcost="80" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="18" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
+  <race name="halfling" magres="5" maxaura="1" regaura="1" recruitcost="80" maintenance="10" weight="1000" capacity="540" speed="1" hp="18" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
     <ai splitsize="10000" moverandom="yes" learn="yes"/>
     <param name="hunger.damage" value="1d14+14"/>
     <skill name="crossbow" modifier="1"/>
@@ -813,7 +813,7 @@
     <familiar race="eagle"/>
     <familiar race="rat"/>
   </race>
-  <race name="insect" magres="50" maxaura="1.000000" regaura="1.000000" recruitcost="80" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="24" ac="2" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
+  <race name="insect" magres="50" maxaura="1" regaura="1" recruitcost="80" maintenance="10" weight="1000" capacity="540" speed="1" hp="24" ac="2" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
     <ai splitsize="10000" moverandom="yes" learn="yes"/>
     <skill name="crossbow" modifier="1"/>
     <skill name="mining" modifier="1"/>
@@ -841,7 +841,7 @@
     <familiar race="tunnelworm"/>
     <familiar race="imp"/>
   </race>
-  <race name="demon" magres="15" maxaura="1.000000" regaura="1.250000" recruitcost="150" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="50" ac="2" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" shapeshift="yes" giveperson="yes" giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes">
+  <race name="demon" magres="15" maxaura="1" regaura="1.25" recruitcost="150" maintenance="10" weight="1000" capacity="540" speed="1" hp="50" ac="2" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" shapeshift="yes" giveperson="yes" giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes">
     <ai splitsize="10000" moverandom="yes" learn="yes"/>
     <skill name="alchemy" modifier="2"/>
     <skill name="trade" modifier="-3"/>
@@ -871,7 +871,7 @@
     <familiar race="wolf"/>
     <familiar race="imp"/>
   </race>
-  <race name="troll" magres="10" maxaura="1.000000" regaura="1.000000" recruitcost="90" maintenance="10" weight="2000" capacity="1080" speed="1.000000" hp="30" ac="1" damage="1d5+3" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
+  <race name="troll" magres="10" maxaura="1" regaura="1" recruitcost="90" maintenance="10" weight="2000" capacity="1080" speed="1" hp="30" ac="1" damage="1d5+3" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
     <ai splitsize="10000" moverandom="yes" learn="yes"/>
     <skill name="mining" modifier="2"/>
     <skill name="bow" modifier="-2"/>
@@ -901,7 +901,7 @@
     <familiar race="tunnelworm"/>
     <familiar race="wolf"/>
   </race>
-  <race name="goblin" magres="-0.050000" maxaura="1.000000" regaura="1.000000" recruitcost="40" maintenance="10" weight="600" capacity="440" speed="1.000000" hp="16" damage="1d5" unarmedattack="-2" unarmeddefense="0" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
+  <race name="goblin" magres="-0.050000" maxaura="1" regaura="1" recruitcost="40" maintenance="10" weight="600" capacity="440" speed="1" hp="16" damage="1d5" unarmedattack="-2" unarmeddefense="0" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
     <ai splitsize="10000" moverandom="yes" learn="yes"/>
     <skill name="alchemy" modifier="1"/>
     <skill name="mining" modifier="1"/>
@@ -925,7 +925,7 @@
     <familiar race="rat"/>
     <familiar race="imp"/>
   </race>
-  <race name="clone" magres="90" maxaura="0.000000" regaura="0.000000" weight="1000" capacity="540" speed="1.000000" hp="40" damage="0d0" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" canlearn="no" teach="no" noheal="yes">
+  <race name="clone" magres="90" maxaura="0" regaura="0" weight="1000" capacity="540" speed="1" hp="40" damage="0d0" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" canlearn="no" teach="no" noheal="yes">
     <ai splitsize="10000"/>
     <skill name="alchemy" modifier="-99"/>
     <skill name="crossbow" modifier="-99"/>
@@ -958,11 +958,11 @@
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="0d0"/>
   </race>
-  <race name="template" maintenance="0" magres="100" maxaura="0.000000" regaura="0.000000" weight="0" capacity="1000" speed="10.000000" hp="10" damage="1d4" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" fly="yes" swim="yes" walk="yes" shapeshift="yes" shapeshiftany="yes" giveperson="yes" giveunit="yes" getitem="yes" recruitethereal="yes" recruitunlimited="yes" equipment="yes">
+  <race name="template" maintenance="0" magres="100" maxaura="0" regaura="0" weight="0" capacity="1000" speed="10" hp="10" damage="1d4" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" fly="yes" swim="yes" walk="yes" shapeshift="yes" shapeshiftany="yes" giveperson="yes" giveunit="yes" getitem="yes" recruitethereal="yes" recruitunlimited="yes" equipment="yes">
     <ai splitsize="10000" moverandom="yes" learn="yes"/>
     <attack type="1" damage="1d4"/>
   </race>
-  <race name="gnome" magres="100" maxaura="0.000000" regaura="0.000000" weight="1000" capacity="540" speed="1.000000" hp="50" damage="1d4" unarmedattack="10" unarmeddefense="10" attackmodifier="10" defensemodifier="10" walk="yes" teach="no">
+  <race name="gnome" magres="100" maxaura="0" regaura="0" weight="1000" capacity="540" speed="1" hp="50" damage="1d4" unarmedattack="10" unarmeddefense="10" attackmodifier="10" defensemodifier="10" walk="yes" teach="no">
     <ai splitsize="10000"/>
     <skill name="tactics" modifier="1"/>
     <skill name="perception" modifier="1"/>
@@ -970,7 +970,7 @@
     <skill name="unarmed" modifier="1"/>
     <attack type="1" damage="1d4"/>
   </race>
-  <race name="museumghost" magres="100" maxaura="0.000000" regaura="0.000000" weight="1000" capacity="540" speed="1.000000" hp="50" damage="1d4" unarmedattack="10" unarmeddefense="10" attackmodifier="10" defensemodifier="10" walk="yes" teach="no">
+  <race name="museumghost" magres="100" maxaura="0" regaura="0" weight="1000" capacity="540" speed="1" hp="50" damage="1d4" unarmedattack="10" unarmeddefense="10" attackmodifier="10" defensemodifier="10" walk="yes" teach="no">
     <ai splitsize="10000"/>
     <skill name="tactics" modifier="1"/>
     <skill name="perception" modifier="1"/>
@@ -984,7 +984,7 @@
     <attack type="2" damage="5d600"/>
     <attack type="1" damage="1d4"/>
   </race>
-  <race name="ghast" magres="60" maxaura="1.000000" regaura="1.000000" weight="1000" capacity="540" speed="1.000000" hp="60" ac="2" damage="1d7" unarmedattack="6" unarmeddefense="6" attackmodifier="6" defensemodifier="6" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes" giveperson="yes">
+  <race name="ghast" magres="60" maxaura="1" regaura="1" weight="1000" capacity="540" speed="1" hp="60" ac="2" damage="1d7" unarmedattack="6" unarmeddefense="6" attackmodifier="6" defensemodifier="6" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes" giveperson="yes">
     <ai splitsize="2000" killpeasants="yes" moverandom="yes"/>
     <skill name="crossbow" modifier="1"/>
     <skill name="bow" modifier="1"/>
@@ -1001,7 +1001,7 @@
     <attack type="2" damage="1d30"/>
     <attack type="2" damage="1d30"/>
   </race>
-  <race name="ghoul" magres="30" maxaura="1.000000" regaura="1.000000" weight="1000" capacity="540" speed="1.000000" hp="30" ac="1" damage="1d7" unarmedattack="3" unarmeddefense="3" attackmodifier="3" defensemodifier="3" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes" giveperson="yes">
+  <race name="ghoul" magres="30" maxaura="1" regaura="1" weight="1000" capacity="540" speed="1" hp="30" ac="1" damage="1d7" unarmedattack="3" unarmeddefense="3" attackmodifier="3" defensemodifier="3" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes" giveperson="yes">
     <ai splitsize="10000" killpeasants="yes" moverandom="yes"/>
     <skill name="crossbow" modifier="1"/>
     <skill name="bow" modifier="1"/>
@@ -1017,7 +1017,7 @@
     <attack type="3" damage="1d2"/>
     <attack type="2" damage="1d30"/>
   </race>
-  <race name="juju" magres="50" maxaura="1.000000" regaura="1.000000" weight="1000" capacity="540" speed="1.000000" hp="80" ac="2" damage="1d7" unarmedattack="6" unarmeddefense="6" attackmodifier="8" defensemodifier="8" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes" resistbash="yes" resistcut="yes" resistpierce="yes" giveperson="yes">
+  <race name="juju" magres="50" maxaura="1" regaura="1" weight="1000" capacity="540" speed="1" hp="80" ac="2" damage="1d7" unarmedattack="6" unarmeddefense="6" attackmodifier="8" defensemodifier="8" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes" resistbash="yes" resistcut="yes" resistpierce="yes" giveperson="yes">
     <ai splitsize="2000" killpeasants="yes" moverandom="yes"/>
     <skill name="crossbow" modifier="1"/>
     <skill name="bow" modifier="1"/>
@@ -1032,7 +1032,7 @@
     <attack type="3" damage="1d1"/>
     <attack type="3" damage="1d1"/>
   </race>
-  <race name="zombie" magres="20" maxaura="1.000000" regaura="1.000000" weight="1000" capacity="540" speed="1.000000" hp="40" ac="1" damage="1d7" unarmedattack="2" unarmeddefense="2" attackmodifier="5" defensemodifier="5" scarepeasants="yes" walk="yes" canlearn="no" teach="no" noheal="yes" undead="yes" equipment="yes" resistcut="yes" resistpierce="yes" giveperson="yes">
+  <race name="zombie" magres="20" maxaura="1" regaura="1" weight="1000" capacity="540" speed="1" hp="40" ac="1" damage="1d7" unarmedattack="2" unarmeddefense="2" attackmodifier="5" defensemodifier="5" scarepeasants="yes" walk="yes" canlearn="no" teach="no" noheal="yes" undead="yes" equipment="yes" resistcut="yes" resistpierce="yes" giveperson="yes">
     <ai splitsize="10000" killpeasants="yes" moverandom="yes"/>
     <skill name="crossbow" modifier="1"/>
     <skill name="bow" modifier="1"/>
@@ -1045,7 +1045,7 @@
     <skill name="unarmed" modifier="1"/>
     <attack type="1" damage="1d7"/>
   </race>
-  <race name="skeletonlord" magres="30" maxaura="1.000000" regaura="1.000000" weight="1000" capacity="540" speed="1.000000" hp="60" ac="4" damage="1d7" unarmedattack="6" unarmeddefense="6" attackmodifier="8" defensemodifier="8" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes" resistcut="yes" resistpierce="yes" giveperson="yes">
+  <race name="skeletonlord" magres="30" maxaura="1" regaura="1" weight="1000" capacity="540" speed="1" hp="60" ac="4" damage="1d7" unarmedattack="6" unarmeddefense="6" attackmodifier="8" defensemodifier="8" scarepeasants="yes" walk="yes" canlearn="no" teach="no" absorbpeasants="yes" noheal="yes" undead="yes" equipment="yes" resistcut="yes" resistpierce="yes" giveperson="yes">
     <ai splitsize="2000" killpeasants="yes" moverandom="yes"/>
     <skill name="crossbow" modifier="1"/>
     <skill name="bow" modifier="1"/>
@@ -1059,7 +1059,7 @@
     <attack type="1" damage="1d7"/>
     <attack type="1" damage="1d7"/>
   </race>
-  <race name="skeleton" magres="10" maxaura="1.000000" regaura="1.000000" weight="500" capacity="540" speed="1.000000" hp="20" ac="1" damage="1d7" unarmedattack="1" unarmeddefense="1" attackmodifier="6" defensemodifier="6" scarepeasants="yes" walk="yes" canlearn="no" teach="no" noheal="yes" undead="yes" equipment="yes" resistcut="yes" resistpierce="yes" giveperson="yes">
+  <race name="skeleton" magres="10" maxaura="1" regaura="1" weight="500" capacity="540" speed="1" hp="20" ac="1" damage="1d7" unarmedattack="1" unarmeddefense="1" attackmodifier="6" defensemodifier="6" scarepeasants="yes" walk="yes" canlearn="no" teach="no" noheal="yes" undead="yes" equipment="yes" resistcut="yes" resistpierce="yes" giveperson="yes">
     <ai splitsize="10000" killpeasants="yes" moverandom="yes"/>
     <skill name="crossbow" modifier="1"/>
     <skill name="bow" modifier="1"/>
@@ -1072,11 +1072,11 @@
     <skill name="unarmed" modifier="1"/>
     <attack type="1" damage="1d7"/>
   </race>
-  <race name="shadowknight" maxaura="0.000000" regaura="0.000000" weight="0" capacity="540" speed="1.000000" hp="1" damage="1d1" unarmedattack="0" unarmeddefense="0" attackmodifier="1" defensemodifier="1" scarepeasants="yes" walk="yes" canlearn="no" teach="no" noblock="yes">
+  <race name="shadowknight" maxaura="0" regaura="0" weight="0" capacity="540" speed="1" hp="1" damage="1d1" unarmedattack="0" unarmeddefense="0" attackmodifier="1" defensemodifier="1" scarepeasants="yes" walk="yes" canlearn="no" teach="no" noblock="yes">
     <ai splitsize="20000" moverandom="yes"/>
     <attack type="1" damage="1d1"/>
   </race>
-  <race name="seaserpent" magres="50" maxaura="1.000000" regaura="1.000000" weight="20000" capacity="5000" speed="1.000000" hp="600" ac="3" damage="2d15" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="4" scarepeasants="yes" swim="yes" teach="no" getitem="yes" resistbash="yes" unarmedguard="yes">
+  <race name="seaserpent" magres="50" maxaura="1" regaura="1" weight="20000" capacity="5000" speed="1" hp="600" ac="3" damage="2d15" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="4" scarepeasants="yes" swim="yes" teach="no" getitem="yes" resistbash="yes" unarmedguard="yes">
     <ai splitsize="6" killpeasants="yes" moverandom="yes" learn="yes" moveattack="yes"/>
     <skill name="tactics" modifier="4"/>
     <attack type="4" damage="1d30"/>
@@ -1086,8 +1086,8 @@
     <attack type="8" damage="1d10"/>
   </race>
 
-  <race name="snotling" magres="-5" maxaura="1.000000" regaura="1.000000" 
-  maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="no" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
+  <race name="snotling" magres="-5" maxaura="1" regaura="1" 
+  maintenance="10" weight="1000" capacity="540" speed="1" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="no" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
     <ai splitsize="10000" moverandom="yes" learn="yes"/>
     <skill name="alchemy" modifier="1"/>
     <skill name="mining" modifier="1"/>
@@ -1116,7 +1116,7 @@
     <familiar race="wolf"/>
     <familiar race="demon"/>
   </race>
-  <race name="elf" magres="10" maxaura="1.000000" regaura="1.250000" recruitcost="130" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="18" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
+  <race name="elf" magres="10" maxaura="1" regaura="1.25" recruitcost="130" maintenance="10" weight="1000" capacity="540" speed="1" hp="18" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
     <ai splitsize="10000" moverandom="yes" learn="yes"/>
     <skill name="alchemy" modifier="-1"/>
     <skill name="mining" modifier="-2"/>
@@ -1142,7 +1142,7 @@
     <familiar race="unicorn"/>
     <familiar race="imp"/>
   </race>
-  <race name="dwarf" magres="5" maxaura="1.000000" regaura="0.500000" recruitcost="110" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
+  <race name="dwarf" magres="5" maxaura="1" regaura="0.5" recruitcost="110" maintenance="10" weight="1000" capacity="540" speed="1" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
     <ai splitsize="10000" moverandom="yes" learn="yes"/>
     <skill name="mining" modifier="2"/>
     <skill name="bow" modifier="-1"/>
@@ -1173,7 +1173,7 @@
     <familiar race="wolf"/>
     <familiar race="rat"/>
   </race>
-  <race name="orc" studyspeed="-5" magres="-5" maxaura="1.000000" regaura="1.000000" recruitcost="70" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
+  <race name="orc" studyspeed="-5" magres="-5" maxaura="1" regaura="1" recruitcost="70" maintenance="10" weight="1000" capacity="540" speed="1" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
     <ai splitsize="10000" moverandom="yes" learn="yes"/>
     <param name="recruit_multi" value="0.5"/>
     <skill name="alchemy" modifier="1"/>
@@ -1203,7 +1203,7 @@
     <familiar race="wolf"/>
     <familiar race="demon"/>
   </race>
-  <race name="shadowdragon" magres="95" maxaura="1.000000" regaura="3.000000" weight="100" capacity="100000" speed="1.000000" hp="2700" ac="10" damage="2d60" unarmedattack="0" unarmeddefense="0" attackmodifier="10" defensemodifier="12" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes">
+  <race name="shadowdragon" magres="95" maxaura="1" regaura="3" weight="100" capacity="100000" speed="1" hp="2700" ac="10" damage="2d60" unarmedattack="0" unarmeddefense="0" attackmodifier="10" defensemodifier="12" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" resistbash="yes">
     <ai splitsize="1" killpeasants="yes" learn="yes"/>
     <skill name="tactics" modifier="20"/>
     <skill name="perception" modifier="20"/>
diff --git a/src/kernel/race.c b/src/kernel/race.c
index ac81f7f78..8a89f73df 100644
--- a/src/kernel/race.c
+++ b/src/kernel/race.c
@@ -363,6 +363,8 @@ race *rc_create(const char *zName)
     rc->regaura = 1.0F;
     rc->speed = 1.0F;
     rc->battle_flags = 0;
+    rc->at_default = -2;
+    rc->df_default = -2;
     if (strchr(zName, ' ') != NULL) {
         log_error("race '%s' has an invalid name. remove spaces\n", zName);
         assert(strchr(zName, ' ') == NULL);
diff --git a/src/kernel/race.test.c b/src/kernel/race.test.c
index dcbe26e0e..0e2aa24f6 100644
--- a/src/kernel/race.test.c
+++ b/src/kernel/race.test.c
@@ -59,6 +59,8 @@ static void test_rc_defaults(CuTest *tc) {
     CuAssertIntEquals(tc, 0, rc->armor);
     CuAssertIntEquals(tc, 0, rc->at_bonus);
     CuAssertIntEquals(tc, 0, rc->df_bonus);
+    CuAssertIntEquals(tc, -2, rc->df_default);
+    CuAssertIntEquals(tc, -2, rc->at_default);
     CuAssertIntEquals(tc, 0, rc->battle_flags);
     CuAssertIntEquals(tc, PERSON_WEIGHT, rc->weight);
     test_teardown();
diff --git a/src/xmlreader.c b/src/xmlreader.c
index 35b4b328e..7f51a7853 100644
--- a/src/xmlreader.c
+++ b/src/xmlreader.c
@@ -1324,8 +1324,8 @@ static int parse_races(xmlDocPtr doc)
                 }
             }
 
-            rc->at_default = (char)xml_ivalue(node, "unarmedattack", -2);
-            rc->df_default = (char)xml_ivalue(node, "unarmeddefense", -2);
+            rc->at_default = (char)xml_ivalue(node, "unarmedattack", rc->at_default);
+            rc->df_default = (char)xml_ivalue(node, "unarmeddefense", rc->df_default);
             rc->at_bonus = (char)xml_ivalue(node, "attackmodifier", rc->at_bonus);
             rc->df_bonus = (char)xml_ivalue(node, "defensemodifier", rc->df_bonus);
 

From 2a213d93020eecb91bc4dc4b36da83adb46b954e Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Thu, 10 May 2018 18:03:47 +0200
Subject: [PATCH 15/24] try to analyze intermittent bug on travis

---
 scripts/tests/e3/buildings.lua | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/scripts/tests/e3/buildings.lua b/scripts/tests/e3/buildings.lua
index 709e7df74..e642c1aa7 100644
--- a/scripts/tests/e3/buildings.lua
+++ b/scripts/tests/e3/buildings.lua
@@ -41,6 +41,11 @@ function test_build_watch()
     u:add_order("MACHE Wache")
     process_orders()
     assert_not_nil(u.building)
+    if 5 ~= u.building.size then
+        for k,v in f.messages do
+            print(v)
+        end
+    end
     assert_equal(5, u.building.size)
 
     u:set_skill("building", 2)

From b0012eeae07498801e69fbdc371e2bca5cd50f03 Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Thu, 10 May 2018 20:02:53 +0200
Subject: [PATCH 16/24] familiars do not need the default value in XML (bad
 XML).

---
 res/e3a/races.xml      | 14 +++++++-------
 res/eressea/races.xml  | 24 ++++++++++++------------
 res/races/aquarian.xml |  2 +-
 res/races/cat.xml      |  2 +-
 res/races/demon.xml    |  2 +-
 res/races/dwarf.xml    |  2 +-
 res/races/elf.xml      |  2 +-
 res/races/goblin-3.xml |  2 +-
 res/races/goblin.xml   |  2 +-
 res/races/halfling.xml |  2 +-
 res/races/human.xml    |  2 +-
 res/races/insect.xml   |  2 +-
 res/races/orc.xml      |  2 +-
 res/races/troll.xml    |  2 +-
 src/xmlreader.c        |  8 +-------
 15 files changed, 32 insertions(+), 38 deletions(-)

diff --git a/res/e3a/races.xml b/res/e3a/races.xml
index 7bb80edc0..2386a5ea9 100644
--- a/res/e3a/races.xml
+++ b/res/e3a/races.xml
@@ -40,7 +40,7 @@
     <skill name="magic" modifier="-99"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="dolphin" default="yes"/>
+    <familiar race="dolphin"/>
     <familiar race="giantturtle"/>
   </race>
 
@@ -67,7 +67,7 @@
     <skill name="unarmed" modifier="-99"/>
     <skill name="weaponsmithing" modifier="2"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="wolf" default="yes"/>
+    <familiar race="wolf"/>
     <familiar race="ghost"/>
   </race>
 
@@ -95,7 +95,7 @@
     <skill name="magic" modifier="-99"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="eagle" default="yes"/>
+    <familiar race="eagle"/>
     <familiar race="imp"/>
   </race>
   
@@ -116,7 +116,7 @@
     <skill name="weaponsmithing" modifier="1"/>
     <attack type="1" damage="1d5"/>
     <attack type="5"/>
-    <familiar race="imp" default="yes"/>
+    <familiar race="imp"/>
     <familiar race="ghost"/>
   </race>
 
@@ -138,7 +138,7 @@
     <skill name="training" modifier="2"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="nymph" default="yes"/>
+    <familiar race="nymph"/>
     <familiar race="unicorn"/>
   </race>
 
@@ -160,7 +160,7 @@
     <skill name="training" modifier="-1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5+3"/>
-    <familiar race="tunnelworm" default="yes"/>
+    <familiar race="tunnelworm"/>
     <familiar race="rat"/>
   </race>
 
@@ -186,7 +186,7 @@
     <skill name="weaponsmithing" modifier="2"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="lynx" default="yes"/>
+    <familiar race="lynx"/>
     <familiar race="songdragon"/>
   </race>
 
diff --git a/res/eressea/races.xml b/res/eressea/races.xml
index b1f105f98..67d84c763 100644
--- a/res/eressea/races.xml
+++ b/res/eressea/races.xml
@@ -20,7 +20,7 @@
     <skill name="sailing" modifier="1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="wolf" default="yes"/>
+    <familiar race="wolf"/>
     <familiar race="dreamcat"/>
     <familiar race="owl"/>
     <familiar race="owl"/>
@@ -749,7 +749,7 @@
     <skill name="roadwork" modifier="-1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="giantturtle" default="yes"/>
+    <familiar race="giantturtle"/>
     <familiar race="dolphin"/>
     <familiar race="giantturtle"/>
     <familiar race="dolphin"/>
@@ -774,7 +774,7 @@
     <skill name="taxation" modifier="1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="lynx" default="yes"/>
+    <familiar race="lynx"/>
     <familiar race="dreamcat"/>
     <familiar race="lynx"/>
     <familiar race="songdragon"/>
@@ -806,7 +806,7 @@
     <skill name="taxation" modifier="-1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="owl" default="yes"/>
+    <familiar race="owl"/>
     <familiar race="rat"/>
     <familiar race="eagle"/>
     <familiar race="songdragon"/>
@@ -834,7 +834,7 @@
     <skill name="perception" modifier="1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="ghost" default="yes"/>
+    <familiar race="ghost"/>
     <familiar race="rat"/>
     <familiar race="owl"/>
     <familiar race="rat"/>
@@ -864,7 +864,7 @@
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
     <attack type="5"/>
-    <familiar race="imp" default="yes"/>
+    <familiar race="imp"/>
     <familiar race="imp"/>
     <familiar race="ghost"/>
     <familiar race="rat"/>
@@ -894,7 +894,7 @@
     <skill name="taxation" modifier="1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5+3"/>
-    <familiar race="tunnelworm" default="yes"/>
+    <familiar race="tunnelworm"/>
     <familiar race="rat"/>
     <familiar race="rat"/>
     <familiar race="eagle"/>
@@ -918,7 +918,7 @@
     <skill name="cartmaking" modifier="-1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="rat" default="yes"/>
+    <familiar race="rat"/>
     <familiar race="songdragon"/>
     <familiar race="imp"/>
     <familiar race="rat"/>
@@ -1109,7 +1109,7 @@
     <skill name="taxation" modifier="1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="goblin" default="yes"/>
+    <familiar race="goblin"/>
     <familiar race="ghost"/>
     <familiar race="imp"/>
     <familiar race="rat"/>
@@ -1135,7 +1135,7 @@
     <skill name="perception" modifier="1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="lynx" default="yes"/>
+    <familiar race="lynx"/>
     <familiar race="fairy"/>
     <familiar race="owl"/>
     <familiar race="nymph"/>
@@ -1166,7 +1166,7 @@
     <skill name="taxation" modifier="1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="tunnelworm" default="yes"/>
+    <familiar race="tunnelworm"/>
     <familiar race="eagle"/>
     <familiar race="owl"/>
     <familiar race="lynx"/>
@@ -1196,7 +1196,7 @@
     <skill name="taxation" modifier="1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="goblin" default="yes"/>
+    <familiar race="goblin"/>
     <familiar race="ghost"/>
     <familiar race="imp"/>
     <familiar race="rat"/>
diff --git a/res/races/aquarian.xml b/res/races/aquarian.xml
index 19fd3aee7..4950d60d1 100644
--- a/res/races/aquarian.xml
+++ b/res/races/aquarian.xml
@@ -10,7 +10,7 @@
     <skill name="roadwork" modifier="-1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="giantturtle" default="yes"/>
+    <familiar race="giantturtle"/>
     <familiar race="dolphin"/>
     <familiar race="giantturtle"/>
     <familiar race="dolphin"/>
diff --git a/res/races/cat.xml b/res/races/cat.xml
index 5986c223c..2e0f73dcf 100644
--- a/res/races/cat.xml
+++ b/res/races/cat.xml
@@ -17,7 +17,7 @@
     <skill name="taxation" modifier="1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="lynx" default="yes"/>
+    <familiar race="lynx"/>
     <familiar race="dreamcat"/>
     <familiar race="lynx"/>
     <familiar race="songdragon"/>
diff --git a/res/races/demon.xml b/res/races/demon.xml
index 69d98145f..21a1f289d 100644
--- a/res/races/demon.xml
+++ b/res/races/demon.xml
@@ -27,7 +27,7 @@ recruitethereal="yes" equipment="yes" healing="1.5">
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
     <attack type="5"/>
-    <familiar race="imp" default="yes"/>
+    <familiar race="imp"/>
     <familiar race="imp"/>
     <familiar race="ghost"/>
     <familiar race="rat"/>
diff --git a/res/races/dwarf.xml b/res/races/dwarf.xml
index 043b76aa7..4f2719649 100644
--- a/res/races/dwarf.xml
+++ b/res/races/dwarf.xml
@@ -23,7 +23,7 @@
     <skill name="taxation" modifier="1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="tunnelworm" default="yes"/>
+    <familiar race="tunnelworm"/>
     <familiar race="eagle"/>
     <familiar race="owl"/>
     <familiar race="lynx"/>
diff --git a/res/races/elf.xml b/res/races/elf.xml
index 683ee823b..968ad22f2 100644
--- a/res/races/elf.xml
+++ b/res/races/elf.xml
@@ -18,7 +18,7 @@
     <skill name="perception" modifier="1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="lynx" default="yes"/>
+    <familiar race="lynx"/>
     <familiar race="fairy"/>
     <familiar race="owl"/>
     <familiar race="nymph"/>
diff --git a/res/races/goblin-3.xml b/res/races/goblin-3.xml
index 636f8cc29..ad83ee7f0 100644
--- a/res/races/goblin-3.xml
+++ b/res/races/goblin-3.xml
@@ -21,7 +21,7 @@ getitem="yes" equipment="yes" healing="2.0">
   <skill name="unarmed" modifier="-99"/>
   <skill name="weaponsmithing" modifier="-1"/>
   <attack type="1" damage="1d5"/>
-  <familiar race="rat" default="yes"/>
+  <familiar race="rat"/>
   <familiar race="imp"/>
 </race>
 </races>
diff --git a/res/races/goblin.xml b/res/races/goblin.xml
index 84d2c5079..ec224a0c7 100644
--- a/res/races/goblin.xml
+++ b/res/races/goblin.xml
@@ -21,7 +21,7 @@ healing="2.0">
     <skill name="cartmaking" modifier="-1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="rat" default="yes"/>
+    <familiar race="rat"/>
     <familiar race="songdragon"/>
     <familiar race="imp"/>
     <familiar race="rat"/>
diff --git a/res/races/halfling.xml b/res/races/halfling.xml
index 3628d2b35..5c17e4a4f 100644
--- a/res/races/halfling.xml
+++ b/res/races/halfling.xml
@@ -24,7 +24,7 @@
     <skill name="taxation" modifier="-1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="owl" default="yes"/>
+    <familiar race="owl"/>
     <familiar race="rat"/>
     <familiar race="eagle"/>
     <familiar race="songdragon"/>
diff --git a/res/races/human.xml b/res/races/human.xml
index f91ba7daf..00c11f8a6 100644
--- a/res/races/human.xml
+++ b/res/races/human.xml
@@ -7,7 +7,7 @@
     <skill name="sailing" modifier="1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="wolf" default="yes"/>
+    <familiar race="wolf"/>
     <familiar race="dreamcat"/>
     <familiar race="owl"/>
     <familiar race="owl"/>
diff --git a/res/races/insect.xml b/res/races/insect.xml
index 75e16f7af..b783f047a 100644
--- a/res/races/insect.xml
+++ b/res/races/insect.xml
@@ -20,7 +20,7 @@
     <skill name="perception" modifier="1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="ghost" default="yes"/>
+    <familiar race="ghost"/>
     <familiar race="rat"/>
     <familiar race="owl"/>
     <familiar race="rat"/>
diff --git a/res/races/orc.xml b/res/races/orc.xml
index a0033759a..47754152a 100644
--- a/res/races/orc.xml
+++ b/res/races/orc.xml
@@ -22,7 +22,7 @@
     <skill name="taxation" modifier="1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5"/>
-    <familiar race="goblin" default="yes"/>
+    <familiar race="goblin"/>
     <familiar race="ghost"/>
     <familiar race="imp"/>
     <familiar race="rat"/>
diff --git a/res/races/troll.xml b/res/races/troll.xml
index 9168a6d0e..7d3f18551 100644
--- a/res/races/troll.xml
+++ b/res/races/troll.xml
@@ -27,7 +27,7 @@ healing="1.5">
     <skill name="taxation" modifier="1"/>
     <skill name="unarmed" modifier="-99"/>
     <attack type="1" damage="1d5+3"/>
-    <familiar race="tunnelworm" default="yes"/>
+    <familiar race="tunnelworm"/>
     <familiar race="rat"/>
     <familiar race="rat"/>
     <familiar race="eagle"/>
diff --git a/src/xmlreader.c b/src/xmlreader.c
index 7f51a7853..0f7b40b93 100644
--- a/src/xmlreader.c
+++ b/src/xmlreader.c
@@ -1464,13 +1464,7 @@ static int parse_races(xmlDocPtr doc)
                         assert(propValue != NULL);
                         frc = rc_get_or_create((const char *)propValue);
                         frc->flags |= RCF_FAMILIAR;
-                        if (xml_bvalue(node, "default", false)) {
-                            rc->familiars[k] = rc->familiars[0];
-                            rc->familiars[0] = frc;
-                        }
-                        else {
-                            rc->familiars[k] = frc;
-                        }
+                        rc->familiars[k] = frc;
                         xmlFree(propValue);
                     }
                     else {

From 94769a66f88c0ed7bef3e474b7f20cfe005af66d Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Thu, 10 May 2018 20:18:40 +0200
Subject: [PATCH 17/24] teach vs canteach mixup

---
 res/eressea/races.xml | 2 +-
 src/xmlreader.c       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/res/eressea/races.xml b/res/eressea/races.xml
index 67d84c763..e6dd7f58d 100644
--- a/res/eressea/races.xml
+++ b/res/eressea/races.xml
@@ -6,7 +6,7 @@
         regaura="0" weight="500" capacity="200" equipment="no"
         speed="1" hp="1000" ac="4" damage="2d4" unarmedattack="10"
         unarmeddefense="10" attackmodifier="8" defensemodifier="8"
-        fly="no" walk="no" canteach="no" getitem="yes">
+        fly="no" walk="no" teach="no" getitem="yes">
     <attack type="4" damage="2d6+2"/>
     <attack type="3" damage="2d6+2"/>
   </race>
diff --git a/src/xmlreader.c b/src/xmlreader.c
index 0f7b40b93..fe6f18e1f 100644
--- a/src/xmlreader.c
+++ b/src/xmlreader.c
@@ -1355,7 +1355,7 @@ static int parse_races(xmlDocPtr doc)
                 rc->flags |= RCF_WALK;
             if (!xml_bvalue(node, "canlearn", true))
                 rc->flags |= RCF_NOLEARN;
-            if (!xml_bvalue(node, "canteach", true))
+            if (!xml_bvalue(node, "teach", true))
                 rc->flags |= RCF_NOTEACH;
             if (xml_bvalue(node, "horse", false))
                 rc->flags |= RCF_HORSE;

From ac73052dc15549a096337f5302254c10fca66b56 Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Fri, 11 May 2018 06:05:28 +0200
Subject: [PATCH 18/24] autoseed code is never used in lua scripts (they have
 their own autoseed implementation).

---
 src/bindings.c | 21 ---------------------
 1 file changed, 21 deletions(-)

diff --git a/src/bindings.c b/src/bindings.c
index 3fda9b844..e08b0850f 100755
--- a/src/bindings.c
+++ b/src/bindings.c
@@ -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);
@@ -1068,7 +1048,6 @@ 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);

From 7b1038b0b1c11a4d8b68b5f2b5add2f9651d1fb1 Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Fri, 11 May 2018 06:06:31 +0200
Subject: [PATCH 19/24] this equipment callback is never used in our lua
 scripts, and we want to use equipment less.

---
 src/bindings.c | 18 ------------------
 1 file changed, 18 deletions(-)

diff --git a/src/bindings.c b/src/bindings.c
index e08b0850f..a8581f2d1 100755
--- a/src/bindings.c
+++ b/src/bindings.c
@@ -403,23 +403,6 @@ static int tolua_equipunit(lua_State * L)
     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);
@@ -1036,7 +1019,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);

From 7e6688552ba5f1b1ce8dc61914d3737bd1c34384 Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Fri, 11 May 2018 21:30:26 +0200
Subject: [PATCH 20/24] create a callback mechanism for equipment.

---
 src/bindings.c              |   2 +-
 src/economy.c               |   2 +-
 src/kernel/callbacks.h      |   3 +
 src/kernel/equipment.c      | 131 +++++++++++++++++++-----------------
 src/kernel/equipment.h      |  15 +++--
 src/kernel/equipment.test.c |  28 +++++++-
 src/kernel/save.c           |   2 +-
 src/magic.c                 |   7 +-
 src/monsters.c              |   8 +--
 src/randenc.c               |   4 +-
 src/teleport.c              |   2 +-
 src/xmlreader.c             |   3 +-
 12 files changed, 122 insertions(+), 85 deletions(-)

diff --git a/src/bindings.c b/src/bindings.c
index a8581f2d1..4444a5515 100755
--- a/src/bindings.c
+++ b/src/bindings.c
@@ -399,7 +399,7 @@ static int tolua_equipunit(lua_State * L)
     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);
+    equip_unit_mask(u, eqname, mask);
     return 0;
 }
 
diff --git a/src/economy.c b/src/economy.c
index a41b4525e..5fbb0111c 100644
--- a/src/economy.c
+++ b/src/economy.c
@@ -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);
diff --git a/src/kernel/callbacks.h b/src/kernel/callbacks.h
index dcdf6ac90..1977cd284 100644
--- a/src/kernel/callbacks.h
+++ b/src/kernel/callbacks.h
@@ -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);
diff --git a/src/kernel/equipment.c b/src/kernel/equipment.c
index 99c0bba7b..7b1af07f9 100644
--- a/src/kernel/equipment.c
+++ b/src/kernel/equipment.c
@@ -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>
@@ -88,80 +89,90 @@ equipment_setitem(equipment * eq, const item_type * itype, const char *value)
 }
 
 void
-equipment_setcallback(struct equipment *eq,
-void(*callback) (const struct equipment *, struct unit *))
+equipment_setcallback(struct equipment *eq, equip_callback_fun callback)
 {
     eq->callback = callback;
 }
 
-void equip_unit(struct unit *u, const struct equipment *eq)
+bool equip_unit(struct unit *u, const char *eqname)
 {
-    equip_unit_mask(u, eq, EQUIP_ALL);
+    return equip_unit_mask(u, eqname, EQUIP_ALL);
 }
 
-void equip_unit_mask(struct unit *u, const struct equipment *eq, int mask)
+bool equip_unit_mask(struct unit *u, const char *eqname, int mask)
 {
+    const equipment * eq = get_equipment(eqname);
     if (eq) {
+        equip_unit_set(u, eq, mask);
+        return true;
+    }
+    if (callbacks.equip_unit) {
+        return callbacks.equip_unit(u, eqname, mask);
+    }
+    return false;
+}
 
-        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);
+void equip_unit_set(struct unit *u, const equipment *eq, int mask)
+{
+    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) {
-                    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;
+                    set_level(u, (skill_t)sk, i);
+                    if (sk == SK_STAMINA) {
+                        u->hp = unit_max_hp(u) * u->number;
                     }
                 }
             }
         }
+    }
 
-        if (mask & EQUIP_SPECIAL) {
-            if (eq->callback)
-                eq->callback(eq, u);
+    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 (eq->items && 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_set(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);
         }
     }
 }
diff --git a/src/kernel/equipment.h b/src/kernel/equipment.h
index 9fbffe67f..5ba1a4182 100644
--- a/src/kernel/equipment.h
+++ b/src/kernel/equipment.h
@@ -21,6 +21,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 #include "skill.h"
 
+#include <stdbool.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -44,12 +46,14 @@ extern "C" {
         subsetitem *sets;
     } subset;
 
+    typedef void(*equip_callback_fun) (const struct equipment *, struct unit *);
+
     typedef struct equipment {
         struct itemdata *items;
         char *skills[MAXSKILLS];
         struct selist *spells;
         struct subset *subsets;
-        void(*callback) (const struct equipment *, struct unit *);
+        equip_callback_fun callback;
     } equipment;
 
     void equipment_done(void);
@@ -64,18 +68,17 @@ extern "C" {
     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 equipment_setcallback(struct equipment *eq, equip_callback_fun callback);
 
-    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);
+    void equip_unit_set(struct unit *u, const struct equipment *eq, int mask);
+    bool equip_unit_mask(struct unit *u, const char *eqname, int mask);
+    bool equip_unit(struct unit *u, const char *eqname);
 
 #ifdef __cplusplus
 }
diff --git a/src/kernel/equipment.test.c b/src/kernel/equipment.test.c
index 1a1bbfdf1..c09945865 100644
--- a/src/kernel/equipment.test.c
+++ b/src/kernel/equipment.test.c
@@ -2,6 +2,7 @@
 
 #include "magic.h"
 
+#include <kernel/callbacks.h>
 #include <kernel/equipment.h>
 #include <kernel/item.h>
 #include <kernel/unit.h>
@@ -35,7 +36,7 @@ static void test_equipment(CuTest * tc)
     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);
+    equip_unit_set(u, eq, EQUIP_ALL);
     CuAssertIntEquals(tc, 1, i_get(u->items, it_horses));
     CuAssertIntEquals(tc, 5, get_level(u, SK_MAGIC));
 
@@ -69,10 +70,35 @@ static void test_get_equipment(CuTest * tc)
     test_teardown();
 }
 
+static bool equip_test(unit *u, const char *name, int mask) {
+    if (mask & EQUIP_ITEMS) {
+        i_change(&u->items, it_find("horse"), 1);
+        return true;
+    }
+    return false;
+}
+
+static void test_equipment_callback(CuTest *tc) {
+    unit *u;
+    item_type *itype;
+    test_setup();
+    itype = test_create_horse();
+    u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
+    CuAssertTrue(tc, !equip_unit_mask(u, "horse", EQUIP_ITEMS));
+    CuAssertPtrEquals(tc, NULL, u->items);
+    callbacks.equip_unit = equip_test;
+    CuAssertTrue(tc, equip_unit(u, "horse"));
+    CuAssertIntEquals(tc, 1, i_get(u->items, itype));
+    CuAssertTrue(tc, !equip_unit_mask(u, "horse", EQUIP_SPELLS));
+    CuAssertIntEquals(tc, 1, i_get(u->items, itype));
+    test_teardown();
+}
+
 CuSuite *get_equipment_suite(void)
 {
     CuSuite *suite = CuSuiteNew();
     SUITE_ADD_TEST(suite, test_equipment);
     SUITE_ADD_TEST(suite, test_get_equipment);
+    SUITE_ADD_TEST(suite, test_equipment_callback);
     return suite;
 }
diff --git a/src/kernel/save.c b/src/kernel/save.c
index 858cd7040..c1c8010d1 100644
--- a/src/kernel/save.c
+++ b/src/kernel/save.c
@@ -1349,7 +1349,7 @@ static void fix_familiars(void) {
                             log_error("%s seems to be a familiar with no spells.",
                                 unitname(u));
                             /* magical familiar, no spells */
-                            equip_unit_mask(u, eq, EQUIP_SPELLS);
+                            equip_unit_set(u, eq, EQUIP_SPELLS);
                         }
                     }
                 }
diff --git a/src/magic.c b/src/magic.c
index 1b41b87af..1f1ec9c26 100644
--- a/src/magic.c
+++ b/src/magic.c
@@ -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: */
diff --git a/src/monsters.c b/src/monsters.c
index 9d113c0e9..db70bebfc 100644
--- a/src/monsters.c
+++ b/src/monsters.c
@@ -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 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++) {
diff --git a/src/randenc.c b/src/randenc.c
index 9630d6e85..709702513 100644
--- a/src/randenc.c
+++ b/src/randenc.c
@@ -265,7 +265,7 @@ static void get_villagers(region * r, unit * u)
         u);
     leave(newunit, true);
     fset(newunit, UFL_ISNEW | UFL_MOVED);
-    equip_unit(newunit, get_equipment("rand_villagers"));
+    equip_unit(newunit, "rand_villagers");
 }
 
 static void get_allies(region * r, unit * u)
@@ -352,7 +352,7 @@ static void get_allies(region * r, unit * u)
     newunit =
         create_unit(r, u->faction, number, u->faction->race, 0,
         LOC(u->faction->locale, name), u);
-    equip_unit(newunit, get_equipment(equip));
+    equip_unit(newunit, equip);
 
     u_setfaction(newunit, u->faction);
     set_racename(&newunit->attribs, get_racename(u->attribs));
diff --git a/src/teleport.c b/src/teleport.c
index 439b44955..36634c5cd 100644
--- a/src/teleport.c
+++ b/src/teleport.c
@@ -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);
         }
diff --git a/src/xmlreader.c b/src/xmlreader.c
index fe6f18e1f..5b6f7d8c1 100644
--- a/src/xmlreader.c
+++ b/src/xmlreader.c
@@ -875,8 +875,7 @@ static void add_callbacks(equipment * eq, xmlNodeSetPtr nsetItems)
             if (propValue != NULL) {
                 fun = get_function((const char *)propValue);
                 if (fun) {
-                    equipment_setcallback(eq, (void(*)(const struct equipment *,
-                    struct unit *))fun);
+                    equipment_setcallback(eq, (equip_callback_fun)fun);
                 }
                 xmlFree(propValue);
             }

From b12050ac2a6e4bd3c13753226f7ef2e7516d5d08 Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Sat, 12 May 2018 18:25:44 +0200
Subject: [PATCH 21/24] lua callback for equip_unit

---
 src/helpers.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/src/helpers.c b/src/helpers.c
index 3b966785b..170ca2969 100644
--- a/src/helpers.c
+++ b/src/helpers.c
@@ -162,6 +162,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 +376,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;

From 271352d0ba27ca73a7ec7d3641644b4465d5bb42 Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Sat, 12 May 2018 19:10:40 +0200
Subject: [PATCH 22/24] create a lua module that can handle simple euipments.
 lua test for equip_unit, with callbacks.

---
 conf/e2/config.json           |  1 -
 scripts/eressea/e2/init.lua   |  2 +-
 scripts/eressea/e3/init.lua   |  2 +-
 scripts/eressea/equipment.lua | 50 +++++++++++++++++++++++++++++++++++
 scripts/tests/config.lua      | 39 +++++++++++++++------------
 scripts/tests/e2/init.lua     |  1 +
 scripts/tests/e3/init.lua     |  1 +
 scripts/tests/init.lua        |  1 -
 src/bind_unit.c               | 12 +++++++++
 src/bindings.c                | 12 ---------
 10 files changed, 88 insertions(+), 33 deletions(-)
 create mode 100644 scripts/eressea/equipment.lua

diff --git a/conf/e2/config.json b/conf/e2/config.json
index b5ed2e68c..ddf6b9dd3 100644
--- a/conf/e2/config.json
+++ b/conf/e2/config.json
@@ -6,7 +6,6 @@
         "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",
diff --git a/scripts/eressea/e2/init.lua b/scripts/eressea/e2/init.lua
index 722078741..ba6c9895b 100644
--- a/scripts/eressea/e2/init.lua
+++ b/scripts/eressea/e2/init.lua
@@ -11,8 +11,8 @@ return {
     require('eressea.tunnels'),
     require('eressea.ponnuki'),
     require('eressea.astral'),
---    require('eressea.locales'),
     require('eressea.jsreport'),
     require('eressea.ents'),
+    require('eressea.equipment'),
     require('eressea.cursed')
 }
diff --git a/scripts/eressea/e3/init.lua b/scripts/eressea/e3/init.lua
index f7402268c..0b1d21664 100644
--- a/scripts/eressea/e3/init.lua
+++ b/scripts/eressea/e3/init.lua
@@ -5,7 +5,7 @@ eressea.log.debug("rules for game E3")
 return {
     require('eressea'),
     require('eressea.xmasitems'),
-    -- require('eressea.markets'),
     require('eressea.frost'),
+    require('eressea.equipment'),
     require('eressea.ents')
 }
diff --git a/scripts/eressea/equipment.lua b/scripts/eressea/equipment.lua
new file mode 100644
index 000000000..d3ef5ccbb
--- /dev/null
+++ b/scripts/eressea/equipment.lua
@@ -0,0 +1,50 @@
+-- Equipment
+
+local sets = {
+    ['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
+        }
+    }
+}
+
+function equip_unit(u, name, flags)
+    set = sets[name]
+    if set then
+        items = set['items']
+        if items then
+            for k,v in pairs(items) do
+                u:add_item(k, v)
+            end
+        end
+        skills = set['skills']
+        if skills then
+            for k,v in pairs(skills) do
+                u:set_skill(k, v)
+            end
+        end
+        return true
+    end
+    return false
+end
+
+return nil
diff --git a/scripts/tests/config.lua b/scripts/tests/config.lua
index a83b64350..a3104a6b6 100644
--- a/scripts/tests/config.lua
+++ b/scripts/tests/config.lua
@@ -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
diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua
index 22195a1f4..5c942fc74 100644
--- a/scripts/tests/e2/init.lua
+++ b/scripts/tests/e2/init.lua
@@ -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'
diff --git a/scripts/tests/e3/init.lua b/scripts/tests/e3/init.lua
index 04b7da4a2..7d30d347f 100644
--- a/scripts/tests/e3/init.lua
+++ b/scripts/tests/e3/init.lua
@@ -6,6 +6,7 @@ require 'tests.e3.parser'
 require 'tests.e3.morale'
 require 'tests.e3.items'
 require 'tests.e3.production'
+require 'tests.config'
 require 'tests.spells'
 require 'tests.economy'
 require 'tests.orders'
diff --git a/scripts/tests/init.lua b/scripts/tests/init.lua
index c933d4e69..a01e1c75c 100644
--- a/scripts/tests/init.lua
+++ b/scripts/tests/init.lua
@@ -1,5 +1,4 @@
 -- new tests 2014-06-11
-require 'tests.config'
 require 'tests.faction'
 require 'tests.locale'
 require 'tests.movement'
diff --git a/src/bind_unit.c b/src/bind_unit.c
index 2ae39bf20..e0fa9f86b 100644
--- a/src/bind_unit.c
+++ b/src/bind_unit.c
@@ -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);
diff --git a/src/bindings.c b/src/bindings.c
index 4444a5515..72a2db782 100755
--- a/src/bindings.c
+++ b/src/bindings.c
@@ -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"
@@ -393,16 +392,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, eqname, mask);
-    return 0;
-}
-
 static int tolua_spawn_braineaters(lua_State * L)
 {
     float chance = (float)tolua_tonumber(L, 1, 0);
@@ -1019,7 +1008,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 "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);

From 298e220cfd0fafb6624a69eb97bde766e2276090 Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Sat, 12 May 2018 19:18:25 +0200
Subject: [PATCH 23/24] Oh. E3 hat kein autoseed, ergo kein seed_elf equipment?

---
 scripts/tests/e3/init.lua | 1 -
 1 file changed, 1 deletion(-)

diff --git a/scripts/tests/e3/init.lua b/scripts/tests/e3/init.lua
index 7d30d347f..04b7da4a2 100644
--- a/scripts/tests/e3/init.lua
+++ b/scripts/tests/e3/init.lua
@@ -6,7 +6,6 @@ require 'tests.e3.parser'
 require 'tests.e3.morale'
 require 'tests.e3.items'
 require 'tests.e3.production'
-require 'tests.config'
 require 'tests.spells'
 require 'tests.economy'
 require 'tests.orders'

From 40125bb75e2b098a229d2ad7f42112fc877f0148 Mon Sep 17 00:00:00 2001
From: Enno Rehling <enno.rehling@gmail.com>
Date: Sat, 12 May 2018 20:52:10 +0200
Subject: [PATCH 24/24] translate seed_%race% equipment from xml to lua.

---
 res/eressea/equipment.xml     | 67 ------------------------
 scripts/eressea/equipment.lua | 97 +++++++++++++++++++++++++++++++++--
 src/bindings.c                |  9 +++-
 src/races/races.c             |  5 +-
 src/races/races.h             |  1 +
 src/xmlreader.c               | 26 ----------
 6 files changed, 104 insertions(+), 101 deletions(-)

diff --git a/res/eressea/equipment.xml b/res/eressea/equipment.xml
index 94d0deb07..d64a5e3e4 100644
--- a/res/eressea/equipment.xml
+++ b/res/eressea/equipment.xml
@@ -1,73 +1,6 @@
 <?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"/>
diff --git a/scripts/eressea/equipment.lua b/scripts/eressea/equipment.lua
index d3ef5ccbb..ffe910e7a 100644
--- a/scripts/eressea/equipment.lua
+++ b/scripts/eressea/equipment.lua
@@ -24,24 +24,115 @@ local sets = {
             ['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)
-    set = sets[name]
+    local set = sets[name]
     if set then
-        items = set['items']
+        local items = set['items']
         if items then
             for k,v in pairs(items) do
                 u:add_item(k, v)
             end
         end
-        skills = set['skills']
+        local skills = set['skills']
         if skills then
             for k,v in pairs(skills) do
                 u:set_skill(k, v)
             end
         end
+        local spells = set['spells']
+        if spells then
+            for k, v in ipairs(spells) do
+                u:add_spell(v)
+            end
+        end
+        local callback = set['callback']
+        if callback and type(callback) == 'function' then
+            callback(u)
+        end
         return true
     end
     return false
diff --git a/src/bindings.c b/src/bindings.c
index 72a2db782..bbea46e60 100755
--- a/src/bindings.c
+++ b/src/bindings.c
@@ -23,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"
@@ -845,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));
@@ -1023,6 +1029,7 @@ int tolua_bindings_open(lua_State * L, const dictionary *inifile)
         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;
 }
diff --git a/src/races/races.c b/src/races/races.c
index 92a3d3e3d..120a15dd9 100644
--- a/src/races/races.c
+++ b/src/races/races.c
@@ -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");
diff --git a/src/races/races.h b/src/races/races.h
index ea7be1337..78c8b062f 100644
--- a/src/races/races.h
+++ b/src/races/races.h
@@ -18,6 +18,7 @@ extern "C" {
 
     void register_races(void);
     void make_undead_unit(struct unit *);
+    void equip_newunits(struct unit *u);
 
 #ifdef __cplusplus
 }
diff --git a/src/xmlreader.c b/src/xmlreader.c
index 5b6f7d8c1..cbae06f58 100644
--- a/src/xmlreader.c
+++ b/src/xmlreader.c
@@ -862,27 +862,6 @@ static void add_items(equipment * eq, xmlNodeSetPtr nsetItems)
     }
 }
 
-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, (equip_callback_fun)fun);
-                }
-                xmlFree(propValue);
-            }
-        }
-    }
-}
-
 static void add_spells(equipment * eq, xmlNodeSetPtr nsetItems)
 {
     if (nsetItems != NULL && nsetItems->nodeNr > 0) {
@@ -1021,11 +1000,6 @@ static int parse_equipment(xmlDocPtr doc)
 
                 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);