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;
|
||||
}
|
||||
|
||||
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
|
||||
setstealth_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
|
@ -281,34 +313,10 @@ setstealth_cmd(unit * u, struct order * ord)
|
|||
a_removeall(&u->attribs, &at_otherfaction);
|
||||
} else {
|
||||
struct faction * f = findfaction(nr);
|
||||
if(f==NULL) {
|
||||
if (f==NULL) {
|
||||
cmistake(u, ord, 66, MSG_EVENT);
|
||||
} else {
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
set_factionstealth(u, f);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -311,8 +311,14 @@ ct_find(const char *c)
|
|||
unsigned int hash = tolower(c[0]);
|
||||
cursetype_list * ctl = cursetypes[hash];
|
||||
while (ctl) {
|
||||
if (strcmp(c, ctl->type->cname)==0) {
|
||||
return ctl->type;
|
||||
} else {
|
||||
size_t k = min(strlen(c), strlen(ctl->type->cname));
|
||||
if (!strncasecmp(c, ctl->type->cname, k)) return ctl->type;
|
||||
if (!strncasecmp(c, ctl->type->cname, k)) {
|
||||
return ctl->type;
|
||||
}
|
||||
}
|
||||
ctl = ctl->next;
|
||||
}
|
||||
return NULL;
|
||||
|
|
|
@ -974,12 +974,12 @@ int
|
|||
alliedunit(const unit * u, const faction * f2, int mode)
|
||||
{
|
||||
ally * sf;
|
||||
const plane * pl = u->region->planep;
|
||||
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 == NULL || f2==NULL) return 0;
|
||||
|
||||
if (u->faction != NULL && f2!=NULL) {
|
||||
plane * pl = u->region->planep;
|
||||
automode = mode & autoalliance(pl, u->faction, f2);
|
||||
|
||||
if (pl!=NULL && (pl->flags & PFL_NOALLIANCES))
|
||||
|
@ -991,6 +991,8 @@ alliedunit(const unit * u, const faction * f2, int mode)
|
|||
if (a!=NULL) sf = ((group*)a->data.v)->allies;
|
||||
}
|
||||
return alliedgroup(pl, u->faction, f2, sf, mode);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
boolean
|
||||
|
|
|
@ -1357,7 +1357,7 @@ do_fumble(castorder *co)
|
|||
/* temporärer Stufenverlust */
|
||||
duration = max(rng_int()%level/2, 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);
|
||||
c->data.i = SK_MAGIC;
|
||||
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) {
|
||||
int mask;
|
||||
|
||||
if (u==v) continue;
|
||||
if (v->items==NULL && rtype->uget==NULL) continue;
|
||||
if ((urace(v)->ec_flags & GIVEITEM) == 0) continue;
|
||||
|
||||
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) {
|
||||
int mask;
|
||||
if ((urace(v)->ec_flags & GIVEITEM) == 0) continue;
|
||||
if (v->items==NULL && rtype->uget==NULL) continue;
|
||||
|
||||
if (v->faction == f) {
|
||||
mask = (mode >> 3) & (GET_SLACK|GET_RESERVE);
|
||||
|
|
|
@ -1211,7 +1211,7 @@ att_modification(const unit *u, skill_t sk)
|
|||
unit * mage = c->magician;
|
||||
/* wir suchen jeweils den größten Bonus und den größten Malus */
|
||||
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;
|
||||
}
|
||||
} else if (mod < malus) {
|
||||
|
|
|
@ -320,20 +320,24 @@ write_skill(struct storage * store, const curse * c)
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
if (self != 0) {
|
||||
unit *u = (unit *)obj;
|
||||
int sk = c->data.i;
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ xml_bvalue(xmlNodePtr node, const char * name, boolean dflt)
|
|||
if (propValue!=NULL) {
|
||||
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, "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, "1")==0) {
|
||||
log_warning(("boolean value is '1': %s::%s\n", node->name, name));
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
using namespace luabind;
|
||||
|
||||
#include <util/language.h>
|
||||
#include <util/rng.h>
|
||||
#include <kernel/skill.h>
|
||||
|
||||
static const char *
|
||||
|
@ -44,6 +45,7 @@ bind_test(lua_State * L)
|
|||
{
|
||||
module(L, "test")[
|
||||
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="en">"$unit($unit) seems to like $race($race, 0). ($int36($id))"</text>
|
||||
</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">
|
||||
<type>
|
||||
<arg name="unit" type="unit"/>
|
||||
|
|
|
@ -329,12 +329,12 @@
|
|||
</item>
|
||||
</resource>
|
||||
|
||||
<resource name="peasant">
|
||||
<resource name="peasant" pooled="false">
|
||||
<function name="change" value="lua_changeresource"/>
|
||||
<function name="get" value="lua_getresource"/>
|
||||
</resource>
|
||||
|
||||
<resource name="hp">
|
||||
<resource name="hp" pooled="false">
|
||||
<function name="change" value="lua_changeresource"/>
|
||||
<function name="get" value="lua_getresource"/>
|
||||
</resource>
|
||||
|
|
Loading…
Reference in a new issue