From c53aa275979ba74308854a592d9f275d356cacc6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 23 May 2020 10:18:18 +0200 Subject: [PATCH 1/2] bug 2661: desertierende einheiten, spoils MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kampfstatus und Tarnung setzen. Spoils-Texte für mehr Rassen. --- res/translations/strings.de.po | 43 +++++++++++++++++++++++++++++++++- src/chaos.c | 8 +++---- src/economy.c | 8 +++---- src/monsters.c | 43 ++++++++++++++++++++++++---------- src/monsters.h | 1 + 5 files changed, 82 insertions(+), 21 deletions(-) diff --git a/res/translations/strings.de.po b/res/translations/strings.de.po index 0e9776a40..ba16c31e9 100644 --- a/res/translations/strings.de.po +++ b/res/translations/strings.de.po @@ -3890,7 +3890,7 @@ msgstr "Ent" msgctxt "iteminfo" msgid "dwarfspoil" -msgstr "Beim Barte des Proheten! Ach nein, Zwergen. Irgendetwas riecht hier ranzig." +msgstr "Beim Barte des Propheten! Ach nein, Zwergen. Irgendetwas riecht hier ranzig." msgctxt "race" msgid "clone" @@ -6320,3 +6320,44 @@ msgctxt "race" msgid "wolf" msgstr "Wolf" +msgctxt "iteminfo" +msgid "elfspoil" +msgstr "Die Ohren sind spitz und beinahe trapezförmig. Wie kann +damit hören?" + +msgctxt "iteminfo" +msgid "goblinspoil" +msgstr "Die Fratze des kleinen Kopfs wirkt beinahe etwas kindlich +zierlich, aber dennoch liegt etwas Listiges darin." + +msgctxt "iteminfo" +msgid "halflingspoil" +msgstr "Die Sohle des behaarten Fußes ist deutlich dicker, beinahe +wie ein Huf." + +msgctxt "iteminfo" +msgid "aquarianspoil" +msgstr "Die kleine, türkisfarbene Schuppe glänzt in der Sonne. Dennoch ist sie erstaunlich hart." + +msgctxt "iteminfo" +msgid "humanspoil" +msgstr "Ob blond oder braun, ob kurz oder lang, du hast ein Büschel Haare mit einem Stück Haut in der Hand." + +msgctxt "iteminfo" +msgid "catspoil" +msgstr "Wie ein kleines Seil aus weichem Fell." + +msgctxt "iteminfo" +msgid "insectspoil" +msgstr "Das am Kopf der meisten Gliederfüßer auftretende, +gegliederte Extremitätenpaar, das mit Sensillen (Tastsinn, Geruchssinn) +ausgestattet ist." + +msgctxt "iteminfo" +msgid "orcspoil" +msgstr "Große, spitze Zähne. Ob sie früher einem Ork oder doch einem Wildschwein gehörten ist nicht so leicht zu unterscheiden." + +msgctxt "iteminfo" +msgid "demonspoil" +msgstr "Eine giftige und grüne Flüssigkeit in einer kleinen Phiole, +keine humanoide Rasse außer Dämonen wagt damit in Kontakt zu kommen." diff --git a/src/chaos.c b/src/chaos.c index 2639592f0..8b474cb24 100644 --- a/src/chaos.c +++ b/src/chaos.c @@ -84,10 +84,10 @@ static void chaos(region * r) if (!(r->terrain->flags & SEA_REGION)) { unit *u = random_unit(r); if (u && playerrace(u_race(u))) { - ADDMSG(&u->faction->msgs, msg_message("chaos_disease", "unit", u)); - u_setfaction(u, get_monsters()); - u_freeorders(u); - u_setrace(u, get_race(RC_GHOUL)); + if (join_monsters(u)) { + ADDMSG(&u->faction->msgs, msg_message("chaos_disease", "unit", u)); + u_setrace(u, get_race(RC_GHOUL)); + } } } break; diff --git a/src/economy.c b/src/economy.c index 482b8d959..a16e9718d 100644 --- a/src/economy.c +++ b/src/economy.c @@ -290,10 +290,10 @@ static int forget_cmd(unit * u, order * ord) else { unit *ufam = get_familiar(u); if (ufam) { - a_removeall(&ufam->attribs, NULL); - u_setfaction(ufam, get_monsters()); - u_freeorders(ufam); - unit_convert_race(ufam, NULL, "ghost"); + if (join_monsters(ufam)) { + a_removeall(&ufam->attribs, NULL); + unit_convert_race(ufam, NULL, "ghost"); + } } a_removeall(&u->attribs, &at_mage); a_removeall(&u->attribs, &at_familiar); diff --git a/src/monsters.c b/src/monsters.c index cd6efc558..c10ad97e9 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -43,9 +43,10 @@ #include /* attributes includes */ -#include -#include #include +#include +#include +#include #include @@ -179,6 +180,23 @@ static order *monster_attack(unit * u, const unit * target) return create_order(K_ATTACK, u->faction->locale, "%i", target->no); } +bool join_monsters(unit *u) { + static faction *monsters = NULL; + if (monsters == NULL) { + monsters = get_monsters(); + if (monsters == NULL) { + return false; + } + } + u_setfaction(u, monsters); + u->status = ST_FIGHT; + a_removeall(&u->attribs, &at_otherfaction); + u->flags &= ~UFL_ANON_FACTION; + u_seteffstealth(u, -1); + u_freeorders(u); + return true; +} + void monsters_desert(struct faction *monsters) { region *r; @@ -193,10 +211,10 @@ void monsters_desert(struct faction *monsters) if (fval(u, UFL_ISNEW)) continue; if (rng_int() % 100 < 5) { - ADDMSG(&u->faction->msgs, msg_message("desertion", - "unit region", u, r)); - u_setfaction(u, monsters); - u_freeorders(u); + if (join_monsters(u)) { + ADDMSG(&u->faction->msgs, msg_message("desertion", + "unit region", u, r)); + } } } } @@ -1175,10 +1193,11 @@ void monster_kills_peasants(unit * u) void make_zombie(unit * u) { - u_setfaction(u, get_monsters()); - u_freeorders(u); - scale_number(u, 1); - u->hp = unit_max_hp(u) * u->number; - u_setrace(u, get_race(RC_ZOMBIE)); - u->irace = NULL; + if (join_monsters(u)) { + u_freeorders(u); + scale_number(u, 1); + u->hp = unit_max_hp(u) * u->number; + u_setrace(u, get_race(RC_ZOMBIE)); + u->irace = NULL; + } } diff --git a/src/monsters.h b/src/monsters.h index e799c68c4..9b2dd2720 100644 --- a/src/monsters.h +++ b/src/monsters.h @@ -23,6 +23,7 @@ extern "C" { void spawn_undead(void); void plan_monsters(struct faction *f); + bool join_monsters(struct unit *u); #ifdef __cplusplus } From 405f8f240ae81d70f70d4a84ccc55c5826954df7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 23 May 2020 11:21:16 +0200 Subject: [PATCH 2/2] No! Static variables are BAD! --- src/chaos.c | 12 ++++++------ src/economy.c | 2 +- src/monsters.c | 9 ++++----- src/monsters.h | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/chaos.c b/src/chaos.c index d866c626f..69b9fa95d 100644 --- a/src/chaos.c +++ b/src/chaos.c @@ -76,7 +76,7 @@ static unit *random_unit(const region * r) return u; } -static void chaos(region * r) +static void chaos(region * r, faction *monsters) { if (rng_int() % 100 < 8) { switch (rng_int() % 3) { @@ -84,7 +84,7 @@ static void chaos(region * r) if (!(r->terrain->flags & SEA_REGION)) { unit *u = random_unit(r); if (u && !undeadrace(u_race(u))) { - if (join_monsters(u)) { + if (join_monsters(u, monsters)) { ADDMSG(&u->faction->msgs, msg_message("chaos_disease", "unit", u)); u_setrace(u, get_race(RC_GHOUL)); } @@ -99,17 +99,17 @@ static void chaos(region * r) case 0: mfac = 100; u = - create_unit(r, get_monsters(), rng_int() % 8 + 1, + create_unit(r, monsters, rng_int() % 8 + 1, get_race(RC_FIREDRAGON), 0, NULL, NULL); break; case 1: mfac = 500; - u = create_unit(r, get_monsters(), rng_int() % 4 + 1, + u = create_unit(r, monsters, rng_int() % 4 + 1, get_race(RC_DRAGON), 0, NULL, NULL); break; default: mfac = 1000; - u = create_unit(r, get_monsters(), rng_int() % 2 + 1, + u = create_unit(r, monsters, rng_int() % 2 + 1, get_race(RC_WYRM), 0, NULL, NULL); break; } @@ -184,7 +184,7 @@ void chaos_update(void) { /* Chaos */ for (r = regions; r; r = r->next) { if ((r->flags & RF_CHAOTIC)) { - chaos(r); + chaos(r, get_monsters()); } } } diff --git a/src/economy.c b/src/economy.c index a16e9718d..4d2c30d90 100644 --- a/src/economy.c +++ b/src/economy.c @@ -290,7 +290,7 @@ static int forget_cmd(unit * u, order * ord) else { unit *ufam = get_familiar(u); if (ufam) { - if (join_monsters(ufam)) { + if (join_monsters(ufam, NULL)) { a_removeall(&ufam->attribs, NULL); unit_convert_race(ufam, NULL, "ghost"); } diff --git a/src/monsters.c b/src/monsters.c index c10ad97e9..34214a342 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -180,8 +180,7 @@ static order *monster_attack(unit * u, const unit * target) return create_order(K_ATTACK, u->faction->locale, "%i", target->no); } -bool join_monsters(unit *u) { - static faction *monsters = NULL; +bool join_monsters(unit *u, faction *monsters) { if (monsters == NULL) { monsters = get_monsters(); if (monsters == NULL) { @@ -206,12 +205,12 @@ void monsters_desert(struct faction *monsters) unit *u; for (u = r->units; u; u = u->next) { - if (u->faction!=monsters + if (u->faction != monsters && (u_race(u)->flags & RCF_DESERT)) { if (fval(u, UFL_ISNEW)) continue; if (rng_int() % 100 < 5) { - if (join_monsters(u)) { + if (join_monsters(u, monsters)) { ADDMSG(&u->faction->msgs, msg_message("desertion", "unit region", u, r)); } @@ -1193,7 +1192,7 @@ void monster_kills_peasants(unit * u) void make_zombie(unit * u) { - if (join_monsters(u)) { + if (join_monsters(u, NULL)) { u_freeorders(u); scale_number(u, 1); u->hp = unit_max_hp(u) * u->number; diff --git a/src/monsters.h b/src/monsters.h index 9b2dd2720..d87398c2c 100644 --- a/src/monsters.h +++ b/src/monsters.h @@ -23,7 +23,7 @@ extern "C" { void spawn_undead(void); void plan_monsters(struct faction *f); - bool join_monsters(struct unit *u); + bool join_monsters(struct unit *u, struct faction *monsters); #ifdef __cplusplus }