2010-02-25 08:27:30 +01:00
|
|
|
#include <platform.h>
|
2010-02-27 09:28:59 +01:00
|
|
|
#include <kernel/types.h>
|
2010-02-25 08:27:30 +01:00
|
|
|
#include "spells/shipcurse.h"
|
|
|
|
|
|
|
|
#include <kernel/ship.h>
|
|
|
|
#include <kernel/unit.h>
|
2010-02-27 09:28:59 +01:00
|
|
|
#include <kernel/faction.h>
|
2010-02-25 08:27:30 +01:00
|
|
|
|
|
|
|
#include <tolua.h>
|
|
|
|
|
|
|
|
static int
|
|
|
|
tolua_levitate_ship(lua_State * L)
|
|
|
|
{
|
|
|
|
ship * sh = (ship *)tolua_tousertype(L, 1, 0);
|
|
|
|
unit * mage = (unit *)tolua_tousertype(L, 2, 0);
|
|
|
|
double power = (double)tolua_tonumber(L, 3, 0);
|
|
|
|
int duration = (int)tolua_tonumber(L, 4, 0);
|
|
|
|
int cno = levitate_ship(sh, mage, power, duration);
|
|
|
|
tolua_pushnumber(L, (lua_Number)cno);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-02-27 09:28:59 +01:00
|
|
|
|
|
|
|
extern void spawn_undead(void);
|
|
|
|
extern void spawn_dragons(void);
|
|
|
|
extern void plan_monsters(struct faction * f);
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
tolua_planmonsters(lua_State * L)
|
|
|
|
{
|
|
|
|
faction * f = (faction *)tolua_tousertype(L, 1, get_monsters());
|
|
|
|
if (f) {
|
|
|
|
plan_monsters(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tolua_spawn_dragons(lua_State * L)
|
|
|
|
{
|
|
|
|
spawn_dragons();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tolua_spawn_undead(lua_State * L)
|
|
|
|
{
|
|
|
|
spawn_undead();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-03-15 00:27:27 +01:00
|
|
|
static int
|
|
|
|
fix_familiars(struct lua_State * L)
|
|
|
|
{
|
|
|
|
faction * f;
|
|
|
|
for (f=factions;f;f=f->next) {
|
|
|
|
unit * u;
|
|
|
|
for (u=f->units;u;u=u->nextF) {
|
|
|
|
struct sc_mage * mage = get_mage(u);
|
|
|
|
if (mage && is_familiar(u)) {
|
|
|
|
if (mage->spells && mage->magietyp==M_GRAY) {
|
|
|
|
equipment * eq;
|
|
|
|
char buffer[64];
|
|
|
|
|
|
|
|
while (mage->spells) {
|
|
|
|
spell_list * slist = mage->spells;
|
|
|
|
mage->spells = mage->spells->next;
|
|
|
|
free(slist);
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(buffer, sizeof(buffer), "%s_familiar", u->race->_name[0]);
|
|
|
|
eq = get_equipment(buffer);
|
|
|
|
if (eq) {
|
|
|
|
equip_unit_mask(u, eq, EQUIP_SPELLS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-02-25 08:27:30 +01:00
|
|
|
void
|
|
|
|
bind_eressea(struct lua_State * L)
|
|
|
|
{
|
|
|
|
tolua_module(L, NULL, 0);
|
|
|
|
tolua_beginmodule(L, NULL);
|
|
|
|
{
|
|
|
|
tolua_function(L, TOLUA_CAST "levitate_ship", tolua_levitate_ship);
|
2010-02-27 09:28:59 +01:00
|
|
|
tolua_function(L, TOLUA_CAST "plan_monsters", tolua_planmonsters);
|
|
|
|
tolua_function(L, TOLUA_CAST "spawn_undead", tolua_spawn_undead);
|
|
|
|
tolua_function(L, TOLUA_CAST "spawn_dragons", tolua_spawn_dragons);
|
2010-03-15 00:27:27 +01:00
|
|
|
tolua_function(L, TOLUA_CAST "fix_familiars", &fix_familiars);
|
2010-02-25 08:27:30 +01:00
|
|
|
}
|
|
|
|
tolua_endmodule(L);
|
|
|
|
}
|
|
|
|
|