moving spells into eressea-only location (should this be eressea/src instead of just eressea?)

This commit is contained in:
Enno Rehling 2010-02-24 16:16:01 +00:00
parent 0dcfada50f
commit c4742f5886
21 changed files with 10895 additions and 19 deletions

332
src/eressea/curses.c Normal file
View File

@ -0,0 +1,332 @@
#include <platform.h>
#include <kernel/types.h>
#include "curses.h"
#include <kernel/connection.h>
#include <kernel/curse.h>
#include <kernel/config.h>
#include <kernel/faction.h>
#include <kernel/message.h>
#include <kernel/region.h>
#include <kernel/save.h>
#include <kernel/terrain.h>
#include <kernel/unit.h>
#include <kernel/version.h>
#include "spells/regioncurse.h"
#include "spells/unitcurse.h"
#include "spells/shipcurse.h"
#include "spells/buildingcurse.h"
#include <util/attrib.h>
#include <util/language.h>
#include <util/rand.h>
#include <util/rng.h>
#include <util/resolve.h>
#include <util/storage.h>
#include <assert.h>
typedef struct wallcurse {
curse * buddy;
connection * wall;
} wallcurse;
void
cw_init(attrib * a) {
curse * c;
curse_init(a);
c = (curse*)a->data.v;
c->data.v = calloc(sizeof(wallcurse), 1);
}
void
cw_write(const attrib * a, const void * target, storage * store) {
connection * b = ((wallcurse*)((curse*)a->data.v)->data.v)->wall;
curse_write(a, target, store);
store->w_int(store, b->id);
}
typedef struct bresvole {
unsigned int id;
curse * self;
} bresolve;
static int resolve_buddy(variant data, void * addr);
static int
cw_read(attrib * a, void * target, storage * store)
{
bresolve * br = calloc(sizeof(bresolve), 1);
curse * c = (curse*)a->data.v;
wallcurse * wc = (wallcurse*)c->data.v;
variant var;
curse_read(a, store, target);
br->self = c;
br->id = store->r_int(store);
var.i = br->id;
ur_add(var, &wc->wall, resolve_borderid);
var.v = br;
ur_add(var, &wc->buddy, resolve_buddy);
return AT_READ_OK;
}
attrib_type at_cursewall =
{
"cursewall",
cw_init,
curse_done,
curse_age,
cw_write,
cw_read,
ATF_CURSE
};
static int
resolve_buddy(variant data, void * addr)
{
curse * result = NULL;
bresolve * br = (bresolve*)data.v;
if (br->id>=0) {
connection * b = find_border(br->id);
if (b && b->from && b->to) {
attrib * a = a_find(b->from->attribs, &at_cursewall);
while (a && a->data.v!=br->self) {
curse * c = (curse*)a->data.v;
wallcurse * wc = (wallcurse*)c->data.v;
if (wc->wall->id==br->id) break;
a = a->next;
}
if (!a || a->type!=&at_cursewall) {
a = a_find(b->to->attribs, &at_cursewall);
while (a && a->type==&at_cursewall && a->data.v!=br->self) {
curse * c = (curse*)a->data.v;
wallcurse * wc = (wallcurse*)c->data.v;
if (wc->wall->id==br->id) break;
a = a->next;
}
}
if (a && a->type==&at_cursewall) {
curse * c = (curse*)a->data.v;
free(br);
result = c;
}
} else {
/* fail, object does not exist (but if you're still loading then
* you may want to try again later) */
*(curse**)addr = NULL;
return -1;
}
}
*(curse**)addr = result;
return 0;
}
attrib_type at_unitdissolve = {
"unitdissolve", NULL, NULL, NULL, a_writechars, a_readchars
};
static void
wall_init(connection * b)
{
wall_data * fd = (wall_data*)calloc(sizeof(wall_data), 1);
fd->countdown = -1; /* infinite */
b->data.v = fd;
}
static void
wall_destroy(connection * b)
{
free(b->data.v);
}
static void
wall_read(connection * b, storage * store)
{
wall_data * fd = (wall_data*)b->data.v;
variant mno;
assert(fd);
if (store->version<STORAGE_VERSION) {
mno.i = store->r_int(store);
fd->mage = findunit(mno.i);
if (!fd->mage) {
ur_add(mno, &fd->mage, resolve_unit);
}
} else {
read_reference(&fd->mage, store, read_unit_reference, resolve_unit);
}
fd->force = store->r_int(store);
if (store->version>=NOBORDERATTRIBS_VERSION) {
fd->countdown = store->r_int(store);
}
fd->active = true;
}
static void
wall_write(const connection * b, storage * store)
{
wall_data * fd = (wall_data*)b->data.v;
write_unit_reference(fd->mage, store);
store->w_int(store, fd->force);
store->w_int(store, fd->countdown);
}
static int
wall_age(connection * b)
{
wall_data * fd = (wall_data*)b->data.v;
--fd->countdown;
return (fd->countdown>0)?AT_AGE_KEEP:AT_AGE_REMOVE;
}
static region *
wall_move(const connection * b, struct unit * u, struct region * from, struct region * to, boolean routing)
{
wall_data * fd = (wall_data*)b->data.v;
if (!routing && fd->active) {
int hp = dice(3, fd->force) * u->number;
hp = MIN(u->hp, hp);
u->hp -= hp;
if (u->hp) {
ADDMSG(&u->faction->msgs, msg_message("firewall_damage",
"region unit", from, u));
}
else ADDMSG(&u->faction->msgs, msg_message("firewall_death", "region unit", from, u));
if (u->number>u->hp) {
scale_number(u, u->hp);
u->hp = u->number;
}
}
return to;
}
static const char *
b_namefirewall(const connection * b, const region * r, const faction * f, int gflags)
{
const char * bname;
unused(f);
unused(r);
unused(b);
if (gflags & GF_ARTICLE) bname = "a_firewall";
else bname = "firewall";
if (gflags & GF_PURE) return bname;
return LOC(f->locale, mkname("border", bname));
}
border_type bt_firewall = {
"firewall", VAR_VOIDPTR,
b_transparent, /* transparent */
wall_init, /* init */
wall_destroy, /* destroy */
wall_read, /* read */
wall_write, /* write */
b_blocknone, /* block */
b_namefirewall, /* name */
b_rvisible, /* rvisible */
b_finvisible, /* fvisible */
b_uinvisible, /* uvisible */
NULL,
wall_move,
wall_age
};
void convert_firewall_timeouts(connection * b, attrib * a)
{
while (a) {
if (b->type==&bt_firewall && a->type==&at_countdown) {
wall_data * fd = (wall_data *)b->data.v;
fd->countdown = a->data.i;
}
}
}
static const char *
wisps_name(const connection * b, const region * r, const faction * f, int gflags)
{
const char * bname;
unused(f);
unused(r);
unused(b);
if (gflags & GF_ARTICLE) {
bname = "a_wisps";
} else {
bname = "wisps";
}
if (gflags & GF_PURE) return bname;
return LOC(f->locale, mkname("border", bname));
}
typedef struct wisps_data {
wall_data wall;
int rnd;
} wisps_data;
static region *
wisps_move(const connection * b, struct unit * u, struct region * from, struct region * next, boolean routing)
{
direction_t reldir = reldirection(from, next);
wisps_data * wd = (wisps_data*)b->data.v;
assert(reldir!=D_SPECIAL);
if (routing && wd->wall.active) {
region * rl = rconnect(from, (direction_t)((reldir+MAXDIRECTIONS-1)%MAXDIRECTIONS));
region * rr = rconnect(from, (direction_t)((reldir+1)%MAXDIRECTIONS));
/* pick left and right region: */
if (wd->rnd<0) {
wd->rnd = rng_int() % 3;
}
if (wd->rnd == 1 && rl && fval(rl->terrain, LAND_REGION)==fval(next, LAND_REGION)) return rl;
if (wd->rnd == 2 && rr && fval(rr->terrain, LAND_REGION)==fval(next, LAND_REGION)) return rr;
}
return next;
}
static void
wisps_init(connection * b)
{
wisps_data * wd = (wisps_data*)calloc(sizeof(wisps_data), 1);
b->data.v = wd;
wd->rnd = -1;
}
border_type bt_wisps = {
"wisps", VAR_VOIDPTR,
b_transparent, /* transparent */
wisps_init, /* init */
wall_destroy, /* destroy */
wall_read, /* read */
wall_write, /* write */
b_blocknone, /* block */
wisps_name, /* name */
b_rvisible, /* rvisible */
b_fvisible, /* fvisible */
b_uvisible, /* uvisible */
NULL, /* visible */
wisps_move
};
void
register_curses(void)
{
border_convert_cb = &convert_firewall_timeouts;
at_register(&at_cursewall);
register_bordertype(&bt_firewall);
register_bordertype(&bt_wisps);
register_bordertype(&bt_chaosgate);
register_unitcurse();
register_regioncurse();
register_shipcurse();
register_buildingcurse();
}

27
src/eressea/curses.h Normal file
View File

@ -0,0 +1,27 @@
#ifndef H_KRNL_CURSES
#define H_KRNL_CURSES
#ifdef __cplusplus
extern "C" {
#endif
extern void register_curses(void);
/* für Feuerwände: in movement muß das noch explizit getestet werden.
** besser wäre eine blcok_type::move() routine, die den effekt
** der Bewegung auf eine struct unit anwendet.
**/
extern struct border_type bt_chaosgate;
extern struct border_type bt_firewall;
typedef struct wall_data {
struct unit * mage;
int force;
boolean active;
int countdown;
} wall_data;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -10,7 +10,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua-bindings", "..\common\l
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "external", "..\external\external.vcproj", "{F9AE4586-8F65-486B-9666-744839E40A54}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "external", "..\external\external.vcproj", "{F9AE4586-8F65-486B-9666-744839E40A54}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "build", "build.vcproj", "{AD80EB0B-7CB4-42F2-9C95-8CCEF68DB387}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "build", "eressea.vcproj", "{AD80EB0B-7CB4-42F2-9C95-8CCEF68DB387}"
EndProject EndProject
Global Global
GlobalSection(SubversionScc) = preSolution GlobalSection(SubversionScc) = preSolution

View File

@ -21,8 +21,8 @@
<Configurations> <Configurations>
<Configuration <Configuration
Name="Debug|Win32" Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)" OutputDirectory="$(ProjectDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)" IntermediateDirectory="$(ProjectDir)$(ConfigurationName)"
ConfigurationType="1" ConfigurationType="1"
CharacterSet="1" CharacterSet="1"
> >
@ -101,8 +101,8 @@
</Configuration> </Configuration>
<Configuration <Configuration
Name="Release|Win32" Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)" OutputDirectory="$(ProjectDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)" IntermediateDirectory="$(ProjectDir)$(ConfigurationName)"
ConfigurationType="1" ConfigurationType="1"
CharacterSet="1" CharacterSet="1"
WholeProgramOptimization="1" WholeProgramOptimization="1"
@ -187,20 +187,84 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
> >
<File <File
RelativePath="..\common\build\curses.c" RelativePath=".\spells\alp.c"
> >
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath="..\common\build\external.c" RelativePath=".\spells\buildingcurse.c"
> >
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath="..\common\build\gamecode.c" RelativePath=".\spells\combatspells.c"
> >
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath="..\common\build\kernel.c" RelativePath=".\curses.c"
> >
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath=".\main.c" RelativePath=".\main.c"
@ -222,6 +286,148 @@
/> />
</FileConfiguration> </FileConfiguration>
</File> </File>
<File
RelativePath=".\spells\regioncurse.c"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\spells\shipcurse.c"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\spells\spells.c"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\spells\unitcurse.c"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\spells\alp.h"
>
</File>
<File
RelativePath=".\spells\buildingcurse.h"
>
</File>
<File
RelativePath=".\spells\combatspells.h"
>
</File>
<File
RelativePath=".\curses.h"
>
</File>
<File
RelativePath=".\spells\regioncurse.h"
>
</File>
<File
RelativePath=".\spells\shipcurse.h"
>
</File>
<File
RelativePath=".\spells\spells.h"
>
</File>
<File
RelativePath="..\common\build\stdafx.h"
>
</File>
<File
RelativePath=".\spells\unitcurse.h"
>
</File>
</Filter>
<Filter
Name="Unity Build"
>
<File
RelativePath="..\common\build\external.c"
>
</File>
<File
RelativePath="..\common\build\gamecode.c"
>
</File>
<File
RelativePath="..\common\build\kernel.c"
>
</File>
<File
RelativePath="..\common\build\lib.c"
>
</File>
<File <File
RelativePath=".\server.c" RelativePath=".\server.c"
> >
@ -260,16 +466,10 @@
</FileConfiguration> </FileConfiguration>
</File> </File>
</Filter> </Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File <File
RelativePath="..\common\build\stdafx.h" RelativePath=".\spells\Jamfile"
> >
</File> </File>
</Filter>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>

View File

@ -47,7 +47,6 @@
/* gamecode includes */ /* gamecode includes */
#include <gamecode/archetype.h> #include <gamecode/archetype.h>
#include <gamecode/curses.h>
#include <gamecode/economy.h> #include <gamecode/economy.h>
#include <gamecode/items.h> #include <gamecode/items.h>
#include <gamecode/laws.h> #include <gamecode/laws.h>
@ -497,6 +496,8 @@ main(int argc, char *argv[])
kernel_init(); kernel_init();
game_init(); game_init();
register_curses();
register_spells();
if (write_csv) { if (write_csv) {
write_skills(); write_skills();

View File

@ -1,4 +1,13 @@
#include <platform.h> #include <platform.h>
#include "stdafx.h" #include "stdafx.h"
#include "curses.c"
#include "spells/alp.c"
#include "spells/buildingcurse.c"
#include "spells/combatspells.c"
#include "spells/regioncurse.c"
#include "spells/shipcurse.c"
#include "spells/spells.c"
#include "spells/unitcurse.c"
#include "main.c" #include "main.c"

View File

@ -0,0 +1,23 @@
SubDir TOP common spells ;
TargetDirectory ;
SubDirHdrs $(SUBDIR)/../gamecode ;
SubDirHdrs $(SUBDIR)/../kernel ;
SubDirHdrs $(SUBDIR)/../util ;
SubDirHdrs $(SUBDIR)/.. ;
SubDirHdrs $(SUBDIR)/../.. ;
SubDirHdrs $(XMLHDRS) ;
SOURCES =
alp.c
buildingcurse.c
combatspells.c
regioncurse.c
shipcurse.c
spells.c
unitcurse.c
;
if $(BUILDTYPE) = REGULAR {
Library spells : $(SOURCES) ;
}

205
src/eressea/spells/alp.c Normal file
View File

@ -0,0 +1,205 @@
/* vi: set ts=2:
*
* Eressea PB(E)M host Copyright (C) 1998-2003
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
* Henning Peters (faroul@beyond.kn-bremen.de)
* Enno Rehling (enno@eressea.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
*/
#include <platform.h>
#include <kernel/config.h>
#include "alp.h"
#include <kernel/config.h>
#include <kernel/faction.h>
#include <kernel/magic.h>
#include <kernel/message.h>
#include <kernel/race.h>
#include <kernel/region.h>
#include <kernel/skill.h>
#include <kernel/unit.h>
/* util includes */
#include <util/attrib.h>
#include <util/event.h>
#include <util/resolve.h>
#include <util/umlaut.h>
#include <util/storage.h>
#include <triggers/createcurse.h>
#include <triggers/killunit.h>
#include <triggers/removecurse.h>
#include <triggers/unitmessage.h>
/* libc includes */
#include <stdlib.h>
#include <string.h>
#include <assert.h>
extern const char *directions[];
typedef struct alp_data {
unit * mage;
unit * target;
} alp_data;
static void
alp_init(attrib * a)
{
a->data.v = calloc(sizeof(alp_data), 1);
}
static void
alp_done(attrib * a)
{
free(a->data.v);
}
static int
alp_verify(attrib * a)
{
alp_data * ad = (alp_data*)a->data.v;
if (ad->mage && ad->target) return 1;
return 0; /* remove the attribute */
}
static void
alp_write(const attrib * a, const void * owner, struct storage * store)
{
alp_data * ad = (alp_data*)a->data.v;
write_unit_reference(ad->mage, store);
write_unit_reference(ad->target, store);
}
static int
alp_read(attrib * a, void * owner, struct storage * store)
{
alp_data * ad = (alp_data*)a->data.v;
int rm = read_reference(&ad->mage, store, read_unit_reference, resolve_unit);
int rt = read_reference(&ad->target, store, read_unit_reference, resolve_unit);
if (rt==0 && rm==0 && (!ad->target || !ad->mage)) {
/* the target or mage disappeared. */
return AT_READ_FAIL;
}
return AT_READ_OK;
}
static attrib_type at_alp = {
"alp",
alp_init,
alp_done,
alp_verify,
alp_write,
alp_read,
ATF_UNIQUE
};
int
sp_summon_alp(struct castorder *co)
{
unit *alp, *opfer;
region *r = co->rt;
unit *mage = co->magician.u;
int cast_level = co->level;
spellparameter *pa = co->par;
const struct race * rc = new_race[RC_ALP];
struct faction * f = get_monsters();
struct message * msg;
opfer = pa->param[0]->data.u;
/* Der Alp gehört den Monstern, darum erhält der Magier auch keine
* Regionsberichte von ihm. Er erhält aber später eine Mitteilung,
* sobald der Alp sein Opfer erreicht hat.
*/
alp = create_unit(r, f, 1, rc, 0, NULL, NULL);
set_level(alp, SK_STEALTH, 7);
setstatus(alp, ST_FLEE); /* flieht */
{
attrib * a = a_add(&alp->attribs, a_new(&at_alp));
alp_data * ad = (alp_data*) a->data.v;
ad->mage = mage;
ad->target = opfer;
}
{
/* Wenn der Alp stirbt, den Magier nachrichtigen */
add_trigger(&alp->attribs, "destroy", trigger_unitmessage(mage,
"trigger_alp_destroy", MSG_EVENT, ML_INFO));
/* Wenn Opfer oder Magier nicht mehr existieren, dann stirbt der Alp */
add_trigger(&mage->attribs, "destroy", trigger_killunit(alp));
add_trigger(&opfer->attribs, "destroy", trigger_killunit(alp));
}
msg = msg_message("summon_alp_effect", "mage alp target", mage, alp, opfer);
r_addmessage(r, mage->faction, msg);
msg_release(msg);
return cast_level;
}
void
alp_findet_opfer(unit *alp, region *r)
{
curse * c;
attrib * a = a_find(alp->attribs, &at_alp);
alp_data * ad = (alp_data*)a->data.v;
unit *mage = ad->mage;
unit *opfer = ad->target;
double effect;
message * msg;
assert(opfer);
assert(mage);
/* Magier und Opfer Bescheid geben */
msg = msg_message("alp_success", "target", opfer);
add_message(&mage->faction->msgs, msg);
r_addmessage(opfer->region, opfer->faction, msg);
msg_release(msg);
/* Relations werden in destroy_unit(alp) automatisch gelöscht.
* Die Aktionen, die beim Tod des Alps ausgelöst werden sollen,
* müssen jetzt aber deaktiviert werden, sonst werden sie gleich
* beim destroy_unit(alp) ausgelöst.
*/
a_removeall(&alp->attribs, &at_eventhandler);
/* Alp umwandeln in Curse */
effect = -2;
c = create_curse(mage, &opfer->attribs, ct_find("worse"), 2, 2, effect, opfer->number);
/* solange es noch keine spezielle alp-Antimagie gibt, reagiert der
* auch auf normale */
set_number(alp, 0);
/* wenn der Magier stirbt, wird der Curse wieder vom Opfer genommen */
add_trigger(&mage->attribs, "destroy", trigger_removecurse(c, opfer));
}
void
register_alp(void)
{
at_register(&at_alp);
}
unit *
alp_target(unit *alp)
{
alp_data* ad;
unit * target = NULL;
attrib * a = a_find(alp->attribs, &at_alp);
if (a) {
ad = (alp_data*) a->data.v;
target = ad->target;
}
return target;
}

54
src/eressea/spells/alp.h Normal file
View File

@ -0,0 +1,54 @@
/* vi: set ts=2:
*
*
* Eressea PB(E)M host Copyright (C) 1998-2003
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
* Henning Peters (faroul@beyond.kn-bremen.de)
* Enno Rehling (enno@eressea.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
*/
#ifndef ALP_H
#define ALP_H
#ifdef __cplusplus
extern "C" {
#endif
struct castorder;
struct region;
struct unit;
/* ------------------------------------------------------------- */
/* Name: Alp
* Stufe: 15
* Gebiet: Illaun
* Wirkung:
* Erschafft ein kleines Monster (den Alp). Dieser bewegt sich jede
* zweite Runde auf eine Zieleinheit zu. Sobald das Ziel erreicht ist,
* verwandelt es sich in einen Curse auf die Einheit, welches -2 auf
* alle Talente bewirkt.
*
* Fähigkeiten (factypes.c):
* Der Alp hat mittlere Tarnung (T7) und exzellente Verteidigung
* (+20, 99% Magieresistenz, siehe factypes.c)
*
* TODO: Der Alp-Curse sollte sich durch besondere Antimagie (Tybied)
* entfernen lassen.
*
* (UNITSPELL | SEARCHGLOBAL | TESTRESISTANCE)
*/
extern int sp_summon_alp(struct castorder *co);
extern void register_alp(void);
struct unit* alp_target(struct unit *alp);
void alp_findet_opfer(struct unit *alp, struct region *r);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,99 @@
/* vi: set ts=2:
*
* Eressea PB(E)M host Copyright (C) 1998-2003
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
* Henning Peters (faroul@beyond.kn-bremen.de)
* Enno Rehling (enno@eressea.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
*/
#include <platform.h>
#include <kernel/config.h>
#include "buildingcurse.h"
/* kernel includes */
#include <kernel/message.h>
#include <kernel/objtypes.h>
#include <kernel/building.h>
#include <kernel/ship.h>
#include <kernel/curse.h>
/* util includes */
#include <util/nrmessage.h>
#include <util/base36.h>
#include <util/functions.h>
#include <util/language.h>
/* libc includes */
#include <string.h>
#include <stdlib.h>
#include <assert.h>
static message *
cinfo_building(const void * obj, typ_t typ, const curse *c, int self)
{
unused(typ);
assert(typ == TYP_BUILDING);
if (self != 0){ /* owner or inside */
return msg_message(mkname("curseinfo", c->type->cname), "id", c->no);
}
return msg_message(mkname("curseinfo", "buildingunknown"), "id", c->no);
}
/* CurseInfo mit Spezialabfragen */
/* C_MAGICWALLS*/
static message *
cinfo_magicrunes(const void * obj, typ_t typ, const curse *c, int self)
{
message * msg = NULL;
if (typ == TYP_BUILDING){
building * b;
b = (building*)obj;
if (self != 0) {
msg = msg_message("curseinfo::magicrunes_building", "building id", b, c->no);
}
} else if (typ == TYP_SHIP) {
ship *sh;
sh = (ship*)obj;
if (self != 0){
msg = msg_message("curseinfo::magicrunes_ship", "ship id", sh, c->no);
}
}
return msg;
}
static struct curse_type ct_magicrunes = { "magicrunes",
CURSETYP_NORM, 0, M_SUMEFFECT, cinfo_magicrunes
};
/* Heimstein-Zauber */
static struct curse_type ct_magicwalls = { "magicwalls",
CURSETYP_NORM, 0, NO_MERGE, cinfo_building
};
/* Feste Mauer - Präkampfzauber, wirkt nur 1 Runde */
static struct curse_type ct_strongwall = { "strongwall",
CURSETYP_NORM, 0, NO_MERGE, NULL
};
/* Ewige Mauern-Zauber */
static struct curse_type ct_nocostbuilding = { "nocostbuilding",
CURSETYP_NORM, CURSE_NOAGE|CURSE_ONLYONE, NO_MERGE, cinfo_building
};
void
register_buildingcurse(void)
{
ct_register(&ct_magicwalls);
ct_register(&ct_strongwall);
ct_register(&ct_magicrunes);
ct_register(&ct_nocostbuilding);
}

View File

@ -0,0 +1,28 @@
/* vi: set ts=2:
*
* Eressea PB(E)M host Copyright (C) 1998-2003
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
* Henning Peters (faroul@beyond.kn-bremen.de)
* Enno Rehling (enno@eressea.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
*/
#ifndef _BCURSE_H
#define _BCURSE_H
#ifdef __cplusplus
extern "C" {
#endif
struct locale;
struct curse;
extern void register_buildingcurse(void);
#ifdef __cplusplus
}
#endif
#endif /* _BCURSE_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,57 @@
/* vi: set ts=2:
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
| | Enno Rehling <enno@eressea.de>
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
+-------------------+ Stefan Reich <reich@halbling.de>
This program may not be used, modified or distributed
without prior permission by the authors of Eressea.
*/
#ifndef H_GC_COMBATSPELLS
#define H_GC_COMBATSPELLS
#ifdef __cplusplus
extern "C" {
#endif
struct fighter;
/* Kampfzauber */
extern int sp_fumbleshield(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_shadowknights(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_combatrosthauch(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_kampfzauber(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_healing(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_keeploot(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_reanimate(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_chaosrow(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_flee(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_berserk(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_tiredsoldiers(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_reeling_arrows(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_denyattack(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_sleep(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_windshield(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_strong_wall(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_petrify(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_hero(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_frighten(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_mindblast(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_mindblast_temp(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_speed(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_wolfhowl(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_dragonodem(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_reduceshield(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_armorshield(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_stun(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_undeadhero(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_shadowcall(struct fighter * fi, int level, double power, struct spell * sp);
extern int sp_immolation(struct fighter * fi, int level, double power, struct spell * sp);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,296 @@
/* vi: set ts=2:
*
* Eressea PB(E)M host Copyright (C) 1998-2003
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
* Henning Peters (faroul@beyond.kn-bremen.de)
* Enno Rehling (enno@eressea.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
*/
#include <platform.h>
#include <kernel/config.h>
#include "regioncurse.h"
/* kernel includes */
#include <kernel/curse.h>
#include <kernel/magic.h>
#include <kernel/message.h>
#include <kernel/objtypes.h>
#include <kernel/region.h>
#include <kernel/terrain.h>
#include <kernel/unit.h>
/* util includes */
#include <util/nrmessage.h>
#include <util/message.h>
#include <util/functions.h>
/* libc includes */
#include <string.h>
#include <stdlib.h>
#include <assert.h>
/* --------------------------------------------------------------------- */
/* CurseInfo mit Spezialabfragen
*/
/*
* godcursezone
*/
static message *
cinfo_cursed_by_the_gods(const void * obj, typ_t typ, const curse *c, int self)
{
region *r = (region *)obj;
unused(typ);
unused(self);
assert(typ == TYP_REGION);
if (fval(r->terrain, SEA_REGION)) {
return msg_message("curseinfo::godcurseocean", "id", c->no);
}
return msg_message("curseinfo::godcurse", "id", c->no);
}
static struct curse_type ct_godcursezone = {
"godcursezone",
CURSETYP_NORM, CURSE_IMMUNE|CURSE_ISNEW, (NO_MERGE), cinfo_cursed_by_the_gods,
};
/* --------------------------------------------------------------------- */
/*
* C_GBDREAM
*/
static message *
cinfo_dreamcurse(const void * obj, typ_t typ, const curse *c, int self)
{
unused(self);
unused(typ);
unused(obj);
assert(typ == TYP_REGION);
if (curse_geteffect(c) > 0) {
return msg_message("curseinfo::gooddream", "id", c->no);
}
return msg_message("curseinfo::baddream", "id", c->no);
}
static struct curse_type ct_gbdream = {
"gbdream",
CURSETYP_NORM, CURSE_ISNEW, (NO_MERGE), cinfo_dreamcurse
};
/* --------------------------------------------------------------------- */
/*
* C_MAGICSTREET
* erzeugt Straßennetz
*/
static message *
cinfo_magicstreet(const void * obj, typ_t typ, const curse *c, int self)
{
unused(typ);
unused(self);
unused(obj);
assert(typ == TYP_REGION);
/* Warnung vor Auflösung */
if (c->duration <= 2) {
return msg_message("curseinfo::magicstreet", "id", c->no);
}
return msg_message("curseinfo::magicstreetwarn", "id", c->no);
}
static struct curse_type ct_magicstreet = {
"magicstreet",
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
cinfo_magicstreet
};
/* --------------------------------------------------------------------- */
static message *
cinfo_antimagiczone(const void * obj, typ_t typ, const curse *c, int self)
{
unused(typ);
unused(self);
unused(obj);
assert(typ == TYP_REGION);
/* Magier spüren eine Antimagiezone */
if (self != 0) {
return msg_message("curseinfo::antimagiczone", "id", c->no);
}
return NULL;
}
/* alle Magier können eine Antimagiezone wahrnehmen */
static int
cansee_antimagiczone(const struct faction *viewer, const void * obj, typ_t typ, const curse *c, int self)
{
region *r;
unit *u = NULL;
unit *mage = c->magician;
unused(typ);
assert(typ == TYP_REGION);
r = (region *)obj;
for (u = r->units; u; u = u->next) {
if (u->faction==viewer) {
if (u==mage) {
self = 2;
break;
}
if (is_mage(u)) {
self = 1;
}
}
}
return self;
}
static struct curse_type ct_antimagiczone = {
"antimagiczone",
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
cinfo_antimagiczone, NULL, NULL, NULL, cansee_antimagiczone
};
/* --------------------------------------------------------------------- */
static message *
cinfo_farvision(const void * obj, typ_t typ, const curse *c, int self)
{
unused(typ);
unused(obj);
assert(typ == TYP_REGION);
/* Magier spüren eine farvision */
if (self != 0) {
return msg_message("curseinfo::farvision", "id", c->no);
}
return 0;
}
static struct curse_type ct_farvision = {
"farvision",
CURSETYP_NORM, 0, (NO_MERGE),
cinfo_farvision
};
/* --------------------------------------------------------------------- */
static struct curse_type ct_fogtrap = {
"fogtrap",
CURSETYP_NORM, 0, (M_DURATION | M_VIGOUR),
cinfo_simple
};
static struct curse_type ct_maelstrom = {
"maelstrom",
CURSETYP_NORM, CURSE_ISNEW, (M_DURATION | M_VIGOUR),
cinfo_simple
};
static struct curse_type ct_blessedharvest = {
"blessedharvest",
CURSETYP_NORM, 0, ( M_DURATION | M_VIGOUR ),
cinfo_simple
};
static struct curse_type ct_drought = {
"drought",
CURSETYP_NORM, 0, ( M_DURATION | M_VIGOUR ),
cinfo_simple
};
static struct curse_type ct_badlearn = {
"badlearn",
CURSETYP_NORM, CURSE_ISNEW, ( M_DURATION | M_VIGOUR ),
cinfo_simple
};
/* Trübsal-Zauber */
static struct curse_type ct_depression = {
"depression",
CURSETYP_NORM, 0, ( M_DURATION | M_VIGOUR ),
cinfo_simple
};
/* Astralblock, auf Astralregion */
static struct curse_type ct_astralblock = {
"astralblock",
CURSETYP_NORM, 0, NO_MERGE,
cinfo_simple
};
/* Unterhaltungsanteil vermehren */
static struct curse_type ct_generous = {
"generous",
CURSETYP_NORM, 0, ( M_DURATION | M_VIGOUR | M_MAXEFFECT ),
cinfo_simple
};
/* verhindert Attackiere regional */
static struct curse_type ct_peacezone = {
"peacezone",
CURSETYP_NORM, 0, NO_MERGE,
cinfo_simple
};
/* erniedigt Magieresistenz von nicht-aliierten Einheiten, wirkt nur 1x
* pro Einheit */
static struct curse_type ct_badmagicresistancezone = {
"badmagicresistancezone",
CURSETYP_NORM, 0, NO_MERGE,
cinfo_simple
};
/* erhöht Magieresistenz von aliierten Einheiten, wirkt nur 1x pro
* Einheit */
static struct curse_type ct_goodmagicresistancezone = {
"goodmagicresistancezone",
CURSETYP_NORM, 0, NO_MERGE,
cinfo_simple
};
static struct curse_type ct_riotzone = {
"riotzone",
CURSETYP_NORM, 0, (M_DURATION),
cinfo_simple
};
static struct curse_type ct_holyground = {
"holyground",
CURSETYP_NORM, CURSE_NOAGE, (M_VIGOUR_ADD),
cinfo_simple
};
static struct curse_type ct_healing = {
"healingzone",
CURSETYP_NORM, 0, (M_VIGOUR | M_DURATION),
cinfo_simple
};
void
register_regioncurse(void)
{
ct_register(&ct_fogtrap);
ct_register(&ct_antimagiczone);
ct_register(&ct_farvision);
ct_register(&ct_gbdream);
ct_register(&ct_maelstrom);
ct_register(&ct_blessedharvest);
ct_register(&ct_drought);
ct_register(&ct_badlearn);
ct_register(&ct_depression);
ct_register(&ct_astralblock);
ct_register(&ct_generous);
ct_register(&ct_peacezone);
ct_register(&ct_magicstreet);
ct_register(&ct_badmagicresistancezone);
ct_register(&ct_goodmagicresistancezone);
ct_register(&ct_riotzone);
ct_register(&ct_godcursezone);
ct_register(&ct_holyground);
ct_register(&ct_healing);
}

View File

@ -0,0 +1,28 @@
/* vi: set ts=2:
*
* Eressea PB(E)M host Copyright (C) 1998-2003
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
* Henning Peters (faroul@beyond.kn-bremen.de)
* Enno Rehling (enno@eressea.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
*/
#ifndef _RCURSE_H
#define _RCURSE_H
#ifdef __cplusplus
extern "C" {
#endif
struct curse;
struct locale;
extern void register_regioncurse(void);
#ifdef __cplusplus
}
#endif
#endif /* _RCURSE_H */

View File

@ -0,0 +1,155 @@
/* vi: set ts=2:
*
* Eressea PB(E)M host Copyright (C) 1998-2003
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
* Henning Peters (faroul@beyond.kn-bremen.de)
* Enno Rehling (enno@eressea.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
*/
#include <platform.h>
#include <kernel/config.h>
#include <kernel/version.h>
#include "shipcurse.h"
/* kernel includes */
#include <kernel/message.h>
#include <kernel/objtypes.h>
#include <kernel/ship.h>
#include <kernel/unit.h>
#include <kernel/curse.h>
/* util includes */
#include <util/base36.h>
#include <util/functions.h>
#include <util/language.h>
#include <util/log.h>
/* libc includes */
#include <string.h>
#include <stdlib.h>
#include <assert.h>
message *
cinfo_ship(const void * obj, typ_t typ, const curse *c, int self)
{
message * msg;
unused(typ);
unused(obj);
assert(typ == TYP_SHIP);
if (self != 0) { /* owner or inside */
msg = msg_message(mkname("curseinfo", c->type->cname), "id", c->no);
} else {
msg = msg_message("curseinfo::ship_unknown", "id", c->no);
}
if (msg==NULL) {
log_error(("There is no curseinfo for %s.\n", c->type->cname));
}
return msg;
}
/* CurseInfo mit Spezialabfragen */
/* C_SHIP_NODRIFT */
static message *
cinfo_shipnodrift(const void * obj, typ_t typ, const curse *c, int self)
{
ship * sh = (ship *)obj;
unused(typ);
assert(typ == TYP_SHIP);
if (self != 0) {
return msg_message("curseinfo::shipnodrift_1", "ship duration id", sh, c->duration, c->no);
}
return msg_message("curseinfo::shipnodrift_0", "ship id", sh, c->no);
}
static struct curse_type ct_stormwind = { "stormwind",
CURSETYP_NORM, 0, NO_MERGE, cinfo_ship
};
static int flyingship_read(storage * store, curse * c, void * target) {
ship * sh = (ship *)target;
c->data.v = sh;
if (store->version<FOSS_VERSION) {
sh->flags |= SF_FLYING;
return 0;
}
assert(sh->flags&SF_FLYING);
return 0;
}
static int flyingship_write(storage * store, const curse * c, const void * target) {
const ship * sh = (const ship *)target;
assert(sh->flags&SF_FLYING);
return 0;
}
static int flyingship_age(curse * c) {
ship * sh = (ship *)c->data.v;
if (sh && c->duration==1) {
freset(sh, SF_FLYING);
return AT_AGE_REMOVE;
}
return AT_AGE_KEEP;
}
static struct curse_type ct_flyingship = { "flyingship",
CURSETYP_NORM, 0, NO_MERGE, cinfo_ship, NULL, flyingship_read, flyingship_write, NULL, flyingship_age
};
static struct curse_type ct_nodrift = { "nodrift",
CURSETYP_NORM, 0, ( M_DURATION | M_VIGOUR ), cinfo_shipnodrift
};
static struct curse_type ct_shipspeedup = { "shipspeedup",
CURSETYP_NORM, 0, 0, cinfo_ship
};
curse *
shipcurse_flyingship(ship* sh, unit * mage, double power, int duration)
{
static const curse_type * ct_flyingship = NULL;
if (!ct_flyingship) {
ct_flyingship = ct_find("flyingship");
assert(ct_flyingship);
}
if (curse_active(get_curse(sh->attribs, ct_flyingship))) {
return NULL;
} else if (is_cursed(sh->attribs, C_SHIP_SPEEDUP, 0)) {
return NULL;
} else {
/* mit C_SHIP_NODRIFT haben wir kein Problem */
curse * c = create_curse(mage, &sh->attribs, ct_flyingship, power, duration, 0.0, 0);
if (c && c->duration>0) {
sh->flags |= SF_FLYING;
}
return c;
}
}
int
levitate_ship(ship * sh, unit * mage, double power, int duration)
{
curse * c = shipcurse_flyingship(sh, mage, power, duration);
if (c) {
return c->no;
}
return 0;
}
void
register_shipcurse(void)
{
ct_register(&ct_stormwind);
ct_register(&ct_flyingship);
ct_register(&ct_nodrift);
ct_register(&ct_shipspeedup);
}

View File

@ -0,0 +1,30 @@
/* vi: set ts=2:
*
* Eressea PB(E)M host Copyright (C) 1998-2003
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
* Henning Peters (faroul@beyond.kn-bremen.de)
* Enno Rehling (enno@eressea.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
*/
#ifndef _SCURSE_H
#define _SCURSE_H
#ifdef __cplusplus
extern "C" {
#endif
struct locale;
struct message;
extern struct message * cinfo_ship(const void * obj, typ_t typ, const struct curse *c, int self);
extern void register_shipcurse(void);
extern struct curse * shipcurse_flyingship(struct ship* sh, struct unit * mage, double power, int duration);
int levitate_ship(struct ship * sh, struct unit * mage, double power, int duration);
#ifdef __cplusplus
}
#endif
#endif /* _SCURSE_H */

7248
src/eressea/spells/spells.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,33 @@
/* vi: set ts=2:
*
*
* Eressea PB(E)M host Copyright (C) 1998-2003
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
* Henning Peters (faroul@beyond.kn-bremen.de)
* Enno Rehling (enno@eressea.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
*/
#ifndef H_SPL_SPELLS
#define H_SPL_SPELLS
#ifdef __cplusplus
extern "C" {
#endif
struct ship;
struct curse;
struct unit;
extern void register_spells(void);
int levitate_ship(struct ship * sh, struct unit * mage, double power, int duration);
void set_spelldata(struct spell * sp);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,363 @@
/* vi: set ts=2:
*
* Eressea PB(E)M host Copyright (C) 1998-2003
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
* Henning Peters (faroul@beyond.kn-bremen.de)
* Enno Rehling (enno@eressea.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
*/
#include <platform.h>
#include <kernel/config.h>
#include "unitcurse.h"
/* kernel includes */
#include <kernel/curse.h>
#include <kernel/message.h>
#include <kernel/race.h>
#include <kernel/skill.h>
#include <kernel/unit.h>
#include <kernel/faction.h>
#include <kernel/objtypes.h>
#include <kernel/version.h>
/* util includes */
#include <util/language.h>
#include <util/nrmessage.h>
#include <util/message.h>
#include <util/base36.h>
#include <util/functions.h>
#include <util/storage.h>
/* libc includes */
#include <string.h>
#include <stdlib.h>
#include <assert.h>
/* ------------------------------------------------------------- */
/*
* C_AURA
*/
/* erhöht/senkt regeneration und maxaura um effect% */
static message *
cinfo_auraboost(const void * obj, typ_t typ, const curse *c, int self)
{
struct unit *u = (struct unit *)obj;
unused(typ);
assert(typ == TYP_UNIT);
if (self != 0){
if (curse_geteffect(c) > 100){
return msg_message("curseinfo::auraboost_0", "unit id", u, c->no);
} else {
return msg_message("curseinfo::auraboost_1", "unit id", u, c->no);
}
}
return NULL;
}
static struct curse_type ct_auraboost = {
"auraboost",
CURSETYP_NORM, CURSE_SPREADMODULO, (NO_MERGE),
cinfo_auraboost
};
/* Magic Boost - Gabe des Chaos */
static struct curse_type ct_magicboost = {
"magicboost",
CURSETYP_UNIT, CURSE_SPREADMODULO|CURSE_IMMUNE, M_MEN, cinfo_simple
};
/* ------------------------------------------------------------- */
/*
* C_SLAVE
*/
static message *
cinfo_slave(const void * obj, typ_t typ, const curse *c, int self)
{
unit *u;
unused(typ);
assert(typ == TYP_UNIT);
u = (unit *)obj;
if (self != 0){
return msg_message("curseinfo::slave_1", "unit duration id", u, c->duration, c->no);
}
return NULL;
}
static struct curse_type ct_slavery = { "slavery",
CURSETYP_NORM, 0, NO_MERGE,
cinfo_slave
};
/* ------------------------------------------------------------- */
/*
* C_CALM
*/
static message *
cinfo_calm(const void * obj, typ_t typ, const curse *c, int self)
{
unused(typ);
assert(typ == TYP_UNIT);
if (c->magician && c->magician->faction) {
faction *f = c->magician->faction;
unit *u = (unit *)obj;
if (f==NULL || self == 0) {
const struct race * rc = u_irace(c->magician);
return msg_message("curseinfo::calm_0", "unit race id", u, rc, c->no);
}
return msg_message("curseinfo::calm_1", "unit faction id", u, f, c->no);
}
return NULL;
}
static struct curse_type ct_calmmonster = {
"calmmonster",
CURSETYP_NORM, CURSE_SPREADNEVER|CURSE_ONLYONE, NO_MERGE,
cinfo_calm
};
/* ------------------------------------------------------------- */
/*
* C_SPEED
*/
static message *
cinfo_speed(const void * obj, typ_t typ, const curse *c, int self)
{
unused(typ);
assert(typ == TYP_UNIT);
if (self != 0){
unit *u = (unit *)obj;
return msg_message("curseinfo::speed_1", "unit number duration id", u, c->data.i, c->duration, c->no);
}
return NULL;
}
static struct curse_type ct_speed = {
"speed",
CURSETYP_UNIT, CURSE_SPREADNEVER, M_MEN,
cinfo_speed
};
/* ------------------------------------------------------------- */
/*
* C_ORC
*/
message *
cinfo_unit(const void * obj, typ_t typ, const curse *c, int self)
{
unused(typ);
assert(typ == TYP_UNIT);
if (self != 0){
unit * u = (unit *)obj;
return msg_message(mkname("curseinfo", c->type->cname), "unit id", u, c->no);
}
return NULL;
}
static struct curse_type ct_orcish = {
"orcish",
CURSETYP_UNIT, CURSE_SPREADMODULO|CURSE_ISNEW, M_MEN,
cinfo_unit
};
/* ------------------------------------------------------------- */
/*
* C_KAELTESCHUTZ
*/
static message *
cinfo_kaelteschutz(const void * obj, typ_t typ, const curse *c, int self)
{
unused(typ);
assert(typ == TYP_UNIT);
if (self != 0) {
unit * u = (unit *)obj;
return msg_message("curseinfo::warmth_1", "unit number id", u, get_cursedmen(u, c), c->no);
}
return NULL;
}
static struct curse_type ct_insectfur = {
"insectfur",
CURSETYP_UNIT, CURSE_SPREADMODULO, ( M_MEN | M_DURATION ),
cinfo_kaelteschutz
};
/* ------------------------------------------------------------- */
/*
* C_SPARKLE
*/
static message *
cinfo_sparkle(const void * obj, typ_t typ, const curse *c, int self)
{
const char * effects[] = {
NULL, /* end grau*/
"sparkle_1",
"sparkle_2",
NULL, /* end traum */
"sparkle_3",
"sparkle_4",
NULL, /* end tybied */
"sparkle_5",
"sparkle_6",
"sparkle_7",
"sparkle_8",
NULL, /* end cerrdor */
"sparkle_9",
"sparkle_10",
"sparkle_11",
"sparkle_12",
NULL, /* end gwyrrd */
"sparkle_13",
"sparkle_14",
"sparkle_15",
"sparkle_16",
"sparkle_17",
"sparkle_18",
NULL, /* end draig */
};
int m, begin=0, end=0;
unit *u;
unused(typ);
assert(typ == TYP_UNIT);
u = (unit *)obj;
if (!c->magician || !c->magician->faction) return NULL;
for (m=0;m!=c->magician->faction->magiegebiet;++m) {
while (effects[end]!=NULL) ++end;
begin = end+1;
end = begin;
}
while (effects[end]!=NULL) ++end;
if (end==begin) return NULL;
else {
int index = begin + curse_geteffect_int(c) % (end-begin);
return msg_message(mkname("curseinfo", effects[index]), "unit id", u, c->no);
}
}
static struct curse_type ct_sparkle = { "sparkle",
CURSETYP_UNIT, CURSE_SPREADMODULO, ( M_MEN | M_DURATION ), cinfo_sparkle
};
/* ------------------------------------------------------------- */
/*
* C_STRENGTH
*/
static struct curse_type ct_strength = { "strength",
CURSETYP_UNIT, CURSE_SPREADMODULO, M_MEN, cinfo_simple
};
/* ------------------------------------------------------------- */
/*
* C_ALLSKILLS (Alp)
*/
static struct curse_type ct_worse = {
"worse", CURSETYP_UNIT, CURSE_SPREADMODULO|CURSE_NOAGE, M_MEN, cinfo_unit
};
/* ------------------------------------------------------------- */
/*
* C_ITEMCLOAK
*/
static struct curse_type ct_itemcloak = {
"itemcloak", CURSETYP_UNIT, CURSE_SPREADNEVER, M_DURATION, cinfo_unit
};
/* ------------------------------------------------------------- */
static struct curse_type ct_fumble = {
"fumble", CURSETYP_NORM, CURSE_SPREADNEVER|CURSE_ONLYONE, NO_MERGE, cinfo_unit
};
/* ------------------------------------------------------------- */
static struct curse_type ct_oldrace = {
"oldrace", CURSETYP_NORM, CURSE_SPREADALWAYS, NO_MERGE, NULL
};
static struct curse_type ct_magicresistance = {
"magicresistance", CURSETYP_UNIT, CURSE_SPREADMODULO, M_MEN, cinfo_simple
};
/* ------------------------------------------------------------- */
/*
* C_SKILL
*/
static int
read_skill(struct storage * store, void * target, curse * c)
{
int skill;
if (store->version<CURSETYPE_VERSION) {
int men;
skill = store->r_int(store);
men = store->r_int(store);
} else {
skill = store->r_int(store);
}
c->data.i = skill;
return 0;
}
static int
write_skill(struct storage * store, const void * target, const curse * c)
{
store->w_int(store, c->data.i);
return 0;
}
static message *
cinfo_skillmod(const void * obj, typ_t typ, const curse *c, int self)
{
unused(typ);
if (self != 0) {
unit *u = (unit *)obj;
int sk = c->data.i;
if (c->effect>0) {
return msg_message("curseinfo::skill_1", "unit skill id", u, sk, c->no);
} else if (c->effect<0) {
return msg_message("curseinfo::skill_2", "unit skill id", u, sk, c->no);
}
}
return NULL;
}
static struct curse_type ct_skillmod = {
"skillmod", CURSETYP_NORM, CURSE_SPREADMODULO, M_MEN, cinfo_skillmod,
NULL, read_skill, write_skill
};
/* ------------------------------------------------------------- */
void
register_unitcurse(void)
{
ct_register(&ct_auraboost);
ct_register(&ct_magicboost);
ct_register(&ct_slavery);
ct_register(&ct_calmmonster);
ct_register(&ct_speed);
ct_register(&ct_orcish);
ct_register(&ct_insectfur);
ct_register(&ct_sparkle);
ct_register(&ct_strength);
ct_register(&ct_worse);
ct_register(&ct_skillmod);
ct_register(&ct_itemcloak);
ct_register(&ct_fumble);
ct_register(&ct_oldrace);
ct_register(&ct_magicresistance);
}

View File

@ -0,0 +1,29 @@
/* vi: set ts=2:
*
* Eressea PB(E)M host Copyright (C) 1998-2003
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
* Henning Peters (faroul@beyond.kn-bremen.de)
* Enno Rehling (enno@eressea.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
*/
#ifndef _UCURSE_H
#define _UCURSE_H
#ifdef __cplusplus
extern "C" {
#endif
struct curse;
struct message;
extern struct message * cinfo_unit(const void * obj, typ_t typ, const struct curse *c, int self);
extern void register_unitcurse(void);
#ifdef __cplusplus
}
#endif
#endif /* _UCURSE_H */