2017-12-29 06:13:28 +01:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#include <platform.h>
|
|
|
|
#endif
|
|
|
|
|
2016-08-31 11:35:07 +02:00
|
|
|
#include "monsters.h"
|
2010-08-08 09:40:42 +02:00
|
|
|
|
2017-08-21 20:18:19 +02:00
|
|
|
#include <spells/flyingship.h>
|
|
|
|
|
2012-06-05 06:45:25 +02:00
|
|
|
#include <kernel/faction.h>
|
2010-08-08 09:40:42 +02:00
|
|
|
#include <kernel/ship.h>
|
|
|
|
#include <kernel/unit.h>
|
|
|
|
|
2017-12-28 18:55:45 +01:00
|
|
|
#include <util/macros.h>
|
|
|
|
|
2018-09-23 19:44:05 +02:00
|
|
|
#include <lua.h>
|
2010-08-08 09:40:42 +02:00
|
|
|
#include <tolua.h>
|
2018-09-23 19:44:05 +02:00
|
|
|
|
2014-03-15 19:29:11 +01:00
|
|
|
#include <stdlib.h>
|
2010-08-08 09:40:42 +02:00
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
static int tolua_levitate_ship(lua_State * L)
|
2010-08-08 09:40:42 +02:00
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
ship *sh = (ship *)tolua_tousertype(L, 1, 0);
|
|
|
|
unit *mage = (unit *)tolua_tousertype(L, 2, 0);
|
|
|
|
float power = (float)tolua_tonumber(L, 3, 0);
|
|
|
|
int duration = (int)tolua_tonumber(L, 4, 0);
|
|
|
|
int cno = levitate_ship(sh, mage, power, duration);
|
2015-06-08 20:53:40 +02:00
|
|
|
lua_pushinteger(L, cno);
|
2015-01-30 20:37:14 +01:00
|
|
|
return 1;
|
2010-08-08 09:40:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
extern void spawn_undead(void);
|
2011-03-07 08:03:10 +01:00
|
|
|
extern void plan_monsters(struct faction *f);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
static int tolua_planmonsters(lua_State * L)
|
2010-08-08 09:40:42 +02:00
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
faction *f = (faction *)tolua_tousertype(L, 1, get_monsters());
|
|
|
|
if (f) {
|
|
|
|
plan_monsters(f);
|
|
|
|
}
|
2010-08-08 09:40:42 +02:00
|
|
|
|
2015-01-30 20:37:14 +01:00
|
|
|
return 0;
|
2010-08-08 09:40:42 +02:00
|
|
|
}
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
static int tolua_spawn_dragons(lua_State * L)
|
2010-08-08 09:40:42 +02:00
|
|
|
{
|
2017-12-28 18:55:45 +01:00
|
|
|
UNUSED_ARG(L);
|
2015-01-30 20:37:14 +01:00
|
|
|
spawn_dragons();
|
|
|
|
return 0;
|
2010-08-08 09:40:42 +02:00
|
|
|
}
|
|
|
|
|
2016-10-26 11:33:41 +02:00
|
|
|
static int tolua_get_monsters(lua_State * L)
|
|
|
|
{
|
|
|
|
tolua_pushusertype(L, get_monsters(), "faction");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
static int tolua_spawn_undead(lua_State * L)
|
2010-08-08 09:40:42 +02:00
|
|
|
{
|
2017-12-28 18:55:45 +01:00
|
|
|
UNUSED_ARG(L);
|
2015-01-30 20:37:14 +01:00
|
|
|
spawn_undead();
|
|
|
|
return 0;
|
2010-08-08 09:40:42 +02:00
|
|
|
}
|
|
|
|
|
2018-09-23 19:44:05 +02:00
|
|
|
void bind_monsters(lua_State *L)
|
2010-08-08 09:40:42 +02:00
|
|
|
{
|
2015-01-30 20:37:14 +01:00
|
|
|
tolua_module(L, NULL, 0);
|
|
|
|
tolua_beginmodule(L, NULL);
|
|
|
|
{
|
|
|
|
tolua_function(L, TOLUA_CAST "levitate_ship", tolua_levitate_ship);
|
|
|
|
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);
|
2016-10-26 11:33:41 +02:00
|
|
|
tolua_function(L, TOLUA_CAST "get_monsters", tolua_get_monsters);
|
2015-01-30 20:37:14 +01:00
|
|
|
}
|
|
|
|
tolua_endmodule(L);
|
2010-08-08 09:40:42 +02:00
|
|
|
}
|