diff --git a/src/common/items/xerewards.c b/src/common/items/xerewards.c index 020ea020e..f779e33d9 100644 --- a/src/common/items/xerewards.c +++ b/src/common/items/xerewards.c @@ -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"); } diff --git a/src/common/items/xerewards.h b/src/common/items/xerewards.h index 4f3e56649..3c6a543c0 100644 --- a/src/common/items/xerewards.h +++ b/src/common/items/xerewards.h @@ -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 diff --git a/src/common/modules/museum.c b/src/common/modules/museum.c index 5dad47b28..fc6217d49 100644 --- a/src/common/modules/museum.c +++ b/src/common/modules/museum.c @@ -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 diff --git a/src/common/modules/xecmd.c b/src/common/modules/xecmd.c index a4f9cea04..2cf2e9629 100644 --- a/src/common/modules/xecmd.c +++ b/src/common/modules/xecmd.c @@ -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 diff --git a/src/eressea/lua/eressea.cpp b/src/eressea/lua/eressea.cpp index 17450209d..dfcf3cc69 100644 --- a/src/eressea/lua/eressea.cpp +++ b/src/eressea/lua/eressea.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -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), diff --git a/src/res/resources.xml b/src/res/resources.xml index e49769266..59bd07eb1 100644 --- a/src/res/resources.xml +++ b/src/res/resources.xml @@ -1,5 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -7,6 +51,25 @@ + + + + + + + + + + + + + + + + + + + @@ -31,35 +94,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/scripts/default.lua b/src/scripts/default.lua index efce2ad8e..cea755376 100644 --- a/src/scripts/default.lua +++ b/src/scripts/default.lua @@ -72,6 +72,7 @@ if orderfile==nil then print "you must specify an orderfile" else loadscript("spells.lua") + loadscript("extensions.lua") process(orderfile) end diff --git a/src/scripts/eressea.lua b/src/scripts/eressea.lua index 31d453254..70d0526fe 100644 --- a/src/scripts/eressea.lua +++ b/src/scripts/eressea.lua @@ -24,7 +24,7 @@ end function run_scripts() scripts = { "spells.lua", - "familiars.lua", + "extensions.lua", "eternath.lua", "wedding-jadee.lua", "ponnuki.lua" diff --git a/src/scripts/familiars.lua b/src/scripts/extensions.lua similarity index 100% rename from src/scripts/familiars.lua rename to src/scripts/extensions.lua diff --git a/src/scripts/hse3-run.lua b/src/scripts/hse3-run.lua index 82c489b41..0732fee41 100644 --- a/src/scripts/hse3-run.lua +++ b/src/scripts/hse3-run.lua @@ -1,7 +1,7 @@ function run_scripts() scripts = { "spells.lua", - "familiars.lua", + "extensions.lua", "hse-portals.lua", "hse-stats.lua" } diff --git a/src/scripts/hse4-run.lua b/src/scripts/hse4-run.lua index 583fabcc7..72eed8ed3 100644 --- a/src/scripts/hse4-run.lua +++ b/src/scripts/hse4-run.lua @@ -1,7 +1,7 @@ function run_scripts() scripts = { "spells.lua", - "familiars.lua", + "extensions.lua", "hse-portals.lua", "hse-stats.lua" } diff --git a/src/scripts/wdw-run.lua b/src/scripts/wdw-run.lua index edd65ad4e..1bfe095ed 100644 --- a/src/scripts/wdw-run.lua +++ b/src/scripts/wdw-run.lua @@ -42,7 +42,7 @@ print("- Running wdw-run.lua") scripts = { "spells.lua", - "familiars.lua", + "extensions.lua", "wdw-sphinx.lua", "wdw-standings.lua" }