HELFE-Status kann von Skripten aus gesetzt, Magier von Skripten aus erzeugt und Aura gesetzt werden.

This commit is contained in:
Enno Rehling 2004-05-29 23:50:39 +00:00
parent 3e3e79d6e5
commit be37935a5c
5 changed files with 1539 additions and 1407 deletions

View File

@ -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
boolean
is_enemy(const struct faction * f, const struct faction * enemy)

View File

@ -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 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
extern boolean is_enemy(const struct faction * f, const struct faction * enemy);
extern void add_enemy(struct faction * f, struct faction * enemy);

View File

@ -82,6 +82,48 @@ operator==(const faction& a, const faction&b)
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
bind_faction(lua_State * L)
{
@ -93,6 +135,8 @@ bind_faction(lua_State * L)
class_<struct faction>("faction")
.def(tostring(self))
.def(self == faction())
.def("set_policy", &faction_setpolicy)
.def("get_policy", &faction_getpolicy)
.def_readonly("name", &faction::name)
.def_readonly("password", &faction::passw)
.def_readonly("email", &faction::email)

View File

@ -234,6 +234,39 @@ operator==(const unit& a, const unit&b)
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
bind_unit(lua_State * L)
{
@ -256,6 +289,8 @@ bind_unit(lua_State * L)
.def("set_racename", &unit_setracename)
.def("add_spell", &unit_addspell)
.def("remove_spell", &unit_removespell)
.property("circle", &unit_getmagic, &unit_setmagic)
.property("aura", &unit_getaura, &unit_setaura)
.property("region", &unit_getregion, &unit_setregion)
.property("is_familiar", &unit_isfamiliar)
.property("spells", &unit_spells, return_stl_iterator)

View File

@ -1409,4 +1409,22 @@
<attack type="2" damage="1d30"/>
</race>
<race name="skeletal_wyrm" magres="0.900000" maxaura="1.000000" regaura="3.000000" recruitcost="250000" maintenance="0" weight="180000" capacity="100000" speed="1.000000" hp="2700" ac="8" damage="2d60" unarmedattack="0" unarmeddefense="0" attackmodifier="10" defensemodifier="10" scarepeasants="yes" fly="yes" walk="yes" teach="no" getitem="yes" canguard="yes" resistbash="yes">
<ai splitsize="1" killpeasants="yes" attackrandom="yes" learn="yes"/>
<function name="name" value="namedragon"/>
<function name="move" value="movedragon"/>
<function name="itemdrop" value="dragondrops"/>
<skill name="sk_magic" modifier="12"/>
<skill name="sk_tactics" modifier="12"/>
<skill name="sk_perception" modifier="10"/>
<attack type="4" damage="3d20"/>
<attack type="4" damage="3d20"/>
<attack type="4" damage="3d20"/>
<attack type="4" damage="3d20"/>
<attack type="4" damage="5d30"/>
<attack type="4" damage="3d20"/>
<attack type="6" spell="83"/>
<attack type="6" spell="83"/>
</race>
</races>