Skip to content

Commit

Permalink
some spells fixed
Browse files Browse the repository at this point in the history
additional testing
  • Loading branch information
ennorehling committed Jul 23, 2023
1 parent f861af6 commit f023fee
Show file tree
Hide file tree
Showing 11 changed files with 311 additions and 60 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# 28.3

- Zauberkosten sind abhängig von der Zauberstufe, oder Effekt:
- Ritual der Aufnahme: Kosten abhängig von der Anzahl betroffener Personen.
- Bei Zeitdehnung wird die Dauer aufgerundet, (Zauberstufe+1)/2
- Verstärkende Wirkungen von Ring der Macht und Magierturm bei Zaubern repariert, e.g. Zeitdehnung
- Sog des Lebens respektiert die Magieresistenz der Zielregion

# 27.1

- Neue Formel zur Vermischung von Talenten bei GIB PERSON und REKRUTIERE
- Bauern in übervölkerten Regionen vermehren sich nicht
- Samen wachsen nicht zu Schößlingen heran, wenn sie dadurch Bauern die Felder wegnehmen.
Expand Down
7 changes: 4 additions & 3 deletions scripts/tests/e2/migration.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ function test_migration_with_ring()
u.aura_max = 9
process_orders()
assert_equal(f, u2.faction)
assert_equal(6, u.aura)
assert_equal(8, u.aura_max)
-- cost scales with result:
assert_equal(3, u.aura)
assert_equal(7, u.aura_max)
end

function test_migration_insufficient_aura()
Expand Down Expand Up @@ -137,7 +138,7 @@ function test_migration_reduced_cost()
-- spell is cast at level 1:
assert_equal(f, u2.faction)
assert_equal(0, u.aura)
assert_equal(7, u.aura_max)
assert_equal(8, u.aura_max)
end

--[[
Expand Down
23 changes: 23 additions & 0 deletions scripts/tests/e2/spells.lua
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,26 @@ function test_courting()
assert_not_nil(u3)
assert_not_nil(string.find(u3:show(), "Goblin"))
end

function test_cast_summonent()
local r = region.create(0, 0, "plain")
local f = faction.create("demon")
local u = unit.create(f, r)
u.magic = "cerddor"
u.aura = 200
u:add_spell("summonent")
u:set_skill("magic", 20)
r:set_resource("tree", 1)
u:add_order('ZAUBERE STUFE 2 "Erwecke Ents"')
process_orders()
assert_equal(188, u.aura)
local u3 = nil
for u2 in r.units do
if u2 ~= u then
u3 = u2
break
end
end
assert_not_nil(u3)
assert_equal(1, u3.number)
end
6 changes: 3 additions & 3 deletions scripts/tests/e3/spells.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ end

function test_raindance()
local r = region.create(0, 0, "plain")
local f = faction.create("halfling", "noreply@eressea.de", "de")
local f = faction.create("halfling")
local u = unit.create(f, r)
r:set_resource("peasant", 100)
r:set_resource("money", 0)
Expand All @@ -26,7 +26,7 @@ function test_raindance()
assert_equal(0, err)

u:clear_orders()
u:add_order("ZAUBERE STUFE 3 Regentanz")
u:add_order("ZAUBERE STUFE 1 Regentanz")
assert_equal(0, r:get_resource("money"), 0)

process_orders()
Expand All @@ -42,7 +42,7 @@ end

function test_magic()
local r = region.create(0, 0, "plain")
local f = faction.create("halfling", "noreply@eressea.de", "de")
local f = faction.create("halfling")
local u = unit.create(f, r)
local b = building.create(r, "castle")

Expand Down
2 changes: 1 addition & 1 deletion src/kernel/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#ifndef ERESSEA_VERSION
/* the version number, if it was not passed to make with -D */
#define ERESSEA_VERSION "28.2.0"
#define ERESSEA_VERSION "28.3.0"
#endif

const char *eressea_version(void) {
Expand Down
3 changes: 2 additions & 1 deletion src/magic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2498,6 +2498,7 @@ static castorder *cast_cmd(unit * u, order * ord)
unit * mage = NULL;
param_t param;

assert(u);
if (LongHunger(u)) {
cmistake(u, ord, 224, MSG_MAGIC);
return 0;
Expand Down Expand Up @@ -2856,7 +2857,7 @@ void magic(void)
}
/* erst bezahlen, dann Kostenzaehler erhoehen */
if (co->level > 0) {
pay_spell(mage, caster, sp, cast_level, co->distance);
pay_spell(mage, caster, sp, co->level, co->distance);
}
if (fumbled) {
do_fumble(co);
Expand Down
84 changes: 50 additions & 34 deletions src/spells.c
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,11 @@ int sp_blessedharvest(castorder * co)

if (create_curse(caster, &r->attribs, &ct_blessedharvest, co->force,
co->level + 1, 1.0, 0)) {
const char * effect = co->sp->sname[0] == 'b' ? "harvest_effect" : "raindance_effect";
const char* effect = "harvest_effect";
// HACK: same function for harvest and raindance, different message:
if (co->sp && co->sp->sname && co->sp->sname[0] != 'b') {
effect = "raindance_effect";
}
message *seen = msg_message(effect, "mage", caster);
message *unseen = msg_message(effect, "mage", (unit *)NULL);
report_effect(r, caster, seen, unseen);
Expand Down Expand Up @@ -1433,27 +1437,30 @@ int sp_kaelteschutz(castorder * co)
if (force < 1)
break;

if (pa->param[n]->flag)
if (pa->param[n]->flag == TARGET_NOTFOUND)
continue;

u = pa->param[n]->data.u;
if (pa->param[n]->flag == 0)
{
u = pa->param[n]->data.u;

if (force < u->number) {
men = (int)force;
}
else {
men = u->number;
}
if (force < u->number) {
men = (int)force;
}
else {
men = u->number;
}

create_curse(caster, &u->attribs, &ct_insectfur, co->force,
co->level + 1, zero_effect, men);
create_curse(caster, &u->attribs, &ct_insectfur, co->force,
co->level + 1, zero_effect, men);

force -= u->number;
ADDMSG(&caster->faction->msgs, msg_message("heat_effect", "mage target", caster,
u));
if (u->faction != caster->faction)
ADDMSG(&u->faction->msgs, msg_message("heat_effect", "mage target",
cansee(u->faction, r, caster, 0) ? caster : NULL, u));
force -= u->number;
ADDMSG(&caster->faction->msgs, msg_message("heat_effect", "mage target", caster,
u));
if (u->faction != caster->faction)
ADDMSG(&u->faction->msgs, msg_message("heat_effect", "mage target",
cansee(u->faction, r, caster, 0) ? caster : NULL, u));
}
cost = co->level;
}
/* Erstattung? */
Expand Down Expand Up @@ -1886,7 +1893,7 @@ int sp_treewalkexit(castorder * co)
unit *u;
int remaining_cap;
int n;
int erfolg = 0;
int cost = 0;
region *r = co_get_region(co);
unit *caster = co_get_caster(co);
spellparameter *pa = co->par;
Expand Down Expand Up @@ -1923,21 +1930,30 @@ int sp_treewalkexit(castorder * co)
return 0;
}

if (pa->param[0]->flag == TARGET_RESISTS) {
/* target region resists the magical invasion */
return co->level;
}

/* fuer jede Einheit in der Kommandozeile */
for (n = 1; n < pa->length; n++) {
if (pa->param[n]->flag)
if (pa->param[n]->flag == TARGET_NOTFOUND) {
continue;

}
u = pa->param[n]->data.u;

if (!ucontact(u, caster)) {
ADDMSG(&caster->faction->msgs, msg_feedback(caster, co->order,
"feedback_no_contact", "target", u));
if (!can_survive(u, rt)) {
cmistake(caster, co->order, 231, MSG_MAGIC);
}
else {
int w = weight(u);
if (!can_survive(u, rt)) {
cmistake(caster, co->order, 231, MSG_MAGIC);

if (pa->param[n]->flag == TARGET_RESISTS) {
cost = cast_level;
}
else if (!ucontact(u, caster)) {
ADDMSG(&caster->faction->msgs, msg_feedback(caster, co->order,
"feedback_no_contact", "target", u));
}
else if (remaining_cap - w < 0) {
ADDMSG(&caster->faction->msgs, msg_feedback(caster, co->order,
Expand All @@ -1946,7 +1962,7 @@ int sp_treewalkexit(castorder * co)
else {
remaining_cap = remaining_cap - w;
move_unit(u, rt, NULL);
erfolg = cast_level;
cost = cast_level;

/* Meldungen in der Ausgangsregion */
astral_disappear(r, u);
Expand All @@ -1956,7 +1972,7 @@ int sp_treewalkexit(castorder * co)
}
}
}
return erfolg;
return cost;
}

/* ------------------------------------------------------------- */
Expand Down Expand Up @@ -2073,7 +2089,6 @@ int sp_drought(castorder * co)
return 0;
}

/* melden, 1x pro Partei */
msg = msg_message("sp_drought_effect", "mage region", caster, r);
report_spell(caster, r, msg);
msg_release(msg);
Expand Down Expand Up @@ -2188,17 +2203,18 @@ int sp_stormwinds(castorder * co)
region *r = co_get_region(co);
unit *caster = co_get_caster(co);
spellparameter *pa = co->par;
int n, force = (int)co->force;
int n, max_targets = (int)co->force;
message *m = NULL;

/* melden vorbereiten */
freset(caster->faction, FFL_SELECT);
for (u = r->units; u; u = u->next)
freset(u->faction, FFL_SELECT);

for (n = 0; n < pa->length && force > 0; n++) {
if (pa->param[n]->flag)
for (n = 0; n < pa->length && max_targets > 0; n++) {
if (pa->param[n]->flag == TARGET_NOTFOUND) {
continue;
}

sh = pa->param[n]->data.sh;

Expand All @@ -2223,7 +2239,7 @@ int sp_stormwinds(castorder * co)
/* Da der Spruch nur diese Runde wirkt wird er nie im Report
* erscheinen */
erfolg++;
force--;
max_targets--;

/* melden vorbereiten: */
for (u = r->units; u; u = u->next) {
Expand Down Expand Up @@ -2252,7 +2268,7 @@ int sp_stormwinds(castorder * co)
}
if (m)
msg_release(m);
return erfolg;
return erfolg ? co->level : 0;
}

/* ------------------------------------------------------------- */
Expand Down Expand Up @@ -3705,7 +3721,7 @@ static int sp_raisepeasantmob(castorder * co)
* Flag:
* (UNITSPELL | SPELLLEVEL | TESTCANSEE)
*/
static int sp_migranten(castorder * co)
int sp_migranten(castorder * co)
{
unit *target;
region *r = co_get_region(co);
Expand Down
1 change: 1 addition & 0 deletions src/spells.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ extern "C" {
int sp_fumblecurse(struct castorder* co);
int sp_deathcloud(struct castorder* co);
int sp_magicboost(struct castorder* co);
int sp_migranten(struct castorder* co);

#define ACTION_RESET 0x01 /* reset the one-time-flag FFL_SELECT (on first pass) */
#define ACTION_CANSEE 0x02 /* to people who can see the actor */
Expand Down
Loading

0 comments on commit f023fee

Please sign in to comment.