forked from github/server
"Hero units cannot be merged with other hero units" - fixed condition in give.c also: - indentation fixes
This commit is contained in:
parent
adab7ea8f6
commit
f168a45b2a
5 changed files with 96 additions and 91 deletions
|
@ -147,17 +147,19 @@ give_men(int n, unit * u, unit * u2, struct order * ord)
|
|||
} else if (u == u2) {
|
||||
error = 10;
|
||||
} 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;
|
||||
#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;
|
||||
#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;
|
||||
} else if (fval(u, UFL_LOCKED) || is_cursed(u->attribs, C_SLAVE, 0)) {
|
||||
error = 74;
|
||||
} else if (u2 && fval(u, UFL_HUNGER)) {
|
||||
/* hungry people cannot be given away */
|
||||
error = 73;
|
||||
} else if (u2 && (fval(u2, UFL_LOCKED)|| is_cursed(u2->attribs, C_SLAVE, 0))) {
|
||||
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));
|
||||
error = -1;
|
||||
} else if (u2 && (has_skill(u, SK_MAGIC) || has_skill(u2, SK_MAGIC))) {
|
||||
/* cannot give units to and from magicians */
|
||||
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;
|
||||
} else if (u2 && u2->number!=0 && u2->race != u->race) {
|
||||
log_warning(("faction %s attempts to give %s to faction %s.\n",
|
||||
|
|
|
@ -939,7 +939,7 @@ restart_cmd(unit * u, struct order * ord)
|
|||
|
||||
if (!checkpasswd(u->faction, (const char *)s_pass, false)) {
|
||||
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));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,10 @@
|
|||
static FILE *bdebug;
|
||||
#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_STRUCTURAL_DAMAGE
|
||||
|
||||
|
@ -97,9 +100,6 @@ boolean battledebug = true;
|
|||
/* globals */
|
||||
static int obs_count = 0;
|
||||
|
||||
#define TACTICS_MALUS 1
|
||||
#undef MAGIC_TURNS
|
||||
|
||||
#define MINSPELLRANGE 1
|
||||
#define MAXSPELLRANGE 7
|
||||
|
||||
|
@ -3102,11 +3102,11 @@ make_fighter(battle * b, unit * u, side * s1, boolean attack)
|
|||
/* Schauen, wie gut wir in Taktik sind. */
|
||||
if (t > 0 && u->race == new_race[RC_INSECT])
|
||||
t -= 1 - (int) log10(fig->side->size[SUM_ROW]);
|
||||
#ifdef TACTICS_MODIFIER
|
||||
if (t > 0 && statusrow(fig->status) == FIGHT_ROW)
|
||||
t += 1;
|
||||
#ifdef TACTICS_MALUS
|
||||
t += TACTICS_MODIFIER;
|
||||
if (t > 0 && statusrow(fig->status) > BEHIND_ROW) {
|
||||
t -= TACTICS_MALUS;
|
||||
t -= TACTICS_MODIFIER;
|
||||
}
|
||||
#endif
|
||||
#ifdef TACTICS_RANDOM
|
||||
|
|
|
@ -786,7 +786,7 @@ transfermen(unit * u, unit * u2, int n)
|
|||
const attrib * a;
|
||||
int hp = u->hp;
|
||||
region * r = u->region;
|
||||
|
||||
|
||||
if (n==0) return;
|
||||
assert(n > 0);
|
||||
/* "hat attackiert"-status wird übergeben */
|
||||
|
@ -798,85 +798,86 @@ transfermen(unit * u, unit * u2, int n)
|
|||
|
||||
assert(u2->number+n>0);
|
||||
|
||||
for (sk=0; sk!=MAXSKILLS; ++sk) {
|
||||
double dlevel = 0.0;
|
||||
int weeks, level = 0;
|
||||
for (sk=0; sk!=MAXSKILLS; ++sk) {
|
||||
double dlevel = 0.0;
|
||||
int weeks, level = 0;
|
||||
|
||||
sv = get_skill(u, sk);
|
||||
sn = get_skill(u2, sk);
|
||||
sv = get_skill(u, sk);
|
||||
sn = get_skill(u2, sk);
|
||||
|
||||
if (sv==NULL && sn==NULL) continue;
|
||||
if (sv && sv->level) {
|
||||
dlevel += (sv->level + 1 - sv->weeks/(sv->level+1.0)) * n;
|
||||
level += sv->level * n;
|
||||
}
|
||||
if (sn && sn->level) {
|
||||
dlevel += (sn->level + 1 - sn->weeks/(sn->level+1.0)) * u2->number;
|
||||
level += sn->level * u2->number;
|
||||
}
|
||||
if (sv==NULL && sn==NULL) continue;
|
||||
if (sv && sv->level) {
|
||||
dlevel += (sv->level + 1 - sv->weeks/(sv->level+1.0)) * n;
|
||||
level += sv->level * n;
|
||||
}
|
||||
if (sn && sn->level) {
|
||||
dlevel += (sn->level + 1 - sn->weeks/(sn->level+1.0)) * u2->number;
|
||||
level += sn->level * u2->number;
|
||||
}
|
||||
|
||||
dlevel = dlevel / (n + u2->number);
|
||||
level = level / (n + u2->number);
|
||||
if (level<=dlevel) {
|
||||
/* apply the remaining fraction to the number of weeks to go.
|
||||
* subtract the according number of weeks, getting closer to the
|
||||
* next level */
|
||||
level = (int)dlevel;
|
||||
weeks = (level+1) - (int)((dlevel - level) * (level+1));
|
||||
} else {
|
||||
/* make it harder to reach the next level.
|
||||
* weeks+level is the max difficulty, 1 - the fraction between
|
||||
* level and dlevel applied to the number of weeks between this
|
||||
* and the previous level is the added difficutly */
|
||||
level = (int)dlevel+1;
|
||||
weeks = 1 + 2 * level - (int)((1 + dlevel - level) * level);
|
||||
}
|
||||
if (level) {
|
||||
if (sn==NULL) sn = add_skill(u2, sk);
|
||||
sn->level = (unsigned char)level;
|
||||
sn->weeks = (unsigned char)weeks;
|
||||
assert(sn->weeks>0 && sn->weeks<=sn->level*2+1);
|
||||
} else if (sn) {
|
||||
remove_skill(u2, sk);
|
||||
sn = NULL;
|
||||
}
|
||||
}
|
||||
a = a_find(u->attribs, &at_effect);
|
||||
while (a && a->type==&at_effect) {
|
||||
effect_data * olde = (effect_data*)a->data.v;
|
||||
if (olde->value) change_effect(u2, olde->type, olde->value);
|
||||
a = a->next;
|
||||
}
|
||||
dlevel = dlevel / (n + u2->number);
|
||||
level = level / (n + u2->number);
|
||||
if (level<=dlevel) {
|
||||
/* apply the remaining fraction to the number of weeks to go.
|
||||
* subtract the according number of weeks, getting closer to the
|
||||
* next level */
|
||||
level = (int)dlevel;
|
||||
weeks = (level+1) - (int)((dlevel - level) * (level+1));
|
||||
} else {
|
||||
/* make it harder to reach the next level.
|
||||
* weeks+level is the max difficulty, 1 - the fraction between
|
||||
* level and dlevel applied to the number of weeks between this
|
||||
* and the previous level is the added difficutly */
|
||||
level = (int)dlevel+1;
|
||||
weeks = 1 + 2 * level - (int)((1 + dlevel - level) * level);
|
||||
}
|
||||
if (level) {
|
||||
if (sn==NULL) sn = add_skill(u2, sk);
|
||||
sn->level = (unsigned char)level;
|
||||
sn->weeks = (unsigned char)weeks;
|
||||
assert(sn->weeks>0 && sn->weeks<=sn->level*2+1);
|
||||
} else if (sn) {
|
||||
remove_skill(u2, sk);
|
||||
sn = NULL;
|
||||
}
|
||||
}
|
||||
a = a_find(u->attribs, &at_effect);
|
||||
while (a && a->type==&at_effect) {
|
||||
effect_data * olde = (effect_data*)a->data.v;
|
||||
if (olde->value) change_effect(u2, olde->type, olde->value);
|
||||
a = a->next;
|
||||
}
|
||||
sh = leftship(u);
|
||||
if (sh!=NULL) set_leftship(u2, sh);
|
||||
u2->flags |= u->flags&(UFL_LONGACTION|UFL_NOTMOVING|UFL_HUNGER|UFL_MOVED|UFL_ENTER);
|
||||
if (u->attribs) {
|
||||
transfer_curse(u, u2, n);
|
||||
}
|
||||
}
|
||||
scale_number(u, u->number - n);
|
||||
if (u2) {
|
||||
set_number(u2, u2->number + n);
|
||||
hp -= u->hp;
|
||||
u2->hp += hp;
|
||||
/* TODO: Das ist schnarchlahm! und gehört ncht hierhin */
|
||||
a = a_find(u2->attribs, &at_effect);
|
||||
while (a && a->type==&at_effect) {
|
||||
attrib * an = a->next;
|
||||
effect_data * olde = (effect_data*)a->data.v;
|
||||
int e = get_effect(u, olde->type);
|
||||
if (e!=0) change_effect(u2, olde->type, -e);
|
||||
a = an;
|
||||
}
|
||||
}
|
||||
else if (r->land)
|
||||
if(u->race != new_race[RC_DAEMON]) {
|
||||
if(u->race != new_race[RC_URUK]) {
|
||||
rsetpeasants(r, rpeasants(r) + n);
|
||||
} else {
|
||||
rsetpeasants(r, rpeasants(r) + n/2);
|
||||
}
|
||||
}
|
||||
if (u->attribs) {
|
||||
transfer_curse(u, u2, n);
|
||||
}
|
||||
}
|
||||
scale_number(u, u->number - n);
|
||||
if (u2) {
|
||||
set_number(u2, u2->number + n);
|
||||
hp -= u->hp;
|
||||
u2->hp += hp;
|
||||
/* TODO: Das ist schnarchlahm! und gehört nicht hierhin */
|
||||
a = a_find(u2->attribs, &at_effect);
|
||||
while (a && a->type==&at_effect) {
|
||||
attrib * an = a->next;
|
||||
effect_data * olde = (effect_data*)a->data.v;
|
||||
int e = get_effect(u, olde->type);
|
||||
if (e!=0) change_effect(u2, olde->type, -e);
|
||||
a = an;
|
||||
}
|
||||
}
|
||||
else if (r->land) {
|
||||
if ((u->race->ec_flags & ECF_REC_UNLIMITED)==0) {
|
||||
if(u->race != new_race[RC_URUK]) {
|
||||
rsetpeasants(r, rpeasants(r) + n);
|
||||
} else {
|
||||
rsetpeasants(r, rpeasants(r) + n/2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct building *
|
||||
|
|
|
@ -5,12 +5,12 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
typedef union variant {
|
||||
void *v;
|
||||
void *v;
|
||||
int i;
|
||||
char c;
|
||||
short s;
|
||||
short sa[2];
|
||||
char ca[4];
|
||||
char c;
|
||||
short s;
|
||||
short sa[2];
|
||||
char ca[4];
|
||||
float f;
|
||||
} variant;
|
||||
|
||||
|
|
Loading…
Reference in a new issue