BUG 2440: the random encounters code was completely unused.

This commit is contained in:
Enno Rehling 2018-05-13 16:13:33 +02:00
parent 666d5715ab
commit 4240e142a5
18 changed files with 3 additions and 552 deletions

View File

@ -7100,112 +7100,6 @@
<text locale="en">Furious peasants</text>
</string>
<string name="random_plain_men">
<text locale="de">Söldner</text>
<text locale="en">Mercenaries</text>
</string>
<string name="random_swamp_men">
<text locale="de">Sumpfbewohner</text>
<text locale="en">Swamp people</text>
</string>
<string name="random_forest_men">
<text locale="de">Waldbewohner</text>
<text locale="en">Woodsmen</text>
</string>
<string name="random_desert_men">
<text locale="de">Nomaden</text>
<text locale="en">Nomads</text>
</string>
<string name="random_glacier_men">
<text locale="de">Eisleute</text>
<text locale="en">Ice people</text>
</string>
<string name="random_mountain_men">
<text locale="de">Bergbewohner</text>
<text locale="en">Mountain people</text>
</string>
<string name="manual_title_magic">
<text locale="de">Magie der Elemente</text>
<text locale="en">Magic of the Elements</text>
</string>
<string name="manual_title_weaponsmithing">
<text locale="de">Schwerter, Armbrüste, Langbögen</text>
<text locale="en">Swords, Crossbows and Longbows</text>
</string>
<string name="manual_title_tactics">
<text locale="de">Gorms Almanach der Rationellen Kriegsführung</text>
<text locale="en">Gorm's Almanach of Rational War</text>
</string>
<string name="manual_title_shipcraft">
<text locale="de">Katamarane, Koggen, Karavellen</text>
<text locale="en">The dragonship, the caravell and the longboat</text>
</string>
<string name="manual_title_sailing">
<text locale="de">Wege der Sterne</text>
<text locale="en">Ways of the Start</text>
</string>
<string name="manual_title_herbalism">
<text locale="de">Nadishahs Kleine Gift- und Kräuterkunde</text>
<text locale="en">Nadishah's collected lore on poisonous and beneficial herbs</text>
</string>
<string name="manual_title_alchemy">
<text locale="de">Mandricks Kompendium der Alchemie</text>
<text locale="en">Mandrick's alchemistic compendium</text>
</string>
<string name="manual_title_building">
<text locale="de">Die Konstruktion der Burgen und Schlösser von Zentralandune</text>
</string>
<string name="manual_title_armorer">
<text locale="de">Die Esse</text>
</string>
<string name="manual_title_mining">
<text locale="de">Über die Gewinnung von Erzen</text>
</string>
<string name="manual_title_entertainment">
<text locale="de">Barinions Lieder, eine Einführung für Unbedarfte</text>
</string>
<string name="manual_location_0">
<text locale="de">die Ruine eines alten Tempels</text>
<text locale="en">the ruins of an ancient temple</text>
</string>
<string name="manual_location_1">
<text locale="de">eine alte Burgruine</text>
<text locale="en">the ruins of a castle</text>
</string>
<string name="manual_location_2">
<text locale="de">ein zerfallenes Bauernhaus</text>
<text locale="en">a dilapitated farm</text>
</string>
<string name="manual_location_3">
<text locale="de">eine Leiche am Wegesrand</text>
<text locale="en">a corpse by the wayside</text>
</string>
<string name="manual_location_3">
<text locale="de">eine Leiche am Wegesrand</text>
<text locale="en">a corpse by the wayside</text>
</string>
<string name="firedragon">
<text locale="de">Feuerdrache</text>
<text locale="en">fire dragon</text>

View File

@ -7991,23 +7991,6 @@
<text locale="en">"A message from $unit($unit): '$message'"</text>
</message>
<message name="encounter_allies" section="events">
<type>
<arg name="unit" type="unit"/>
<arg name="name" type="string"/>
</type>
<text locale="de">"Plötzlich stolpert $unit($unit) über einige $localize($name). Nach kurzem Zögern entschließen die $localize($name), sich Deiner Partei anzuschließen."</text>
<text locale="en">"$unit($unit) stumbles upon $localize($name). After short hesitation, $localize($name) agrees to join your faction."</text>
</message>
<message name="encounter_villagers" section="events">
<type>
<arg name="unit" type="unit"/>
</type>
<text locale="de">"$unit($unit) entdeckt ein kleines Dorf. Die meisten Häuser wurden durch einen über die Ufer getretenen Fluß zerstört. Eine Gruppe der verzweifelten Menschen schließt sich deiner Partei an."</text>
<text locale="en">"$unit($unit) discovers a small village. Most of the houses have been destroyed by flooding, and a group of the distressed villagers join your faction."</text>
</message>
<message name="mob_warning" section="events">
<text locale="de">"Ein Bauernmob erhebt sich und macht Jagd auf Schwarzmagier."</text>
<text locale="en">"An angry mob forms and hunts practitioners of the dark arts."</text>

View File

@ -1,163 +1,6 @@
<?xml version="1.0"?>
<eressea><equipment>
<!-- equipment-sets for random encounters -->
<set name="rand_desert">
<skill name="melee" level="d2"/>
<skill name="trade" level="d3"/>
<skill name="riding" level="d2+1"/>
<skill name="training" level="d2+1"/>
<item name="horse" amount="1"/>
<item name="sword" amount="1"/>
<item name="money" amount="d30+19"/>
</set>
<set name="rand_swamp">
<skill name="stealth" level="d3+1"/>
<skill name="polearm" level="d3+1"/>
<item name="spear" amount="1"/>
<item name="money" amount="d20+9"/>
</set>
<set name="rand_glacier">
<skill name="armorer" level="d2+1"/>
<skill name="melee" level="d2+1"/>
<item name="sword" amount="1"/>
<item name="money" amount="d20+19"/>
</set>
<set name="rand_mountain">
<skill name="armorer" level="d2+1"/>
<skill name="melee" level="d2+1"/>
<skill name="trade" level="d3"/>
<item name="sword" amount="1"/>
<item name="money" amount="d40+59"/>
<subset chance="0.6">
<set name="i_plate"/>
</subset>
</set>
<set name="rand_highland">
<skill name="melee" level="d2"/>
<item name="sword" amount="1"/>
<item name="money" amount="d10+19"/>
</set>
<set name="rand_forest">
<skill name="stealth" level="d2"/>
<skill name="perception" level="d2+1"/>
<skill name="bow" level="d3+1"/>
<item name="bow" amount="1"/>
<item name="money" amount="d20+9"/>
<subset chance="0.2">
<set name="rand_herbalist"/>
</subset>
</set>
<set name="rand_herbalist">
<skill name="herbalism" level="d2"/>
</set>
<set name="rand_villagers">
<item name="money" amount="d80+19"/>
<skill name="cartmaking" level="d2-1"/>
<skill name="mining" level="d2-1"/>
<skill name="quarrying" level="d2-1"/>
<skill name="forestry" level="d2-1"/>
<item name="horse" amount="2"/>
<item name="wagon" amount="d2-1"/>
<item name="money" amount="d30+10"/>
</set>
<set name="rand_plain">
<item name="money" amount="d80+19"/>
<subset>
<set name="rand_sword" chance="0.25"/>
<set name="rand_spear" chance="0.25"/>
<set name="rand_crossbow" chance="0.25"/>
<set name="rand_bow" chance="0.25"/>
</subset>
<subset chance="0.4">
<set name="i_chain"/>
</subset>
<subset chance="0.3">
<set name="rand_rider"/>
</subset>
</set>
<set name="rand_spear">
<skill name="polearm" level="d3"/>
<item name="spear" amount="1"/>
</set>
<set name="rand_sword">
<skill name="melee" level="d3"/>
<item name="sword" amount="1"/>
</set>
<set name="rand_crossbow">
<skill name="crossbow" level="d3"/>
<item name="crossbow" amount="1"/>
</set>
<set name="rand_bow">
<skill name="bow" level="d3"/>
<item name="bow" amount="1"/>
</set>
<set name="rand_rider">
<item name="horse" amount="1"/>
<skill name="riding" level="d3"/>
</set>
<set name="new_dracoid">
<!-- dracoiden, von drachen rekrutiert -->
<skill name="polearm" level="d4+2"/>
<skill name="melee" level="d4+2"/>
<skill name="bow" level="d3+1"/>
<subset>
<!-- dracoiden haben immer eine von drei waffen -->
<set name="i_sword" chance="0.33"/>
<set name="i_spear" chance="0.33"/>
<set name="i_bow" chance="0.34"/>
</subset>
</set>
<set name="rising_undead">
<!-- untote, von den graebern auferstanden -->
<item name="rustysword" amount="1"/>
<item name="rustychainmail" amount="d2-1"/>
<subset chance="0.3">
<set name="i_rustyshield"/>
</subset>
</set>
<!-- single-item sets (that can be given a percentage-chance in a subset) -->
<set name="i_plate">
<item name="plate" amount="1"/>
</set>
<set name="i_spear">
<item name="spear" amount="1"/>
</set>
<set name="i_bow">
<item name="bow" amount="1"/>
</set>
<set name="i_sword">
<item name="sword" amount="1"/>
</set>
<set name="i_chain">
<item name="chainmail" amount="1"/>
</set>
<set name="i_rustyshield">
<item name="rustyshield" amount="1"/>
</set>
<set name="spo_dragon">
<item name="dragonblood" amount="4"/>
<item name="dragonhead" amount="1"/>

View File

@ -105,7 +105,7 @@ local sets = {
['sailing'] = 1
},
['callback'] = equip_newunits
}
},
}
function equip_unit(u, name, flags)

View File

@ -22,7 +22,6 @@ eressea.settings.set("rules.food.flags", "4")
eressea.settings.set("rules.ship.damage.nocrew", "0")
eressea.settings.set("rules.ship.drifting", "0")
eressea.settings.set("rules.ship.storms", "0")
eressea.settings.set("rules.encounters", "0")
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("NewbieImmunity", "0")
rules = require('eressea.' .. config.rules)

View File

@ -23,7 +23,6 @@ eressea.settings.set("rules.food.flags", "4")
eressea.settings.set("rules.ship.damage.nocrew", "0")
eressea.settings.set("rules.ship.drifting", "0")
eressea.settings.set("rules.ship.storms", "0")
eressea.settings.set("rules.encounters", "0")
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("NewbieImmunity", "0")
rules = require('eressea.' .. config.rules)

View File

@ -33,7 +33,6 @@ function setup()
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("NewbieImmunity", "0")
eressea.settings.set("rules.food.flags", "4")
eressea.settings.set("rules.encounters", "0")
eressea.settings.set("rules.peasants.growth", "1")
eressea.settings.set("study.random_progress", "0")
end
@ -968,7 +967,6 @@ module("tests.parser", package.seeall, lunit.testcase)
function setup()
eressea.free_game()
eressea.settings.set("rules.food.flags", "4") -- FOOD_IS_FREE
eressea.settings.set("rules.encounters", "0")
eressea.settings.set("rules.move.owner_leave", "0")
end

View File

@ -7,7 +7,6 @@ function setup()
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("rules.food.flags", "4")
eressea.settings.set("rules.ship.storms", "0")
eressea.settings.set("rules.encounters", "0")
end
local function create_faction(race)

View File

@ -7,7 +7,6 @@ function setup()
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("rules.food.flags", "4")
eressea.settings.set("rules.ship.storms", "0")
eressea.settings.set("rules.encounters", "0")
eressea.settings.set("magic.regeneration.enable", "0")
eressea.settings.set("rules.grow.formula", "0")
eressea.settings.set("study.random_progress", "0")

View File

@ -8,7 +8,6 @@ function setup()
eressea.settings.set("NewbieImmunity", "0")
eressea.settings.set("rules.food.flags", "4")
eressea.settings.set("rules.ship.storms", "0")
eressea.settings.set("rules.encounters", "0")
eressea.settings.set("magic.regeneration.enable", "0")
end

View File

@ -36,7 +36,6 @@ function test_study_expensive()
local f = faction.create("human", "test@example.com", "de")
local u = unit.create(f, r, 1)
eressea.settings.set("skills.cost.alchemy", "50")
eressea.settings.set("rules.encounters", "0")
u:add_order("LERNEN Alchemie")
u:add_item("money", 50)
process_orders()

View File

@ -7,7 +7,6 @@ function setup()
eressea.settings.set("nmr.timeout", "0")
eressea.settings.set("NewbieImmunity", "0")
eressea.settings.set("rules.food.flags", "4")
eressea.settings.set("rules.encounters", "0")
eressea.settings.set("rules.peasants.growth", "1")
eressea.settings.set("study.random_progress", "0")
eressea.settings.set("GiveRestriction", "0")

View File

@ -1091,7 +1091,6 @@ void terraform_region(region * r, const terrain_type * terrain)
rsethorses(r, 0);
rsetpeasants(r, 0);
rsetmoney(r, 0);
freset(r, RF_ENCOUNTER);
freset(r, RF_MALLORN);
return;
}
@ -1195,9 +1194,6 @@ void terraform_region(region * r, const terrain_type * terrain)
fset(r, RF_MALLORN);
else
freset(r, RF_MALLORN);
if (rng_int() % 100 < ENCCHANCE) {
fset(r, RF_ENCOUNTER);
}
}
}

View File

@ -42,7 +42,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define RF_UNUSED_7 (1<<7)
#define RF_UNUSED_8 (1<<8)
#define RF_ENCOUNTER (1<<9) /* persistent */
#define RF_MAPPER_HIGHLIGHT (1<<10)
#define RF_LIGHTHOUSE (1<<11) /* this region may contain a lighthouse */
#define RF_MIGRATION (1<<13)
@ -58,7 +57,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define RF_ALL 0xFFFFFF
#define RF_SAVEMASK (RF_CHAOTIC|RF_MALLORN|RF_BLOCKED|RF_ENCOUNTER|RF_GUARDED|RF_LIGHTHOUSE)
#define RF_SAVEMASK (RF_CHAOTIC|RF_MALLORN|RF_BLOCKED|RF_GUARDED|RF_LIGHTHOUSE)
struct message;
struct message_list;
struct rawmaterial;

View File

@ -4040,11 +4040,6 @@ void init_processor(void)
p += 10;
add_proc_order(p, K_GUARD, guard_on_cmd, 0, "Bewache (an)");
if (config_get_int("rules.encounters", 0)) {
p += 10;
add_proc_global(p, encounters, "Zufallsbegegnungen");
}
p += 10;
add_proc_unit(p, monster_kills_peasants,
"Monster fressen und vertreiben Bauern");

View File

@ -168,254 +168,6 @@ static bool improve_all(faction * f, skill_t sk, int by_weeks)
return result;
}
void find_manual(region * r, unit * u)
{
char zLocation[32];
char zBook[32];
skill_t skill = NOSKILL;
message *msg;
switch (rng_int() % 36) {
case 0:
skill = SK_MAGIC;
break;
case 1:
case 2:
case 3:
case 4:
skill = SK_WEAPONSMITH;
break;
case 5:
case 6:
skill = SK_TACTICS;
break;
case 7:
case 8:
case 9:
case 10:
skill = SK_SHIPBUILDING;
break;
case 11:
case 12:
case 13:
case 14:
skill = SK_SAILING;
break;
case 15:
case 16:
case 17:
skill = SK_HERBALISM;
break;
case 18:
case 19:
skill = SK_ALCHEMY;
break;
case 20:
case 21:
case 22:
case 23:
skill = SK_BUILDING;
break;
case 24:
case 25:
case 26:
case 27:
skill = SK_ARMORER;
break;
case 28:
case 29:
case 30:
case 31:
skill = SK_MINING;
break;
case 32:
case 33:
case 34:
case 35:
skill = SK_ENTERTAINMENT;
break;
}
snprintf(zLocation, sizeof(zLocation), "manual_location_%d",
(int)(rng_int() % 4));
snprintf(zBook, sizeof(zLocation), "manual_title_%s", skillnames[skill]);
msg = msg_message("find_manual", "unit location book", u, zLocation, zBook);
if (msg) {
r_addmessage(r, u->faction, msg);
msg_release(msg);
}
if (!improve_all(u->faction, skill, 3)) {
increase_skill(u, skill, 9);
}
}
static void get_villagers(region * r, unit * u)
{
unit *newunit;
message *msg = msg_message("encounter_villagers", "unit", u);
const char *name = LOC(u->faction->locale, "villagers");
r_addmessage(r, u->faction, msg);
msg_release(msg);
newunit =
create_unit(r, u->faction, rng_int() % 20 + 3, u->faction->race, 0, name,
u);
leave(newunit, true);
fset(newunit, UFL_ISNEW | UFL_MOVED);
equip_unit(newunit, "rand_villagers");
}
static void get_allies(region * r, unit * u)
{
unit *newunit = NULL;
const char *name;
const char *equip;
int number;
message *msg;
assert(u->number);
switch (rterrain(r)) {
case T_PLAIN:
if (!r_isforest(r)) {
if (get_money(u) / u->number < 100 + rng_int() % 200)
return;
name = "random_plain_men";
equip = "rand_plain";
number = rng_int() % 8 + 2;
break;
}
else {
if (effskill(u, SK_LONGBOW, r) < 3
&& effskill(u, SK_HERBALISM, r) < 2
&& effskill(u, SK_MAGIC, r) < 2) {
return;
}
name = "random_forest_men";
equip = "rand_forest";
number = rng_int() % 6 + 2;
}
break;
case T_SWAMP:
if (effskill(u, SK_MELEE, r) <= 1) {
return;
}
name = "random_swamp_men";
equip = "rand_swamp";
number = rng_int() % 6 + 2;
break;
case T_DESERT:
if (effskill(u, SK_RIDING, r) <= 2) {
return;
}
name = "random_desert_men";
equip = "rand_desert";
number = rng_int() % 12 + 2;
break;
case T_HIGHLAND:
if (effskill(u, SK_MELEE, r) <= 1) {
return;
}
name = "random_highland_men";
equip = "rand_highland";
number = rng_int() % 8 + 2;
break;
case T_MOUNTAIN:
if (effskill(u, SK_MELEE, r) <= 1 || effskill(u, SK_TRADE, r) <= 2) {
return;
}
name = "random_mountain_men";
equip = "rand_mountain";
number = rng_int() % 6 + 2;
break;
case T_GLACIER:
if (effskill(u, SK_MELEE, r) <= 1 || effskill(u, SK_TRADE, r) <= 1) {
return;
}
name = "random_glacier_men";
equip = "rand_glacier";
number = rng_int() % 4 + 2;
break;
default:
return;
}
newunit =
create_unit(r, u->faction, number, u->faction->race, 0,
LOC(u->faction->locale, name), u);
equip_unit(newunit, equip);
u_setfaction(newunit, u->faction);
set_racename(&newunit->attribs, get_racename(u->attribs));
if (u_race(u)->flags & RCF_SHAPESHIFT) {
newunit->irace = u->irace;
}
if (fval(u, UFL_ANON_FACTION))
fset(newunit, UFL_ANON_FACTION);
fset(newunit, UFL_ISNEW);
msg = msg_message("encounter_allies", "unit name", u, name);
r_addmessage(r, u->faction, msg);
msg_release(msg);
}
static void encounter(region * r, unit * u)
{
if (!fval(r, RF_ENCOUNTER))
return;
freset(r, RF_ENCOUNTER);
if (rng_int() % 100 >= ENCCHANCE)
return;
switch (rng_int() % 3) {
case 0:
find_manual(r, u);
break;
case 1:
get_villagers(r, u);
break;
case 2:
get_allies(r, u);
break;
}
}
void encounters(void)
{
region *r;
for (r = regions; r; r = r->next) {
if (fval(r->terrain, LAND_REGION) && fval(r, RF_ENCOUNTER)) {
int c = 0;
unit *u;
for (u = r->units; u; u = u->next) {
c += u->number;
}
if (c > 0) {
int i = 0;
int n = rng_int() % c;
for (u = r->units; u; u = u->next) {
if (i + u->number > n)
break;
i += u->number;
}
assert(u && u->number);
encounter(r, u);
}
}
}
}
void drown(region * r)
{
if (fval(r->terrain, SEA_REGION)) {
@ -611,7 +363,7 @@ static void move_icebergs(void)
}
}
void create_icebergs(void)
static void create_icebergs(void)
{
region *r;
const struct terrain_type *t_iceberg, *t_sleep;

View File

@ -30,7 +30,6 @@ extern "C" {
#define PLAGUE_HEALCHANCE 0.25 /* Wahrscheinlichkeit Heilung */
#define PLAGUE_HEALCOST 30 /* Heilkosten */
void plagues(struct region *r);
void encounters(void);
void randomevents(void);
#ifdef __cplusplus

View File

@ -31,6 +31,5 @@
/* Gebaeudegroesse = Minimalbelagerer */
#define SIEGEFACTOR 2
#define ENCCHANCE 10 /* %-Chance fuer einmalige Zufallsbegegnung */
#define BAGCAPACITY 20000 /* soviel passt in einen Bag of Holding */
#define PERSON_WEIGHT 1000 /* weight of a "normal" human unit */