forked from github/server
WIP bug 2737
fix cost of spells with ring of power. test and fix cost and limits of familiars casting spells.
This commit is contained in:
parent
5564543bfd
commit
c8e975333b
|
@ -7,6 +7,7 @@ require 'tests.e2.carts'
|
|||
require 'tests.e2.astral'
|
||||
require 'tests.e2.spells'
|
||||
require 'tests.e2.migration'
|
||||
require 'tests.e2.familiars'
|
||||
require 'tests.e2.e2features'
|
||||
require 'tests.e2.insects'
|
||||
require 'tests.e2.production'
|
||||
|
|
|
@ -181,7 +181,7 @@ function test_familiar()
|
|||
local f = faction.create("human")
|
||||
local u = unit.create(f, r)
|
||||
local uid = u.id
|
||||
u.name = 'Hodor'
|
||||
u.name = 'Bonzi'
|
||||
u.magic = "gwyrrd"
|
||||
u.race = "elf"
|
||||
u:set_skill("magic", 10)
|
||||
|
@ -192,7 +192,7 @@ function test_familiar()
|
|||
process_orders()
|
||||
for u in r.units do
|
||||
if u.id ~= uid then
|
||||
assert_equal('Vertrauter von Hodor (' .. itoa36(uid) ..')', u.name)
|
||||
assert_equal('Vertrauter von Bonzi (' .. itoa36(uid) ..')', u.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -222,6 +222,8 @@ function test_bug_2480()
|
|||
end
|
||||
|
||||
function test_bug_2517()
|
||||
-- Magier macht lange Befehle, wenn sein Vertrauter
|
||||
-- zaubert (auch wenn es nicht eigene Zauber sind).
|
||||
local r = region.create(0, 0, "plain")
|
||||
local f = faction.create("elf")
|
||||
local um = unit.create(f, r, 1)
|
||||
|
@ -242,12 +244,25 @@ function test_bug_2517()
|
|||
assert_equal('gray', uf.magic)
|
||||
uf:add_order('LERNE Magie')
|
||||
um:clear_orders()
|
||||
assert_equal(1, uf:get_skill('magic'))
|
||||
um:add_order('ARBEITEN')
|
||||
assert_equal(0, um:get_item('money'))
|
||||
process_orders()
|
||||
assert_equal('gray', uf.magic)
|
||||
uf:add_order('ZAUBERE STUFE 1 Viehheilung')
|
||||
um.aura = 10
|
||||
uf.aura = 10
|
||||
assert_equal(10, um:get_item('money')) -- langer Befehl wurde ausgefuehrt
|
||||
process_orders()
|
||||
assert_equal(50, uf:get_item('money'))
|
||||
assert_equal(20, um:get_item('money')) -- langer Befehl wurde ausgefuehrt
|
||||
assert_equal(8, um.aura) -- kein eigener Zauber, Aura des Magiers
|
||||
assert_equal(10, uf.aura)
|
||||
uf:add_spell('earn_silver#gwyrrd') -- ins private spellbook aufnehmen
|
||||
process_orders()
|
||||
assert_equal(9, uf.aura) -- einfache Kosten, aus eigener Aura
|
||||
assert_equal(8, um.aura) -- keine Kosten für den Magier
|
||||
assert_equal(30, um:get_item('money')) -- langer Befehl wurde ausgefuehrt
|
||||
end
|
||||
|
||||
function test_familiar_school()
|
||||
|
|
|
@ -94,7 +94,6 @@ function test_appeasement_can_move()
|
|||
r2 = region.create(1, 0, 'plain')
|
||||
u2 = unit.create(faction.create('human'), r1, 1)
|
||||
u2.race = 'elf'
|
||||
u2.name = 'Angsthase'
|
||||
u2.magic = 'gwyrrd'
|
||||
u2:set_skill('magic', 5)
|
||||
u2.aura = 10
|
||||
|
@ -118,7 +117,6 @@ function test_appeasement_break_guard()
|
|||
r2 = region.create(1, 0, 'plain')
|
||||
u2 = unit.create(faction.create('human'), r1, 1)
|
||||
u2.race = 'elf'
|
||||
u2.name = 'Angsthase'
|
||||
u2.magic = 'gwyrrd'
|
||||
u2.guard = true
|
||||
u2.status = 1
|
||||
|
|
|
@ -599,13 +599,13 @@ static int tolua_unit_get_familiar(lua_State * L)
|
|||
|
||||
static int tolua_unit_set_familiar(lua_State * L)
|
||||
{
|
||||
unit *mag = (unit *)tolua_tousertype(L, 1, NULL);
|
||||
unit *u = (unit *)tolua_tousertype(L, 1, NULL);
|
||||
unit *fam = (unit *)tolua_tousertype(L, 2, NULL);
|
||||
if (fam) {
|
||||
set_familiar(mag, fam);
|
||||
set_familiar(u, fam);
|
||||
}
|
||||
else {
|
||||
remove_familiar(mag);
|
||||
remove_familiar(u);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1165,9 +1165,9 @@ faction *read_faction(gamedata * data)
|
|||
}
|
||||
read_allies(data, &f->allies);
|
||||
read_groups(data, f);
|
||||
f->spellbook = 0;
|
||||
f->spellbook = NULL;
|
||||
if (data->version >= REGIONOWNER_VERSION) {
|
||||
read_spellbook(FactionSpells() ? &f->spellbook : 0, data, get_spell_level_faction, (void *)f);
|
||||
read_spellbook(FactionSpells() ? &f->spellbook : NULL, data, get_spell_level_faction, (void *)f);
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
|
11
src/magic.c
11
src/magic.c
|
@ -364,11 +364,18 @@ write_mage(const variant *var, const void *owner, struct storage *store)
|
|||
write_spellbook(mage->spellbook, store);
|
||||
}
|
||||
|
||||
static int reset_mage(attrib *a, void *owner) {
|
||||
sc_mage *mage = (sc_mage *)a->data.v;
|
||||
UNUSED_ARG(owner);
|
||||
mage->spellcount = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
attrib_type at_mage = {
|
||||
"mage",
|
||||
init_mage,
|
||||
free_mage,
|
||||
NULL,
|
||||
reset_mage,
|
||||
write_mage,
|
||||
read_mage,
|
||||
NULL,
|
||||
|
@ -498,7 +505,7 @@ sc_mage *create_mage(unit * u, magic_t mtyp)
|
|||
bool u_hasspell(const unit *u, const struct spell *sp)
|
||||
{
|
||||
spellbook * book = unit_get_spellbook(u);
|
||||
spellbook_entry * sbe = book ? spellbook_get(book, sp) : 0;
|
||||
spellbook_entry * sbe = book ? spellbook_get(book, sp) : NULL;
|
||||
if (sbe) {
|
||||
return sbe->level <= effskill(u, SK_MAGIC, NULL);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue