forked from github/server
HELFE-Status kann von Skripten aus gesetzt, Magier von Skripten aus erzeugt und Aura gesetzt werden.
This commit is contained in:
parent
3e3e79d6e5
commit
be37935a5c
|
@ -306,6 +306,38 @@ destroyfaction(faction * f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
get_alliance(const faction * a, const faction * b)
|
||||||
|
{
|
||||||
|
const ally * sf = a->allies;
|
||||||
|
for (;sf!=NULL;sf=sf->next) {
|
||||||
|
if (sf->faction==b) {
|
||||||
|
return sf->status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
set_alliance(faction * a, faction * b, int status)
|
||||||
|
{
|
||||||
|
ally ** sfp;
|
||||||
|
sfp = &a->allies;
|
||||||
|
while (*sfp) {
|
||||||
|
ally * sf = *sfp;
|
||||||
|
if (sf->faction==b) break;
|
||||||
|
sfp = &sf->next;
|
||||||
|
}
|
||||||
|
if (*sfp==NULL) {
|
||||||
|
ally * sf = *sfp = malloc(sizeof(ally));
|
||||||
|
sf->next = NULL;
|
||||||
|
sf->status = status;
|
||||||
|
sf->faction = b;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
(*sfp)->status |= status;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef REGIONOWNERS
|
#ifdef REGIONOWNERS
|
||||||
boolean
|
boolean
|
||||||
is_enemy(const struct faction * f, const struct faction * enemy)
|
is_enemy(const struct faction * f, const struct faction * enemy)
|
||||||
|
|
|
@ -116,6 +116,9 @@ extern struct faction * addfaction(const char *email, const char* password,
|
||||||
extern boolean checkpasswd(const faction * f, const char * passwd, boolean shortp);
|
extern boolean checkpasswd(const faction * f, const char * passwd, boolean shortp);
|
||||||
extern void destroyfaction(faction * f);
|
extern void destroyfaction(faction * f);
|
||||||
|
|
||||||
|
extern void set_alliance(struct faction * a, struct faction * b, int status);
|
||||||
|
extern int get_alliance(const struct faction * a, const struct faction * b);
|
||||||
|
|
||||||
#ifdef REGIONOWNERS
|
#ifdef REGIONOWNERS
|
||||||
extern boolean is_enemy(const struct faction * f, const struct faction * enemy);
|
extern boolean is_enemy(const struct faction * f, const struct faction * enemy);
|
||||||
extern void add_enemy(struct faction * f, struct faction * enemy);
|
extern void add_enemy(struct faction * f, struct faction * enemy);
|
||||||
|
|
|
@ -82,6 +82,48 @@ operator==(const faction& a, const faction&b)
|
||||||
return a.no==b.no;
|
return a.no==b.no;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct helpmode {
|
||||||
|
const char * name;
|
||||||
|
int status;
|
||||||
|
} helpmodes[] = {
|
||||||
|
{ "money", HELP_MONEY },
|
||||||
|
{ "fight", HELP_FIGHT },
|
||||||
|
{ "observe", HELP_OBSERVE },
|
||||||
|
{ "give", HELP_GIVE },
|
||||||
|
{ "guard", HELP_GUARD },
|
||||||
|
{ "stealth", HELP_FSTEALTH },
|
||||||
|
{ "travel", HELP_TRAVEL },
|
||||||
|
{ "all", HELP_ALL },
|
||||||
|
{ NULL, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
faction_getpolicy(const faction& a, const faction& b, const char * flag)
|
||||||
|
{
|
||||||
|
int mode;
|
||||||
|
|
||||||
|
for (mode=0;helpmodes[mode].name!=NULL;++mode) {
|
||||||
|
if (strcmp(flag, helpmodes[mode].name)==0) {
|
||||||
|
return get_alliance(&a, &b) & mode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
faction_setpolicy(faction& a, faction& b, const char * flag, boolean value)
|
||||||
|
{
|
||||||
|
int mode;
|
||||||
|
|
||||||
|
for (mode=0;helpmodes[mode].name!=NULL;++mode) {
|
||||||
|
if (strcmp(flag, helpmodes[mode].name)==0) {
|
||||||
|
if (value) set_alliance(&a, &b, get_alliance(&a, &b) | mode);
|
||||||
|
else set_alliance(&a, &b, get_alliance(&a, &b) & ~mode);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
bind_faction(lua_State * L)
|
bind_faction(lua_State * L)
|
||||||
{
|
{
|
||||||
|
@ -93,6 +135,8 @@ bind_faction(lua_State * L)
|
||||||
class_<struct faction>("faction")
|
class_<struct faction>("faction")
|
||||||
.def(tostring(self))
|
.def(tostring(self))
|
||||||
.def(self == faction())
|
.def(self == faction())
|
||||||
|
.def("set_policy", &faction_setpolicy)
|
||||||
|
.def("get_policy", &faction_getpolicy)
|
||||||
.def_readonly("name", &faction::name)
|
.def_readonly("name", &faction::name)
|
||||||
.def_readonly("password", &faction::passw)
|
.def_readonly("password", &faction::passw)
|
||||||
.def_readonly("email", &faction::email)
|
.def_readonly("email", &faction::email)
|
||||||
|
|
|
@ -234,6 +234,39 @@ operator==(const unit& a, const unit&b)
|
||||||
return a.no==b.no;
|
return a.no==b.no;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
unit_getaura(const unit& u)
|
||||||
|
{
|
||||||
|
return get_spellpoints(&u);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
unit_setaura(unit& u, int points)
|
||||||
|
{
|
||||||
|
return set_spellpoints(&u, points);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
unit_getmagic(const unit& u)
|
||||||
|
{
|
||||||
|
sc_mage * mage = get_mage(&u);
|
||||||
|
return mage?magietypen[mage->magietyp]:NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
unit_setmagic(unit& u, const char * type)
|
||||||
|
{
|
||||||
|
sc_mage * mage = get_mage(&u);
|
||||||
|
magic_t mtype;
|
||||||
|
for (mtype=0;mtype!=MAXMAGIETYP;++mtype) {
|
||||||
|
if (strcmp(magietypen[mtype], type)==0) break;
|
||||||
|
}
|
||||||
|
if (mtype==MAXMAGIETYP) return;
|
||||||
|
if (mage==NULL) {
|
||||||
|
mage = create_mage(&u, mtype);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
bind_unit(lua_State * L)
|
bind_unit(lua_State * L)
|
||||||
{
|
{
|
||||||
|
@ -256,6 +289,8 @@ bind_unit(lua_State * L)
|
||||||
.def("set_racename", &unit_setracename)
|
.def("set_racename", &unit_setracename)
|
||||||
.def("add_spell", &unit_addspell)
|
.def("add_spell", &unit_addspell)
|
||||||
.def("remove_spell", &unit_removespell)
|
.def("remove_spell", &unit_removespell)
|
||||||
|
.property("circle", &unit_getmagic, &unit_setmagic)
|
||||||
|
.property("aura", &unit_getaura, &unit_setaura)
|
||||||
.property("region", &unit_getregion, &unit_setregion)
|
.property("region", &unit_getregion, &unit_setregion)
|
||||||
.property("is_familiar", &unit_isfamiliar)
|
.property("is_familiar", &unit_isfamiliar)
|
||||||
.property("spells", &unit_spells, return_stl_iterator)
|
.property("spells", &unit_spells, return_stl_iterator)
|
||||||
|
|
2832
src/res/races.xml
2832
src/res/races.xml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue