forked from github/server
new loot and give rules
This commit is contained in:
parent
79cebe53c4
commit
871088807a
3 changed files with 74 additions and 20 deletions
|
@ -80,6 +80,31 @@ add_give(unit * u, unit * u2, int n, const resource_type * rtype, struct order *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int give_quota(const unit * src, const unit * dst, const item_type * type, int n)
|
||||||
|
{
|
||||||
|
static float divisor = -1;
|
||||||
|
if (dst && src && src->faction!=dst->faction) {
|
||||||
|
if (divisor<0) {
|
||||||
|
divisor = get_param_flt(global.parameters, "rules.items.give_divisor", 1);
|
||||||
|
assert(divisor==0 || divisor>=1);
|
||||||
|
}
|
||||||
|
if (divisor>=1) {
|
||||||
|
/* predictable > correct: */
|
||||||
|
#if 0
|
||||||
|
double r = n / divisor;
|
||||||
|
int x = (int)r;
|
||||||
|
|
||||||
|
r = r - x;
|
||||||
|
if (chance(r)) ++x;
|
||||||
|
#else
|
||||||
|
int x = (int)(n/divisor);
|
||||||
|
#endif
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
give_item(int want, const item_type * itype, unit * src, unit * dest, struct order * ord)
|
give_item(int want, const item_type * itype, unit * src, unit * dest, struct order * ord)
|
||||||
{
|
{
|
||||||
|
|
|
@ -129,6 +129,7 @@ static int skill_formula = 0;
|
||||||
#define LOOT_MONSTERS (1<<0)
|
#define LOOT_MONSTERS (1<<0)
|
||||||
#define LOOT_SELF (1<<1) /* code is mutually exclusive with LOOT_OTHERS */
|
#define LOOT_SELF (1<<1) /* code is mutually exclusive with LOOT_OTHERS */
|
||||||
#define LOOT_OTHERS (1<<2)
|
#define LOOT_OTHERS (1<<2)
|
||||||
|
#define LOOT_KEEPLOOT (1<<4)
|
||||||
|
|
||||||
#define DAMAGE_CRITICAL (1<<0)
|
#define DAMAGE_CRITICAL (1<<0)
|
||||||
#define DAMAGE_MELEE_BONUS (1<<1)
|
#define DAMAGE_MELEE_BONUS (1<<1)
|
||||||
|
@ -140,7 +141,7 @@ static int skill_formula = 0;
|
||||||
static void
|
static void
|
||||||
static_rules(void)
|
static_rules(void)
|
||||||
{
|
{
|
||||||
loot_rules = get_param_int(global.parameters, "rules.combat.loot", LOOT_MONSTERS|LOOT_OTHERS);
|
loot_rules = get_param_int(global.parameters, "rules.combat.loot", LOOT_MONSTERS|LOOT_OTHERS|LOOT_KEEPLOOT);
|
||||||
/* new formula to calculate to-hit-chance */
|
/* new formula to calculate to-hit-chance */
|
||||||
skill_formula = get_param_int(global.parameters, "rules.combat.skill_formula", FORMULA_ORIG);
|
skill_formula = get_param_int(global.parameters, "rules.combat.skill_formula", FORMULA_ORIG);
|
||||||
/* maximum number of combat turns */
|
/* maximum number of combat turns */
|
||||||
|
@ -2484,6 +2485,28 @@ select_ally(fighter * af, int minrow, int maxrow, int allytype)
|
||||||
return no_troop;
|
return no_troop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int loot_quota(const unit * src, const unit * dst, const item_type * type, int n)
|
||||||
|
{
|
||||||
|
static float divisor = -1;
|
||||||
|
if (dst && src && src->faction!=dst->faction) {
|
||||||
|
if (divisor<0) {
|
||||||
|
divisor = get_param_flt(global.parameters, "rules.items.loot_divisor", 1);
|
||||||
|
assert(divisor==0 || divisor>=1);
|
||||||
|
}
|
||||||
|
if (divisor>=1) {
|
||||||
|
double r = n / divisor;
|
||||||
|
int x = (int)r;
|
||||||
|
|
||||||
|
r = r - x;
|
||||||
|
if (chance(r)) ++x;
|
||||||
|
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
loot_items(fighter * corpse)
|
loot_items(fighter * corpse)
|
||||||
{
|
{
|
||||||
|
@ -2506,6 +2529,8 @@ loot_items(fighter * corpse)
|
||||||
fighter *fig = NULL;
|
fighter *fig = NULL;
|
||||||
int looting = 0;
|
int looting = 0;
|
||||||
int maxrow = 0;
|
int maxrow = 0;
|
||||||
|
/* mustloot: we absolutely, positively must have somebody loot this thing */
|
||||||
|
int mustloot = itm->type->flags & (ITF_CURSED|ITF_NOTLOST);
|
||||||
|
|
||||||
itm->number -= loot;
|
itm->number -= loot;
|
||||||
maxloot -= loot;
|
maxloot -= loot;
|
||||||
|
@ -2518,30 +2543,31 @@ loot_items(fighter * corpse)
|
||||||
looting = 2;
|
looting = 2;
|
||||||
}
|
}
|
||||||
if (looting) {
|
if (looting) {
|
||||||
if (itm->type->flags & (ITF_CURSED|ITF_NOTLOST)) {
|
if (mustloot) {
|
||||||
maxrow = LAST_ROW;
|
maxrow = LAST_ROW;
|
||||||
} else {
|
} else if (loot_rules&LOOT_KEEPLOOT) {
|
||||||
int lootchance = 50 + b->keeploot;
|
int lootchance = 50 + b->keeploot;
|
||||||
if (rng_int() % 100 < lootchance) {
|
if (rng_int() % 100 < lootchance) {
|
||||||
maxrow = BEHIND_ROW;
|
maxrow = BEHIND_ROW;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
maxrow = LAST_ROW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (maxrow>0) {
|
if (maxrow>0) {
|
||||||
if (looting==1) {
|
if (looting==1) {
|
||||||
|
/* enemies get dibs */
|
||||||
fig = select_enemy(corpse, FIGHT_ROW, maxrow, 0).fighter;
|
fig = select_enemy(corpse, FIGHT_ROW, maxrow, 0).fighter;
|
||||||
} else if (looting==2) {
|
|
||||||
fig = select_ally(corpse, FIGHT_ROW, LAST_ROW, ALLY_SELF).fighter;
|
|
||||||
} else if (itm->type->flags & (ITF_CURSED|ITF_NOTLOST)) {
|
|
||||||
/* we absolutely, positively must have somebody loot this thing */
|
|
||||||
fig = select_enemy(corpse, FIGHT_ROW, maxrow, 0).fighter;
|
|
||||||
if (!fig) {
|
|
||||||
fig = select_ally(corpse, FIGHT_ROW, LAST_ROW, ALLY_SELF).fighter;
|
|
||||||
}
|
}
|
||||||
|
if (!fig) {
|
||||||
|
/* self and allies get second pick */
|
||||||
|
fig = select_ally(corpse, FIGHT_ROW, LAST_ROW, ALLY_SELF).fighter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fig) {
|
if (fig) {
|
||||||
|
int trueloot = mustloot?loot:loot_quota(corpse->unit, fig->unit, itm->type, loot);
|
||||||
|
if (trueloot>0) {
|
||||||
item * l = fig->loot;
|
item * l = fig->loot;
|
||||||
while (l && l->type!=itm->type) l=l->next;
|
while (l && l->type!=itm->type) l=l->next;
|
||||||
if (!l) {
|
if (!l) {
|
||||||
|
@ -2550,7 +2576,8 @@ loot_items(fighter * corpse)
|
||||||
fig->loot = l;
|
fig->loot = l;
|
||||||
l->type = itm->type;
|
l->type = itm->type;
|
||||||
}
|
}
|
||||||
l->number += loot;
|
l->number += trueloot;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,9 @@
|
||||||
<param name="rules.combat.herospeed" value="3"/>
|
<param name="rules.combat.herospeed" value="3"/>
|
||||||
<param name="rules.combat.demon_vampire" value="5"/> <!-- regen 1 hp per X points of damage done -->
|
<param name="rules.combat.demon_vampire" value="5"/> <!-- regen 1 hp per X points of damage done -->
|
||||||
<param name="rules.combat.skill_bonus" value="0"/>
|
<param name="rules.combat.skill_bonus" value="0"/>
|
||||||
<param name="rules.combat.loot" value="3"/> <!-- only self + monsters -->
|
<param name="rules.combat.loot" value="5"/> <!-- only self + others - keeploot -->
|
||||||
|
<param name="rules.items.loot_divisor" value="4"/> <!-- damage skims off 3/4 of goods transfers -->
|
||||||
|
<param name="rules.items.give_divisor" value="3"/> <!-- corruption skims off 2/3 of goods transfers -->
|
||||||
<param name="rules.move.owner_leave" value="1"/> <!-- owner must leave before moving -->
|
<param name="rules.move.owner_leave" value="1"/> <!-- owner must leave before moving -->
|
||||||
<param name="rules.cavalry.skill" value="2"/>
|
<param name="rules.cavalry.skill" value="2"/>
|
||||||
<param name="rules.cavalry.mode" value="1"/>
|
<param name="rules.cavalry.mode" value="1"/>
|
||||||
|
@ -167,7 +169,7 @@
|
||||||
<param name="rules.economy.roqf" value="5"/>
|
<param name="rules.economy.roqf" value="5"/>
|
||||||
<param name="rules.economy.herbrot" value="0"/>
|
<param name="rules.economy.herbrot" value="0"/>
|
||||||
<param name="rules.nmr.destroy" value="1"/>
|
<param name="rules.nmr.destroy" value="1"/>
|
||||||
<param name="rules.give" value="15"/> <!-- self + peasants + herbs + lux - goods -->
|
<!--param name="rules.give" value="15"/ --> <!-- self + peasants + herbs + lux - goods -->
|
||||||
<param name="rules.economy.grow" value="1"/>
|
<param name="rules.economy.grow" value="1"/>
|
||||||
<param name="rules.tactics.formula" value="1"/> <!-- 10% per skilldiff -->
|
<param name="rules.tactics.formula" value="1"/> <!-- 10% per skilldiff -->
|
||||||
<param name="rules.help.mask" value="fight guard money give"/>
|
<param name="rules.help.mask" value="fight guard money give"/>
|
||||||
|
|
Loading…
Reference in a new issue