forked from github/server
Merge branch 'ennorehling-feature/bug-1588-magicpower-limit' into develop
normalize use of MagicPower, only use it when setting castorder.force
This commit is contained in:
commit
2305466853
|
@ -1,3 +1,4 @@
|
|||
require 'tests.e2.spells'
|
||||
require 'tests.e2.undead'
|
||||
require 'tests.e2.shiplanding'
|
||||
require 'tests.e2.e2features'
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
require "lunit"
|
||||
|
||||
module("tests.e2.spells", package.seeall, lunit.testcase)
|
||||
|
||||
function setup()
|
||||
eressea.free_game()
|
||||
eressea.settings.set("nmr.removenewbie", "0")
|
||||
eressea.settings.set("nmr.timeout", "0")
|
||||
eressea.settings.set("NewbieImmunity", "0")
|
||||
eressea.settings.set("rules.economy.food", "4")
|
||||
end
|
||||
|
||||
function test_shapeshift()
|
||||
local r = region.create(42, 0, "plain")
|
||||
local f = faction.create("noreply@eressea.de", "demon", "de")
|
||||
local u1 = unit.create(f, r, 1)
|
||||
local u2 = unit.create(f, r, 1)
|
||||
u1:clear_orders()
|
||||
u1.magic = "gray"
|
||||
u1:set_skill("magic", 2)
|
||||
u1.aura = 1
|
||||
u1:add_spell("shapeshift")
|
||||
u1:add_order("ZAUBERE STUFE 1 Gestaltwandlung " .. itoa36(u2.id) .. " Goblin")
|
||||
process_orders()
|
||||
assert_equal(f.race, u2.race)
|
||||
s = u2:show()
|
||||
assert_equal("1 Goblin", string.sub(s, string.find(s, "1 Goblin")))
|
||||
end
|
|
@ -1869,9 +1869,8 @@ static void do_extra_spell(troop at, const att * a)
|
|||
log_error("spell '%s' has no function.\n", sp->sname);
|
||||
}
|
||||
else {
|
||||
double force = a->level * MagicPower();
|
||||
assert(a->level > 0);
|
||||
cast_combatspell(at, sp, a->level, force);
|
||||
cast_combatspell(at, sp, a->level, a->level);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ without prior permission by the authors of Eressea.
|
|||
#include "alchemy.h"
|
||||
#include "bindings.h"
|
||||
#include "move.h"
|
||||
#include "reports.h"
|
||||
|
||||
/* attributes includes */
|
||||
#include <attributes/racename.h>
|
||||
|
@ -54,6 +55,17 @@ without prior permission by the authors of Eressea.
|
|||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
|
||||
static int tolua_bufunit(lua_State * L) {
|
||||
char buf[8192];
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
int mode = (int)tolua_tonumber(L, 2, see_unit);
|
||||
if (!self) return 0;
|
||||
|
||||
bufunit(self->faction, self, 0, mode, buf, sizeof(buf));
|
||||
tolua_pushstring(L, buf);
|
||||
return 1;
|
||||
|
||||
}
|
||||
static int tolua_unit_get_objects(lua_State * L)
|
||||
{
|
||||
unit *self = (unit *)tolua_tousertype(L, 1, 0);
|
||||
|
@ -513,7 +525,7 @@ static void unit_castspell(unit * u, const char *name, int level)
|
|||
}
|
||||
else {
|
||||
castorder co;
|
||||
create_castorder(&co, u, 0, sp, u->region, level, level * MagicPower(), 0, 0, 0);
|
||||
create_castorder(&co, u, 0, sp, u->region, level, (double)level, 0, 0, 0);
|
||||
sp->cast(&co);
|
||||
free_castorder(&co);
|
||||
}
|
||||
|
@ -1034,6 +1046,7 @@ void tolua_unit_open(lua_State * L)
|
|||
tolua_variable(L, TOLUA_CAST "hp_max", &tolua_unit_get_hpmax, 0);
|
||||
|
||||
tolua_variable(L, TOLUA_CAST "objects", &tolua_unit_get_objects, 0);
|
||||
tolua_function(L, TOLUA_CAST "show", &tolua_bufunit);
|
||||
}
|
||||
tolua_endmodule(L);
|
||||
}
|
||||
|
|
|
@ -120,7 +120,6 @@ extern "C" {
|
|||
extern int num_races;
|
||||
|
||||
typedef struct race {
|
||||
struct param *parameters;
|
||||
char *_name;
|
||||
float magres;
|
||||
double maxaura; /* Faktor auf Maximale Aura */
|
||||
|
@ -141,6 +140,7 @@ extern "C" {
|
|||
int df_default; /* Verteidigungsskill Unbewaffnet (default: -2) */
|
||||
int at_bonus; /* Verändert den Angriffsskill (default: 0) */
|
||||
int df_bonus; /* Verändert den Verteidigungskill (default: 0) */
|
||||
struct param *parameters; // additional properties, for an example see natural_armor
|
||||
const struct spell *precombatspell;
|
||||
signed char *study_speed; /* study-speed-bonus in points/turn (0=30 Tage) */
|
||||
int flags;
|
||||
|
|
|
@ -1,176 +0,0 @@
|
|||
/*
|
||||
* +-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
* | | Enno Rehling <enno@eressea.de>
|
||||
* | Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
* | (c) 1998 - 2005 |
|
||||
* | | This program may not be used, modified or distributed
|
||||
* +-------------------+ without prior permission by the authors of Eressea.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef H_KRNL_SPELLID
|
||||
#define H_KRNL_SPELLID
|
||||
|
||||
/* Sprüche. Neue NUR hinten anfügen, oder das Datenfile geht kaputt */
|
||||
enum {
|
||||
SPL_NOSPELL = 0,
|
||||
SPL_FIREBALL = 4,
|
||||
SPL_HAGEL,
|
||||
SPL_RUSTWEAPON,
|
||||
SPL_COMBATRUST,
|
||||
SPL_TREEGROW,
|
||||
SPL_HEALING,
|
||||
SPL_HEALINGSONG,
|
||||
SPL_BADDREAMS,
|
||||
SPL_GOODDREAMS,
|
||||
SPL_DREAMREADING,
|
||||
SPL_SWEETDREAMS,
|
||||
SPL_TIREDSOLDIERS,
|
||||
SPL_PLAGUE,
|
||||
SPL_MAGICBOOST,
|
||||
SPL_CHAOSROW,
|
||||
SPL_SONG_OF_CONFUSION,
|
||||
SPL_FLEE,
|
||||
SPL_SONG_OF_FEAR,
|
||||
SPL_BERSERK,
|
||||
SPL_BLOODTHIRST,
|
||||
SPL_MAELSTROM,
|
||||
SPL_TRANSFERAURA_DRUIDE = 27,
|
||||
SPL_TRANSFERAURA_BARDE,
|
||||
SPL_TRANSFERAURA_CHAOS,
|
||||
SPL_TRANSFERAURA_TRAUM,
|
||||
SPL_TRANSFERAURA_ASTRAL,
|
||||
SPL_STONEGOLEM,
|
||||
SPL_IRONGOLEM,
|
||||
SPL_SUMMONSHADOW,
|
||||
SPL_SUMMONSHADOWLORDS,
|
||||
SPL_REELING_ARROWS,
|
||||
SPL_ANTIMAGICZONE = 37,
|
||||
SPL_KAELTESCHUTZ = 39,
|
||||
SPL_STEALAURA,
|
||||
SPL_SUMMONUNDEAD,
|
||||
SPL_AURALEAK,
|
||||
SPL_GREAT_DROUGHT,
|
||||
SPL_STRONG_WALL,
|
||||
SPL_HOMESTONE,
|
||||
SPL_DROUGHT,
|
||||
SPL_FOREST_FIRE = 47,
|
||||
SPL_SUMMONENT = 49,
|
||||
SPL_DISTURBINGDREAMS,
|
||||
SPL_DENYATTACK,
|
||||
SPL_SLEEP,
|
||||
SPL_EARTHQUAKE,
|
||||
SPL_IRONKEEPER,
|
||||
SPL_STORMWINDS,
|
||||
SPL_GOODWINDS,
|
||||
SPL_FLYING_SHIP,
|
||||
SPL_SUMMON_ALP,
|
||||
SPL_WINDSHIELD,
|
||||
SPL_RAISEPEASANTS,
|
||||
SPL_DEPRESSION,
|
||||
SPL_HEADACHE = 62,
|
||||
SPL_ENTERASTRAL = 64,
|
||||
SPL_LEAVEASTRAL,
|
||||
SPL_SHOWASTRAL,
|
||||
SPL_VERSTEINERN,
|
||||
SPL_TREEWALKENTER,
|
||||
SPL_TREEWALKEXIT,
|
||||
SPL_CHAOSSUCTION,
|
||||
SPL_VIEWREALITY,
|
||||
SPL_DISRUPTASTRAL,
|
||||
SPL_SEDUCE,
|
||||
SPL_PUMP,
|
||||
SPL_CALM_MONSTER,
|
||||
SPL_HERO,
|
||||
SPL_FRIGHTEN,
|
||||
SPL_MINDBLAST,
|
||||
SPL_SPEED,
|
||||
SPL_SPEED2,
|
||||
SPL_FIREDRAGONODEM,
|
||||
SPL_DRAGONODEM,
|
||||
SPL_WYRMODEM, /* 83 */
|
||||
SPL_MAGICSTREET,
|
||||
SPL_REANIMATE,
|
||||
SPL_RECRUIT,
|
||||
SPL_GENEROUS,
|
||||
SPL_PERMTRANSFER,
|
||||
SPL_SONG_OF_PEACE,
|
||||
SPL_MIGRANT,
|
||||
SPL_RALLYPEASANTMOB,
|
||||
SPL_RAISEPEASANTMOB,
|
||||
SPL_ILL_SHAPESHIFT,
|
||||
SPL_WOLFHOWL,
|
||||
SPL_FOG_OF_CONFUSION,
|
||||
SPL_DREAM_OF_CONFUSION,
|
||||
SPL_RESISTMAGICBONUS,
|
||||
SPL_KEEPLOOT,
|
||||
SPL_SCHILDRUNEN,
|
||||
SPL_SONG_RESISTMAGIC,
|
||||
SPL_SONG_SUSCEPTMAGIC,
|
||||
SPL_ANALYSEMAGIC,
|
||||
SPL_ANALYSEDREAM,
|
||||
SPL_UNIT_ANALYSESONG,
|
||||
SPL_OBJ_ANALYSESONG,
|
||||
SPL_TYBIED_DESTROY_MAGIC,
|
||||
SPL_DESTROY_MAGIC,
|
||||
SPL_METEORRAIN,
|
||||
SPL_REDUCESHIELD,
|
||||
SPL_ARMORSHIELD,
|
||||
SPL_DEATHCLOUD,
|
||||
SPL_ORKDREAM,
|
||||
SPL_SUMMONDRAGON = 113,
|
||||
SPL_MOVECASTLE = 116,
|
||||
SPL_BLESSSTONECIRCLE,
|
||||
SPL_ILLAUN_FAMILIAR,
|
||||
SPL_GWYRRD_FAMILIAR,
|
||||
SPL_DRAIG_FAMILIAR,
|
||||
SPL_CERDDOR_FAMILIAR,
|
||||
SPL_TYBIED_FAMILIAR,
|
||||
SPL_SONG_OF_ENSLAVE = 123,
|
||||
SPL_FUMBLECURSE = 136,
|
||||
SPL_ICASTLE,
|
||||
SPL_GWYRRD_DESTROY_MAGIC,
|
||||
SPL_DRAIG_DESTROY_MAGIC,
|
||||
SPL_ILLAUN_DESTROY_MAGIC,
|
||||
SPL_CERDDOR_DESTROY_MAGIC,
|
||||
SPL_GWYRRD_ARMORSHIELD,
|
||||
SPL_DRAIG_FUMBLESHIELD,
|
||||
SPL_GWYRRD_FUMBLESHIELD,
|
||||
SPL_CERDDOR_FUMBLESHIELD,
|
||||
SPL_TYBIED_FUMBLESHIELD,
|
||||
SPL_SHADOWKNIGHTS = 147,
|
||||
SPL_ITEMCLOAK = 150,
|
||||
SPL_FIREWALL,
|
||||
SPL_WISPS,
|
||||
SPL_SPARKLE_CHAOS,
|
||||
SPL_SPARKLE_DREAM = 154,
|
||||
SPL_PULLASTRAL = 156,
|
||||
SPL_FETCHASTRAL = 157,
|
||||
SPL_SHOCKWAVE = 163,
|
||||
SPL_UNDEADHERO = 164,
|
||||
SPL_BECOMEWYRM = 166,
|
||||
SPL_ETERNIZEWALL,
|
||||
SPL_PUTTOREST,
|
||||
SPL_UNHOLYPOWER,
|
||||
SPL_HOLYGROUND,
|
||||
SPL_BLOODSACRIFICE,
|
||||
SPL_MALLORN,
|
||||
SPL_CLONECOPY,
|
||||
SPL_DRAINODEM,
|
||||
SPL_AURA_OF_FEAR,
|
||||
SPL_SHADOWCALL,
|
||||
SPL_MALLORNTREEGROW = 177,
|
||||
SPL_BIGRECRUIT = 179,
|
||||
SPL_IMMOLATION,
|
||||
SPL_FIREODEM, /* 181 */
|
||||
SPL_ICEODEM,
|
||||
SPL_ACIDODEM,
|
||||
/* no longer used, but kept for reference: */
|
||||
XMLSPL_WDWPYRAMID_TRAUM = 184,
|
||||
XMLSPL_WDWPYRAMID_ASTRAL = 185,
|
||||
XMLSPL_WDWPYRAMID_DRUIDE = 186,
|
||||
XMLSPL_WDWPYRAMID_BARDE = 187,
|
||||
XMLSPL_WDWPYRAMID_CHAOS = 188
|
||||
};
|
||||
|
||||
#endif
|
16
src/magic.c
16
src/magic.c
|
@ -118,14 +118,14 @@ static float MagicRegeneration(void)
|
|||
return value;
|
||||
}
|
||||
|
||||
double MagicPower(void)
|
||||
static double MagicPower(double force)
|
||||
{
|
||||
static double value = -1.0;
|
||||
if (value < 0) {
|
||||
if (force > 0) {
|
||||
const char *str = get_param(global.parameters, "magic.power");
|
||||
value = str ? atof(str) : 1.0;
|
||||
double value = str ? atof(str) : 1.0;
|
||||
return _max(value * force, 1.0f);
|
||||
}
|
||||
return value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int a_readicastle(attrib * a, void *owner, struct storage *store)
|
||||
|
@ -1075,8 +1075,6 @@ spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order
|
|||
}
|
||||
}
|
||||
|
||||
force = force * MagicPower();
|
||||
|
||||
return _max(force, 0);
|
||||
}
|
||||
|
||||
|
@ -2074,7 +2072,7 @@ castorder *create_castorder(castorder * co, unit *caster, unit * familiar, const
|
|||
co->_familiar = familiar;
|
||||
co->sp = sp;
|
||||
co->level = lev;
|
||||
co->force = force;
|
||||
co->force = MagicPower(force);
|
||||
co->_rtarget = r ? r : (familiar ? familiar->region : (caster ? caster->region : 0));
|
||||
co->distance = range;
|
||||
co->order = copy_order(ord);
|
||||
|
@ -2824,7 +2822,7 @@ void magic(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
co->force = spellpower(target_r, u, sp, co->level, ord);
|
||||
co->force = MagicPower(spellpower(target_r, u, sp, co->level, ord));
|
||||
/* die Stärke kann durch Antimagie auf 0 sinken */
|
||||
if (co->force <= 0) {
|
||||
co->force = 0;
|
||||
|
|
|
@ -360,7 +360,6 @@ extern "C" {
|
|||
extern void write_spells(struct quicklist *slist, struct storage *store);
|
||||
extern void read_spells(struct quicklist **slistp, magic_t mtype,
|
||||
struct storage *store);
|
||||
extern double MagicPower(void);
|
||||
|
||||
extern struct spellbook * get_spellbook(const char * name);
|
||||
extern void free_spellbooks(void);
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include <kernel/connection.h>
|
||||
#include <kernel/building.h>
|
||||
#include <kernel/curse.h>
|
||||
#include <kernel/spellid.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/messages.h>
|
||||
|
@ -6647,7 +6646,6 @@ static spelldata spell_functions[] = {
|
|||
{ "firestorm", sp_immolation, 0 },
|
||||
{ "coldfront", sp_immolation, 0 },
|
||||
{ "acidrain", sp_immolation, 0 },
|
||||
/* SPL_NOSPELL MUSS der letzte Spruch der Liste sein */
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include <kernel/region.h>
|
||||
#include <kernel/unit.h>
|
||||
#include <kernel/spell.h>
|
||||
#include <kernel/spellid.h>
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/terrain.h>
|
||||
|
||||
|
@ -47,6 +46,30 @@
|
|||
|
||||
#define EFFECT_HEALING_SPELL 5
|
||||
|
||||
// Some spells with a fixed, known ID (in XML).
|
||||
// TODO: this method of identifying spells is error-prone, do not use it for new spells.
|
||||
enum {
|
||||
SPL_FIREBALL = 4,
|
||||
SPL_HAGEL = 5,
|
||||
SPL_CHAOSROW = 18,
|
||||
SPL_FLEE = 20,
|
||||
SPL_SONG_OF_FEAR = 21,
|
||||
SPL_BERSERK = 22,
|
||||
SPL_BLOODTHIRST = 23,
|
||||
SPL_WINDSHIELD = 59,
|
||||
SPL_HERO = 76,
|
||||
SPL_METEORRAIN = 108,
|
||||
SPL_REDUCESHIELD = 109,
|
||||
SPL_ARMORSHIELD = 110,
|
||||
SPL_DRAIG_FUMBLESHIELD = 143,
|
||||
SPL_GWYRRD_FUMBLESHIELD = 144,
|
||||
SPL_CERDDOR_FUMBLESHIELD = 145,
|
||||
SPL_TYBIED_FUMBLESHIELD = 146,
|
||||
SPL_SHADOWKNIGHTS = 147,
|
||||
SPL_SHOCKWAVE = 163,
|
||||
SPL_AURA_OF_FEAR = 175
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Kampfzauberfunktionen */
|
||||
|
||||
|
|
Loading…
Reference in New Issue