From ca099ec5ae1823bf19f9e16e623f6120851a1dcc Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 6 Feb 2005 09:29:22 +0000 Subject: [PATCH] =?UTF-8?q?lua=20erweiterung:=20=20unit:cast=5Fspell,=20um?= =?UTF-8?q?=20einen=20zauber=20zu=20wirken=20(vorerst=20nur=20testweise,?= =?UTF-8?q?=20syntac=20wird=20sich=20=C3=A4ndern)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/eressea/lua/unit.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/eressea/lua/unit.cpp b/src/eressea/lua/unit.cpp index bd6116d14..a0d1ce3a6 100644 --- a/src/eressea/lua/unit.cpp +++ b/src/eressea/lua/unit.cpp @@ -192,6 +192,30 @@ unit_setrace(unit& u, const char * rcname) } } +static void +unit_castspell(unit& u, const char * name) +{ + spell_list * slist = spells; + while (slist!=NULL) { + spell * sp = slist->data; + if (strcmp(name, sp->sname)==0) { + castorder * co = (castorder*)malloc(sizeof(castorder)); + co->distance = 0; + co->familiar = NULL; + co->force = sp->level; + co->level = sp->level; + co->magician = &u; + co->order = NULL; + co->par = NULL; + co->rt = u.region; + co->sp = sp; + sp->sp_function(co); + free(co); + } + slist=slist->next; + } +} + static void unit_addspell(unit& u, const char * name) { @@ -556,6 +580,8 @@ bind_unit(lua_State * L) .def("set_racename", &unit_setracename) .def("add_spell", &unit_addspell) .def("remove_spell", &unit_removespell) + .def("cast_spell", &unit_castspell) + .property("magic", &unit_getmagic, &unit_setmagic) .property("aura", &unit_getaura, &unit_setaura) .property("building", &unit_getbuilding, &unit_setbuilding)