Bergwächter können auch ohne Waffen bewachen.
This commit is contained in:
Enno Rehling 2007-01-01 12:06:29 +00:00
parent 56a28511a4
commit 97342e5b81
10 changed files with 204 additions and 172 deletions

View File

@ -1195,7 +1195,7 @@ can_guard(const unit * guard, const unit * u)
{
if (fval(guard, UFL_ISNEW)) return false;
if (guard->number<=0 || !cansee(guard->faction, guard->region, u, 0)) return false;
if (besieged(guard) || !armedmen(guard)) return false;
if (besieged(guard) || !(fval(guard->race, RCF_UNARMEDGUARD) || armedmen(guard))) return false;
return !alliedunit(guard, u->faction, HELP_GUARD);
}
@ -1229,7 +1229,6 @@ allocate_resource(unit * u, const resource_type * rtype, int want)
cmistake(u, u->thisorder, 121, MSG_PRODUCE);
return;
}
}
if (itype == olditemtype[I_LAEN]) {

View File

@ -2547,18 +2547,32 @@ combatspell_cmd(unit * u, struct order * ord)
/* ------------------------------------------------------------- */
/* Beachten: einige Monster sollen auch unbewaffent die Region bewachen
* können */
enum { E_GUARD_OK, E_GUARD_UNARMED, E_GUARD_NEWBIE };
static int
can_start_guarding(const unit * u)
{
if (fval(u->race, RCF_UNARMEDGUARD)) return E_GUARD_OK;
if (!armedmen(u)) return E_GUARD_UNARMED;
if (u->faction->age < NewbieImmunity()) return E_GUARD_NEWBIE;
return E_GUARD_OK;
}
void
update_guards(void)
{
region *r;
unit *u;
const region *r;
for (r = regions; r; r = r->next)
for (r = regions; r; r = r->next) {
unit *u;
for (u = r->units; u; u = u->next) {
if (getguard(u) && (!armedmen(u) || u->faction->age < NewbieImmunity()))
if (can_start_guarding(u)!=E_GUARD_OK) {
setguard(u, GUARD_NONE);
}
}
}
}
static int
guard_on_cmd(unit * u, struct order * ord)
@ -2582,15 +2596,18 @@ guard_on_cmd(unit * u, struct order * ord)
/* Monster der Monsterpartei dürfen immer bewachen */
if (u->faction == findfaction(MONSTER_FACTION)) {
guard(u, GUARD_ALL);
} else if (!armedmen(u)) {
} else {
int err = can_start_guarding(u);
if (err==E_GUARD_UNARMED) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "unit_unarmed", ""));
} else if (u->faction->age < NewbieImmunity()) {
} else if (err==E_GUARD_NEWBIE) {
cmistake(u, ord, 304, MSG_EVENT);
} else {
guard(u, GUARD_ALL);
}
}
}
}
return 0;
}

View File

@ -856,7 +856,7 @@ is_guardian(unit * u2, unit *u, unsigned int mask)
if (alliedunit(u2, u->faction, HELP_GUARD)) return false;
if (ucontact(u2, u)) return false;
if (besieged(u2)) return false;
if (!armedmen(u2)) return false;
if (!armedmen(u2) && !fval(u2->race, RCF_UNARMEDGUARD)) return false;
if (!cansee(u2->faction, u->region, u, 0)) return false;
return true;

View File

@ -135,6 +135,7 @@ extern int rc_specialdamage(const race *, const race *, const struct weapon_type
#define RCF_UNDEAD (1<<20) /* Undead. */
#define RCF_DRAGON (1<<21) /* Drachenart (für Zauber)*/
#define RCF_COASTAL (1<<22) /* kann in Landregionen an der Küste sein */
#define RCF_UNARMEDGUARD (1<<23) /* kann ohne Waffen bewachen */
/* Economic flags */
#define NOGIVE (1<<0) /* gibt niemals nix */

View File

@ -1412,6 +1412,7 @@ parse_races(xmlDocPtr doc)
if (xml_bvalue(node, "cannotmove", false)) rc->flags |= RCF_CANNOTMOVE;
if (xml_bvalue(node, "fly", false)) rc->flags |= RCF_FLY;
if (xml_bvalue(node, "coastal", false)) rc->flags |= RCF_COASTAL;
if (xml_bvalue(node, "unarmedguard", false)) rc->flags |= RCF_UNARMEDGUARD;
if (xml_bvalue(node, "swim", false)) rc->flags |= RCF_SWIM;
if (xml_bvalue(node, "walk", false)) rc->flags |= RCF_WALK;
if (xml_bvalue(node, "nolearn", false)) rc->flags |= RCF_NOLEARN;

View File

@ -39,6 +39,7 @@ using namespace luabind;
static int
lua_addequipment(const char * eqname, const char * iname, const char * value)
{
if (iname==NULL) return -1;
const struct item_type * itype = it_find(iname);
if (itype==NULL) return -1;
equipment_setitem(create_equipment(eqname), itype, value);

View File

@ -161,11 +161,13 @@ faction_delete_variable(faction& f, const char *key)
static int
faction_additem(faction& f, const char * iname, int number)
{
if (iname!=NULL) {
const item_type * itype = it_find(iname);
if (itype!=NULL) {
item * i = i_change(&f.items, itype, number);
return i?i->number:0;
} // if (itype!=NULL)
}
return -1;
}

View File

@ -296,11 +296,13 @@ region_items(const region& r) {
static int
region_additem(region& r, const char * iname, int number)
{
if (iname!=NULL) {
const item_type * itype = it_find(iname);
if (itype!=NULL && r.land) {
item * i = i_change(&r.land->items, itype, number);
return i?i->number:0;
} // if (itype!=NULL)
}
return -1;
}

View File

@ -114,16 +114,25 @@ unit_getnumber(const unit& u)
static int
unit_getitem(const unit& u, const char * iname)
{
if (iname!=NULL) {
const item_type * itype = it_find(iname);
if (itype!=NULL) {
return i_get(u.items, itype);
}
}
return -1;
}
static int
unit_additem(unit& u, const char * iname, int number)
{
if (iname!=NULL) {
const item_type * itype = it_find(iname);
if (itype!=NULL) {
item * i = i_change(&u.items, itype, number);
return i?i->number:0;
} // if (itype!=NULL)
}
const item_type * itype = it_find(iname);
if (itype!=NULL) {
item * i = i_change(&u.items, itype, number);

View File

@ -644,7 +644,7 @@
<ai splitsize="1"/>
<attack type="1" damage="1d4"/>
</race>
<race name="mountainguard" magres="0.500000" maxaura="1.000000" regaura="0.500000" recruitcost="50000" weight="10000" capacity="2000" speed="0.000000" hp="1000" ac="12" damage="2d40" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="8" cannotmove="yes" nolearn="yes" teach="no" noweapons="yes" giveitem="yes">
<race name="mountainguard" unarmedguard="yes" magres="0.500000" maxaura="1.000000" regaura="0.500000" recruitcost="50000" weight="10000" capacity="2000" speed="0.000000" hp="1000" ac="12" damage="2d40" unarmedattack="0" unarmeddefense="0" attackmodifier="6" defensemodifier="8" cannotmove="yes" nolearn="yes" teach="no" noweapons="yes" giveitem="yes">
<ai splitsize="1"/>
<attack type="4" damage="2d40"/>
</race>