forked from github/server
"Zauberpatzer - Effektmeldung" - fixed positive message should be negative - fixed ct_find - fixed a few places not checking u->number or u->region - speeding up pool when units have no items.
This commit is contained in:
parent
f54037295a
commit
7cb18e90ea
11 changed files with 81 additions and 49 deletions
|
@ -208,6 +208,38 @@ setwere_cmd(unit *u, struct order * ord)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
set_factionstealth(unit * u, faction * f)
|
||||||
|
{
|
||||||
|
region * lastr = NULL;
|
||||||
|
/* for all units mu of our faction, check all the units in the region
|
||||||
|
* they are in, if their visible faction is f, it's ok. use lastr to
|
||||||
|
* avoid testing the same region twice in a row. */
|
||||||
|
unit * mu = u->faction->units;
|
||||||
|
while (mu!=NULL) {
|
||||||
|
if (mu->number && mu->region!=lastr) {
|
||||||
|
unit * ru = mu->region->units;
|
||||||
|
lastr = mu->region;
|
||||||
|
while (ru!=NULL) {
|
||||||
|
if (ru->number) {
|
||||||
|
faction * fv = visible_faction(f, ru);
|
||||||
|
if (fv==f) {
|
||||||
|
if (cansee(f, lastr, ru, 0)) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ru = ru->next;
|
||||||
|
}
|
||||||
|
if (ru!=NULL) break;
|
||||||
|
}
|
||||||
|
mu = mu->nextF;
|
||||||
|
}
|
||||||
|
if (mu!=NULL) {
|
||||||
|
attrib * a = a_find(u->attribs, &at_otherfaction);
|
||||||
|
if (!a) a = a_add(&u->attribs, make_otherfaction(f));
|
||||||
|
else a->data.v = f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
setstealth_cmd(unit * u, struct order * ord)
|
setstealth_cmd(unit * u, struct order * ord)
|
||||||
{
|
{
|
||||||
|
@ -281,34 +313,10 @@ setstealth_cmd(unit * u, struct order * ord)
|
||||||
a_removeall(&u->attribs, &at_otherfaction);
|
a_removeall(&u->attribs, &at_otherfaction);
|
||||||
} else {
|
} else {
|
||||||
struct faction * f = findfaction(nr);
|
struct faction * f = findfaction(nr);
|
||||||
if(f==NULL) {
|
if (f==NULL) {
|
||||||
cmistake(u, ord, 66, MSG_EVENT);
|
cmistake(u, ord, 66, MSG_EVENT);
|
||||||
} else {
|
} else {
|
||||||
region * lastr = NULL;
|
set_factionstealth(u, f);
|
||||||
/* for all units mu of our faction, check all the units in the region
|
|
||||||
* they are in, if their visible faction is f, it's ok. use lastr to
|
|
||||||
* avoid testing the same region twice in a row. */
|
|
||||||
unit * mu = u->faction->units;
|
|
||||||
while (mu!=NULL) {
|
|
||||||
unit * ru = mu->region->units;
|
|
||||||
if (mu->region!=lastr) {
|
|
||||||
lastr = mu->region;
|
|
||||||
while (ru!=NULL) {
|
|
||||||
faction * fv = visible_faction(f, ru);
|
|
||||||
if (fv==f) {
|
|
||||||
if (cansee(f, lastr, ru, 0)) break;
|
|
||||||
}
|
|
||||||
ru = ru->next;
|
|
||||||
}
|
|
||||||
if (ru!=NULL) break;
|
|
||||||
}
|
|
||||||
mu = mu->nextF;
|
|
||||||
}
|
|
||||||
if (mu!=NULL) {
|
|
||||||
attrib * a = a_find(u->attribs, &at_otherfaction);
|
|
||||||
if (!a) a = a_add(&u->attribs, make_otherfaction(f));
|
|
||||||
else a->data.v = f;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -311,8 +311,14 @@ ct_find(const char *c)
|
||||||
unsigned int hash = tolower(c[0]);
|
unsigned int hash = tolower(c[0]);
|
||||||
cursetype_list * ctl = cursetypes[hash];
|
cursetype_list * ctl = cursetypes[hash];
|
||||||
while (ctl) {
|
while (ctl) {
|
||||||
size_t k = min(strlen(c), strlen(ctl->type->cname));
|
if (strcmp(c, ctl->type->cname)==0) {
|
||||||
if (!strncasecmp(c, ctl->type->cname, k)) return ctl->type;
|
return ctl->type;
|
||||||
|
} else {
|
||||||
|
size_t k = min(strlen(c), strlen(ctl->type->cname));
|
||||||
|
if (!strncasecmp(c, ctl->type->cname, k)) {
|
||||||
|
return ctl->type;
|
||||||
|
}
|
||||||
|
}
|
||||||
ctl = ctl->next;
|
ctl = ctl->next;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -974,23 +974,25 @@ int
|
||||||
alliedunit(const unit * u, const faction * f2, int mode)
|
alliedunit(const unit * u, const faction * f2, int mode)
|
||||||
{
|
{
|
||||||
ally * sf;
|
ally * sf;
|
||||||
const plane * pl = u->region->planep;
|
|
||||||
int automode;
|
int automode;
|
||||||
|
|
||||||
|
assert(u->region); /* the unit should be in a region, but it's possible that u->number==0 (TEMP units) */
|
||||||
if (u->faction == f2) return mode;
|
if (u->faction == f2) return mode;
|
||||||
if (u->faction == NULL || f2==NULL) return 0;
|
if (u->faction != NULL && f2!=NULL) {
|
||||||
|
plane * pl = u->region->planep;
|
||||||
|
automode = mode & autoalliance(pl, u->faction, f2);
|
||||||
|
|
||||||
automode = mode & autoalliance(pl, u->faction, f2);
|
if (pl!=NULL && (pl->flags & PFL_NOALLIANCES))
|
||||||
|
mode = (mode & automode) | (mode & HELP_GIVE);
|
||||||
|
|
||||||
if (pl!=NULL && (pl->flags & PFL_NOALLIANCES))
|
sf = u->faction->allies;
|
||||||
mode = (mode & automode) | (mode & HELP_GIVE);
|
if (fval(u, UFL_GROUP)) {
|
||||||
|
const attrib * a = a_findc(u->attribs, &at_group);
|
||||||
sf = u->faction->allies;
|
if (a!=NULL) sf = ((group*)a->data.v)->allies;
|
||||||
if (fval(u, UFL_GROUP)) {
|
}
|
||||||
const attrib * a = a_findc(u->attribs, &at_group);
|
return alliedgroup(pl, u->faction, f2, sf, mode);
|
||||||
if (a!=NULL) sf = ((group*)a->data.v)->allies;
|
|
||||||
}
|
}
|
||||||
return alliedgroup(pl, u->faction, f2, sf, mode);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean
|
boolean
|
||||||
|
|
|
@ -1357,7 +1357,7 @@ do_fumble(castorder *co)
|
||||||
/* temporärer Stufenverlust */
|
/* temporärer Stufenverlust */
|
||||||
duration = max(rng_int()%level/2, 2);
|
duration = max(rng_int()%level/2, 2);
|
||||||
effect.i = -(level/2);
|
effect.i = -(level/2);
|
||||||
c = create_curse(u, &u->attribs, ct_find("skill"), (float)level, duration,
|
c = create_curse(u, &u->attribs, ct_find("skillmod"), (float)level, duration,
|
||||||
effect, 1);
|
effect, 1);
|
||||||
c->data.i = SK_MAGIC;
|
c->data.i = SK_MAGIC;
|
||||||
ADDMSG(&u->faction->msgs, msg_message("patzer2", "unit region", u, r));
|
ADDMSG(&u->faction->msgs, msg_message("patzer2", "unit region", u, r));
|
||||||
|
|
|
@ -188,7 +188,7 @@ get_pooled(const unit * u, const resource_type * rtype, unsigned int mode, int c
|
||||||
for (v = r->units; v && use<count; v = v->next) if (u!=v) {
|
for (v = r->units; v && use<count; v = v->next) if (u!=v) {
|
||||||
int mask;
|
int mask;
|
||||||
|
|
||||||
if (u==v) continue;
|
if (v->items==NULL && rtype->uget==NULL) continue;
|
||||||
if ((urace(v)->ec_flags & GIVEITEM) == 0) continue;
|
if ((urace(v)->ec_flags & GIVEITEM) == 0) continue;
|
||||||
|
|
||||||
if (v->faction == f) {
|
if (v->faction == f) {
|
||||||
|
@ -238,6 +238,7 @@ use_pooled(unit * u, const resource_type * rtype, unsigned int mode, int count)
|
||||||
for (v = r->units; use>0 && v!=NULL; v = v->next) if (u!=v) {
|
for (v = r->units; use>0 && v!=NULL; v = v->next) if (u!=v) {
|
||||||
int mask;
|
int mask;
|
||||||
if ((urace(v)->ec_flags & GIVEITEM) == 0) continue;
|
if ((urace(v)->ec_flags & GIVEITEM) == 0) continue;
|
||||||
|
if (v->items==NULL && rtype->uget==NULL) continue;
|
||||||
|
|
||||||
if (v->faction == f) {
|
if (v->faction == f) {
|
||||||
mask = (mode >> 3) & (GET_SLACK|GET_RESERVE);
|
mask = (mode >> 3) & (GET_SLACK|GET_RESERVE);
|
||||||
|
|
|
@ -1211,7 +1211,7 @@ att_modification(const unit *u, skill_t sk)
|
||||||
unit * mage = c->magician;
|
unit * mage = c->magician;
|
||||||
/* wir suchen jeweils den größten Bonus und den größten Malus */
|
/* wir suchen jeweils den größten Bonus und den größten Malus */
|
||||||
if (mod>bonus) {
|
if (mod>bonus) {
|
||||||
if (mage==NULL || alliedunit(mage, u->faction, HELP_GUARD)) {
|
if (mage==NULL || mage->number==0 || alliedunit(mage, u->faction, HELP_GUARD)) {
|
||||||
bonus = mod;
|
bonus = mod;
|
||||||
}
|
}
|
||||||
} else if (mod < malus) {
|
} else if (mod < malus) {
|
||||||
|
|
|
@ -320,20 +320,24 @@ write_skill(struct storage * store, const curse * c)
|
||||||
}
|
}
|
||||||
|
|
||||||
static message *
|
static message *
|
||||||
cinfo_skill(const void * obj, typ_t typ, const curse *c, int self)
|
cinfo_skillmod(const void * obj, typ_t typ, const curse *c, int self)
|
||||||
{
|
{
|
||||||
unused(typ);
|
unused(typ);
|
||||||
|
|
||||||
if (self != 0) {
|
if (self != 0) {
|
||||||
unit *u = (unit *)obj;
|
unit *u = (unit *)obj;
|
||||||
int sk = c->data.i;
|
int sk = c->data.i;
|
||||||
return msg_message("curseinfo::skill_1", "unit skill id", u, sk, c->no);
|
if (c->effect.i>0) {
|
||||||
|
return msg_message("curseinfo::skill_1", "unit skill id", u, sk, c->no);
|
||||||
|
} else if (c->effect.i<0) {
|
||||||
|
return msg_message("curseinfo::skill_2", "unit skill id", u, sk, c->no);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct curse_type ct_skillmod = {
|
static struct curse_type ct_skillmod = {
|
||||||
"skillmod", CURSETYP_NORM, CURSE_SPREADMODULO, M_MEN, cinfo_skill,
|
"skillmod", CURSETYP_NORM, CURSE_SPREADMODULO, M_MEN, cinfo_skillmod,
|
||||||
NULL, read_skill, write_skill
|
NULL, read_skill, write_skill
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ xml_bvalue(xmlNodePtr node, const char * name, boolean dflt)
|
||||||
if (propValue!=NULL) {
|
if (propValue!=NULL) {
|
||||||
if (strcmp((const char*)propValue, "no")==0) result = false;
|
if (strcmp((const char*)propValue, "no")==0) result = false;
|
||||||
else if (strcmp((const char*)propValue, "yes")==0) result = true;
|
else if (strcmp((const char*)propValue, "yes")==0) result = true;
|
||||||
else if (strcmp((const char*)propValue, "false")==0) result = true;
|
else if (strcmp((const char*)propValue, "false")==0) result = false;
|
||||||
else if (strcmp((const char*)propValue, "true")==0) result = true;
|
else if (strcmp((const char*)propValue, "true")==0) result = true;
|
||||||
else if (strcmp((const char*)propValue, "1")==0) {
|
else if (strcmp((const char*)propValue, "1")==0) {
|
||||||
log_warning(("boolean value is '1': %s::%s\n", node->name, name));
|
log_warning(("boolean value is '1': %s::%s\n", node->name, name));
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
using namespace luabind;
|
using namespace luabind;
|
||||||
|
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
|
#include <util/rng.h>
|
||||||
#include <kernel/skill.h>
|
#include <kernel/skill.h>
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
|
@ -44,6 +45,7 @@ bind_test(lua_State * L)
|
||||||
{
|
{
|
||||||
module(L, "test")[
|
module(L, "test")[
|
||||||
def("loc_skill", &loc_getskill),
|
def("loc_skill", &loc_getskill),
|
||||||
def("loc_keyword", &loc_getkeyword)
|
def("loc_keyword", &loc_getkeyword),
|
||||||
|
def("rng_int", &rng_int)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,6 +235,15 @@
|
||||||
<text locale="de">"$unit($unit) scheint $race($race, 0) zu mögen. ($int36($id))"</text>
|
<text locale="de">"$unit($unit) scheint $race($race, 0) zu mögen. ($int36($id))"</text>
|
||||||
<text locale="en">"$unit($unit) seems to like $race($race, 0). ($int36($id))"</text>
|
<text locale="en">"$unit($unit) seems to like $race($race, 0). ($int36($id))"</text>
|
||||||
</message>
|
</message>
|
||||||
|
<message name="curseinfo::skill_2" section="events">
|
||||||
|
<type>
|
||||||
|
<arg name="unit" type="unit"/>
|
||||||
|
<arg name="skill" type="skill"/>
|
||||||
|
<arg name="id" type="int"/>
|
||||||
|
</type>
|
||||||
|
<text locale="de">"$unit($unit) ist ungewöhnlich ungeschickt in $skill($skill). ($int36($id))"</text>
|
||||||
|
<text locale="en">"$unit($unit) has some troubles with $skill($skill). ($int36($id))"</text>
|
||||||
|
</message>
|
||||||
<message name="curseinfo::skill_1" section="events">
|
<message name="curseinfo::skill_1" section="events">
|
||||||
<type>
|
<type>
|
||||||
<arg name="unit" type="unit"/>
|
<arg name="unit" type="unit"/>
|
||||||
|
|
|
@ -329,12 +329,12 @@
|
||||||
</item>
|
</item>
|
||||||
</resource>
|
</resource>
|
||||||
|
|
||||||
<resource name="peasant">
|
<resource name="peasant" pooled="false">
|
||||||
<function name="change" value="lua_changeresource"/>
|
<function name="change" value="lua_changeresource"/>
|
||||||
<function name="get" value="lua_getresource"/>
|
<function name="get" value="lua_getresource"/>
|
||||||
</resource>
|
</resource>
|
||||||
|
|
||||||
<resource name="hp">
|
<resource name="hp" pooled="false">
|
||||||
<function name="change" value="lua_changeresource"/>
|
<function name="change" value="lua_changeresource"/>
|
||||||
<function name="get" value="lua_getresource"/>
|
<function name="get" value="lua_getresource"/>
|
||||||
</resource>
|
</resource>
|
||||||
|
|
Loading…
Reference in a new issue