2001-01-25 10:37:55 +01:00
|
|
|
|
/* vi: set ts=2:
|
|
|
|
|
*
|
2003-07-29 11:48:03 +02:00
|
|
|
|
* Eressea PB(E)M host Copyright (C) 1998-2003
|
2001-01-25 10:37:55 +01:00
|
|
|
|
* 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-pbem.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.
|
|
|
|
|
*/
|
|
|
|
|
|
2003-07-29 11:48:03 +02:00
|
|
|
|
#ifndef H_KRNL_ITEM
|
|
|
|
|
#define H_KRNL_ITEM
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
struct unit;
|
|
|
|
|
struct attrib;
|
|
|
|
|
struct attrib_type;
|
|
|
|
|
struct region;
|
|
|
|
|
struct resource_type;
|
|
|
|
|
struct locale;
|
|
|
|
|
struct troop;
|
|
|
|
|
|
|
|
|
|
typedef struct item {
|
|
|
|
|
const struct item_type * type;
|
|
|
|
|
int number;
|
|
|
|
|
struct item * next;
|
|
|
|
|
} item;
|
|
|
|
|
|
|
|
|
|
/* bitfield values for resource_type::flags */
|
|
|
|
|
#define RTF_NONE 0
|
|
|
|
|
#define RTF_ITEM (1<<0) /* this resource is an item */
|
|
|
|
|
#define RTF_SNEAK (1<<1) /* can be sneaked to another struct unit, e.g. P_FOOL */
|
|
|
|
|
#define RTF_LIMITED (1<<2) /* a resource that's freely available, but in
|
|
|
|
|
* limited supply */
|
2005-11-01 21:33:21 +01:00
|
|
|
|
#define RTF_POOLED (1<<3) /* resource is available in pool */
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
/* flags for resource_type::name() */
|
|
|
|
|
#define NMF_PLURAL 0x01
|
|
|
|
|
#define NMF_APPEARANCE 0x02
|
|
|
|
|
|
2004-04-12 02:57:09 +02:00
|
|
|
|
typedef int (*rtype_uchange)(struct unit * user, const struct resource_type * rtype, int delta);
|
|
|
|
|
typedef int (*rtype_uget)(const struct unit * user, const struct resource_type * rtype);
|
|
|
|
|
typedef char * (*rtype_name)(const struct resource_type * rtype, int flags);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
typedef struct resource_type {
|
|
|
|
|
/* --- constants --- */
|
2005-10-25 22:44:18 +02:00
|
|
|
|
char * _name[2]; /* wie es hei<65>t */
|
|
|
|
|
char * _appearance[2]; /* wie es f<>r andere aussieht */
|
2001-01-25 10:37:55 +01:00
|
|
|
|
unsigned int flags;
|
|
|
|
|
/* --- functions --- */
|
2004-04-12 02:57:09 +02:00
|
|
|
|
rtype_uchange uchange;
|
|
|
|
|
rtype_uget uget;
|
|
|
|
|
rtype_name name;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
/* --- pointers --- */
|
|
|
|
|
struct attrib * attribs;
|
|
|
|
|
struct resource_type * next;
|
|
|
|
|
unsigned int hashkey;
|
2001-02-13 03:58:51 +01:00
|
|
|
|
struct item_type * itype;
|
|
|
|
|
struct potion_type * ptype;
|
|
|
|
|
struct luxury_type * ltype;
|
|
|
|
|
struct weapon_type * wtype;
|
2005-07-31 03:07:07 +02:00
|
|
|
|
struct armor_type * atype;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
} resource_type;
|
|
|
|
|
extern resource_type * resourcetypes;
|
|
|
|
|
extern const char* resourcename(const resource_type * rtype, int flags);
|
|
|
|
|
extern const resource_type * findresourcetype(const char * name, const struct locale * lang);
|
|
|
|
|
|
|
|
|
|
/* resource-limits for regions */
|
|
|
|
|
extern struct attrib_type at_resourcelimit;
|
2004-04-12 02:57:09 +02:00
|
|
|
|
typedef int (*rlimit_limit)(const struct region * r, const struct resource_type * rtype);
|
|
|
|
|
typedef void (*rlimit_use)(struct region * r, const struct resource_type * rtype, int n);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
typedef struct resource_limit {
|
2004-04-12 02:57:09 +02:00
|
|
|
|
rlimit_limit limit;
|
|
|
|
|
rlimit_use use;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
int value;
|
|
|
|
|
} resource_limit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* bitfield values for item_type::flags */
|
|
|
|
|
#define ITF_NONE 0x0000
|
|
|
|
|
#define ITF_HERB 0x0001 /* this item is a herb */
|
|
|
|
|
#define ITF_CURSED 0x0010 /* cursed object, cannot be given away */
|
|
|
|
|
#define ITF_NOTLOST 0x0020 /* special object (quests), cannot be lost through death etc. */
|
|
|
|
|
#define ITF_BIG 0x0040 /* big item, e.g. does not fit in a bag of holding */
|
|
|
|
|
#define ITF_ANIMAL 0x0080 /* an animal */
|
|
|
|
|
|
|
|
|
|
/* error codes for item_type::use */
|
|
|
|
|
#define ECUSTOM -1;
|
|
|
|
|
#define ENOITEM -2;
|
|
|
|
|
#define ENOSKILL -3;
|
|
|
|
|
#define EUNUSABLE -4;
|
|
|
|
|
|
|
|
|
|
typedef struct itemtype_list {
|
2005-10-30 19:22:28 +01:00
|
|
|
|
struct itemtype_list * next;
|
|
|
|
|
const struct item_type * type;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
} itemtype_list;
|
|
|
|
|
|
|
|
|
|
typedef struct item_type {
|
2005-10-30 19:22:28 +01:00
|
|
|
|
resource_type * rtype;
|
|
|
|
|
/* --- constants --- */
|
|
|
|
|
unsigned int flags;
|
|
|
|
|
int weight;
|
|
|
|
|
int capacity;
|
|
|
|
|
struct construction * construction;
|
|
|
|
|
/* --- functions --- */
|
|
|
|
|
int (*use)(struct unit * user, const struct item_type * itype, int amount, struct order * ord);
|
|
|
|
|
int (*useonother)(struct unit * user, int targetno, const struct item_type * itype, int amount, struct order * ord);
|
|
|
|
|
boolean (*give)(const struct unit * src, const struct unit * dest, const struct item_type * itm, int number, struct order * ord);
|
2005-07-31 18:07:02 +02:00
|
|
|
|
#ifdef SCORE_MODULE
|
|
|
|
|
int score;
|
|
|
|
|
#endif
|
2005-10-30 19:22:28 +01:00
|
|
|
|
struct item_type * next;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
} item_type;
|
|
|
|
|
|
|
|
|
|
extern const item_type * finditemtype(const char * name, const struct locale * lang);
|
2004-06-07 23:43:55 +02:00
|
|
|
|
extern void init_itemnames(void);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
typedef struct luxury_type {
|
2005-10-30 19:22:28 +01:00
|
|
|
|
struct luxury_type * next;
|
|
|
|
|
const item_type * itype;
|
|
|
|
|
int price;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
} luxury_type;
|
|
|
|
|
extern luxury_type * luxurytypes;
|
|
|
|
|
|
|
|
|
|
typedef struct potion_type {
|
2005-10-30 19:22:28 +01:00
|
|
|
|
struct potion_type * next;
|
|
|
|
|
const item_type * itype;
|
|
|
|
|
int level;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
} potion_type;
|
|
|
|
|
extern potion_type * potiontypes;
|
|
|
|
|
|
|
|
|
|
#define WMF_WALKING 0x0001
|
|
|
|
|
#define WMF_RIDING 0x0002
|
|
|
|
|
#define WMF_ANYONE 0x000F /* convenience */
|
|
|
|
|
|
|
|
|
|
#define WMF_AGAINST_RIDING 0x0010
|
|
|
|
|
#define WMF_AGAINST_WALKING 0x0020
|
|
|
|
|
#define WMF_AGAINST_ANYONE 0x00F0 /* convenience */
|
|
|
|
|
|
|
|
|
|
#define WMF_OFFENSIVE 0x0100
|
|
|
|
|
#define WMF_DEFENSIVE 0x0200
|
|
|
|
|
#define WMF_ANYTIME 0x0F00 /* convenience */
|
|
|
|
|
|
|
|
|
|
#define WMF_DAMAGE 0x1000
|
|
|
|
|
#define WMF_SKILL 0x2000
|
|
|
|
|
#define WMF_MISSILE_TARGET 0x4000
|
|
|
|
|
|
2004-06-11 21:59:02 +02:00
|
|
|
|
struct race_list;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
typedef struct weapon_mod {
|
2004-06-11 21:59:02 +02:00
|
|
|
|
int value;
|
|
|
|
|
unsigned int flags;
|
|
|
|
|
struct race_list * races;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
} weapon_mod;
|
|
|
|
|
|
2005-07-31 03:07:07 +02:00
|
|
|
|
#define ATF_NONE 0x00
|
|
|
|
|
#define ATF_SHIELD 0x01
|
|
|
|
|
#define ATF_LAEN 0x02
|
|
|
|
|
|
|
|
|
|
typedef struct armor_type {
|
|
|
|
|
const item_type * itype;
|
|
|
|
|
double penalty;
|
|
|
|
|
double magres;
|
|
|
|
|
int prot;
|
|
|
|
|
unsigned int flags;
|
|
|
|
|
} armor_type;
|
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
#define WTF_NONE 0x00
|
|
|
|
|
#define WTF_MISSILE 0x01
|
|
|
|
|
#define WTF_MAGICAL 0x02
|
|
|
|
|
#define WTF_PIERCE 0x04
|
|
|
|
|
#define WTF_CUT 0x08
|
|
|
|
|
#define WTF_BLUNT 0x10
|
2002-04-27 16:46:27 +02:00
|
|
|
|
#define WTF_ARMORPIERCING 0x40 /* armor has only half value */
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
typedef struct weapon_type {
|
2005-10-30 19:22:28 +01:00
|
|
|
|
const item_type * itype;
|
|
|
|
|
const char * damage[2];
|
|
|
|
|
unsigned int flags;
|
|
|
|
|
skill_t skill;
|
|
|
|
|
int minskill;
|
|
|
|
|
int offmod;
|
|
|
|
|
int defmod;
|
|
|
|
|
double magres;
|
|
|
|
|
int reload; /* time to reload this weapon */
|
|
|
|
|
weapon_mod * modifiers;
|
|
|
|
|
/* --- functions --- */
|
|
|
|
|
boolean (*attack)(const struct troop *, const struct weapon_type *, int *deaths, int row);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
} weapon_type;
|
|
|
|
|
|
|
|
|
|
extern void rt_register(resource_type * it);
|
|
|
|
|
extern resource_type * rt_find(const char * name);
|
|
|
|
|
extern item_type * it_find(const char * name);
|
|
|
|
|
|
|
|
|
|
extern void it_register(item_type * it);
|
|
|
|
|
extern void wt_register(weapon_type * wt);
|
|
|
|
|
|
|
|
|
|
extern const item_type * resource2item(const resource_type * rtype);
|
|
|
|
|
extern const resource_type * item2resource(const item_type * i);
|
|
|
|
|
|
|
|
|
|
extern const weapon_type * resource2weapon(const resource_type * i);
|
|
|
|
|
extern const potion_type * resource2potion(const resource_type * i);
|
|
|
|
|
extern const luxury_type * resource2luxury(const resource_type * i);
|
|
|
|
|
|
|
|
|
|
extern item ** i_find(item ** pi, const item_type * it);
|
|
|
|
|
extern item * i_add(item ** pi, item * it);
|
|
|
|
|
extern void i_merge(item ** pi, item ** si);
|
|
|
|
|
extern item * i_remove(item ** pi, item * it);
|
|
|
|
|
extern void i_free(item * i);
|
|
|
|
|
extern void i_freeall(item * i);
|
2001-12-10 01:13:39 +01:00
|
|
|
|
extern item * i_new(const item_type * it, int number);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
/* convenience: */
|
|
|
|
|
extern item * i_change(item ** items, const item_type * it, int delta);
|
|
|
|
|
extern int i_get(const item * i, const item_type * it);
|
|
|
|
|
|
|
|
|
|
/* creation */
|
|
|
|
|
extern resource_type * new_resourcetype(const char ** names, const char ** appearances, int flags);
|
2001-12-10 01:13:39 +01:00
|
|
|
|
extern item_type * new_itemtype(resource_type * rtype, int iflags, int weight, int capacity);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
extern luxury_type * new_luxurytype(item_type * itype, int price);
|
2002-02-15 17:13:30 +01:00
|
|
|
|
extern weapon_type * new_weapontype(item_type * itype, int wflags, double magres, const char* damage[], int offmod, int defmod, int reload, skill_t sk, int minskill);
|
2005-07-31 03:07:07 +02:00
|
|
|
|
extern armor_type * new_armortype(item_type * itype, double penalty, double magres, int prot, unsigned int flags);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
extern potion_type * new_potiontype(item_type * itype, int level);
|
2005-10-25 14:38:01 +02:00
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
/* for lack of another file: */
|
|
|
|
|
|
|
|
|
|
/* sonstige resourcen */
|
|
|
|
|
extern resource_type * r_silver;
|
|
|
|
|
extern resource_type * r_aura;
|
|
|
|
|
extern resource_type * r_permaura;
|
|
|
|
|
extern resource_type * r_unit;
|
|
|
|
|
extern resource_type * r_hp;
|
|
|
|
|
|
|
|
|
|
typedef struct t_item {
|
|
|
|
|
const char *name[4];
|
|
|
|
|
/* [0]: Einzahl f<>r eigene; [1]: Mehrzahl f<>r eigene;
|
|
|
|
|
* [2]: Einzahl f<EFBFBD>r Fremde; [3]: Mehrzahl f<EFBFBD>r Fremde */
|
|
|
|
|
item_t typ;
|
|
|
|
|
skill_t skill;
|
|
|
|
|
int minskill;
|
|
|
|
|
int material[6];
|
|
|
|
|
int gewicht;
|
|
|
|
|
int preis;
|
|
|
|
|
unsigned int flags;
|
2004-06-21 18:45:27 +02:00
|
|
|
|
void (*benutze_funktion) (struct region *, struct unit *, int amount, struct order *);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
} t_item;
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
I_IRON, /* 0 */
|
|
|
|
|
I_WOOD,
|
|
|
|
|
I_STONE,
|
|
|
|
|
I_HORSE,
|
|
|
|
|
I_WAGON,
|
|
|
|
|
I_SPEAR,
|
|
|
|
|
/* alte Artefakte */
|
|
|
|
|
I_AMULET_OF_HEALING,
|
|
|
|
|
I_AMULET_OF_TRUE_SEEING,
|
|
|
|
|
I_RING_OF_INVISIBILITY,
|
|
|
|
|
I_RING_OF_POWER,
|
|
|
|
|
I_DRAGONHEAD,
|
|
|
|
|
I_CHASTITY_BELT, /* bleibt */
|
2001-12-10 01:13:39 +01:00
|
|
|
|
I_LAENSWORD,
|
|
|
|
|
I_LAEN,
|
2001-01-25 10:37:55 +01:00
|
|
|
|
I_LANCE,
|
|
|
|
|
I_MALLORN,
|
|
|
|
|
I_DRACHENBLUT,
|
|
|
|
|
I_FEENSTIEFEL,
|
|
|
|
|
I_BIRTHDAYAMULET,
|
|
|
|
|
I_PEGASUS,
|
|
|
|
|
I_UNICORN,
|
|
|
|
|
I_DOLPHIN,
|
|
|
|
|
I_RING_OF_NIMBLEFINGER,
|
|
|
|
|
I_TROLLBELT,
|
|
|
|
|
I_PRESSCARD,
|
|
|
|
|
I_AURAKULUM,
|
|
|
|
|
I_SEASERPENTHEAD,
|
2005-10-29 16:12:46 +02:00
|
|
|
|
I_SPHERE_OF_INVISIBILITY,
|
|
|
|
|
I_TOADSLIME,
|
|
|
|
|
I_BAG_OF_HOLDING,
|
|
|
|
|
I_SACK_OF_CONSERVATION,
|
2001-01-25 10:37:55 +01:00
|
|
|
|
I_TACTICCRYSTAL,
|
|
|
|
|
MAX_ITEMS /* do not use outside item.c ! */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
/* ITEMS: */
|
|
|
|
|
R_IRON,
|
|
|
|
|
R_WOOD,
|
|
|
|
|
R_STONE,
|
|
|
|
|
R_HORSE,
|
|
|
|
|
R_WAGON,
|
|
|
|
|
R_SPEAR,
|
2005-10-29 18:10:08 +02:00
|
|
|
|
/**/
|
2001-01-25 10:37:55 +01:00
|
|
|
|
R_AMULET_OF_HEALING,
|
|
|
|
|
R_AMULET_OF_TRUE_SEEING,
|
|
|
|
|
R_RING_OF_INVISIBILITY,
|
|
|
|
|
R_RING_OF_POWER,
|
|
|
|
|
R_DRAGONHEAD,
|
|
|
|
|
R_CHASTITY_BELT,
|
|
|
|
|
R_EOGSWORD,
|
|
|
|
|
R_EOG,
|
|
|
|
|
R_LANCE,
|
|
|
|
|
R_MALLORN,
|
|
|
|
|
R_DRACHENBLUT,
|
|
|
|
|
R_FEENSTIEFEL,
|
|
|
|
|
R_BIRTHDAYAMULET,
|
|
|
|
|
R_PEGASUS,
|
|
|
|
|
R_UNICORN,
|
|
|
|
|
R_DOLPHIN,
|
|
|
|
|
R_RING_OF_NIMBLEFINGER,
|
|
|
|
|
R_TROLLBELT,
|
|
|
|
|
R_PRESSCARD,
|
|
|
|
|
R_AURAKULUM,
|
|
|
|
|
R_SEASERPENTHEAD,
|
2005-10-29 16:12:46 +02:00
|
|
|
|
R_SPHERE_OF_INVISIBILITY,
|
|
|
|
|
R_TOADSLIME,
|
|
|
|
|
R_BAG_OF_HOLDING,
|
|
|
|
|
R_SACK_OF_CONSERVATION,
|
2001-01-25 10:37:55 +01:00
|
|
|
|
R_TACTICCRYSTAL,
|
|
|
|
|
|
|
|
|
|
/* SONSTIGE */
|
|
|
|
|
R_SILVER,
|
|
|
|
|
R_AURA, /* Aura */
|
|
|
|
|
R_PERMAURA, /* Permanente Aura */
|
|
|
|
|
|
|
|
|
|
MAX_RESOURCES, /* do not use outside item.c ! */
|
2005-10-29 18:10:08 +02:00
|
|
|
|
NORESOURCE = -1
|
2001-01-25 10:37:55 +01:00
|
|
|
|
};
|
|
|
|
|
|
2003-07-29 11:48:03 +02:00
|
|
|
|
extern struct potion_type * oldpotiontype[];
|
2001-12-10 01:13:39 +01:00
|
|
|
|
extern struct item_type * olditemtype[];
|
2003-07-29 11:48:03 +02:00
|
|
|
|
extern struct resource_type * oldresourcetype[];
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
int get_item(const struct unit *, item_t);
|
|
|
|
|
int set_item(struct unit *, item_t, int);
|
|
|
|
|
|
|
|
|
|
int get_money(const struct unit *);
|
|
|
|
|
int set_money(struct unit *, int);
|
|
|
|
|
int change_money(struct unit *, int);
|
|
|
|
|
int res_changeitem(struct unit * u, const resource_type * rtype, int delta);
|
|
|
|
|
|
|
|
|
|
extern struct attrib_type at_showitem; /* show this potion's description */
|
|
|
|
|
extern struct attrib_type at_seenitem; /* knows this potion's description, no need to reshow */
|
|
|
|
|
|
2002-01-09 09:20:33 +01:00
|
|
|
|
extern void register_resources(void);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
extern void init_resources(void);
|
|
|
|
|
|
2004-08-03 17:34:26 +02:00
|
|
|
|
extern struct item_type *i_silver;
|
|
|
|
|
|
2003-07-29 11:48:03 +02:00
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2001-01-25 10:37:55 +01:00
|
|
|
|
#endif /* _ITEM_H */
|