- goblins get only simple weapons.

This commit is contained in:
Enno Rehling 2009-06-06 12:05:16 +00:00
parent e939b5fdc9
commit d0d17043e8
17 changed files with 46 additions and 36 deletions

View File

@ -127,7 +127,7 @@ typedef struct item_type {
int capacity; int capacity;
struct construction * construction; struct construction * construction;
/* --- functions --- */ /* --- functions --- */
int (*canuse)(const struct unit * user, const struct item_type * itype); boolean (*canuse)(const struct unit * user, const struct item_type * itype);
int (*use)(struct unit * user, const struct item_type * itype, int amount, struct order * ord); int (*use)(struct unit * user, const struct item_type * itype, int amount, struct order * ord);
int (*useonother)(struct unit * user, int targetno, const struct item_type * itype, int amount, struct order * ord); int (*useonother)(struct unit * user, int targetno, const struct item_type * itype, int amount, struct order * ord);
int (*give)(struct unit * src, struct unit * dest, const struct item_type * itm, int number, struct order * ord); int (*give)(struct unit * src, struct unit * dest, const struct item_type * itm, int number, struct order * ord);

View File

@ -313,11 +313,14 @@ lua_getresource(unit * u, const struct resource_type * rtype)
return result; return result;
} }
static int static boolean
lua_canuse_item(const unit * u, const struct item_type * itype) lua_canuse_item(const unit * u, const struct item_type * itype)
{ {
static int function_exists = 1;
boolean result = true;
if (function_exists) {
lua_State * L = (lua_State *)global.vm_state; lua_State * L = (lua_State *)global.vm_state;
int result = -1;
const char * fname = "item_canuse"; const char * fname = "item_canuse";
lua_pushstring(L, fname); lua_pushstring(L, fname);
@ -336,11 +339,12 @@ lua_canuse_item(const unit * u, const struct item_type * itype)
lua_pop(L, 1); lua_pop(L, 1);
} }
} else { } else {
function_exists = 0;
log_error(("get(%s) calling '%s': not a function.\n", log_error(("get(%s) calling '%s': not a function.\n",
unitname(u), fname)); unitname(u), fname));
lua_pop(L, 1); lua_pop(L, 1);
} }
}
return result; return result;
} }

View File

@ -1,10 +0,0 @@
<?xml version="1.0"?>
<resource name="plate">
<item weight="400" score="150">
<function name="canuse" value="lua_canuse_item"/>
<construction skill="armorer" minskill="4" reqsize="1">
<requirement type="iron" quantity="5"/>
</construction>
<armor ac="5" penalty="0.30" magres="0.0"/>
</item>
</resource>

View File

@ -1,6 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<resource name="plate"> <resource name="plate">
<item weight="400" score="150"> <item weight="400" score="150">
<function name="canuse" value="lua_canuse_item"/>
<construction skill="armorer" minskill="4" reqsize="1"> <construction skill="armorer" minskill="4" reqsize="1">
<requirement type="iron" quantity="5"/> <requirement type="iron" quantity="5"/>
</construction> </construction>

View File

@ -1,6 +1,6 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<resources xmlns:xi="http://www.w3.org/2001/XInclude"> <resources xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="../armor/plate-2.xml"/> <xi:include href="../armor/plate.xml"/>
<xi:include href="../armor/chainmail.xml"/> <xi:include href="../armor/chainmail.xml"/>
<xi:include href="../armor/laenmail.xml"/> <xi:include href="../armor/laenmail.xml"/>
<xi:include href="../armor/laenshield.xml"/> <xi:include href="../armor/laenshield.xml"/>

View File

@ -66,7 +66,6 @@
<skill name="shipcraft" modifier="2"/> <skill name="shipcraft" modifier="2"/>
<skill name="sailing" modifier="2"/> <skill name="sailing" modifier="2"/>
<skill name="magic" modifier="-99"/> <skill name="magic" modifier="-99"/>
<skill name="training" modifier="+1"/>
<skill name="unarmed" modifier="-99"/> <skill name="unarmed" modifier="-99"/>
<attack type="1" damage="1d5"/> <attack type="1" damage="1d5"/>
<familiar race="dolphin" default="yes"/> <familiar race="dolphin" default="yes"/>
@ -141,7 +140,7 @@
<skill name="roadwork" modifier="-1"/> <skill name="roadwork" modifier="-1"/>
<skill name="sailing" modifier="-1"/> <skill name="sailing" modifier="-1"/>
<skill name="shipcraft" modifier="-1"/> <skill name="shipcraft" modifier="-1"/>
<skill name="training" modifier="1"/> <skill name="training" modifier="2"/>
<skill name="unarmed" modifier="-99"/> <skill name="unarmed" modifier="-99"/>
<attack type="1" damage="1d5"/> <attack type="1" damage="1d5"/>
<familiar race="nymph" default="yes"/> <familiar race="nymph" default="yes"/>

View File

@ -1,6 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<resource name="axe"> <resource name="axe">
<item weight="200"> <item weight="200">
<function name="canuse" value="lua_canuse_item"/>
<construction skill="weaponsmithing" minskill="3" reqsize="1"> <construction skill="weaponsmithing" minskill="3" reqsize="1">
<requirement type="log" quantity="1"/> <requirement type="log" quantity="1"/>
<requirement type="iron" quantity="1"/> <requirement type="iron" quantity="1"/>

View File

@ -1,6 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<resource name="greatbow"> <resource name="greatbow">
<item weight="100"> <item weight="100">
<function name="canuse" value="lua_canuse_item"/>
<construction skill="weaponsmithing" minskill="5" reqsize="1"> <construction skill="weaponsmithing" minskill="5" reqsize="1">
<modifier function="mod_elves_only"/> <modifier function="mod_elves_only"/>
<requirement type="mallorn" quantity="2"/> <requirement type="mallorn" quantity="2"/>

View File

@ -1,6 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<resource name="greatsword"> <resource name="greatsword">
<item weight="200" score="30"> <item weight="200" score="30">
<function name="canuse" value="lua_canuse_item"/>
<construction skill="weaponsmithing" minskill="4" reqsize="1"> <construction skill="weaponsmithing" minskill="4" reqsize="1">
<requirement type="iron" quantity="2"/> <requirement type="iron" quantity="2"/>
</construction> </construction>

View File

@ -4,6 +4,7 @@
--> -->
<resource name="halberd"> <resource name="halberd">
<item weight="200"> <item weight="200">
<function name="canuse" value="lua_canuse_item"/>
<construction skill="weaponsmithing" minskill="3" reqsize="1"> <construction skill="weaponsmithing" minskill="3" reqsize="1">
<requirement type="log" quantity="2"/> <requirement type="log" quantity="2"/>
<requirement type="iron" quantity="1"/> <requirement type="iron" quantity="1"/>

View File

@ -1,6 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<resource name="halberd"> <resource name="halberd">
<item weight="200"> <item weight="200">
<function name="canuse" value="lua_canuse_item"/>
<construction skill="weaponsmithing" minskill="3" reqsize="1"> <construction skill="weaponsmithing" minskill="3" reqsize="1">
<requirement type="log" quantity="2"/> <requirement type="log" quantity="2"/>
<requirement type="iron" quantity="1"/> <requirement type="iron" quantity="1"/>

View File

@ -1,6 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<resource name="lance"> <resource name="lance">
<item weight="200"> <item weight="200">
<function name="canuse" value="lua_canuse_item"/>
<construction skill="weaponsmithing" minskill="2" reqsize="1"> <construction skill="weaponsmithing" minskill="2" reqsize="1">
<requirement type="log" quantity="2"/> <requirement type="log" quantity="2"/>
</construction> </construction>

View File

@ -1,6 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<resource name="mallornlance"> <resource name="mallornlance">
<item weight="100"> <item weight="100">
<function name="canuse" value="lua_canuse_item"/>
<construction skill="weaponsmithing" minskill="5" reqsize="1"> <construction skill="weaponsmithing" minskill="5" reqsize="1">
<requirement type="mallorn" quantity="2"/> <requirement type="mallorn" quantity="2"/>
</construction> </construction>

View File

@ -1,6 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<resource name="rustyaxe"> <resource name="rustyaxe">
<item weight="200"> <item weight="200">
<function name="canuse" value="lua_canuse_item"/>
<construction skill="weaponsmithing" minskill="3" reqsize="1"> <construction skill="weaponsmithing" minskill="3" reqsize="1">
<requirement type="log" quantity="1"/> <requirement type="log" quantity="1"/>
<requirement type="iron" quantity="1"/> <requirement type="iron" quantity="1"/>

View File

@ -1,9 +1,10 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!-- changes to the regular weapon: <!-- changes to the regular weapon:
1. you cannt use this with cavalry 1. you cannot use this with cavalry
--> -->
<resource name="rustyhalberd"> <resource name="rustyhalberd">
<item weight="200" score="20"> <item weight="200" score="20">
<function name="canuse" value="lua_canuse_item"/>
<construction skill="weaponsmithing" minskill="3" reqsize="1"> <construction skill="weaponsmithing" minskill="3" reqsize="1">
<requirement type="iron" quantity="1"/> <requirement type="iron" quantity="1"/>
<requirement type="log" quantity="1"/> <requirement type="log" quantity="1"/>

View File

@ -1,6 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<resource name="rustyhalberd"> <resource name="rustyhalberd">
<item weight="200" score="20"> <item weight="200" score="20">
<function name="canuse" value="lua_canuse_item"/>
<construction skill="weaponsmithing" minskill="3" reqsize="1"> <construction skill="weaponsmithing" minskill="3" reqsize="1">
<requirement type="iron" quantity="1"/> <requirement type="iron" quantity="1"/>
<requirement type="log" quantity="1"/> <requirement type="log" quantity="1"/>

View File

@ -1,5 +1,11 @@
-- used internally to check greatbow and towershield -- when appending to this, make sure the item has a canuse-function!
local goblin_denied = " plate lance mallornlance greatbow axe greatsword halberd rustyaxe rustyhalberd towershield "
function item_canuse(u, iname) function item_canuse(u, iname)
if u.race=="goblin" then
if string.find(goblin_denied, " " .. iname .. " ") then
return false
end
end
if iname=="towershield" then if iname=="towershield" then
-- only dwarves allowed to use towershield -- only dwarves allowed to use towershield
return u.race=="dwarf" return u.race=="dwarf"