forked from github/server
- goblins get only simple weapons.
This commit is contained in:
parent
e939b5fdc9
commit
d0d17043e8
|
@ -127,7 +127,7 @@ typedef struct item_type {
|
|||
int capacity;
|
||||
struct construction * construction;
|
||||
/* --- 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 (*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);
|
||||
|
|
|
@ -313,34 +313,38 @@ lua_getresource(unit * u, const struct resource_type * rtype)
|
|||
return result;
|
||||
}
|
||||
|
||||
static int
|
||||
static boolean
|
||||
lua_canuse_item(const unit * u, const struct item_type * itype)
|
||||
{
|
||||
lua_State * L = (lua_State *)global.vm_state;
|
||||
int result = -1;
|
||||
const char * fname = "item_canuse";
|
||||
static int function_exists = 1;
|
||||
boolean result = true;
|
||||
|
||||
lua_pushstring(L, fname);
|
||||
lua_rawget(L, LUA_GLOBALSINDEX);
|
||||
if (lua_isfunction(L, 1)) {
|
||||
tolua_pushusertype(L, (void *)u, "unit");
|
||||
tolua_pushstring(L, itype->rtype->_name[0]);
|
||||
if (function_exists) {
|
||||
lua_State * L = (lua_State *)global.vm_state;
|
||||
const char * fname = "item_canuse";
|
||||
|
||||
if (lua_pcall(L, 2, 1, 0)!=0) {
|
||||
const char* error = lua_tostring(L, -1);
|
||||
log_error(("get(%s) calling '%s': %s.\n",
|
||||
unitname(u), fname, error));
|
||||
lua_pop(L, 1);
|
||||
lua_pushstring(L, fname);
|
||||
lua_rawget(L, LUA_GLOBALSINDEX);
|
||||
if (lua_isfunction(L, 1)) {
|
||||
tolua_pushusertype(L, (void *)u, "unit");
|
||||
tolua_pushstring(L, itype->rtype->_name[0]);
|
||||
|
||||
if (lua_pcall(L, 2, 1, 0)!=0) {
|
||||
const char* error = lua_tostring(L, -1);
|
||||
log_error(("get(%s) calling '%s': %s.\n",
|
||||
unitname(u), fname, error));
|
||||
lua_pop(L, 1);
|
||||
} else {
|
||||
result = lua_toboolean(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else {
|
||||
result = lua_toboolean(L, -1);
|
||||
function_exists = 0;
|
||||
log_error(("get(%s) calling '%s': not a function.\n",
|
||||
unitname(u), fname));
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else {
|
||||
log_error(("get(%s) calling '%s': not a function.\n",
|
||||
unitname(u), fname));
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -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>
|
|
@ -1,6 +1,7 @@
|
|||
<?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>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0"?>
|
||||
<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/laenmail.xml"/>
|
||||
<xi:include href="../armor/laenshield.xml"/>
|
||||
|
|
|
@ -66,7 +66,6 @@
|
|||
<skill name="shipcraft" modifier="2"/>
|
||||
<skill name="sailing" modifier="2"/>
|
||||
<skill name="magic" modifier="-99"/>
|
||||
<skill name="training" modifier="+1"/>
|
||||
<skill name="unarmed" modifier="-99"/>
|
||||
<attack type="1" damage="1d5"/>
|
||||
<familiar race="dolphin" default="yes"/>
|
||||
|
@ -141,7 +140,7 @@
|
|||
<skill name="roadwork" modifier="-1"/>
|
||||
<skill name="sailing" modifier="-1"/>
|
||||
<skill name="shipcraft" modifier="-1"/>
|
||||
<skill name="training" modifier="1"/>
|
||||
<skill name="training" modifier="2"/>
|
||||
<skill name="unarmed" modifier="-99"/>
|
||||
<attack type="1" damage="1d5"/>
|
||||
<familiar race="nymph" default="yes"/>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<resource name="axe">
|
||||
<item weight="200">
|
||||
<function name="canuse" value="lua_canuse_item"/>
|
||||
<construction skill="weaponsmithing" minskill="3" reqsize="1">
|
||||
<requirement type="log" quantity="1"/>
|
||||
<requirement type="iron" quantity="1"/>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<resource name="greatbow">
|
||||
<item weight="100">
|
||||
<function name="canuse" value="lua_canuse_item"/>
|
||||
<construction skill="weaponsmithing" minskill="5" reqsize="1">
|
||||
<modifier function="mod_elves_only"/>
|
||||
<requirement type="mallorn" quantity="2"/>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<resource name="greatsword">
|
||||
<item weight="200" score="30">
|
||||
<function name="canuse" value="lua_canuse_item"/>
|
||||
<construction skill="weaponsmithing" minskill="4" reqsize="1">
|
||||
<requirement type="iron" quantity="2"/>
|
||||
</construction>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
-->
|
||||
<resource name="halberd">
|
||||
<item weight="200">
|
||||
<function name="canuse" value="lua_canuse_item"/>
|
||||
<construction skill="weaponsmithing" minskill="3" reqsize="1">
|
||||
<requirement type="log" quantity="2"/>
|
||||
<requirement type="iron" quantity="1"/>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<resource name="halberd">
|
||||
<item weight="200">
|
||||
<function name="canuse" value="lua_canuse_item"/>
|
||||
<construction skill="weaponsmithing" minskill="3" reqsize="1">
|
||||
<requirement type="log" quantity="2"/>
|
||||
<requirement type="iron" quantity="1"/>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<resource name="lance">
|
||||
<item weight="200">
|
||||
<function name="canuse" value="lua_canuse_item"/>
|
||||
<construction skill="weaponsmithing" minskill="2" reqsize="1">
|
||||
<requirement type="log" quantity="2"/>
|
||||
</construction>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<resource name="mallornlance">
|
||||
<item weight="100">
|
||||
<function name="canuse" value="lua_canuse_item"/>
|
||||
<construction skill="weaponsmithing" minskill="5" reqsize="1">
|
||||
<requirement type="mallorn" quantity="2"/>
|
||||
</construction>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<resource name="rustyaxe">
|
||||
<item weight="200">
|
||||
<function name="canuse" value="lua_canuse_item"/>
|
||||
<construction skill="weaponsmithing" minskill="3" reqsize="1">
|
||||
<requirement type="log" quantity="1"/>
|
||||
<requirement type="iron" quantity="1"/>
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- changes to the regular weapon:
|
||||
1. you cannt use this with cavalry
|
||||
1. you cannot use this with cavalry
|
||||
-->
|
||||
<resource name="rustyhalberd">
|
||||
<item weight="200" score="20">
|
||||
<function name="canuse" value="lua_canuse_item"/>
|
||||
<construction skill="weaponsmithing" minskill="3" reqsize="1">
|
||||
<requirement type="iron" quantity="1"/>
|
||||
<requirement type="log" quantity="1"/>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<resource name="rustyhalberd">
|
||||
<item weight="200" score="20">
|
||||
<function name="canuse" value="lua_canuse_item"/>
|
||||
<construction skill="weaponsmithing" minskill="3" reqsize="1">
|
||||
<requirement type="iron" quantity="1"/>
|
||||
<requirement type="log" quantity="1"/>
|
||||
|
|
|
@ -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)
|
||||
if u.race=="goblin" then
|
||||
if string.find(goblin_denied, " " .. iname .. " ") then
|
||||
return false
|
||||
end
|
||||
end
|
||||
if iname=="towershield" then
|
||||
-- only dwarves allowed to use towershield
|
||||
return u.race=="dwarf"
|
||||
|
|
Loading…
Reference in New Issue