forked from github/server
Total ohne Not mal wieder eine grosse Umstellung gemacht: Diesmal am Parser.
Okay, natuerlich habe ich damit was im Sinne: Das ist eine Vorbereitung auf voll geskriptete, neu zugefuegte Befehle und anderes Processing (aus Skripten). Fuer ein neues Spiel. Hoffen wir, dass nicht zuviel kaputtgeht :-)
This commit is contained in:
parent
150a1e38b0
commit
ed70863843
|
@ -995,93 +995,86 @@ gebaeude_stuerzt_ein(region * r, building * b)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
maintain_buildings(boolean crash)
|
maintain_buildings(region * r, boolean crash)
|
||||||
{
|
{
|
||||||
region * r;
|
building **bp = &r->buildings;
|
||||||
for (r = regions; r; r = r->next) {
|
while (*bp) {
|
||||||
building **bp = &r->buildings;
|
building * b = *bp;
|
||||||
while (*bp) {
|
boolean maintained = maintain(b, !crash);
|
||||||
building * b = *bp;
|
|
||||||
boolean maintained = maintain(b, !crash);
|
|
||||||
|
|
||||||
/* the second time, send a message */
|
/* the second time, send a message */
|
||||||
if (crash) {
|
if (crash) {
|
||||||
if (!maintained && (rng_int() % 100 < EINSTURZCHANCE)) {
|
if (!maintained && (rng_int() % 100 < EINSTURZCHANCE)) {
|
||||||
gebaeude_stuerzt_ein(r, b);
|
gebaeude_stuerzt_ein(r, b);
|
||||||
continue;
|
continue;
|
||||||
} else if (!fval(b, BLD_WORKING)) {
|
} else if (!fval(b, BLD_WORKING)) {
|
||||||
unit * u = buildingowner(r, b);
|
unit * u = buildingowner(r, b);
|
||||||
const char * msgtype = maintained?"maintenance_nowork":"maintenance_none";
|
const char * msgtype = maintained?"maintenance_nowork":"maintenance_none";
|
||||||
struct message * msg = msg_message(msgtype, "building", b);
|
struct message * msg = msg_message(msgtype, "building", b);
|
||||||
|
|
||||||
if (u) {
|
if (u) {
|
||||||
add_message(&u->faction->msgs, msg);
|
add_message(&u->faction->msgs, msg);
|
||||||
r_addmessage(r, u->faction, msg);
|
r_addmessage(r, u->faction, msg);
|
||||||
} else {
|
} else {
|
||||||
add_message(&r->msgs, msg);
|
add_message(&r->msgs, msg);
|
||||||
}
|
|
||||||
msg_release(msg);
|
|
||||||
}
|
}
|
||||||
|
msg_release(msg);
|
||||||
}
|
}
|
||||||
bp=&b->next;
|
}
|
||||||
}
|
bp=&b->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
economics(void)
|
economics(region *r)
|
||||||
{
|
{
|
||||||
region *r;
|
|
||||||
unit *u;
|
unit *u;
|
||||||
|
request *recruitorders = NULL;
|
||||||
|
|
||||||
/* Geben vor Selbstmord (doquit)! Hier alle unmittelbaren Befehle.
|
/* Geben vor Selbstmord (doquit)! Hier alle unmittelbaren Befehle.
|
||||||
* Rekrutieren vor allen Einnahmequellen. Bewachen JA vor Steuern
|
* Rekrutieren vor allen Einnahmequellen. Bewachen JA vor Steuern
|
||||||
* eintreiben. */
|
* eintreiben. */
|
||||||
|
|
||||||
for (r = regions; r; r = r->next) if (r->units) {
|
for (u = r->units; u; u = u->next) {
|
||||||
request *recruitorders = NULL;
|
order * ord;
|
||||||
|
boolean destroyed = false;
|
||||||
for (u = r->units; u; u = u->next) {
|
for (ord = u->orders; ord; ord = ord->next) {
|
||||||
order * ord;
|
switch (get_keyword(ord)) {
|
||||||
boolean destroyed = false;
|
case K_DESTROY:
|
||||||
for (ord = u->orders; ord; ord = ord->next) {
|
if (!destroyed) {
|
||||||
switch (get_keyword(ord)) {
|
if (destroy_cmd(u, ord)!=0) ord = NULL;
|
||||||
case K_DESTROY:
|
destroyed = true;
|
||||||
if (!destroyed) {
|
}
|
||||||
if (destroy_cmd(u, ord)!=0) ord = NULL;
|
|
||||||
destroyed = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case K_GIVE:
|
|
||||||
case K_LIEFERE:
|
|
||||||
give_cmd(u, ord);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case K_FORGET:
|
|
||||||
forget_cmd(u, ord);
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
if (u->orders==NULL) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* RECRUIT orders */
|
|
||||||
|
|
||||||
for (u = r->units; u; u = u->next) {
|
|
||||||
order * ord;
|
|
||||||
for (ord = u->orders; ord; ord = ord->next) {
|
|
||||||
if (get_keyword(ord) == K_RECRUIT) {
|
|
||||||
recruit(u, ord, &recruitorders);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
case K_GIVE:
|
||||||
|
case K_LIEFERE:
|
||||||
|
give_cmd(u, ord);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case K_FORGET:
|
||||||
|
forget_cmd(u, ord);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (u->orders==NULL) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* RECRUIT orders */
|
||||||
|
|
||||||
|
for (u = r->units; u; u = u->next) {
|
||||||
|
order * ord;
|
||||||
|
for (ord = u->orders; ord; ord = ord->next) {
|
||||||
|
if (get_keyword(ord) == K_RECRUIT) {
|
||||||
|
recruit(u, ord, &recruitorders);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recruitorders) expandrecruit(r, recruitorders);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (recruitorders) expandrecruit(r, recruitorders);
|
||||||
|
remove_empty_units_in_region(r);
|
||||||
}
|
}
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
|
@ -47,11 +47,11 @@ extern int income(const struct unit * u);
|
||||||
/* Wieviel Fremde eine Partei pro Woche aufnehmen kann */
|
/* Wieviel Fremde eine Partei pro Woche aufnehmen kann */
|
||||||
#define MAXNEWBIES 5
|
#define MAXNEWBIES 5
|
||||||
|
|
||||||
void economics(void);
|
void economics(struct region *r);
|
||||||
void produce(void);
|
void produce(void);
|
||||||
|
|
||||||
enum { IC_WORK, IC_ENTERTAIN, IC_TAX, IC_TRADE, IC_TRADETAX, IC_STEAL, IC_MAGIC };
|
enum { IC_WORK, IC_ENTERTAIN, IC_TAX, IC_TRADE, IC_TRADETAX, IC_STEAL, IC_MAGIC };
|
||||||
void maintain_buildings(boolean crash);
|
void maintain_buildings(struct region * r, boolean crash);
|
||||||
extern void add_spende(struct faction * f1, struct faction * f2, int betrag, struct region * r);
|
extern void add_spende(struct faction * f1, struct faction * f2, int betrag, struct region * r);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -761,23 +761,16 @@ monster_learn(unit *u)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
monsters_kill_peasants(void)
|
monsters_kill_peasants(unit * u)
|
||||||
{
|
{
|
||||||
region *r;
|
if (u->race->flags & RCF_SCAREPEASANTS) {
|
||||||
unit *u;
|
scared_by_monster(u);
|
||||||
|
}
|
||||||
for (r = regions; r; r = r->next) {
|
if (u->race->flags & RCF_KILLPEASANTS) {
|
||||||
for (u = r->units; u; u = u->next) if(!fval(u, UFL_MOVED)) {
|
eaten_by_monster(u);
|
||||||
if (u->race->flags & RCF_SCAREPEASANTS) {
|
}
|
||||||
scared_by_monster(u);
|
if (u->race->flags & RCF_ABSORBPEASANTS) {
|
||||||
}
|
absorbed_by_monster(u);
|
||||||
if (u->race->flags & RCF_KILLPEASANTS) {
|
|
||||||
eaten_by_monster(u);
|
|
||||||
}
|
|
||||||
if (u->race->flags & RCF_ABSORBPEASANTS) {
|
|
||||||
absorbed_by_monster(u);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ extern "C" {
|
||||||
|
|
||||||
void age_illusion(struct unit *u);
|
void age_illusion(struct unit *u);
|
||||||
|
|
||||||
void monsters_kill_peasants(void);
|
void monsters_kill_peasants(struct unit * u);
|
||||||
void plan_monsters(void);
|
void plan_monsters(void);
|
||||||
struct unit *random_unit(const struct region * r);
|
struct unit *random_unit(const struct region * r);
|
||||||
|
|
||||||
|
|
|
@ -459,9 +459,8 @@ sink_ship(region * r, ship * sh, const char *name, char spy, unit * saboteur)
|
||||||
sprintf(buf, (dead == 1) ? person_lost_msg : persons_lost_msg,
|
sprintf(buf, (dead == 1) ? person_lost_msg : persons_lost_msg,
|
||||||
dead, unitname(u), unit_dies_msg);
|
dead, unitname(u), unit_dies_msg);
|
||||||
}
|
}
|
||||||
if (dead == u->number)
|
if (dead == u->number) {
|
||||||
/* the poor creature, she dies */
|
/* the poor creature, she dies */
|
||||||
{
|
|
||||||
*ui = u->next;
|
*ui = u->next;
|
||||||
destroy_unit(u);
|
destroy_unit(u);
|
||||||
}
|
}
|
||||||
|
|
|
@ -439,11 +439,10 @@ teach(unit * u, struct order * ord)
|
||||||
}
|
}
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
|
||||||
void
|
int
|
||||||
learn(void)
|
learn_cmd(unit * u, order * ord)
|
||||||
{
|
{
|
||||||
region *r;
|
region *r = u->region;
|
||||||
unit *u;
|
|
||||||
int p;
|
int p;
|
||||||
magic_t mtyp;
|
magic_t mtyp;
|
||||||
int l;
|
int l;
|
||||||
|
@ -451,286 +450,281 @@ learn(void)
|
||||||
|
|
||||||
/* lernen nach lehren */
|
/* lernen nach lehren */
|
||||||
|
|
||||||
for (r = regions; r; r = r->next) {
|
int days;
|
||||||
for (u = r->units; u; u = u->next) {
|
double multi = 1.0;
|
||||||
int days;
|
attrib * a = NULL;
|
||||||
if (fval(r->terrain, SEA_REGION)) {
|
teaching_info * teach = NULL;
|
||||||
/* sonderbehandlung aller die auf Ozeanen lernen können */
|
int money = 0;
|
||||||
if (u->race!=new_race[RC_AQUARIAN] && !(u->race->flags & RCF_SWIM)) {
|
skill_t sk;
|
||||||
continue;
|
int maxalchemy = 0;
|
||||||
|
|
||||||
|
if (fval(r->terrain, SEA_REGION)) {
|
||||||
|
/* sonderbehandlung aller die auf Ozeanen lernen können */
|
||||||
|
if (u->race!=new_race[RC_AQUARIAN] && !(u->race->flags & RCF_SWIM)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fval(u, UFL_LONGACTION)) return 0;
|
||||||
|
|
||||||
|
if (u->race == new_race[RC_INSECT] && r_insectstalled(r)
|
||||||
|
&& !is_cursed(u->attribs, C_KAELTESCHUTZ,0)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (fval(u, UFL_LONGACTION)) {
|
||||||
|
cmistake(u, ord, 52, MSG_PRODUCE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if ((u->race->flags & RCF_NOLEARN) || fval(u, UFL_WERE)) {
|
||||||
|
sprintf(buf, "%s können nichts lernen", LOC(default_locale, rc_name(u->race, 1)));
|
||||||
|
mistake(u, ord, buf, MSG_EVENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
init_tokens(ord);
|
||||||
|
skip_token();
|
||||||
|
sk = getskill(u->faction->locale);
|
||||||
|
|
||||||
|
if (sk < 0) {
|
||||||
|
cmistake(u, ord, 77, MSG_EVENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (SkillCap(sk) && SkillCap(sk) <= effskill(u, sk)) {
|
||||||
|
cmistake(u, ord, 77, MSG_EVENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* Hack: Talente mit Malus -99 können nicht gelernt werden */
|
||||||
|
if (u->race->bonus[sk] == -99) {
|
||||||
|
cmistake(u, ord, 77, MSG_EVENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* snotlings können Talente nur bis T8 lernen */
|
||||||
|
if (u->race == new_race[RC_SNOTLING]){
|
||||||
|
if (get_level(u, sk) >= 8){
|
||||||
|
cmistake(u, ord, 308, MSG_EVENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p = studycost = study_cost(u, sk);
|
||||||
|
a = a_find(u->attribs, &at_learning);
|
||||||
|
if (a!=NULL) {
|
||||||
|
teach = (teaching_info*)a->data.v;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* keine kostenpflichtigen Talente für Migranten. Vertraute sind
|
||||||
|
* keine Migranten, wird in is_migrant abgefangen. Vorsicht,
|
||||||
|
* studycost darf hier noch nicht durch Akademie erhöht sein */
|
||||||
|
if (studycost > 0 && !ExpensiveMigrants() && is_migrant(u)) {
|
||||||
|
sprintf(buf, "Migranten können keine kostenpflichtigen Talente lernen");
|
||||||
|
mistake(u, ord, buf, MSG_EVENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* Akademie: */
|
||||||
|
{
|
||||||
|
struct building * b = inside_building(u);
|
||||||
|
const struct building_type * btype = b?b->type:NULL;
|
||||||
|
|
||||||
|
if (btype == bt_find("academy")) {
|
||||||
|
studycost = max(50, studycost * 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sk == SK_MAGIC) {
|
||||||
|
if (u->number > 1){
|
||||||
|
cmistake(u, ord, 106, MSG_MAGIC);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (is_familiar(u)){
|
||||||
|
/* Vertraute zählen nicht zu den Magiern einer Partei,
|
||||||
|
* können aber nur Graue Magie lernen */
|
||||||
|
mtyp = M_GRAU;
|
||||||
|
if (!is_mage(u)) create_mage(u, mtyp);
|
||||||
|
} else if (!has_skill(u, SK_MAGIC)) {
|
||||||
|
/* Die Einheit ist noch kein Magier */
|
||||||
|
if (count_skill(u->faction, SK_MAGIC) + u->number >
|
||||||
|
max_skill(u->faction, SK_MAGIC))
|
||||||
|
{
|
||||||
|
sprintf(buf, "Es kann maximal %d Magier pro Partei geben",
|
||||||
|
max_skill(u->faction, SK_MAGIC));
|
||||||
|
mistake(u, ord, buf, MSG_EVENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
mtyp = getmagicskill();
|
||||||
|
if (mtyp == M_NONE || mtyp == M_GRAU) {
|
||||||
|
/* wurde kein Magiegebiet angegeben, wird davon
|
||||||
|
* ausgegangen, daß das normal gelernt werden soll */
|
||||||
|
if(u->faction->magiegebiet != 0) {
|
||||||
|
mtyp = u->faction->magiegebiet;
|
||||||
|
} else {
|
||||||
|
/* Es wurde kein Magiegebiet angegeben und die Partei
|
||||||
|
* hat noch keins gewählt. */
|
||||||
|
cmistake(u, ord, 178, MSG_MAGIC);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fval(u, UFL_LONGACTION)) continue;
|
if (mtyp != u->faction->magiegebiet){
|
||||||
if (get_keyword(u->thisorder) == K_STUDY) {
|
/* Es wurde versucht, ein anderes Magiegebiet zu lernen
|
||||||
double multi = 1.0;
|
* als das der Partei */
|
||||||
attrib * a = NULL;
|
if (u->faction->magiegebiet != 0){
|
||||||
teaching_info * teach = NULL;
|
cmistake(u, ord, 179, MSG_MAGIC);
|
||||||
int money = 0;
|
return 0;
|
||||||
skill_t sk;
|
} else {
|
||||||
int maxalchemy = 0;
|
/* Lernt zum ersten mal Magie und legt damit das
|
||||||
|
* Magiegebiet der Partei fest */
|
||||||
|
u->faction->magiegebiet = mtyp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!is_mage(u)) create_mage(u, mtyp);
|
||||||
|
} else {
|
||||||
|
/* ist schon ein Magier und kein Vertrauter */
|
||||||
|
if(u->faction->magiegebiet == 0){
|
||||||
|
/* die Partei hat noch kein Magiegebiet gewählt. */
|
||||||
|
mtyp = getmagicskill();
|
||||||
|
if (mtyp == M_NONE){
|
||||||
|
cmistake(u, ord, 178, MSG_MAGIC);
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
/* Legt damit das Magiegebiet der Partei fest */
|
||||||
|
u->faction->magiegebiet = mtyp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sk == SK_ALCHEMY) {
|
||||||
|
maxalchemy = eff_skill(u, SK_ALCHEMY, r);
|
||||||
|
if (has_skill(u, SK_ALCHEMY)==0
|
||||||
|
&& count_skill(u->faction, SK_ALCHEMY) + u->number >
|
||||||
|
max_skill(u->faction, SK_ALCHEMY)) {
|
||||||
|
sprintf(buf, "Es kann maximal %d Alchemisten pro Partei geben",
|
||||||
|
max_skill(u->faction, SK_ALCHEMY));
|
||||||
|
mistake(u, ord, buf, MSG_EVENT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (studycost) {
|
||||||
|
int cost = studycost * u->number;
|
||||||
|
money = get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, cost);
|
||||||
|
money = min(money, cost);
|
||||||
|
}
|
||||||
|
if (money < studycost * u->number) {
|
||||||
|
studycost = p; /* Ohne Univertreurung */
|
||||||
|
money = min(money, studycost);
|
||||||
|
if (p>0 && money < studycost * u->number) {
|
||||||
|
#ifdef PARTIAL_STUDY
|
||||||
|
cmistake(u, ord, 65, MSG_EVENT);
|
||||||
|
multi = money / (double)(studycost * u->number);
|
||||||
|
#else
|
||||||
|
cmistake(u, ord, 65, MSG_EVENT);
|
||||||
|
return 0; /* nein, Silber reicht auch so nicht */
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (u->race == new_race[RC_INSECT] && r_insectstalled(r)
|
if (teach==NULL) {
|
||||||
&& !is_cursed(u->attribs, C_KAELTESCHUTZ,0)) {
|
a = a_add(&u->attribs, a_new(&at_learning));
|
||||||
continue;
|
teach = (teaching_info*)a->data.v;
|
||||||
}
|
teach->teachers[0] = 0;
|
||||||
if (fval(u, UFL_LONGACTION)) {
|
}
|
||||||
cmistake(u, u->thisorder, 52, MSG_PRODUCE);
|
if (money>0) {
|
||||||
continue;
|
use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, money);
|
||||||
}
|
ADDMSG(&u->faction->msgs, msg_message("studycost",
|
||||||
if ((u->race->flags & RCF_NOLEARN) || fval(u, UFL_WERE)) {
|
"unit region cost skill", u, u->region, money, sk));
|
||||||
sprintf(buf, "%s können nichts lernen", LOC(default_locale, rc_name(u->race, 1)));
|
}
|
||||||
mistake(u, u->thisorder, buf, MSG_EVENT);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
init_tokens(u->thisorder);
|
if (get_effect(u, oldpotiontype[P_WISE])) {
|
||||||
skip_token();
|
l = min(u->number, get_effect(u, oldpotiontype[P_WISE]));
|
||||||
sk = getskill(u->faction->locale);
|
teach->value += l * 10;
|
||||||
|
change_effect(u, oldpotiontype[P_WISE], -l);
|
||||||
|
}
|
||||||
|
if (get_effect(u, oldpotiontype[P_FOOL])) {
|
||||||
|
l = min(u->number, get_effect(u, oldpotiontype[P_FOOL]));
|
||||||
|
teach->value -= l * 30;
|
||||||
|
change_effect(u, oldpotiontype[P_FOOL], -l);
|
||||||
|
}
|
||||||
|
|
||||||
if (sk < 0) {
|
#ifdef KARMA_MODULE
|
||||||
cmistake(u, u->thisorder, 77, MSG_EVENT);
|
l = fspecial(u->faction, FS_WARRIOR);
|
||||||
continue;
|
if (l > 0) {
|
||||||
}
|
if (sk == SK_CROSSBOW || sk == SK_LONGBOW
|
||||||
if (SkillCap(sk) && SkillCap(sk) <= effskill(u, sk)) {
|
|| sk == SK_CATAPULT || sk == SK_MELEE || sk == SK_SPEAR
|
||||||
cmistake(u, u->thisorder, 77, MSG_EVENT);
|
|| sk == SK_AUSDAUER || sk == SK_WEAPONLESS)
|
||||||
continue;
|
{
|
||||||
}
|
teach->value += u->number * 5 * (l+1);
|
||||||
/* Hack: Talente mit Malus -99 können nicht gelernt werden */
|
} else {
|
||||||
if (u->race->bonus[sk] == -99) {
|
teach->value -= u->number * 5 * (l+1);
|
||||||
cmistake(u, u->thisorder, 77, MSG_EVENT);
|
teach->value = max(0, teach->value);
|
||||||
continue;
|
}
|
||||||
}
|
}
|
||||||
/* snotlings können Talente nur bis T8 lernen */
|
#endif /* KARMA_MODULE */
|
||||||
if (u->race == new_race[RC_SNOTLING]){
|
|
||||||
if (get_level(u, sk) >= 8){
|
|
||||||
cmistake(u, u->thisorder, 308, MSG_EVENT);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p = studycost = study_cost(u, sk);
|
if (p != studycost) {
|
||||||
a = a_find(u->attribs, &at_learning);
|
/* ist_in_gebaeude(r, u, BT_UNIVERSITAET) == 1) { */
|
||||||
if (a!=NULL) {
|
/* p ist Kosten ohne Uni, studycost mit; wenn
|
||||||
teach = (teaching_info*)a->data.v;
|
* p!=studycost, ist die Einheit zwangsweise
|
||||||
}
|
* in einer Uni */
|
||||||
|
teach->value += u->number * 10;
|
||||||
|
}
|
||||||
|
|
||||||
/* keine kostenpflichtigen Talente für Migranten. Vertraute sind
|
if (is_cursed(r->attribs, C_BADLEARN,0)) {
|
||||||
* keine Migranten, wird in is_migrant abgefangen. Vorsicht,
|
teach->value -= u->number * 10;
|
||||||
* studycost darf hier noch nicht durch Akademie erhöht sein */
|
}
|
||||||
if (studycost > 0 && !ExpensiveMigrants() && is_migrant(u)) {
|
|
||||||
sprintf(buf, "Migranten können keine kostenpflichtigen Talente lernen");
|
|
||||||
mistake(u, u->thisorder, buf, MSG_EVENT);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/* Akademie: */
|
|
||||||
{
|
|
||||||
struct building * b = inside_building(u);
|
|
||||||
const struct building_type * btype = b?b->type:NULL;
|
|
||||||
|
|
||||||
if (btype == bt_find("academy")) {
|
days = (int)((u->number * 30 + teach->value) * multi);
|
||||||
studycost = max(50, studycost * 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sk == SK_MAGIC) {
|
/* the artacademy currently improves the learning of entertainment
|
||||||
if (u->number > 1){
|
of all units in the region, to be able to make it cumulative with
|
||||||
cmistake(u, u->thisorder, 106, MSG_MAGIC);
|
with an academy */
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (is_familiar(u)){
|
|
||||||
/* Vertraute zählen nicht zu den Magiern einer Partei,
|
|
||||||
* können aber nur Graue Magie lernen */
|
|
||||||
mtyp = M_GRAU;
|
|
||||||
if (!is_mage(u)) create_mage(u, mtyp);
|
|
||||||
} else if (!has_skill(u, SK_MAGIC)) {
|
|
||||||
/* Die Einheit ist noch kein Magier */
|
|
||||||
if (count_skill(u->faction, SK_MAGIC) + u->number >
|
|
||||||
max_skill(u->faction, SK_MAGIC))
|
|
||||||
{
|
|
||||||
sprintf(buf, "Es kann maximal %d Magier pro Partei geben",
|
|
||||||
max_skill(u->faction, SK_MAGIC));
|
|
||||||
mistake(u, u->thisorder, buf, MSG_EVENT);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
mtyp = getmagicskill();
|
|
||||||
if (mtyp == M_NONE || mtyp == M_GRAU) {
|
|
||||||
/* wurde kein Magiegebiet angegeben, wird davon
|
|
||||||
* ausgegangen, daß das normal gelernt werden soll */
|
|
||||||
if(u->faction->magiegebiet != 0) {
|
|
||||||
mtyp = u->faction->magiegebiet;
|
|
||||||
} else {
|
|
||||||
/* Es wurde kein Magiegebiet angegeben und die Partei
|
|
||||||
* hat noch keins gewählt. */
|
|
||||||
cmistake(u, u->thisorder, 178, MSG_MAGIC);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mtyp != u->faction->magiegebiet){
|
|
||||||
/* Es wurde versucht, ein anderes Magiegebiet zu lernen
|
|
||||||
* als das der Partei */
|
|
||||||
if (u->faction->magiegebiet != 0){
|
|
||||||
cmistake(u, u->thisorder, 179, MSG_MAGIC);
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
/* Lernt zum ersten mal Magie und legt damit das
|
|
||||||
* Magiegebiet der Partei fest */
|
|
||||||
u->faction->magiegebiet = mtyp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!is_mage(u)) create_mage(u, mtyp);
|
|
||||||
} else {
|
|
||||||
/* ist schon ein Magier und kein Vertrauter */
|
|
||||||
if(u->faction->magiegebiet == 0){
|
|
||||||
/* die Partei hat noch kein Magiegebiet gewählt. */
|
|
||||||
mtyp = getmagicskill();
|
|
||||||
if (mtyp == M_NONE){
|
|
||||||
cmistake(u, u->thisorder, 178, MSG_MAGIC);
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
/* Legt damit das Magiegebiet der Partei fest */
|
|
||||||
u->faction->magiegebiet = mtyp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (sk == SK_ALCHEMY) {
|
|
||||||
maxalchemy = eff_skill(u, SK_ALCHEMY, r);
|
|
||||||
if (has_skill(u, SK_ALCHEMY)==0
|
|
||||||
&& count_skill(u->faction, SK_ALCHEMY) + u->number >
|
|
||||||
max_skill(u->faction, SK_ALCHEMY)) {
|
|
||||||
sprintf(buf, "Es kann maximal %d Alchemisten pro Partei geben",
|
|
||||||
max_skill(u->faction, SK_ALCHEMY));
|
|
||||||
mistake(u, u->thisorder, buf, MSG_EVENT);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (studycost) {
|
|
||||||
int cost = studycost * u->number;
|
|
||||||
money = get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, cost);
|
|
||||||
money = min(money, cost);
|
|
||||||
}
|
|
||||||
if (money < studycost * u->number) {
|
|
||||||
studycost = p; /* Ohne Univertreurung */
|
|
||||||
money = min(money, studycost);
|
|
||||||
if (p>0 && money < studycost * u->number) {
|
|
||||||
#ifdef PARTIAL_STUDY
|
|
||||||
cmistake(u, u->thisorder, 65, MSG_EVENT);
|
|
||||||
multi = money / (double)(studycost * u->number);
|
|
||||||
#else
|
|
||||||
cmistake(u, u->thisorder, 65, MSG_EVENT);
|
|
||||||
continue; /* nein, Silber reicht auch so nicht */
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (teach==NULL) {
|
if (sk == SK_ENTERTAINMENT && buildingtype_exists(r, bt_find("artacademy"))) {
|
||||||
a = a_add(&u->attribs, a_new(&at_learning));
|
days *= 2;
|
||||||
teach = (teaching_info*)a->data.v;
|
}
|
||||||
teach->teachers[0] = 0;
|
|
||||||
}
|
if (fval(u, UFL_HUNGER)) days /= 2;
|
||||||
if (money>0) {
|
|
||||||
use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, money);
|
while (days) {
|
||||||
ADDMSG(&u->faction->msgs, msg_message("studycost",
|
if (days>=u->number*30) {
|
||||||
"unit region cost skill", u, u->region, money, sk));
|
learn_skill(u, sk, 1.0);
|
||||||
|
days -= u->number*30;
|
||||||
|
} else {
|
||||||
|
double chance = (double)days/u->number/30;
|
||||||
|
learn_skill(u, sk, chance);
|
||||||
|
days = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (a!=NULL) {
|
||||||
|
if (teach!=NULL) {
|
||||||
|
int index = 0;
|
||||||
|
while (teach->teachers[index] && index!=MAXTEACHERS) {
|
||||||
|
unit * teacher = teach->teachers[index++];
|
||||||
|
if (teacher->faction != u->faction) {
|
||||||
|
ADDMSG(&u->faction->msgs, msg_message("teach_student",
|
||||||
|
"teacher student skill", teacher, u, sk));
|
||||||
|
ADDMSG(&teacher->faction->msgs, msg_message("teach_teacher",
|
||||||
|
"teacher student skill level", teacher, u, sk,
|
||||||
|
effskill(u, sk)));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a_remove(&u->attribs, a);
|
||||||
|
a = NULL;
|
||||||
|
}
|
||||||
|
fset(u, UFL_LONGACTION);
|
||||||
|
|
||||||
if (get_effect(u, oldpotiontype[P_WISE])) {
|
/* Anzeigen neuer Tränke */
|
||||||
l = min(u->number, get_effect(u, oldpotiontype[P_WISE]));
|
/* Spruchlistenaktualiesierung ist in Regeneration */
|
||||||
teach->value += l * 10;
|
|
||||||
change_effect(u, oldpotiontype[P_WISE], -l);
|
|
||||||
}
|
|
||||||
if (get_effect(u, oldpotiontype[P_FOOL])) {
|
|
||||||
l = min(u->number, get_effect(u, oldpotiontype[P_FOOL]));
|
|
||||||
teach->value -= l * 30;
|
|
||||||
change_effect(u, oldpotiontype[P_FOOL], -l);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef KARMA_MODULE
|
if (sk == SK_ALCHEMY) {
|
||||||
l = fspecial(u->faction, FS_WARRIOR);
|
const potion_type * ptype;
|
||||||
if (l > 0) {
|
faction * f = u->faction;
|
||||||
if (sk == SK_CROSSBOW || sk == SK_LONGBOW
|
int skill = eff_skill(u, SK_ALCHEMY, r);
|
||||||
|| sk == SK_CATAPULT || sk == SK_MELEE || sk == SK_SPEAR
|
if (skill>maxalchemy) {
|
||||||
|| sk == SK_AUSDAUER || sk == SK_WEAPONLESS)
|
for (ptype=potiontypes; ptype; ptype=ptype->next) {
|
||||||
{
|
if (skill == ptype->level * 2) {
|
||||||
teach->value += u->number * 5 * (l+1);
|
attrib * a = a_find(f->attribs, &at_showitem);
|
||||||
} else {
|
while (a && a->type==&at_showitem && a->data.v != ptype) a=a->next;
|
||||||
teach->value -= u->number * 5 * (l+1);
|
if (a==NULL || a->type!=&at_showitem) {
|
||||||
teach->value = max(0, teach->value);
|
a = a_add(&f->attribs, a_new(&at_showitem));
|
||||||
}
|
a->data.v = (void*) ptype->itype;
|
||||||
}
|
|
||||||
#endif /* KARMA_MODULE */
|
|
||||||
|
|
||||||
if (p != studycost) {
|
|
||||||
/* ist_in_gebaeude(r, u, BT_UNIVERSITAET) == 1) { */
|
|
||||||
/* p ist Kosten ohne Uni, studycost mit; wenn
|
|
||||||
* p!=studycost, ist die Einheit zwangsweise
|
|
||||||
* in einer Uni */
|
|
||||||
teach->value += u->number * 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_cursed(r->attribs, C_BADLEARN,0)) {
|
|
||||||
teach->value -= u->number * 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
days = (int)((u->number * 30 + teach->value) * multi);
|
|
||||||
|
|
||||||
/* the artacademy currently improves the learning of entertainment
|
|
||||||
of all units in the region, to be able to make it cumulative with
|
|
||||||
with an academy */
|
|
||||||
|
|
||||||
if (sk == SK_ENTERTAINMENT && buildingtype_exists(r, bt_find("artacademy"))) {
|
|
||||||
days *= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fval(u, UFL_HUNGER)) days /= 2;
|
|
||||||
|
|
||||||
while (days) {
|
|
||||||
if (days>=u->number*30) {
|
|
||||||
learn_skill(u, sk, 1.0);
|
|
||||||
days -= u->number*30;
|
|
||||||
} else {
|
|
||||||
double chance = (double)days/u->number/30;
|
|
||||||
learn_skill(u, sk, chance);
|
|
||||||
days = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (a!=NULL) {
|
|
||||||
if (teach!=NULL) {
|
|
||||||
int index = 0;
|
|
||||||
while (teach->teachers[index] && index!=MAXTEACHERS) {
|
|
||||||
unit * teacher = teach->teachers[index++];
|
|
||||||
if (teacher->faction != u->faction) {
|
|
||||||
ADDMSG(&u->faction->msgs, msg_message("teach_student",
|
|
||||||
"teacher student skill", teacher, u, sk));
|
|
||||||
ADDMSG(&teacher->faction->msgs, msg_message("teach_teacher",
|
|
||||||
"teacher student skill level", teacher, u, sk,
|
|
||||||
effskill(u, sk)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
a_remove(&u->attribs, a);
|
|
||||||
a = NULL;
|
|
||||||
}
|
|
||||||
fset(u, UFL_LONGACTION);
|
|
||||||
|
|
||||||
/* Anzeigen neuer Tränke */
|
|
||||||
/* Spruchlistenaktualiesierung ist in Regeneration */
|
|
||||||
|
|
||||||
if (sk == SK_ALCHEMY) {
|
|
||||||
const potion_type * ptype;
|
|
||||||
faction * f = u->faction;
|
|
||||||
int skill = eff_skill(u, SK_ALCHEMY, r);
|
|
||||||
if (skill>maxalchemy) {
|
|
||||||
for (ptype=potiontypes; ptype; ptype=ptype->next) {
|
|
||||||
if (skill == ptype->level * 2) {
|
|
||||||
attrib * a = a_find(f->attribs, &at_showitem);
|
|
||||||
while (a && a->type==&at_showitem && a->data.v != ptype) a=a->next;
|
|
||||||
if (a==NULL || a->type!=&at_showitem) {
|
|
||||||
a = a_add(&f->attribs, a_new(&at_showitem));
|
|
||||||
a->data.v = (void*) ptype->itype;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -738,54 +732,50 @@ learn(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
teaching(void)
|
teaching(region *r)
|
||||||
{
|
{
|
||||||
region *r;
|
|
||||||
/* das sind alles befehle, die 30 tage brauchen, und die in thisorder
|
/* das sind alles befehle, die 30 tage brauchen, und die in thisorder
|
||||||
* stehen! von allen 30-tage befehlen wird einfach der letzte verwendet
|
* stehen! von allen 30-tage befehlen wird einfach der letzte verwendet
|
||||||
* (dosetdefaults).
|
* (dosetdefaults).
|
||||||
*
|
*
|
||||||
* lehren vor lernen. */
|
* lehren vor lernen. */
|
||||||
|
|
||||||
for (r = regions; r; r = r->next) {
|
unit *u;
|
||||||
unit *u;
|
|
||||||
|
|
||||||
for (u = r->units; u; u = u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
|
|
||||||
if (u->race == new_race[RC_SPELL] || fval(u, UFL_LONGACTION))
|
if (u->race == new_race[RC_SPELL] || fval(u, UFL_LONGACTION))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (fval(r->terrain, SEA_REGION)
|
||||||
|
&& u->race != new_race[RC_AQUARIAN]
|
||||||
|
&& !(u->race->flags & RCF_SWIM))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (fval(r->terrain, SEA_REGION)
|
if (u->race == new_race[RC_INSECT] && r_insectstalled(r)
|
||||||
&& u->race != new_race[RC_AQUARIAN]
|
&& !is_cursed(u->attribs, C_KAELTESCHUTZ,0)) {
|
||||||
&& !(u->race->flags & RCF_SWIM))
|
continue;
|
||||||
continue;
|
}
|
||||||
|
|
||||||
if (u->race == new_race[RC_INSECT] && r_insectstalled(r)
|
switch (get_keyword(u->thisorder)) {
|
||||||
&& !is_cursed(u->attribs, C_KAELTESCHUTZ,0)) {
|
case K_TEACH:
|
||||||
|
if (fval(u, UFL_LONGACTION)) {
|
||||||
|
cmistake(u, u->thisorder, 52, MSG_PRODUCE);
|
||||||
continue;
|
continue;
|
||||||
}
|
} else {
|
||||||
|
static const curse_type * gbdream_ct = NULL;
|
||||||
switch (get_keyword(u->thisorder)) {
|
if (gbdream_ct==0) gbdream_ct = ct_find("gbdream");
|
||||||
case K_TEACH:
|
if (gbdream_ct) {
|
||||||
if (fval(u, UFL_LONGACTION)) {
|
if (get_curse(u->region->attribs, gbdream_ct)) {
|
||||||
cmistake(u, u->thisorder, 52, MSG_PRODUCE);
|
ADDMSG(&u->faction->msgs,
|
||||||
continue;
|
msg_feedback(u, u->thisorder, "gbdream_noteach", ""));
|
||||||
} else {
|
continue;
|
||||||
static const curse_type * gbdream_ct = NULL;
|
|
||||||
if (gbdream_ct==0) gbdream_ct = ct_find("gbdream");
|
|
||||||
if (gbdream_ct) {
|
|
||||||
if (get_curse(u->region->attribs, gbdream_ct)) {
|
|
||||||
ADDMSG(&u->faction->msgs,
|
|
||||||
msg_feedback(u, u->thisorder, "gbdream_noteach", ""));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
teach(u, u->thisorder);
|
}
|
||||||
break;
|
teach(u, u->thisorder);
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void teaching(void);
|
extern void teaching(struct region * r);
|
||||||
extern void learn(void);
|
extern int learn_cmd(struct unit * u, struct order * ord);
|
||||||
|
|
||||||
extern magic_t getmagicskill(void);
|
extern magic_t getmagicskill(void);
|
||||||
extern boolean is_migrant(struct unit *u);
|
extern boolean is_migrant(struct unit *u);
|
||||||
|
|
|
@ -3988,106 +3988,101 @@ battle_flee(battle * b)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
do_battle(void)
|
do_battle(region * r)
|
||||||
{
|
{
|
||||||
region *r;
|
|
||||||
#ifdef SMALL_BATTLE_MESSAGES
|
#ifdef SMALL_BATTLE_MESSAGES
|
||||||
char smallbuf[512];
|
char smallbuf[512];
|
||||||
#endif
|
#endif
|
||||||
|
battle *b = NULL;
|
||||||
|
boolean fighting = false;
|
||||||
|
ship * sh;
|
||||||
|
building *bu;
|
||||||
|
|
||||||
for (r=regions;r!=NULL;r=r->next) {
|
fighting = init_battle(r, &b);
|
||||||
battle *b = NULL;
|
|
||||||
boolean fighting = false;
|
|
||||||
ship * sh;
|
|
||||||
building *bu;
|
|
||||||
/* int *rows; */
|
|
||||||
|
|
||||||
fighting = init_battle(r, &b);
|
if (b==NULL) return;
|
||||||
|
|
||||||
if (b==NULL) continue;
|
/* Bevor wir die alliierten hineinziehen, sollten wir schauen, *
|
||||||
|
* Ob jemand fliehen kann. Dann erübrigt sich das ganze ja
|
||||||
/* Bevor wir die alliierten hineinziehen, sollten wir schauen, *
|
* vielleicht schon. */
|
||||||
* Ob jemand fliehen kann. Dann erübrigt sich das ganze ja
|
print_header(b);
|
||||||
* vielleicht schon. */
|
if (!fighting) {
|
||||||
print_header(b);
|
/* Niemand mehr da, Kampf kann nicht stattfinden. */
|
||||||
if (!fighting) {
|
message * m = msg_message("battle::aborted", "");
|
||||||
/* Niemand mehr da, Kampf kann nicht stattfinden. */
|
message_all(b, m);
|
||||||
message * m = msg_message("battle::aborted", "");
|
msg_release(m);
|
||||||
message_all(b, m);
|
free_battle(b);
|
||||||
msg_release(m);
|
free(b);
|
||||||
free_battle(b);
|
return;
|
||||||
free(b);
|
}
|
||||||
continue;
|
join_allies(b);
|
||||||
}
|
|
||||||
join_allies(b);
|
|
||||||
#ifdef HEROES
|
#ifdef HEROES
|
||||||
make_heroes(b);
|
make_heroes(b);
|
||||||
#endif
|
#endif
|
||||||
/* Alle Mann raus aus der Burg! */
|
/* Alle Mann raus aus der Burg! */
|
||||||
for (bu=r->buildings; bu!=NULL; bu=bu->next) bu->sizeleft = bu->size;
|
for (bu=r->buildings; bu!=NULL; bu=bu->next) bu->sizeleft = bu->size;
|
||||||
|
|
||||||
/* make sure no ships are damaged initially */
|
/* make sure no ships are damaged initially */
|
||||||
for (sh=r->ships; sh; sh=sh->next) freset(sh, SF_DAMAGED);
|
for (sh=r->ships; sh; sh=sh->next) freset(sh, SF_DAMAGED);
|
||||||
|
|
||||||
/* Gibt es eine Taktikrunde ? */
|
/* Gibt es eine Taktikrunde ? */
|
||||||
if (cv_size(&b->leaders)) {
|
if (cv_size(&b->leaders)) {
|
||||||
b->turn = 0;
|
b->turn = 0;
|
||||||
b->has_tactics_turn = true;
|
b->has_tactics_turn = true;
|
||||||
} else {
|
} else {
|
||||||
b->turn = 1;
|
b->turn = 1;
|
||||||
b->has_tactics_turn = false;
|
b->has_tactics_turn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b->region->flags & RF_COMBATDEBUG) battle_stats(bdebug, b);
|
if (b->region->flags & RF_COMBATDEBUG) battle_stats(bdebug, b);
|
||||||
|
|
||||||
/* PRECOMBATSPELLS */
|
/* PRECOMBATSPELLS */
|
||||||
do_combatmagic(b, DO_PRECOMBATSPELL);
|
do_combatmagic(b, DO_PRECOMBATSPELL);
|
||||||
|
|
||||||
print_stats(b); /* gibt die Kampfaufstellung aus */
|
print_stats(b); /* gibt die Kampfaufstellung aus */
|
||||||
printf("%s (%d, %d) : ", rname(r, NULL), r->x, r->y);
|
printf("%s (%d, %d) : ", rname(r, NULL), r->x, r->y);
|
||||||
|
|
||||||
#ifdef SMALL_BATTLE_MESSAGES
|
#ifdef SMALL_BATTLE_MESSAGES
|
||||||
if (b->nfighters <= 30) {
|
if (b->nfighters <= 30) {
|
||||||
b->small = true;
|
b->small = true;
|
||||||
} else {
|
} else {
|
||||||
b->small = false;
|
b->small = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (;battle_report(b) && b->turn<=COMBAT_TURNS;++b->turn) {
|
for (;battle_report(b) && b->turn<=COMBAT_TURNS;++b->turn) {
|
||||||
char lbuf[256];
|
char lbuf[256];
|
||||||
|
|
||||||
sprintf(lbuf, "*** Runde: %d", b->turn);
|
sprintf(lbuf, "*** Runde: %d", b->turn);
|
||||||
battledebug(lbuf);
|
battledebug(lbuf);
|
||||||
|
|
||||||
battle_flee(b);
|
battle_flee(b);
|
||||||
battle_update(b);
|
battle_update(b);
|
||||||
battle_attacks(b);
|
battle_attacks(b);
|
||||||
|
|
||||||
#ifdef KARMA_MODULE
|
#ifdef KARMA_MODULE
|
||||||
/* Regeneration */
|
/* Regeneration */
|
||||||
for (fi=0;fi!=b->nfighters;++fi) {
|
for (fi=0;fi!=b->nfighters;++fi) {
|
||||||
fighter *fig = b->fighters[fi];
|
fighter *fig = b->fighters[fi];
|
||||||
|
|
||||||
if (fspecial(fig->unit->faction, FS_REGENERATION)) {
|
if (fspecial(fig->unit->faction, FS_REGENERATION)) {
|
||||||
fig->fighting = fig->alive - fig->removed;
|
fig->fighting = fig->alive - fig->removed;
|
||||||
if (fig->fighting == 0) continue;
|
if (fig->fighting == 0) continue;
|
||||||
do_regenerate(fig);
|
do_regenerate(fig);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif /* KARMA_MODULE */
|
#endif /* KARMA_MODULE */
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
/* Auswirkungen berechnen: */
|
/* Auswirkungen berechnen: */
|
||||||
aftermath(b);
|
aftermath(b);
|
||||||
/* Hier ist das Gefecht beendet, und wir können die
|
/* Hier ist das Gefecht beendet, und wir können die
|
||||||
* Hilfsstrukturen * wieder löschen: */
|
* Hilfsstrukturen * wieder löschen: */
|
||||||
|
|
||||||
if (b) {
|
if (b) {
|
||||||
free_battle(b);
|
free_battle(b);
|
||||||
free(b);
|
free(b);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,7 +206,7 @@ extern "C" {
|
||||||
|
|
||||||
extern const troop no_troop;
|
extern const troop no_troop;
|
||||||
|
|
||||||
extern void do_battle(void);
|
extern void do_battle(struct region * r);
|
||||||
|
|
||||||
/* for combar spells and special attacks */
|
/* for combar spells and special attacks */
|
||||||
enum { SELECT_ADVANCE = 0x1, SELECT_DISTANCE = 0x2, SELECT_FIND = 0x4 };
|
enum { SELECT_ADVANCE = 0x1, SELECT_DISTANCE = 0x2, SELECT_FIND = 0x4 };
|
||||||
|
|
|
@ -281,18 +281,14 @@ siege_cmd(unit * u, order * ord)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
do_siege(void)
|
do_siege(region *r)
|
||||||
{
|
{
|
||||||
region *r;
|
if (fval(r->terrain, LAND_REGION)) {
|
||||||
|
unit *u;
|
||||||
|
|
||||||
for (r = regions; r; r = r->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
if (fval(r->terrain, LAND_REGION)) {
|
if (get_keyword(u->thisorder) == K_BESIEGE) {
|
||||||
unit *u;
|
siege_cmd(u, u->thisorder);
|
||||||
|
|
||||||
for (u = r->units; u; u = u->next) {
|
|
||||||
if (get_keyword(u->thisorder) == K_BESIEGE) {
|
|
||||||
siege_cmd(u, u->thisorder);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1106,26 +1102,6 @@ mayboard(const unit * u, const ship * sh)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
remove_contacts(void)
|
|
||||||
{
|
|
||||||
region *r;
|
|
||||||
|
|
||||||
for (r = regions; r; r = r->next) {
|
|
||||||
unit *u;
|
|
||||||
|
|
||||||
for (u = r->units; u; u = u->next) {
|
|
||||||
attrib * a = (attrib *)a_find(u->attribs, &at_contact);
|
|
||||||
|
|
||||||
while (a!=NULL &&a->type==&at_contact) {
|
|
||||||
attrib * ar = a;
|
|
||||||
a = a->next;
|
|
||||||
a_remove(&u->attribs, ar);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
leave_cmd(unit * u, struct order * ord)
|
leave_cmd(unit * u, struct order * ord)
|
||||||
{
|
{
|
||||||
|
@ -1255,93 +1231,87 @@ enter_building(unit * u, order * ord, int id, boolean report)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
do_misc(boolean lasttry)
|
do_misc(region * r, boolean lasttry)
|
||||||
{
|
{
|
||||||
region *r;
|
unit **uptr, *uc;
|
||||||
|
|
||||||
/* lasttry: Fehler nur im zweiten Versuch melden. Sonst konfus. */
|
for (uc = r->units; uc; uc = uc->next) {
|
||||||
|
order * ord;
|
||||||
|
for (ord = uc->orders; ord; ord = ord->next) {
|
||||||
|
switch (get_keyword(ord)) {
|
||||||
|
case K_CONTACT:
|
||||||
|
contact_cmd(uc, ord, lasttry);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (r = regions; r; r = r->next) {
|
for (uptr = &r->units; *uptr;) {
|
||||||
unit **uptr, *uc;
|
unit * u = *uptr;
|
||||||
|
order ** ordp = &u->orders;
|
||||||
|
|
||||||
for (uc = r->units; uc; uc = uc->next) {
|
while (*ordp) {
|
||||||
order * ord;
|
order * ord = *ordp;
|
||||||
for (ord = uc->orders; ord; ord = ord->next) {
|
if (get_keyword(ord) == K_ENTER) {
|
||||||
switch (get_keyword(ord)) {
|
param_t p;
|
||||||
case K_CONTACT:
|
int id;
|
||||||
contact_cmd(uc, ord, lasttry);
|
unit * ulast = NULL;
|
||||||
|
|
||||||
|
init_tokens(ord);
|
||||||
|
skip_token();
|
||||||
|
p = getparam(u->faction->locale);
|
||||||
|
id = getid();
|
||||||
|
|
||||||
|
switch (p) {
|
||||||
|
case P_BUILDING:
|
||||||
|
case P_GEBAEUDE:
|
||||||
|
if (u->building && u->building->no==id) break;
|
||||||
|
if (enter_building(u, ord, id, lasttry)) {
|
||||||
|
unit *ub;
|
||||||
|
for (ub=u;ub;ub=ub->next) {
|
||||||
|
if (ub->building==u->building) {
|
||||||
|
ulast = ub;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case P_SHIP:
|
||||||
|
if (u->ship && u->ship->no==id) break;
|
||||||
|
if (enter_ship(u, ord, id, lasttry)) {
|
||||||
|
unit *ub;
|
||||||
|
ulast = u;
|
||||||
|
for (ub=u;ub;ub=ub->next) {
|
||||||
|
if (ub->ship==u->ship) {
|
||||||
|
ulast = ub;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (lasttry) cmistake(u, ord, 79, MSG_MOVE);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (ulast!=NULL) {
|
||||||
|
/* Wenn wir hier angekommen sind, war der Befehl
|
||||||
|
* erfolgreich und wir löschen ihn, damit er im
|
||||||
|
* zweiten Versuch nicht nochmal ausgeführt wird. */
|
||||||
|
*ordp = ord->next;
|
||||||
|
ord->next = NULL;
|
||||||
|
free_order(ord);
|
||||||
|
|
||||||
|
if (ulast!=u) {
|
||||||
|
/* put u behind ulast so it's the last unit in the building */
|
||||||
|
*uptr = u->next;
|
||||||
|
u->next = ulast->next;
|
||||||
|
ulast->next = u;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (*ordp==ord) ordp = &ord->next;
|
||||||
}
|
}
|
||||||
|
if (*uptr==u) uptr = &u->next;
|
||||||
for (uptr = &r->units; *uptr;) {
|
|
||||||
unit * u = *uptr;
|
|
||||||
order ** ordp = &u->orders;
|
|
||||||
|
|
||||||
while (*ordp) {
|
|
||||||
order * ord = *ordp;
|
|
||||||
if (get_keyword(ord) == K_ENTER) {
|
|
||||||
param_t p;
|
|
||||||
int id;
|
|
||||||
unit * ulast = NULL;
|
|
||||||
|
|
||||||
init_tokens(ord);
|
|
||||||
skip_token();
|
|
||||||
p = getparam(u->faction->locale);
|
|
||||||
id = getid();
|
|
||||||
|
|
||||||
switch (p) {
|
|
||||||
case P_BUILDING:
|
|
||||||
case P_GEBAEUDE:
|
|
||||||
if (u->building && u->building->no==id) break;
|
|
||||||
if (enter_building(u, ord, id, lasttry)) {
|
|
||||||
unit *ub;
|
|
||||||
for (ub=u;ub;ub=ub->next) {
|
|
||||||
if (ub->building==u->building) {
|
|
||||||
ulast = ub;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case P_SHIP:
|
|
||||||
if (u->ship && u->ship->no==id) break;
|
|
||||||
if (enter_ship(u, ord, id, lasttry)) {
|
|
||||||
unit *ub;
|
|
||||||
ulast = u;
|
|
||||||
for (ub=u;ub;ub=ub->next) {
|
|
||||||
if (ub->ship==u->ship) {
|
|
||||||
ulast = ub;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if (lasttry) cmistake(u, ord, 79, MSG_MOVE);
|
|
||||||
|
|
||||||
}
|
|
||||||
if (ulast!=NULL) {
|
|
||||||
/* Wenn wir hier angekommen sind, war der Befehl
|
|
||||||
* erfolgreich und wir löschen ihn, damit er im
|
|
||||||
* zweiten Versuch nicht nochmal ausgeführt wird. */
|
|
||||||
*ordp = ord->next;
|
|
||||||
ord->next = NULL;
|
|
||||||
free_order(ord);
|
|
||||||
|
|
||||||
if (ulast!=u) {
|
|
||||||
/* put u behind ulast so it's the last unit in the building */
|
|
||||||
*uptr = u->next;
|
|
||||||
u->next = ulast->next;
|
|
||||||
ulast->next = u;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (*ordp==ord) ordp = &ord->next;
|
|
||||||
}
|
|
||||||
if (*uptr==u) uptr = &u->next;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ extern int leave_cmd(struct unit * u, struct order * ord);
|
||||||
|
|
||||||
extern boolean can_contact(const struct region *r, const struct unit *u, const struct unit *u2);
|
extern boolean can_contact(const struct region *r, const struct unit *u, const struct unit *u2);
|
||||||
|
|
||||||
void do_siege(void);
|
void do_siege(struct region *r);
|
||||||
void build_road(struct region * r, struct unit * u, int size, direction_t d);
|
void build_road(struct region * r, struct unit * u, int size, direction_t d);
|
||||||
void create_ship(struct region * r, struct unit * u, const struct ship_type * newtype, int size, struct order * ord);
|
void create_ship(struct region * r, struct unit * u, const struct ship_type * newtype, int size, struct order * ord);
|
||||||
void continue_ship(struct region * r, struct unit * u, int size);
|
void continue_ship(struct region * r, struct unit * u, int size);
|
||||||
|
@ -70,8 +70,7 @@ void continue_ship(struct region * r, struct unit * u, int size);
|
||||||
struct building * getbuilding(const struct region * r);
|
struct building * getbuilding(const struct region * r);
|
||||||
struct ship *getship(const struct region * r);
|
struct ship *getship(const struct region * r);
|
||||||
|
|
||||||
void remove_contacts(void);
|
void do_misc(struct region *r, boolean tries);
|
||||||
void do_misc(boolean tries);
|
|
||||||
|
|
||||||
void reportevent(struct region * r, char *s);
|
void reportevent(struct region * r, char *s);
|
||||||
|
|
||||||
|
|
|
@ -496,7 +496,7 @@ destroy_building(building * b)
|
||||||
|
|
||||||
/* Stattdessen nur aus Liste entfernen, aber im Speicher halten. */
|
/* Stattdessen nur aus Liste entfernen, aber im Speicher halten. */
|
||||||
choplist(&b->region->buildings, b);
|
choplist(&b->region->buildings, b);
|
||||||
handle_event(&b->attribs, "destroy", b);
|
handle_event(b->attribs, "destroy", b);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern attrib_type at_icastle;
|
extern attrib_type at_icastle;
|
||||||
|
|
|
@ -2539,9 +2539,9 @@ remove_empty_units_in_region(region *r)
|
||||||
faction * f = u->faction;
|
faction * f = u->faction;
|
||||||
if (!fval(f, FFL_NOTIMEOUT) && f->age > MaxAge()) set_number(u, 0);
|
if (!fval(f, FFL_NOTIMEOUT) && f->age > MaxAge()) set_number(u, 0);
|
||||||
}
|
}
|
||||||
if ((u->number == 0 && u->race != new_race[RC_SPELL])
|
if ((u->number == 0 && u->race != new_race[RC_SPELL]) || (u->age <= 0 && u->race == new_race[RC_SPELL])) {
|
||||||
|| (u->age <= 0 && u->race == new_race[RC_SPELL])) {
|
|
||||||
destroy_unit(u);
|
destroy_unit(u);
|
||||||
|
if (u->number==0) remove_unit(u);
|
||||||
}
|
}
|
||||||
if (*up==u) up=&u->next;
|
if (*up==u) up=&u->next;
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,7 +253,7 @@ destroyfaction(faction * f)
|
||||||
}
|
}
|
||||||
f->alive = 0;
|
f->alive = 0;
|
||||||
/* no way! f->units = NULL; */
|
/* no way! f->units = NULL; */
|
||||||
handle_event(&f->attribs, "destroy", f);
|
handle_event(f->attribs, "destroy", f);
|
||||||
for (ff = factions; ff; ff = ff->next) {
|
for (ff = factions; ff; ff = ff->next) {
|
||||||
group *g;
|
group *g;
|
||||||
ally *sf, *sfn;
|
ally *sf, *sfn;
|
||||||
|
|
|
@ -124,8 +124,8 @@ give_item(int want, const item_type * itype, unit * src, unit * dest, struct ord
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
handle_event(&src->attribs, "give", dest);
|
handle_event(src->attribs, "give", dest);
|
||||||
handle_event(&dest->attribs, "receive", src);
|
handle_event(dest->attribs, "receive", src);
|
||||||
#if defined(MUSEUM_MODULE) && defined(TODO)
|
#if defined(MUSEUM_MODULE) && defined(TODO)
|
||||||
/* TODO: Einen Trigger für den museums-warden benutzen! */
|
/* TODO: Einen Trigger für den museums-warden benutzen! */
|
||||||
if (a_find(dest->attribs, &at_warden)) {
|
if (a_find(dest->attribs, &at_warden)) {
|
||||||
|
|
|
@ -2807,6 +2807,7 @@ magic(void)
|
||||||
for (spellrank = 0; spellrank < MAX_SPELLRANK; spellrank++) {
|
for (spellrank = 0; spellrank < MAX_SPELLRANK; spellrank++) {
|
||||||
free_castorders(cll[spellrank]);
|
free_castorders(cll[spellrank]);
|
||||||
}
|
}
|
||||||
|
remove_empty_units();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
|
|
@ -2524,83 +2524,81 @@ movement(void)
|
||||||
* FOLLOW SHIP is a long order, and doesn't need to be treated in here.
|
* FOLLOW SHIP is a long order, and doesn't need to be treated in here.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
follow_unit(void)
|
follow_unit(unit * u)
|
||||||
{
|
{
|
||||||
region * r;
|
region * r = u->region;
|
||||||
|
attrib * a = NULL;
|
||||||
|
order * ord;
|
||||||
|
|
||||||
for (r=regions;r;r=r->next) {
|
if (fval(u, UFL_LONGACTION) || LongHunger(u)) return;
|
||||||
unit * u;
|
|
||||||
|
|
||||||
for (u=r->units;u;u=u->next) {
|
for (ord=u->orders;ord;ord=ord->next) {
|
||||||
attrib * a;
|
const struct locale * lang = u->faction->locale;
|
||||||
order * ord;
|
|
||||||
|
|
||||||
if (fval(u, UFL_LONGACTION) || LongHunger(u)) continue;
|
if (get_keyword(ord) == K_FOLLOW) {
|
||||||
a = a_find(u->attribs, &at_follow);
|
init_tokens(ord);
|
||||||
for (ord=u->orders;ord;ord=ord->next) {
|
skip_token();
|
||||||
const struct locale * lang = u->faction->locale;
|
if (getparam(lang) == P_UNIT) {
|
||||||
|
int id = read_unitid(u->faction, r);
|
||||||
|
|
||||||
if (get_keyword(ord) == K_FOLLOW) {
|
if (a!=NULL) {
|
||||||
init_tokens(ord);
|
a = a_find(u->attribs, &at_follow);
|
||||||
skip_token();
|
}
|
||||||
if (getparam(lang) == P_UNIT) {
|
|
||||||
int id = read_unitid(u->faction, r);
|
|
||||||
|
|
||||||
if (id>0) {
|
if (id>0) {
|
||||||
unit * uf = findunit(id);
|
unit * uf = findunit(id);
|
||||||
if (!a) {
|
if (!a) {
|
||||||
a = a_add(&u->attribs, make_follow(uf));
|
a = a_add(&u->attribs, make_follow(uf));
|
||||||
} else {
|
} else {
|
||||||
a->data.v = uf;
|
a->data.v = uf;
|
||||||
}
|
|
||||||
} else if (a) {
|
|
||||||
a_remove(&u->attribs, a);
|
|
||||||
a = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
} else if (a) {
|
||||||
}
|
a_remove(&u->attribs, a);
|
||||||
|
a = NULL;
|
||||||
if (a && !fval(u, UFL_MOVED|UFL_NOTMOVING)) {
|
|
||||||
unit * u2 = a->data.v;
|
|
||||||
boolean follow = false;
|
|
||||||
|
|
||||||
if (!u2 || u2->region!=r || !cansee(u->faction, r, u2, 0))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
switch (get_keyword(u2->thisorder)) {
|
|
||||||
case K_MOVE:
|
|
||||||
case K_ROUTE:
|
|
||||||
case K_DRIVE:
|
|
||||||
follow = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
for (ord=u2->orders;ord;ord=ord->next) {
|
|
||||||
switch (get_keyword(ord)) {
|
|
||||||
case K_FOLLOW:
|
|
||||||
case K_PIRACY:
|
|
||||||
follow = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!follow) {
|
|
||||||
attrib * a2 = a_find(u2->attribs, &at_follow);
|
|
||||||
if (a2!=NULL) {
|
|
||||||
unit * u3 = a2->data.v;
|
|
||||||
follow = (u3 && u2->region == u2->region);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (follow) {
|
|
||||||
fset(u, UFL_FOLLOWING);
|
|
||||||
fset(u2, UFL_FOLLOWED);
|
|
||||||
set_order(&u->thisorder, NULL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (a && !fval(u, UFL_MOVED|UFL_NOTMOVING)) {
|
||||||
|
unit * u2 = a->data.v;
|
||||||
|
boolean follow = false;
|
||||||
|
|
||||||
|
if (!u2 || u2->region!=r || !cansee(u->faction, r, u2, 0)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (get_keyword(u2->thisorder)) {
|
||||||
|
case K_MOVE:
|
||||||
|
case K_ROUTE:
|
||||||
|
case K_DRIVE:
|
||||||
|
follow = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
for (ord=u2->orders;ord;ord=ord->next) {
|
||||||
|
switch (get_keyword(ord)) {
|
||||||
|
case K_FOLLOW:
|
||||||
|
case K_PIRACY:
|
||||||
|
follow = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!follow) {
|
||||||
|
attrib * a2 = a_find(u2->attribs, &at_follow);
|
||||||
|
if (a2!=NULL) {
|
||||||
|
unit * u3 = a2->data.v;
|
||||||
|
follow = (u3 && u2->region == u2->region);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (follow) {
|
||||||
|
fset(u, UFL_FOLLOWING);
|
||||||
|
fset(u2, UFL_FOLLOWED);
|
||||||
|
set_order(&u->thisorder, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ extern void travelthru(const struct unit * u, struct region * r);
|
||||||
extern struct ship * move_ship(struct ship * sh, struct region * from, struct region * to, struct region_list * route);
|
extern struct ship * move_ship(struct ship * sh, struct region * from, struct region * to, struct region_list * route);
|
||||||
extern int walkingcapacity(const struct unit * u);
|
extern int walkingcapacity(const struct unit * u);
|
||||||
|
|
||||||
extern void follow_unit(void);
|
extern void follow_unit(struct unit * u);
|
||||||
|
|
||||||
struct building_type;
|
struct building_type;
|
||||||
boolean buildingtype_exists(const struct region * r, const struct building_type * bt);
|
boolean buildingtype_exists(const struct region * r, const struct building_type * bt);
|
||||||
|
|
|
@ -260,38 +260,27 @@ use_pooled(unit * u, const resource_type * rtype, unsigned int mode, int count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
int
|
||||||
init_pool(void)
|
reserve_cmd(unit * u, struct order *ord)
|
||||||
{
|
{
|
||||||
unit *u;
|
if (u->number > 0 && (urace(u)->ec_flags & GETITEM)) {
|
||||||
region *r;
|
int use, count = geti();
|
||||||
|
const resource_type * rtype;
|
||||||
|
|
||||||
/* Falls jemand diese Listen erweitert hat, muß er auch den R_* enum
|
init_tokens(ord);
|
||||||
* erweitert haben. */
|
skip_token();
|
||||||
for (r = regions; r; r = r->next) {
|
count = geti();
|
||||||
for (u = r->units; u; u = u->next) {
|
|
||||||
order * ord;
|
|
||||||
for (ord=u->orders; ord; ord=ord->next) {
|
|
||||||
if (u->number > 0 && (urace(u)->ec_flags & GETITEM) && get_keyword(ord) == K_RESERVE) {
|
|
||||||
int use, count = geti();
|
|
||||||
const resource_type * rtype;
|
|
||||||
|
|
||||||
init_tokens(ord);
|
rtype = findresourcetype(getstrtoken(), u->faction->locale);
|
||||||
skip_token();
|
if (rtype == NULL) return 0;
|
||||||
count = geti();
|
|
||||||
|
|
||||||
rtype = findresourcetype(getstrtoken(), u->faction->locale);
|
new_set_resvalue(u, rtype, 0); /* make sure the pool is empty */
|
||||||
if (rtype == NULL) continue;
|
use = use_pooled(u, rtype, GET_DEFAULT, count);
|
||||||
|
if (use) {
|
||||||
new_set_resvalue(u, rtype, 0); /* make sure the pool is empty */
|
new_set_resvalue(u, rtype, use);
|
||||||
use = use_pooled(u, rtype, GET_DEFAULT, count);
|
change_resource(u, rtype, use);
|
||||||
if (use) {
|
|
||||||
new_set_resvalue(u, rtype, use);
|
|
||||||
change_resource(u, rtype, use);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ int change_resource(struct unit * u, const struct resource_type * res, int chang
|
||||||
int get_reservation(const struct unit * u, const struct resource_type * res);
|
int get_reservation(const struct unit * u, const struct resource_type * res);
|
||||||
int change_reservation(struct unit * u, const struct resource_type * res, int value);
|
int change_reservation(struct unit * u, const struct resource_type * res, int value);
|
||||||
|
|
||||||
void init_pool(void);
|
int reserve_cmd(struct unit *u, struct order *ord);
|
||||||
|
|
||||||
/** init_pool
|
/** init_pool
|
||||||
* initialisiert den regionalen Pool.
|
* initialisiert den regionalen Pool.
|
||||||
|
|
|
@ -199,7 +199,7 @@ destroy_ship(ship * sh)
|
||||||
}
|
}
|
||||||
sunhash(sh);
|
sunhash(sh);
|
||||||
choplist(&r->ships, sh);
|
choplist(&r->ships, sh);
|
||||||
handle_event(&sh->attribs, "destroy", sh);
|
handle_event(sh->attribs, "destroy", sh);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
|
|
@ -178,6 +178,17 @@ distribute_items(unit * u)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
remove_unit(unit * u)
|
||||||
|
{
|
||||||
|
region * r = u->region;
|
||||||
|
assert(u->number==0);
|
||||||
|
uunhash(u);
|
||||||
|
if (r) choplist(&r->units, u);
|
||||||
|
u->next = udestroy;
|
||||||
|
udestroy = u;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
destroy_unit(unit * u)
|
destroy_unit(unit * u)
|
||||||
{
|
{
|
||||||
|
@ -261,17 +272,13 @@ destroy_unit(unit * u)
|
||||||
u->race = u->irace = new_race[RC_ZOMBIE];
|
u->race = u->irace = new_race[RC_ZOMBIE];
|
||||||
} else {
|
} else {
|
||||||
if (u->number) set_number(u, 0);
|
if (u->number) set_number(u, 0);
|
||||||
handle_event(&u->attribs, "destroy", u);
|
handle_event(u->attribs, "destroy", u);
|
||||||
if (r && !fval(r->terrain, SEA_REGION)) {
|
if (r && !fval(r->terrain, SEA_REGION)) {
|
||||||
rsetmoney(r, rmoney(r) + get_money(u));
|
rsetmoney(r, rmoney(r) + get_money(u));
|
||||||
}
|
}
|
||||||
dhash(u->no, u->faction);
|
dhash(u->no, u->faction);
|
||||||
u_setfaction(u, NULL);
|
u_setfaction(u, NULL);
|
||||||
if (r) leave(r, u);
|
if (r) leave(r, u);
|
||||||
uunhash(u);
|
|
||||||
if (r) choplist(&r->units, u);
|
|
||||||
u->next = udestroy;
|
|
||||||
udestroy = u;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -189,6 +189,7 @@ extern int get_modifier(const struct unit * u, skill_t sk, int lvl, const struct
|
||||||
|
|
||||||
/* Einheiten werden nicht wirklich zerstört. */
|
/* Einheiten werden nicht wirklich zerstört. */
|
||||||
extern void destroy_unit(struct unit * u);
|
extern void destroy_unit(struct unit * u);
|
||||||
|
extern void remove_unit(struct unit * u);
|
||||||
extern void distribute_items(struct unit * u);
|
extern void distribute_items(struct unit * u);
|
||||||
|
|
||||||
/* see resolve.h */
|
/* see resolve.h */
|
||||||
|
|
|
@ -88,36 +88,29 @@ xe_giveballon(unit *u, struct order *ord)
|
||||||
fset(u2, UFL_OWNER);
|
fset(u2, UFL_OWNER);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
xecmd(void)
|
xecmd(unit * u, order * ord)
|
||||||
{
|
{
|
||||||
faction *f;
|
faction *f = u->faction;
|
||||||
|
|
||||||
for(f=factions; f; f=f->next) {
|
if (a_find(f->attribs, &at_xontormiaexpress)) {
|
||||||
if(a_find(f->attribs, &at_xontormiaexpress)) {
|
if (get_keyword(ord) == K_XE) {
|
||||||
unit *u;
|
init_tokens(ord);
|
||||||
for(u=f->units; u; u=u->nextF) {
|
skip_token();
|
||||||
order * ord;
|
switch(findparam(getstrtoken(),f->locale)) {
|
||||||
for (ord=u->orders; ord; ord=ord->next) {
|
case P_XEPOTION:
|
||||||
if (get_keyword(ord) == K_XE) {
|
xe_givepotion(u, ord);
|
||||||
init_tokens(ord);
|
break;
|
||||||
skip_token();
|
case P_XEBALLOON:
|
||||||
switch(findparam(getstrtoken(),f->locale)) {
|
xe_giveballon(u, ord);
|
||||||
case P_XEPOTION:
|
break;
|
||||||
xe_givepotion(u, ord);
|
case P_XELAEN:
|
||||||
break;
|
xe_givelaen(u, ord);
|
||||||
case P_XEBALLOON:
|
break;
|
||||||
xe_giveballon(u, ord);
|
|
||||||
break;
|
|
||||||
case P_XELAEN:
|
|
||||||
xe_givelaen(u, ord);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -18,7 +18,7 @@ extern "C" {
|
||||||
|
|
||||||
#ifdef XECMD_MODULE
|
#ifdef XECMD_MODULE
|
||||||
extern attrib_type at_xontormiaexpress;
|
extern attrib_type at_xontormiaexpress;
|
||||||
void xecmd(void);
|
int xecmd(struct unit * u, struct order * ord);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -200,20 +200,20 @@ add_trigger(struct attrib ** ap, const char * eventname, struct trigger * t)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
handle_event(attrib ** attribs, const char * eventname, void * data)
|
handle_event(attrib * attribs, const char * eventname, void * data)
|
||||||
{
|
{
|
||||||
while (*attribs) {
|
while (attribs) {
|
||||||
if ((*attribs)->type==&at_eventhandler) break;
|
if (attribs->type==&at_eventhandler) break;
|
||||||
attribs = &(*attribs)->next;
|
attribs = attribs->nexttype;
|
||||||
}
|
}
|
||||||
while (*attribs && (*attribs)->type==&at_eventhandler) {
|
while (attribs && attribs->type==&at_eventhandler) {
|
||||||
handler_info * tl = (handler_info*)(*attribs)->data.v;
|
handler_info * tl = (handler_info*)attribs->data.v;
|
||||||
if (!strcmp(tl->event, eventname)) {
|
if (!strcmp(tl->event, eventname)) {
|
||||||
handler_info * tl = (handler_info*)(*attribs)->data.v;
|
handler_info * tl = (handler_info*)attribs->data.v;
|
||||||
handle_triggers(&tl->triggers, data);
|
handle_triggers(&tl->triggers, data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
attribs = &(*attribs)->next;
|
attribs = attribs->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ extern void add_trigger(struct attrib ** ap, const char * eventname, struct trig
|
||||||
extern void remove_triggers(struct attrib ** ap, const char * eventname, const trigger_type * tt);
|
extern void remove_triggers(struct attrib ** ap, const char * eventname, const trigger_type * tt);
|
||||||
extern struct trigger ** get_triggers(struct attrib * ap, const char * eventname);
|
extern struct trigger ** get_triggers(struct attrib * ap, const char * eventname);
|
||||||
/* calls handle() for each of these. e.g. used in timeout */
|
/* calls handle() for each of these. e.g. used in timeout */
|
||||||
extern void handle_event(struct attrib ** attribs, const char * eventname, void * data);
|
extern void handle_event(struct attrib * attribs, const char * eventname, void * data);
|
||||||
|
|
||||||
/* functions for making complex triggers: */
|
/* functions for making complex triggers: */
|
||||||
extern void free_triggers(trigger * triggers); /* release all these triggers */
|
extern void free_triggers(trigger * triggers); /* release all these triggers */
|
||||||
|
|
|
@ -232,7 +232,9 @@ region_remove(region& r)
|
||||||
while (*rp) {
|
while (*rp) {
|
||||||
if (*rp==&r) {
|
if (*rp==&r) {
|
||||||
while (r.units) {
|
while (r.units) {
|
||||||
destroy_unit(r.units);
|
unit * u = r.units;
|
||||||
|
destroy_unit(u);
|
||||||
|
remove_unit(u);
|
||||||
}
|
}
|
||||||
*rp = r.next;
|
*rp = r.next;
|
||||||
#ifdef FAST_CONNECT
|
#ifdef FAST_CONNECT
|
||||||
|
|
|
@ -1465,6 +1465,7 @@ showunits(region * r)
|
||||||
if (yes_no(0, lbuf, 'n')) {
|
if (yes_no(0, lbuf, 'n')) {
|
||||||
modified = 1;
|
modified = 1;
|
||||||
destroy_unit(clipunit);
|
destroy_unit(clipunit);
|
||||||
|
if (clipunit->number==0) remove_unit(clipunit);
|
||||||
clipunit = 0;
|
clipunit = 0;
|
||||||
clipregion = 0;
|
clipregion = 0;
|
||||||
for (pline = 0, tmp = eh; tmp != pointer; tmp = tmp->next)
|
for (pline = 0, tmp = eh; tmp != pointer; tmp = tmp->next)
|
||||||
|
|
Loading…
Reference in New Issue