"Hero units cannot be merged with other hero units"
- fixed condition in give.c
also:
- indentation fixes
This commit is contained in:
Enno Rehling 2008-01-27 11:57:54 +00:00
parent adab7ea8f6
commit f168a45b2a
5 changed files with 96 additions and 91 deletions

View file

@ -147,17 +147,19 @@ give_men(int n, unit * u, unit * u2, struct order * ord)
} else if (u == u2) { } else if (u == u2) {
error = 10; error = 10;
} else if (!u2 && u->race == new_race[RC_SNOTLING]) { } else if (!u2 && u->race == new_race[RC_SNOTLING]) {
/* Snotlings können nicht an Bauern übergeben werden. */ /* snotlings may not be given to the peasants. */
error = 307; error = 307;
#ifdef HEROES #ifdef HEROES
} else if (fval(u, UFL_HERO) || (u2 && fval(u2, UFL_HERO))) { } else if (u2 && (fval(u, UFL_HERO) != fval(u2, UFL_HERO))) {
/* heroes may not be given to non-heroes and vice versa*/
error = 75; error = 75;
#endif #endif
} else if ((u && unit_has_cursed_item(u)) || (u2 && unit_has_cursed_item(u2))) { } else if (unit_has_cursed_item(u) || (u2 && unit_has_cursed_item(u2))) {
error = 78; error = 78;
} else if (fval(u, UFL_LOCKED) || is_cursed(u->attribs, C_SLAVE, 0)) { } else if (fval(u, UFL_LOCKED) || is_cursed(u->attribs, C_SLAVE, 0)) {
error = 74; error = 74;
} else if (u2 && fval(u, UFL_HUNGER)) { } else if (u2 && fval(u, UFL_HUNGER)) {
/* hungry people cannot be given away */
error = 73; error = 73;
} else if (u2 && (fval(u2, UFL_LOCKED)|| is_cursed(u2->attribs, C_SLAVE, 0))) { } else if (u2 && (fval(u2, UFL_LOCKED)|| is_cursed(u2->attribs, C_SLAVE, 0))) {
error = 75; error = 75;
@ -165,8 +167,10 @@ give_men(int n, unit * u, unit * u2, struct order * ord)
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_no_contact", "target", u2)); ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_no_contact", "target", u2));
error = -1; error = -1;
} else if (u2 && (has_skill(u, SK_MAGIC) || has_skill(u2, SK_MAGIC))) { } else if (u2 && (has_skill(u, SK_MAGIC) || has_skill(u2, SK_MAGIC))) {
/* cannot give units to and from magicians */
error = 158; error = 158;
} else if (u2 && fval(u, UFL_WERE) != fval(u2, UFL_WERE)) { } else if (u2 && (fval(u, UFL_WERE) != fval(u2, UFL_WERE))) {
/* werewolves can't be given to non-werewolves and vice-versa */
error = 312; error = 312;
} else if (u2 && u2->number!=0 && u2->race != u->race) { } else if (u2 && u2->number!=0 && u2->race != u->race) {
log_warning(("faction %s attempts to give %s to faction %s.\n", log_warning(("faction %s attempts to give %s to faction %s.\n",

View file

@ -939,7 +939,7 @@ restart_cmd(unit * u, struct order * ord)
if (!checkpasswd(u->faction, (const char *)s_pass, false)) { if (!checkpasswd(u->faction, (const char *)s_pass, false)) {
cmistake(u, ord, 86, MSG_EVENT); cmistake(u, ord, 86, MSG_EVENT);
log_warning(("NEUSTART mit falschem Passwort für Partei %s: %s\n", log_warning(("RESTART with wrong password, faction %s, pass %s\n",
factionid(u->faction), s_pass)); factionid(u->faction), s_pass));
return 0; return 0;
} }

View file

@ -70,7 +70,10 @@
static FILE *bdebug; static FILE *bdebug;
#undef DELAYED_OFFENSE /* non-guarding factions cannot attack after moving */ #undef DELAYED_OFFENSE /* non-guarding factions cannot attack after moving */
#define TACTICS_RANDOM 5 /* define this as 1 to deactivate */ #define TACTICS_BONUS 1 /* when undefined, we have a tactics round. else this is the bonus tactics give */
#define TACTICS_RANDOM /* undefine this to deactivate */
#define TACTICS_MODIFIER 1 /* modifier for generals in the fromt/rear */
#define CATAPULT_INITIAL_RELOAD 4 /* erster schuss in runde 1 + rng_int() % INITIAL */ #define CATAPULT_INITIAL_RELOAD 4 /* erster schuss in runde 1 + rng_int() % INITIAL */
#define CATAPULT_STRUCTURAL_DAMAGE #define CATAPULT_STRUCTURAL_DAMAGE
@ -97,9 +100,6 @@ boolean battledebug = true;
/* globals */ /* globals */
static int obs_count = 0; static int obs_count = 0;
#define TACTICS_MALUS 1
#undef MAGIC_TURNS
#define MINSPELLRANGE 1 #define MINSPELLRANGE 1
#define MAXSPELLRANGE 7 #define MAXSPELLRANGE 7
@ -3102,11 +3102,11 @@ make_fighter(battle * b, unit * u, side * s1, boolean attack)
/* Schauen, wie gut wir in Taktik sind. */ /* Schauen, wie gut wir in Taktik sind. */
if (t > 0 && u->race == new_race[RC_INSECT]) if (t > 0 && u->race == new_race[RC_INSECT])
t -= 1 - (int) log10(fig->side->size[SUM_ROW]); t -= 1 - (int) log10(fig->side->size[SUM_ROW]);
#ifdef TACTICS_MODIFIER
if (t > 0 && statusrow(fig->status) == FIGHT_ROW) if (t > 0 && statusrow(fig->status) == FIGHT_ROW)
t += 1; t += TACTICS_MODIFIER;
#ifdef TACTICS_MALUS
if (t > 0 && statusrow(fig->status) > BEHIND_ROW) { if (t > 0 && statusrow(fig->status) > BEHIND_ROW) {
t -= TACTICS_MALUS; t -= TACTICS_MODIFIER;
} }
#endif #endif
#ifdef TACTICS_RANDOM #ifdef TACTICS_RANDOM

View file

@ -786,7 +786,7 @@ transfermen(unit * u, unit * u2, int n)
const attrib * a; const attrib * a;
int hp = u->hp; int hp = u->hp;
region * r = u->region; region * r = u->region;
if (n==0) return; if (n==0) return;
assert(n > 0); assert(n > 0);
/* "hat attackiert"-status wird übergeben */ /* "hat attackiert"-status wird übergeben */
@ -798,85 +798,86 @@ transfermen(unit * u, unit * u2, int n)
assert(u2->number+n>0); assert(u2->number+n>0);
for (sk=0; sk!=MAXSKILLS; ++sk) { for (sk=0; sk!=MAXSKILLS; ++sk) {
double dlevel = 0.0; double dlevel = 0.0;
int weeks, level = 0; int weeks, level = 0;
sv = get_skill(u, sk); sv = get_skill(u, sk);
sn = get_skill(u2, sk); sn = get_skill(u2, sk);
if (sv==NULL && sn==NULL) continue; if (sv==NULL && sn==NULL) continue;
if (sv && sv->level) { if (sv && sv->level) {
dlevel += (sv->level + 1 - sv->weeks/(sv->level+1.0)) * n; dlevel += (sv->level + 1 - sv->weeks/(sv->level+1.0)) * n;
level += sv->level * n; level += sv->level * n;
} }
if (sn && sn->level) { if (sn && sn->level) {
dlevel += (sn->level + 1 - sn->weeks/(sn->level+1.0)) * u2->number; dlevel += (sn->level + 1 - sn->weeks/(sn->level+1.0)) * u2->number;
level += sn->level * u2->number; level += sn->level * u2->number;
} }
dlevel = dlevel / (n + u2->number); dlevel = dlevel / (n + u2->number);
level = level / (n + u2->number); level = level / (n + u2->number);
if (level<=dlevel) { if (level<=dlevel) {
/* apply the remaining fraction to the number of weeks to go. /* apply the remaining fraction to the number of weeks to go.
* subtract the according number of weeks, getting closer to the * subtract the according number of weeks, getting closer to the
* next level */ * next level */
level = (int)dlevel; level = (int)dlevel;
weeks = (level+1) - (int)((dlevel - level) * (level+1)); weeks = (level+1) - (int)((dlevel - level) * (level+1));
} else { } else {
/* make it harder to reach the next level. /* make it harder to reach the next level.
* weeks+level is the max difficulty, 1 - the fraction between * weeks+level is the max difficulty, 1 - the fraction between
* level and dlevel applied to the number of weeks between this * level and dlevel applied to the number of weeks between this
* and the previous level is the added difficutly */ * and the previous level is the added difficutly */
level = (int)dlevel+1; level = (int)dlevel+1;
weeks = 1 + 2 * level - (int)((1 + dlevel - level) * level); weeks = 1 + 2 * level - (int)((1 + dlevel - level) * level);
} }
if (level) { if (level) {
if (sn==NULL) sn = add_skill(u2, sk); if (sn==NULL) sn = add_skill(u2, sk);
sn->level = (unsigned char)level; sn->level = (unsigned char)level;
sn->weeks = (unsigned char)weeks; sn->weeks = (unsigned char)weeks;
assert(sn->weeks>0 && sn->weeks<=sn->level*2+1); assert(sn->weeks>0 && sn->weeks<=sn->level*2+1);
} else if (sn) { } else if (sn) {
remove_skill(u2, sk); remove_skill(u2, sk);
sn = NULL; sn = NULL;
} }
} }
a = a_find(u->attribs, &at_effect); a = a_find(u->attribs, &at_effect);
while (a && a->type==&at_effect) { while (a && a->type==&at_effect) {
effect_data * olde = (effect_data*)a->data.v; effect_data * olde = (effect_data*)a->data.v;
if (olde->value) change_effect(u2, olde->type, olde->value); if (olde->value) change_effect(u2, olde->type, olde->value);
a = a->next; a = a->next;
} }
sh = leftship(u); sh = leftship(u);
if (sh!=NULL) set_leftship(u2, sh); if (sh!=NULL) set_leftship(u2, sh);
u2->flags |= u->flags&(UFL_LONGACTION|UFL_NOTMOVING|UFL_HUNGER|UFL_MOVED|UFL_ENTER); u2->flags |= u->flags&(UFL_LONGACTION|UFL_NOTMOVING|UFL_HUNGER|UFL_MOVED|UFL_ENTER);
if (u->attribs) { if (u->attribs) {
transfer_curse(u, u2, n); transfer_curse(u, u2, n);
} }
} }
scale_number(u, u->number - n); scale_number(u, u->number - n);
if (u2) { if (u2) {
set_number(u2, u2->number + n); set_number(u2, u2->number + n);
hp -= u->hp; hp -= u->hp;
u2->hp += hp; u2->hp += hp;
/* TODO: Das ist schnarchlahm! und gehört ncht hierhin */ /* TODO: Das ist schnarchlahm! und gehört nicht hierhin */
a = a_find(u2->attribs, &at_effect); a = a_find(u2->attribs, &at_effect);
while (a && a->type==&at_effect) { while (a && a->type==&at_effect) {
attrib * an = a->next; attrib * an = a->next;
effect_data * olde = (effect_data*)a->data.v; effect_data * olde = (effect_data*)a->data.v;
int e = get_effect(u, olde->type); int e = get_effect(u, olde->type);
if (e!=0) change_effect(u2, olde->type, -e); if (e!=0) change_effect(u2, olde->type, -e);
a = an; a = an;
} }
} }
else if (r->land) else if (r->land) {
if(u->race != new_race[RC_DAEMON]) { if ((u->race->ec_flags & ECF_REC_UNLIMITED)==0) {
if(u->race != new_race[RC_URUK]) { if(u->race != new_race[RC_URUK]) {
rsetpeasants(r, rpeasants(r) + n); rsetpeasants(r, rpeasants(r) + n);
} else { } else {
rsetpeasants(r, rpeasants(r) + n/2); rsetpeasants(r, rpeasants(r) + n/2);
} }
} }
}
} }
struct building * struct building *

View file

@ -5,12 +5,12 @@ extern "C" {
#endif #endif
typedef union variant { typedef union variant {
void *v; void *v;
int i; int i;
char c; char c;
short s; short s;
short sa[2]; short sa[2];
char ca[4]; char ca[4];
float f; float f;
} variant; } variant;