kicking out a few more hardcoded item_type objects.

This commit is contained in:
Enno Rehling 2005-10-29 14:48:37 +00:00
parent cb9106473b
commit f6524ee015
12 changed files with 88 additions and 109 deletions

View File

@ -36,6 +36,11 @@
static int
use_skillpotion(struct unit * u, const struct item_type * itype, int amount, struct order * ord)
{
/* the problem with making this a lua function is that there's no way
* to get the list of skills for a unit. and with the way skills are
* currently saved, it doesn't look likely (can't make eressea::list
* from them)
*/
int i;
for (i=0;i!=amount;++i) {
skill * sv = u->skills;
@ -52,23 +57,6 @@ use_skillpotion(struct unit * u, const struct item_type * itype, int amount, str
return 0;
}
static resource_type rt_skillpotion = {
{ "skillpotion", "skillpotion_p" },
{ "skillpotion", "skillpotion_p" },
RTF_ITEM,
&res_changeitem
};
item_type it_skillpotion = {
&rt_skillpotion, /* resourcetype */
0, 0, 0, /* flags, weight, capacity */
NULL, /* construction */
&use_skillpotion,
NULL,
NULL
};
static int
use_manacrystal(struct unit * u, const struct item_type * itype, int amount, struct order * ord)
{
@ -91,28 +79,9 @@ use_manacrystal(struct unit * u, const struct item_type * itype, int amount, str
return 0;
}
static resource_type rt_manacrystal = {
{ "manacrystal", "manacrystal_p" },
{ "manacrystal", "manacrystal_p" },
RTF_ITEM,
&res_changeitem
};
item_type it_manacrystal = {
&rt_manacrystal, /* resourcetype */
0, 0, 0, /* flags, weight, capacity */
NULL, /* construction */
&use_manacrystal,
NULL,
NULL
};
void
register_xerewards(void)
{
it_register(&it_skillpotion);
it_register(&it_manacrystal);
register_function((pf_generic)use_skillpotion, "useskillpotion");
register_function((pf_generic)use_manacrystal, "usemanacrystal");
}

View File

@ -18,8 +18,6 @@
extern "C" {
#endif
extern struct item_type it_skillpotion;
extern struct item_type it_astralcrystal;
extern void register_xerewards(void);
#ifdef __cplusplus

View File

@ -332,20 +332,6 @@ use_museumexitticket(unit *u, const struct item_type *itype, int amount, order *
return 0;
}
resource_type rt_museumexitticket = {
{ "museumexitticket", "museumexitticket_p"},
{ "museumexitticket", "museumexitticket_p"},
RTF_ITEM,
&res_changeitem
};
item_type it_museumexitticket = {
&rt_museumexitticket,
ITF_CURSED, 0, 0,
NULL,
&use_museumexitticket
};
static int
use_museumticket(unit *u, const struct item_type *itype, int amount, order * ord)
{
@ -382,25 +368,11 @@ use_museumticket(unit *u, const struct item_type *itype, int amount, order * ord
i_change(&u->items, itype, -1);
/* Benutzer ein Exitticket geben */
i_change(&u->items, &it_museumexitticket, 1);
i_change(&u->items, itype, 1);
return 0;
}
resource_type rt_museumticket = {
{ "museumticket", "museumticket_p"},
{ "museumticket", "museumticket_p"},
RTF_ITEM,
&res_changeitem
};
item_type it_museumticket = {
&rt_museumticket,
ITF_NONE, 0, 0,
NULL,
&use_museumticket
};
void
register_museum(void)
{
@ -409,14 +381,8 @@ register_museum(void)
at_register(&at_museumgivebackcookie);
at_register(&at_museumgiveback);
rt_register(&rt_museumticket);
it_register(&it_museumticket);
rt_register(&rt_museumexitticket);
it_register(&it_museumexitticket);
register_function((pf_generic)use_museumticket, "usemuseumticket");
register_function((pf_generic)use_museumexitticket, "usemuseumexitticket");
register_function((pf_generic)use_museumticket, "use_museumticket");
register_function((pf_generic)use_museumexitticket, "use_museumexitticket");
}
#endif

View File

@ -65,7 +65,7 @@ xe_givepotion(unit *u, struct order *ord)
cmistake(u, ord, 63, MSG_EVENT);
return;
}
i_change(&u2->items, &it_skillpotion, 1);
i_change(&u2->items, it_find("skillpotion"), 1);
}
static void

View File

@ -21,6 +21,7 @@
#include <kernel/race.h>
#include <kernel/reports.h>
#include <kernel/save.h>
#include <kernel/skill.h>
#include <kernel/teleport.h>
#include <kernel/unit.h>
@ -217,6 +218,15 @@ lua_equipunit(unit& u, const char * eqname)
equip_unit(&u, get_equipment(eqname));
}
static void
lua_learnskill(unit& u, const char * skname, float chances)
{
skill_t sk = sk_find(skname);
if (sk!=NOSKILL) {
learn_skill(&u, sk, chances);
}
}
void
bind_eressea(lua_State * L)
{
@ -239,6 +249,7 @@ bind_eressea(lua_State * L)
def("remove_empty_units", &remove_empty_units),
def("equip_unit", &lua_equipunit),
def("learn_skill", &lua_learnskill),
/* scripted monsters */
def("plan_monsters", &lua_planmonsters),

View File

@ -1,5 +1,49 @@
<?xml version="1.0"?>
<resources>
<resource name="aog">
<!-- Amulett des Treffens -->
<item notlost="yes" weight="0"/>
</resource>
<!-- museum items -->
<resource name="museumexitticket">
<!-- you get your stuff back when leaving the museum -->
<item notlost="yes" weight="0">
<function name="use" value="use_museumexitticket"/>
</item>
</resource>
<resource name="museumticket">
<!-- you get your stuff back when leaving the museum -->
<item weight="0">
<function name="use" value="use_museumticket"/>
</item>
</resource>
<!-- XE items -->
<resource name="skillpotion">
<!-- gives user one free learning attempt -->
<item weight="0">
<function name="use" value="useskillpotion"/>
</item>
</resource>
<resource name="manacrystal">
<!-- gives user free aura -->
<item weight="0">
<function name="use" value="usemanacrystal"/>
</item>
</resource>
<!-- HSE items -->
<resource name="studypotion">
<item weight="0">
<function name="use" value="use_studypotion"/>
</item>
</resource>
<!-- xmas items -->
<resource name="mistletoe">
<!-- Sets the chance of escape in a fight to 100 percent -->
<item notlost="yes" weight="0">
@ -7,6 +51,25 @@
</item>
</resource>
<resource name="speedsail">
<item weight="0" cursed="yes">
<function name="use" value="use_speedsail"/>
</item>
</resource>
<resource name="snowball">
<!-- xmas gimmik -->
<item notlost="yes" weight="0">
<function name="use" value="usesnowball"/>
</item>
</resource>
<resource name="snowman">
<!-- xmas gimmik -->
<item notlost="yes" weight="1"/>
</resource>
<!-- items -->
<resource name="seed" limited="yes">
<item weight="10" score="50">
<construction skill="herbalism" minskill="3" reqsize="1"/>
@ -31,35 +94,6 @@
</item>
</resource>
<resource name="aog">
<!-- Amulett des Treffens -->
<item notlost="yes" weight="0"/>
</resource>
<resource name="snowball">
<!-- xmas gimmik -->
<item notlost="yes" weight="0">
<function name="use" value="usesnowball"/>
</item>
</resource>
<resource name="studypotion">
<item weight="0">
<function name="use" value="use_studypotion"/>
</item>
</resource>
<resource name="speedsail">
<item weight="0" cursed="yes">
<function name="use" value="use_speedsail"/>
</item>
</resource>
<resource name="snowman">
<!-- xmas gimmik -->
<item notlost="yes" weight="1"/>
</resource>
<resource name="mallornbow">
<item weight="100">
<construction skill="weaponsmithing" minskill="5" reqsize="1">

View File

@ -72,6 +72,7 @@ if orderfile==nil then
print "you must specify an orderfile"
else
loadscript("spells.lua")
loadscript("extensions.lua")
process(orderfile)
end

View File

@ -24,7 +24,7 @@ end
function run_scripts()
scripts = {
"spells.lua",
"familiars.lua",
"extensions.lua",
"eternath.lua",
"wedding-jadee.lua",
"ponnuki.lua"

View File

@ -1,7 +1,7 @@
function run_scripts()
scripts = {
"spells.lua",
"familiars.lua",
"extensions.lua",
"hse-portals.lua",
"hse-stats.lua"
}

View File

@ -1,7 +1,7 @@
function run_scripts()
scripts = {
"spells.lua",
"familiars.lua",
"extensions.lua",
"hse-portals.lua",
"hse-stats.lua"
}

View File

@ -42,7 +42,7 @@ print("- Running wdw-run.lua")
scripts = {
"spells.lua",
"familiars.lua",
"extensions.lua",
"wdw-sphinx.lua",
"wdw-standings.lua"
}