forked from github/server
parent
40fb0c5528
commit
dfc6f83c62
12
src/Jamrules
12
src/Jamrules
|
@ -1,9 +1,9 @@
|
||||||
C++ = g++-3.3 ;
|
#C++ = g++-3.3 ;
|
||||||
CC = gcc-3.3 ;
|
#CC = gcc-3.3 ;
|
||||||
LINK = gcc-3.3 ;
|
#LINK = gcc-3.3 ;
|
||||||
|
C++ = g++ ;
|
||||||
#CC = tcc ;
|
CC = gcc ;
|
||||||
#LINK = tcc ;
|
LINK = gcc ;
|
||||||
|
|
||||||
# ECHO $(JAMUNAME) ;
|
# ECHO $(JAMUNAME) ;
|
||||||
|
|
||||||
|
|
|
@ -2572,7 +2572,7 @@ breedhorses(region *r, unit *u)
|
||||||
|
|
||||||
for (c = 0; c < n; c++) {
|
for (c = 0; c < n; c++) {
|
||||||
if (rand() % 100 < eff_skill(u, SK_HORSE_TRAINING, r)) {
|
if (rand() % 100 < eff_skill(u, SK_HORSE_TRAINING, r)) {
|
||||||
change_item(u, I_HORSE, 1);
|
i_change(&u->items, olditemtype[I_HORSE], 1);
|
||||||
gezuechtet++;
|
gezuechtet++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3249,7 +3249,7 @@ age_building(building * b)
|
||||||
int n, unicorns = 0;
|
int n, unicorns = 0;
|
||||||
for (n=0; n!=u->number; ++n) {
|
for (n=0; n!=u->number; ++n) {
|
||||||
if (chance(0.02)) {
|
if (chance(0.02)) {
|
||||||
change_item(u, I_UNICORN, 1);
|
i_change(&u->items, olditemtype[I_UNICORN], 1);
|
||||||
++unicorns;
|
++unicorns;
|
||||||
}
|
}
|
||||||
if (unicorns) {
|
if (unicorns) {
|
||||||
|
|
|
@ -676,7 +676,7 @@ damage_unit(unit *u, const char *dam, boolean physical, boolean magic)
|
||||||
if (get_effect(u, oldpotiontype[P_HEAL]) > 0) {
|
if (get_effect(u, oldpotiontype[P_HEAL]) > 0) {
|
||||||
change_effect(u, oldpotiontype[P_HEAL], -1);
|
change_effect(u, oldpotiontype[P_HEAL], -1);
|
||||||
heiltrank = 1;
|
heiltrank = 1;
|
||||||
} else if (get_potion(u, P_HEAL) > 0) {
|
} else if (i_get(u->items, oldpotiontype[P_HEAL]->itype) > 0) {
|
||||||
i_change(&u->items, oldpotiontype[P_HEAL]->itype, -1);
|
i_change(&u->items, oldpotiontype[P_HEAL]->itype, -1);
|
||||||
change_effect(u, oldpotiontype[P_HEAL], 3);
|
change_effect(u, oldpotiontype[P_HEAL], 3);
|
||||||
heiltrank = 1;
|
heiltrank = 1;
|
||||||
|
|
|
@ -30,11 +30,6 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static weapon_mod wm_catapult[] = {
|
|
||||||
{ 4, WMF_MISSILE_TARGET },
|
|
||||||
{ 0, 0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
static weapon_mod wm_spear[] = {
|
static weapon_mod wm_spear[] = {
|
||||||
{ 1, WMF_SKILL|WMF_RIDING|WMF_AGAINST_ANYONE|WMF_OFFENSIVE },
|
{ 1, WMF_SKILL|WMF_RIDING|WMF_AGAINST_ANYONE|WMF_OFFENSIVE },
|
||||||
{ 1, WMF_SKILL|WMF_WALKING|WMF_AGAINST_RIDING|WMF_DEFENSIVE },
|
{ 1, WMF_SKILL|WMF_WALKING|WMF_AGAINST_RIDING|WMF_DEFENSIVE },
|
||||||
|
@ -48,19 +43,12 @@ static weapon_mod wm_lance[] = {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
WP_EOGSWORD,
|
WP_EOGSWORD,
|
||||||
WP_CATAPULT,
|
|
||||||
WP_SPEAR,
|
WP_SPEAR,
|
||||||
WP_LANCE,
|
WP_LANCE,
|
||||||
WP_NONE,
|
WP_NONE,
|
||||||
WP_MAX
|
WP_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
|
||||||
RL_CATAPULT,
|
|
||||||
RL_MAX,
|
|
||||||
RL_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
/* damage types */
|
/* damage types */
|
||||||
|
|
||||||
#define CUT (1<<0)
|
#define CUT (1<<0)
|
||||||
|
@ -89,17 +77,15 @@ static weapondata weapontable[WP_MAX + 1] =
|
||||||
/* MagRes, Schaden/Fuß, Schaden/Pferd, Item, Skill, OffMod, DefMod,
|
/* MagRes, Schaden/Fuß, Schaden/Pferd, Item, Skill, OffMod, DefMod,
|
||||||
* missile, is_magic */
|
* missile, is_magic */
|
||||||
{
|
{
|
||||||
{0.30, "3d6+10", "3d6+10", I_LAENSWORD, SK_MELEE, 1, 1, false, false, { RL_NONE, 0}, CUT },
|
{0.30, "3d6+10", "3d6+10", I_LAENSWORD, SK_MELEE, 1, 1, false, false, { 0, 0}, CUT },
|
||||||
/* Katapult */
|
|
||||||
{0.00, "3d10+5", "3d10+5", I_CATAPULT, SK_CATAPULT, 0, 0, true, false, { RL_CATAPULT, 5 }, BASH },
|
|
||||||
/* Speer */
|
/* Speer */
|
||||||
{0.00, "1d10+0", "1d12+2", I_SPEAR, SK_SPEAR, 0, 0, false, false, { RL_NONE, 0}, PIERCE },
|
{0.00, "1d10+0", "1d12+2", I_SPEAR, SK_SPEAR, 0, 0, false, false, { 0, 0}, PIERCE },
|
||||||
/* Lanze */
|
/* Lanze */
|
||||||
{0.00, "1d5", "2d6+5", I_LANCE, SK_SPEAR, 0, -2, false, false, { RL_NONE, 0}, PIERCE },
|
{0.00, "1d5", "2d6+5", I_LANCE, SK_SPEAR, 0, -2, false, false, { 0, 0}, PIERCE },
|
||||||
/* Unbewaffnet */
|
/* Unbewaffnet */
|
||||||
{0.00, "1d5+0", "1d6+0", I_WOOD, SK_MELEE, 0, 0, false, false, { RL_NONE, 0}, BASH },
|
{0.00, "1d5+0", "1d6+0", I_WOOD, SK_MELEE, 0, 0, false, false, { 0, 0}, BASH },
|
||||||
/* Dummy */
|
/* Dummy */
|
||||||
{0.00, "0d0+0", "0d0+0", I_WOOD, SK_MELEE, 0, 0, false, false, { RL_NONE, 0}, 0 }
|
{0.00, "0d0+0", "0d0+0", I_WOOD, SK_MELEE, 0, 0, false, false, { 0, 0}, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
weapon_type * oldweapontype[WP_MAX];
|
weapon_type * oldweapontype[WP_MAX];
|
||||||
|
@ -236,10 +222,6 @@ init_oldweapons(void)
|
||||||
case WP_LANCE:
|
case WP_LANCE:
|
||||||
modifiers = wm_lance;
|
modifiers = wm_lance;
|
||||||
break;
|
break;
|
||||||
case WP_CATAPULT:
|
|
||||||
modifiers = wm_catapult;
|
|
||||||
attack = attack_catapult;
|
|
||||||
break;
|
|
||||||
case WP_SPEAR:
|
case WP_SPEAR:
|
||||||
modifiers = wm_spear;
|
modifiers = wm_spear;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1708,7 +1708,7 @@ attack_message(const troop at, const troop dt, const weapon * wp, int dist)
|
||||||
return smallbuf;
|
return smallbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dist > 1 || wp->type->itype == olditemtype[I_CATAPULT]) {
|
if (dist > 1 || wp->type->missile) {
|
||||||
sprintf(smallbuf, "%s schießt mit %s auf %s",
|
sprintf(smallbuf, "%s schießt mit %s auf %s",
|
||||||
a_unit,
|
a_unit,
|
||||||
locale_string(default_locale, resourcename(wp->type->itype->rtype, GR_INDEFINITE_ARTICLE)), d_unit);
|
locale_string(default_locale, resourcename(wp->type->itype->rtype, GR_INDEFINITE_ARTICLE)), d_unit);
|
||||||
|
|
|
@ -197,10 +197,12 @@ siege_cmd(unit * u, order * ord)
|
||||||
static boolean init = false;
|
static boolean init = false;
|
||||||
static const curse_type * magicwalls_ct;
|
static const curse_type * magicwalls_ct;
|
||||||
static item_type * it_catapultammo = NULL;
|
static item_type * it_catapultammo = NULL;
|
||||||
|
static item_type * it_catapult = NULL;
|
||||||
if (!init) {
|
if (!init) {
|
||||||
init = true;
|
init = true;
|
||||||
magicwalls_ct = ct_find("magicwalls");
|
magicwalls_ct = ct_find("magicwalls");
|
||||||
it_catapultammo = it_find("catapultammo");
|
it_catapultammo = it_find("catapultammo");
|
||||||
|
it_catapult = it_find("catapult");
|
||||||
}
|
}
|
||||||
/* gibt es ueberhaupt Burgen? */
|
/* gibt es ueberhaupt Burgen? */
|
||||||
|
|
||||||
|
@ -220,8 +222,8 @@ siege_cmd(unit * u, order * ord)
|
||||||
}
|
}
|
||||||
/* schaden durch katapulte */
|
/* schaden durch katapulte */
|
||||||
|
|
||||||
d = min(u->number,
|
d = min(u->number, i_get(u->items, it_catapult));
|
||||||
min(get_pooled(u, it_catapultammo->rtype, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK), get_item(u, I_CATAPULT)));
|
d = min(get_pooled(u, it_catapultammo->rtype, GET_DEFAULT), d);
|
||||||
if (eff_skill(u, SK_CATAPULT, r) >= 1) {
|
if (eff_skill(u, SK_CATAPULT, r) >= 1) {
|
||||||
katapultiere = d;
|
katapultiere = d;
|
||||||
d *= eff_skill(u, SK_CATAPULT, r);
|
d *= eff_skill(u, SK_CATAPULT, r);
|
||||||
|
|
|
@ -47,7 +47,6 @@ extern "C" {
|
||||||
#define skill_t short
|
#define skill_t short
|
||||||
#define typ_t short
|
#define typ_t short
|
||||||
#define herb_t short
|
#define herb_t short
|
||||||
#define potion_t short
|
|
||||||
#define luxury_t short
|
#define luxury_t short
|
||||||
#define weapon_t short
|
#define weapon_t short
|
||||||
#define item_t short
|
#define item_t short
|
||||||
|
|
|
@ -625,31 +625,6 @@ set_item(unit * u, item_t it, int value)
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
change_item(unit * u, item_t it, int value)
|
|
||||||
{
|
|
||||||
const item_type * type = olditemtype[it];
|
|
||||||
item * i = *i_find(&u->items, type);
|
|
||||||
if (!i) {
|
|
||||||
if (!value) return 0;
|
|
||||||
assert(value>0);
|
|
||||||
i = i_add(&u->items, i_new(type, value));
|
|
||||||
} else {
|
|
||||||
i->number += value;
|
|
||||||
}
|
|
||||||
return i->number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** alte potions ***/
|
|
||||||
|
|
||||||
int
|
|
||||||
get_potion(const unit * u, potion_t p)
|
|
||||||
{
|
|
||||||
const item_type * type = oldpotiontype[p]->itype;
|
|
||||||
item * it = *i_find((item**)&u->items, type);
|
|
||||||
return it?it->number:0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void use_birthdayamulet(region * r, unit * magician, int amount, struct order * ord);
|
void use_birthdayamulet(region * r, unit * magician, int amount, struct order * ord);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -718,10 +693,6 @@ static t_item itemdata[MAXITEMS] = {
|
||||||
{"Wagen", "Wagen", "Wagen", "Wagen"},
|
{"Wagen", "Wagen", "Wagen", "Wagen"},
|
||||||
IS_PRODUCT, SK_CARTMAKER, 1, {0, 5, 0, 0, 0, 0}, 4000, 0, FL_ITEM_NOTINBAG, NULL
|
IS_PRODUCT, SK_CARTMAKER, 1, {0, 5, 0, 0, 0, 0}, 4000, 0, FL_ITEM_NOTINBAG, NULL
|
||||||
},
|
},
|
||||||
{ /* I_CATAPULT */
|
|
||||||
{"Katapult", "Katapulte", "Katapult", "Katapulte"},
|
|
||||||
IS_PRODUCT, SK_CARTMAKER, 5, {0, 10, 0, 0, 0, 0}, 10000, 0, FL_ITEM_NOTINBAG, NULL
|
|
||||||
},
|
|
||||||
{ /* I_SPEAR */
|
{ /* I_SPEAR */
|
||||||
{"Speer", "Speere", "Speer", "Speere"},
|
{"Speer", "Speere", "Speer", "Speere"},
|
||||||
IS_PRODUCT, SK_WEAPONSMITH, 2, {0, 1, 0, 0, 0, 0}, 100, 0, 0, NULL
|
IS_PRODUCT, SK_WEAPONSMITH, 2, {0, 1, 0, 0, 0, 0}, 100, 0, 0, NULL
|
||||||
|
@ -1354,7 +1325,7 @@ init_oldpotions(void)
|
||||||
"p0", "goliathwater", "p2", "p3", "p4", "peasantblood", "p6",
|
"p0", "goliathwater", "p2", "p3", "p4", "peasantblood", "p6",
|
||||||
"p7", "nestwarmth", "p9", "p10", "p11", "truthpotion", "p13", "p14"
|
"p7", "nestwarmth", "p9", "p10", "p11", "truthpotion", "p13", "p14"
|
||||||
};
|
};
|
||||||
potion_t p;
|
int p;
|
||||||
|
|
||||||
for (p=0;p!=MAXPOTIONS;++p) {
|
for (p=0;p!=MAXPOTIONS;++p) {
|
||||||
item_type * itype = it_find(potionnames[p]);
|
item_type * itype = it_find(potionnames[p]);
|
||||||
|
|
|
@ -262,7 +262,6 @@ enum {
|
||||||
I_STONE,
|
I_STONE,
|
||||||
I_HORSE,
|
I_HORSE,
|
||||||
I_WAGON,
|
I_WAGON,
|
||||||
I_CATAPULT,
|
|
||||||
I_SPEAR,
|
I_SPEAR,
|
||||||
/* alte Artefakte */
|
/* alte Artefakte */
|
||||||
I_AMULET_OF_HEALING,
|
I_AMULET_OF_HEALING,
|
||||||
|
@ -301,7 +300,6 @@ enum {
|
||||||
R_STONE,
|
R_STONE,
|
||||||
R_HORSE,
|
R_HORSE,
|
||||||
R_WAGON,
|
R_WAGON,
|
||||||
R_CATAPULT,
|
|
||||||
R_SPEAR,
|
R_SPEAR,
|
||||||
/**/
|
/**/
|
||||||
R_AMULET_OF_HEALING,
|
R_AMULET_OF_HEALING,
|
||||||
|
@ -346,9 +344,6 @@ extern struct resource_type * oldresourcetype[];
|
||||||
|
|
||||||
int get_item(const struct unit *, item_t);
|
int get_item(const struct unit *, item_t);
|
||||||
int set_item(struct unit *, item_t, int);
|
int set_item(struct unit *, item_t, int);
|
||||||
int change_item(struct unit *, item_t, int);
|
|
||||||
|
|
||||||
int get_potion(const struct unit *, potion_t);
|
|
||||||
|
|
||||||
int get_money(const struct unit *);
|
int get_money(const struct unit *);
|
||||||
int set_money(struct unit *, int);
|
int set_money(struct unit *, int);
|
||||||
|
|
|
@ -706,7 +706,7 @@ gm_addquest(const char * email, const char * name, short radius, unsigned int fl
|
||||||
|
|
||||||
a_add((attrib**)&a->data.v, make_atgmcreate(resource2item(r_silver)));
|
a_add((attrib**)&a->data.v, make_atgmcreate(resource2item(r_silver)));
|
||||||
|
|
||||||
for (i=0;i<=I_SPEAR;++i) {
|
for (i=0;i<=I_WAGON;++i) {
|
||||||
a_add((attrib**)&a->data.v, make_atgmcreate(olditemtype[i]));
|
a_add((attrib**)&a->data.v, make_atgmcreate(olditemtype[i]));
|
||||||
}
|
}
|
||||||
for (i=I_LAENSWORD;i!=I_DRACHENBLUT;++i) {
|
for (i=I_LAENSWORD;i!=I_DRACHENBLUT;++i) {
|
||||||
|
@ -771,7 +771,7 @@ gm_addfaction(const char * email, plane * p, region * r)
|
||||||
|
|
||||||
a_add((attrib**)&a->data.v, make_atgmcreate(resource2item(r_silver)));
|
a_add((attrib**)&a->data.v, make_atgmcreate(resource2item(r_silver)));
|
||||||
|
|
||||||
for (i=0;i<=I_SPEAR;++i) {
|
for (i=0;i<=I_WAGON;++i) {
|
||||||
a_add((attrib**)&a->data.v, make_atgmcreate(olditemtype[i]));
|
a_add((attrib**)&a->data.v, make_atgmcreate(olditemtype[i]));
|
||||||
}
|
}
|
||||||
for (i=I_LAENSWORD;i!=I_DRACHENBLUT;++i) {
|
for (i=I_LAENSWORD;i!=I_DRACHENBLUT;++i) {
|
||||||
|
|
|
@ -559,7 +559,7 @@ update_gmquests(void)
|
||||||
faction * f = findfaction(atoi36("gm04"));
|
faction * f = findfaction(atoi36("gm04"));
|
||||||
if (f) {
|
if (f) {
|
||||||
unit * u = f->units;
|
unit * u = f->units;
|
||||||
potion_t p;
|
int p;
|
||||||
attrib * permissions = a_find(f->attribs, &at_permissions);
|
attrib * permissions = a_find(f->attribs, &at_permissions);
|
||||||
|
|
||||||
if (u!=NULL) {
|
if (u!=NULL) {
|
||||||
|
|
|
@ -43,14 +43,14 @@ lc_age(struct attrib * a)
|
||||||
if (fname==NULL) return -1;
|
if (fname==NULL) return -1;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
luabind::object globals = luabind::get_globals(L);
|
luabind::object globals = luabind::globals(L);
|
||||||
luabind::object fun = globals.at(fname);
|
luabind::object fun = globals[fname];
|
||||||
if (!fun.is_valid()) {
|
if (!fun.is_valid()) {
|
||||||
log_error(("Could not index function %s\n", fname));
|
log_error(("Could not index function %s\n", fname));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (fun.type()!=LUA_TFUNCTION) {
|
if (type(fun)!=LUA_TFUNCTION) {
|
||||||
log_error(("Lua global object %s is not a function, type is %u\n", fname, fun.type()));
|
log_error(("Lua global object %s is not a function, type is %u\n", fname, type(fun)));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,11 +159,11 @@ lua_planmonsters(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
race_setscript(const char * rcname, const functor<void>& f)
|
race_setscript(const char * rcname, const luabind::object& f)
|
||||||
{
|
{
|
||||||
race * rc = rc_find(rcname);
|
race * rc = rc_find(rcname);
|
||||||
if (rc!=NULL) {
|
if (rc!=NULL) {
|
||||||
luabind::functor<void> * fptr = new luabind::functor<void>(f);
|
luabind::object * fptr = new luabind::object(f);
|
||||||
setscript(&rc->attribs, fptr);
|
setscript(&rc->attribs, fptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,8 @@ lua_useitem(struct unit * u, const struct item_type * itype,
|
||||||
strcat(strcpy(fname, iname), "_use");
|
strcat(strcpy(fname, iname), "_use");
|
||||||
|
|
||||||
{
|
{
|
||||||
luabind::object globals = luabind::get_globals(L);
|
luabind::object globals = luabind::globals(L);
|
||||||
if (globals.at(fname).type()!=LUA_TFUNCTION) return -1;
|
if (type(globals[fname])!=LUA_TFUNCTION) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = luabind::call_function<int>(L, fname, *u, amount);
|
retval = luabind::call_function<int>(L, fname, *u, amount);
|
||||||
|
|
|
@ -37,7 +37,7 @@ static lua_State * luaState;
|
||||||
static void
|
static void
|
||||||
free_script(attrib * a) {
|
free_script(attrib * a) {
|
||||||
if (a->data.v!=NULL) {
|
if (a->data.v!=NULL) {
|
||||||
luabind::functor<void> * f = (luabind::functor<void> *)a->data.v;
|
luabind::object * f = (luabind::object *)a->data.v;
|
||||||
delete f;
|
delete f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ call_script(struct unit * u)
|
||||||
const attrib * a = a_findc(u->attribs, &at_script);
|
const attrib * a = a_findc(u->attribs, &at_script);
|
||||||
if (a==NULL) a = a_findc(u->race->attribs, &at_script);
|
if (a==NULL) a = a_findc(u->race->attribs, &at_script);
|
||||||
if (a!=NULL && a->data.v!=NULL) {
|
if (a!=NULL && a->data.v!=NULL) {
|
||||||
luabind::functor<void> * func = (luabind::functor<void> *)a->data.v;
|
luabind::object * func = (luabind::object *)a->data.v;
|
||||||
try {
|
try {
|
||||||
func->operator()(u);
|
func->operator()(u);
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ setscript(struct attrib ** ap, void * fptr)
|
||||||
if (a == NULL) {
|
if (a == NULL) {
|
||||||
a = a_add(ap, a_new(&at_script));
|
a = a_add(ap, a_new(&at_script));
|
||||||
} else if (a->data.v!=NULL) {
|
} else if (a->data.v!=NULL) {
|
||||||
luabind::functor<void> * f = (luabind::functor<void> *)a->data.v;
|
luabind::object * f = (luabind::object *)a->data.v;
|
||||||
delete f;
|
delete f;
|
||||||
}
|
}
|
||||||
a->data.v = fptr;
|
a->data.v = fptr;
|
||||||
|
@ -116,11 +116,11 @@ lua_useitem(struct unit * u, const struct item_type * itype, int amount, struct
|
||||||
char fname[64];
|
char fname[64];
|
||||||
snprintf(fname, sizeof(fname), "use_%s", itype->rtype->_name[0]);
|
snprintf(fname, sizeof(fname), "use_%s", itype->rtype->_name[0]);
|
||||||
|
|
||||||
luabind::object globals = luabind::get_globals(luaState);
|
luabind::object globals = luabind::globals(luaState);
|
||||||
luabind::object fun = globals.at(fname);
|
luabind::object fun = globals[fname];
|
||||||
if (fun.is_valid()) {
|
if (fun.is_valid()) {
|
||||||
if (fun.type()!=LUA_TFUNCTION) {
|
if (luabind::type(fun)!=LUA_TFUNCTION) {
|
||||||
log_warning(("Lua global object %s is not a function, type is %u\n", fname, fun.type()));
|
log_warning(("Lua global object %s is not a function, type is %u\n", fname, luabind::type(fun)));
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
retval = luabind::call_function<int>(luaState, fname, u, amount);
|
retval = luabind::call_function<int>(luaState, fname, u, amount);
|
||||||
|
@ -145,11 +145,11 @@ lua_initfamiliar(unit * u)
|
||||||
char fname[64];
|
char fname[64];
|
||||||
snprintf(fname, sizeof(fname), "initfamiliar_%s", u->race->_name[0]);
|
snprintf(fname, sizeof(fname), "initfamiliar_%s", u->race->_name[0]);
|
||||||
|
|
||||||
luabind::object globals = luabind::get_globals(luaState);
|
luabind::object globals = luabind::globals(luaState);
|
||||||
luabind::object fun = globals.at(fname);
|
luabind::object fun = globals[fname];
|
||||||
if (fun.is_valid()) {
|
if (fun.is_valid()) {
|
||||||
if (fun.type()!=LUA_TFUNCTION) {
|
if (luabind::type(fun)!=LUA_TFUNCTION) {
|
||||||
log_warning(("Lua global object %s is not a function, type is %u\n", fname, fun.type()));
|
log_warning(("Lua global object %s is not a function, type is %u\n", fname, luabind::type(fun)));
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
luabind::call_function<int>(luaState, fname, u);
|
luabind::call_function<int>(luaState, fname, u);
|
||||||
|
@ -176,11 +176,11 @@ lua_changeresource(unit * u, const struct resource_type * rtype, int delta)
|
||||||
snprintf(fname, sizeof(fname), "%s_changeresource", rtype->_name[0]);
|
snprintf(fname, sizeof(fname), "%s_changeresource", rtype->_name[0]);
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
||||||
luabind::object globals = luabind::get_globals(luaState);
|
luabind::object globals = luabind::globals(luaState);
|
||||||
luabind::object fun = globals.at(fname);
|
luabind::object fun = globals[fname];
|
||||||
if (fun.is_valid()) {
|
if (fun.is_valid()) {
|
||||||
if (fun.type()!=LUA_TFUNCTION) {
|
if (luabind::type(fun)!=LUA_TFUNCTION) {
|
||||||
log_warning(("Lua global object %s is not a function, type is %u\n", fname, fun.type()));
|
log_warning(("Lua global object %s is not a function, type is %u\n", fname, luabind::type(fun)));
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
retval = luabind::call_function<int>(luaState, fname, u, delta);
|
retval = luabind::call_function<int>(luaState, fname, u, delta);
|
||||||
|
@ -206,11 +206,11 @@ lua_getresource(unit * u, const struct resource_type * rtype)
|
||||||
snprintf(fname, sizeof(fname), "%s_getresource", rtype->_name[0]);
|
snprintf(fname, sizeof(fname), "%s_getresource", rtype->_name[0]);
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
|
|
||||||
luabind::object globals = luabind::get_globals(luaState);
|
luabind::object globals = luabind::globals(luaState);
|
||||||
luabind::object fun = globals.at(fname);
|
luabind::object fun = globals[fname];
|
||||||
if (fun.is_valid()) {
|
if (fun.is_valid()) {
|
||||||
if (fun.type()!=LUA_TFUNCTION) {
|
if (luabind::type(fun)!=LUA_TFUNCTION) {
|
||||||
log_warning(("Lua global object %s is not a function, type is %u\n", fname, fun.type()));
|
log_warning(("Lua global object %s is not a function, type is %u\n", fname, luabind::type(fun)));
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
retval = luabind::call_function<int>(luaState, fname, u);
|
retval = luabind::call_function<int>(luaState, fname, u);
|
||||||
|
|
|
@ -429,9 +429,9 @@ unit_clearorders(unit& u)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_setscript(struct unit& u, const functor<void>& f)
|
unit_setscript(struct unit& u, const luabind::object& f)
|
||||||
{
|
{
|
||||||
luabind::functor<void> * fptr = new luabind::functor<void>(f);
|
luabind::object * fptr = new luabind::object(f);
|
||||||
setscript(&u.attribs, fptr);
|
setscript(&u.attribs, fptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,7 +443,7 @@ unit_weight(const struct unit& u)
|
||||||
|
|
||||||
typedef struct fctr_data {
|
typedef struct fctr_data {
|
||||||
unit * target;
|
unit * target;
|
||||||
luabind::functor<void> * fptr;
|
luabind::object * fptr;
|
||||||
} fctr_data;
|
} fctr_data;
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
@ -489,9 +489,9 @@ static struct trigger_type tt_functor = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static trigger *
|
static trigger *
|
||||||
trigger_functor(struct unit& u, const functor<void>& f)
|
trigger_functor(struct unit& u, const object& f)
|
||||||
{
|
{
|
||||||
luabind::functor<void> * fptr = new luabind::functor<void>(f);
|
luabind::object * fptr = new luabind::object(f);
|
||||||
trigger * t = t_new(&tt_functor);
|
trigger * t = t_new(&tt_functor);
|
||||||
fctr_data * td = (fctr_data*)t->data.v;
|
fctr_data * td = (fctr_data*)t->data.v;
|
||||||
td->target = &u;
|
td->target = &u;
|
||||||
|
@ -500,7 +500,7 @@ trigger_functor(struct unit& u, const functor<void>& f)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unit_addhandler(struct unit& u, const char * event, const functor<void>& f)
|
unit_addhandler(struct unit& u, const char * event, const object& f)
|
||||||
{
|
{
|
||||||
add_trigger(&u.attribs, event, trigger_functor(u, f));
|
add_trigger(&u.attribs, event, trigger_functor(u, f));
|
||||||
}
|
}
|
||||||
|
|
|
@ -487,14 +487,14 @@ usage(const char * prog, const char * arg)
|
||||||
static void
|
static void
|
||||||
setLuaString(lua_State * luaState, const char * name, const char * value)
|
setLuaString(lua_State * luaState, const char * name, const char * value)
|
||||||
{
|
{
|
||||||
luabind::object globals = luabind::get_globals(luaState);
|
luabind::object globals = luabind::globals(luaState);
|
||||||
globals[name] = value;
|
globals[name] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setLuaNumber(lua_State * luaState, const char * name, double value)
|
setLuaNumber(lua_State * luaState, const char * name, double value)
|
||||||
{
|
{
|
||||||
luabind::object globals = luabind::get_globals(luaState);
|
luabind::object globals = luabind::globals(luaState);
|
||||||
globals[name] = value;
|
globals[name] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ give_latestart_bonus(region *r, unit *u, int b)
|
||||||
unit *u2 = createunit(r, u->faction, 2*b, u->race);
|
unit *u2 = createunit(r, u->faction, 2*b, u->race);
|
||||||
change_level(u2, SK_SPEAR, 3);
|
change_level(u2, SK_SPEAR, 3);
|
||||||
change_level(u2, SK_TAXING, 3);
|
change_level(u2, SK_TAXING, 3);
|
||||||
change_item(u2, I_SPEAR, u2->number);
|
i_change(&u2->items, olditemtype[I_SPEAR], u2->number);
|
||||||
u2->irace = u->irace;
|
u2->irace = u->irace;
|
||||||
/* fset(u2, UFL_PARTEITARNUNG); */
|
/* fset(u2, UFL_PARTEITARNUNG); */
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,6 +236,20 @@
|
||||||
</item>
|
</item>
|
||||||
</resource>
|
</resource>
|
||||||
|
|
||||||
|
<resource name="catapult">
|
||||||
|
<item weight="4000">
|
||||||
|
<construction skill="cartmaking" minskill="1" reqsize="1">
|
||||||
|
<requirement type="log" quantity="5"/>
|
||||||
|
</construction>
|
||||||
|
<weapon bash="true" missile="true" skill="catapult" offmod="0" defmod="0" reload="5">
|
||||||
|
<damage type="rider" value="3d10+5"/>
|
||||||
|
<damage type="footman" value="3d10+5"/>
|
||||||
|
<modifier type="missile_target" value="4"/>
|
||||||
|
<function name="attack" value="attack_catapult"/>
|
||||||
|
</weapon>
|
||||||
|
</item>
|
||||||
|
</resource>
|
||||||
|
|
||||||
<resource name="crossbow">
|
<resource name="crossbow">
|
||||||
<item weight="100">
|
<item weight="100">
|
||||||
<construction skill="weaponsmithing" minskill="3" reqsize="1">
|
<construction skill="weaponsmithing" minskill="3" reqsize="1">
|
||||||
|
|
Loading…
Reference in New Issue