From: Martin Read Date: Tue, 11 Feb 2014 23:26:07 +0000 (+0000) Subject: Header fun for cleaner deps X-Git-Tag: out_of_tree_builds~5 X-Git-Url: http://git.blackswordsonics.com/?a=commitdiff_plain;h=98fd89f1fbb395d2b4c28e646e6d5f912a3dc8f4;p=victrix-abyssi Header fun for cleaner deps It should now be easier to put clean dependencies in the Makefile, since things that shouldn't need to be included in a given file are easier to exclude. Note that I haven't actually done the dependency cleanup work yet. --- diff --git a/MANIFEST b/MANIFEST index 4541964..e099fe4 100644 --- a/MANIFEST +++ b/MANIFEST @@ -7,6 +7,7 @@ man/victrix-abyssi.6 combat.cc combat.hh coord.hh +core.hh default.permobjs default.permons display.hh @@ -26,6 +27,8 @@ notify.hh notify-local-tty.cc objects.cc objects.hh +permobj.hh +permon.hh player.hh pmon2.cc pmon_comp diff --git a/Makefile b/Makefile index 0c08832..e5a6dcf 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ OBJS:=$(GENERATED_OBJS) $(HANDWRITTEN_OBJS) GAME:=victrix-abyssi MAJVERS:=0 MINVERS:=9 -PATCHVERS:=0 +PATCHVERS:=1 COMMON_CFLAGS:=-Wall -Wwrite-strings -Wunreachable-code -Wformat -Werror=format-security -fstack-protector --param=ssp-buffer-size=4 -DMAJVERS=$(MAJVERS) -DMINVERS=$(MINVERS) -DPATCHVERS=$(PATCHVERS)-std=gnu11 -D_FORTIFY_SOURCE=2 COMMON_CXXFLAGS:=-Wall -Wwrite-strings -Wno-unused-but-set-variable -Wredundant-decls -Wunreachable-code -Wformat -Werror=format-security -fstack-protector --param=ssp-buffer-size=4 -DMAJVERS=$(MAJVERS) -DMINVERS=$(MINVERS) -DPATCHVERS=$(PATCHVERS) -std=gnu++11 -D_FORTIFY_SOURCE=2 PRODUCTION_CFLAGS:=$(COMMON_CFLAGS) @@ -111,9 +111,9 @@ notify-local-tty.o: notify-local-tty.cc victrix-abyssi.hh combat.hh monsters.hh # file a bug report over this, I will close it NOTABUG; if you submit a # patch to add such a dependency, I will reject it out of hand. -permobj.o: permobj.cc victrix-abyssi.hh objects.hh pobj_id.hh pmon_id.hh +permobj.o: permobj.cc core.hh permobj.hh pobj_id.hh -permons.o: permons.cc victrix-abyssi.hh monsters.hh pobj_id.hh pmon_id.hh +permons.o: permons.cc core.hh permon.hh pmon_id.hh pmon2.o: pmon2.cc victrix-abyssi.hh notify.hh monsters.hh pobj_id.hh pmon_id.hh player.hh diff --git a/combat.cc b/combat.cc index e803241..573cff6 100644 --- a/combat.cc +++ b/combat.cc @@ -29,6 +29,7 @@ #include "victrix-abyssi.hh" #include "combat.hh" #include "monsters.hh" +#include "objects.hh" Action_cost player_attack(Offset delta) { diff --git a/combat.hh b/combat.hh index b04b5b2..27df577 100644 --- a/combat.hh +++ b/combat.hh @@ -33,7 +33,9 @@ #include "victrix-abyssi.hh" #endif +#ifndef MONSTERS_HH #include "monsters.hh" +#endif #define agility_modifier() (u.withering ? (u.agility / 10) : (u.agility / 5)) /* XXX combat.c data and funcs */ diff --git a/core.hh b/core.hh new file mode 100644 index 0000000..61fe154 --- /dev/null +++ b/core.hh @@ -0,0 +1,166 @@ +/*! \file core.hh + * \brief Essential predefinitions header for Victrix Abyssi + */ + +/* Copyright 2014 Martin Read + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef CORE_HH +#define CORE_HH + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include +#include +#include +#include +#include + +#ifndef COORD_HH +#include "coord.hh" +#endif + +#ifndef RNG_HH +#include "rng.hh" +#endif + +enum Comparison +{ + Lesser = -1, + Equal = 0, + Greater = 1 +}; + +enum Pass_fail +{ + You_fail = -1, + You_pass = 0 +}; + +enum Action_cost +{ + Cost_none = 0, + Cost_std = 1 +}; + +enum Noisiness +{ + Noise_silent, + Noise_low, + Noise_std +}; + +#define is_vowel(ch) (((ch) == 'a') || ((ch) == 'e') || ((ch) == 'i') || ((ch) == 'o') || ((ch) == 'u')) + +/* XXX ENUMERATED TYPES XXX */ + +/*! \brief Defines the displayable colour of things in the game. + * + * Game colours after Gcol_l_cyan may alias to a colour in the range l_grey + * through l_cyan depending on your display. + */ +enum Gamecolour +{ + /* l_cyan is the last "core" colour. Colours after it may alias to one + * of the core colours depending on the nature of your display. */ + Gcol_l_grey, Gcol_d_grey, Gcol_red, Gcol_blue, + Gcol_green, Gcol_purple, Gcol_brown, Gcol_cyan, + Gcol_white, Gcol_l_red, Gcol_l_blue, Gcol_l_green, + Gcol_l_purple, Gcol_yellow, Gcol_l_cyan, + /* Fancy colours now! */ + Gcol_iron, Gcol_gold, Gcol_silver, + /* UI customizable colours */ + Gcol_prio_low, Gcol_prio_normal, Gcol_prio_alert, Gcol_prio_warn, Gcol_prio_bug +}; +#define LAST_CORE_COLOUR Gcol_l_cyan +#define LAST_FIXED_COLOUR Gcol_silver +#define LAST_COLOUR Gcol_prio_bug + +/* XXX enum damtyp - types of damage. */ +enum Damtyp { + DT_PHYS = 0, DT_COLD, DT_FIRE, DT_NECRO, + DT_ELEC, DT_HELLFIRE, DT_POISON, + DT_KNOCKBACK, DT_DROWNING +}; +#define DT_COUNT (1 + DT_DROWNING) + +/* XXX enum Game_cmd - player actions. */ +enum Game_cmd { + WALK, STAND_STILL, GO_DOWN_STAIRS, ATTACK, + GET_ITEM, DROP_ITEM, + WIELD_WEAPON, WEAR_ARMOUR, TAKE_OFF_ARMOUR, PUT_ON_RING, REMOVE_RING, + QUAFF_POTION, READ_SCROLL, THROW_FLASK, EAT_FOOD, + EMANATE_ARMOUR, ZAP_WEAPON, MAGIC_RING, + USE_ACTIVE_SKILL, ALLOCATE_SKILL_POINT, + SAVE_GAME, QUIT, + WIZARD_LEVELUP, WIZARD_DESCEND +}; + +/* XXX enum Death */ +/* Sadly, there are not 52 kinds of way to die. */ +enum Death { + DEATH_KILLED, DEATH_KILLED_MON, DEATH_BODY, DEATH_AGILITY, + DEATH_LASH, DEATH_RIBBONS +}; + +enum Fell_powers { + FePo_iron, // boosted by ironguard armour, hellglaive + FePo_decay, // boosted by foetid vestments, + FePo_bone, // boosted by lich's robe, vampire ring + FePo_flesh // boosted by t's lash or the ribbons, +}; + +#define TOTAL_FELL_POWERS (1 + FePo_flesh) + +#define RESIST_MASK_TEMPORARY 0x0000FFFFu +#define RESIST_MASK_PERM_EQUIP 0xFFFF0000u +#define RESIST_RING 0x00010000u +#define RESIST_ARMOUR 0x00020000u + +/*! \brief Represent an in-game action in more detail than Game_cmd + */ +struct Action +{ + Game_cmd cmd; + uint32_t details[8]; +}; + + +class Permobj; +class Permon; +class Obj; +class Mon; + +#define NO_POBJ (-1) +#define NO_PMON (-1) +#define NO_OBJ (-1) +#define NO_MON (-1) +#define NO_REGION 0xffffffffu + +#endif + +/* victrix-abyssi.hh */ +// vim:cindent:ts=8:sw=4:expandtab diff --git a/debian/changelog b/debian/changelog index 765fe9e..80ea173 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,5 @@ -victrix-abyssi (0.9.0-1) UNRELEASED; urgency=low +victrix-abyssi (0.9.1-1) UNRELEASED; urgency=low * Initial release. (Closes: #XXXXXX) - -- Martin Read Sat, 08 Feb 2014 15:43:32 +0000 + -- Martin Read Sat, 10 Feb 2014 23:25:00 +0000 diff --git a/display-nc.cc b/display-nc.cc index 839181a..259153c 100644 --- a/display-nc.cc +++ b/display-nc.cc @@ -29,6 +29,7 @@ #define DISPLAY_NC_CC #include "victrix-abyssi.hh" #include "monsters.hh" +#include "objects.hh" #include #include #include @@ -45,6 +46,7 @@ void reset_inventory_message(void); void hide_inv(void); void show_inv(void); void update_inv(enum poclass_num filter); +int inv_select(enum poclass_num filter, char const *action, int accept_blank); WINDOW *status_window; WINDOW *world_window; WINDOW *message_window; diff --git a/display.hh b/display.hh index 0e8ff27..aeccb8d 100644 --- a/display.hh +++ b/display.hh @@ -47,7 +47,6 @@ extern void display_update(void); extern int display_shutdown(void); extern void newsym(Coord c); extern void touch_back_buffer(void); -extern int inv_select(enum poclass_num filter, char const *action, int accept_blank); extern void get_player_action(Action *act); extern Pass_fail select_dir(Offset *pstep); extern int getYN(char const *msg); diff --git a/log.cc b/log.cc index 7c03396..2c4a90d 100644 --- a/log.cc +++ b/log.cc @@ -27,6 +27,10 @@ */ #include "victrix-abyssi.hh" +#include "objects.hh" +#include "monsters.hh" +#include "player.hh" +#include "map.hh" #include "util.h" #include #include diff --git a/main.cc b/main.cc index 9d5ffbb..3544227 100644 --- a/main.cc +++ b/main.cc @@ -28,6 +28,10 @@ #include "victrix-abyssi.hh" #include "combat.hh" +#include "objects.hh" +#include "monsters.hh" +#include "map.hh" +#include "player.hh" #include #include #include diff --git a/map.cc b/map.cc index b0567a2..332f918 100644 --- a/map.cc +++ b/map.cc @@ -27,7 +27,8 @@ */ #include "victrix-abyssi.hh" -#include "fov.hh" +#include "objects.hh" +#include "monsters.hh" #include Level lvl; diff --git a/monsters.cc b/monsters.cc index 5d5fb4f..4c667a9 100644 --- a/monsters.cc +++ b/monsters.cc @@ -29,6 +29,7 @@ #define MONSTERS_CC #include "victrix-abyssi.hh" #include "monsters.hh" +#include "objects.hh" Mon monsters[100]; static int reject_mon(int pm); diff --git a/monsters.hh b/monsters.hh index 070a13c..535df27 100644 --- a/monsters.hh +++ b/monsters.hh @@ -29,60 +29,13 @@ #ifndef MONSTERS_HH #define MONSTERS_HH -#ifndef VICTRIX_ABYSSI_HH -#include "victrix-abyssi.hh" +#ifndef CORE_HH +#include "core.hh" #endif -/* XXX struct permon */ -#include "pmon_id.hh" - -#define PMF_RESIST_FIRE 0x00000001 -#define PMF_RESIST_COLD 0x00000002 -#define PMF_RESIST_ELEC 0x00000004 -#define PMF_RESIST_POIS 0x00000008 -#define PMF_RESIST_NECR 0x00000010 -#define PMF_RESIST_SLAM 0x00000020 -#define PMF_RESIST_DRWN 0x00000040 -#define PMF_UNDEAD 0x00010000 -#define PMF_DEMONIC 0x00020000 -#define PMF_MAGICIAN 0x00040000 -#define PMF_ARCHER 0x00080000 -#define PMF_SMART 0x00100000 -#define PMF_STUPID 0x00200000 -#define PMF_ETHEREAL 0x00400000 -#define PMF_FLYING 0x00800000 - -#define PERMON_FLAG_FIELDS 1 -struct Permon { - char const *name; - char const *plural; - char const *description; - char sym; - char const *unicode; - int colour; - int rarity; /* Chance in 100 of being thrown back and regen'd. */ - int power; /* Used to determine OOD rating. */ - /* All OOD-improved stats cap out at base + (power * base) */ - int hp; /* Improved by OOD rating at 1:1. */ - int mtohit; /* Improved by OOD rating at 1:3. */ - int rtohit; /* Improved by OOD rating at 1:3. */ - int mdam; /* Improved by OOD rating at 1:5. */ - int rdam; /* Improved by OOD rating at 1:5. */ - Damtyp rdtyp; /* type of damage used by ranged attack. */ - char const *shootverb; /* shooting verb e.g. "fires an arrow", "breathes". */ - int defence; /* Improved by OOD rating at 1:3. */ - int exp; /* Unaffected by OOD rating. */ - int speed; /* 0 = slow; 1 = normal; 2 = quick */ - uint32_t flags[PERMON_FLAG_FIELDS]; /* resistances, AI settings, etc. */ -}; -extern struct Permon permons[NUM_OF_PERMONS]; - -#define NO_ATK (-1) -#define NO_PMON (-1) - -enum AI_mode { - AI_charger, AI_archer, AI_dodger, AI_drunk, AI_seeker, AI_chaser -}; +#ifndef PERMON_HH +#include "permon.hh" +#endif /* XXX struct mon */ #define MONSTERS_IN_PLAY 100 @@ -133,23 +86,7 @@ extern void heal_mon(int mon, int amount, int cansee); /* XXX mon2.c data and funcs */ extern void select_space(int *py, int *px, int dy, int dx, int selection_mode); -/* XXX pmon2.c data and funcs */ -extern bool pmon_is_archer(int pm); -extern bool pmon_is_magician(int pm); -extern bool pmon_is_smart(int pm); -extern bool pmon_is_stupid(int pm); -extern bool pmon_is_undead(int pm); -extern bool pmon_resists_cold(int pm); -extern bool pmon_resists_fire(int pm); -extern bool pmon_resists_poison(int pm); -extern bool pmon_resists_necro(int pm); -extern bool pmon_resists_elec(int pm); -extern bool pmon_resists_drowning(int pm); -extern bool pmon_can_fly(int pm); -extern bool pmon_is_ethereal(int pm); -extern bool pmon_resists_knockback(int pm); - #endif -/* monsters.h */ +/* monsters.hh */ // vim:cindent:expandtab diff --git a/notify-local-tty.cc b/notify-local-tty.cc index c37d57e..17c1c91 100644 --- a/notify-local-tty.cc +++ b/notify-local-tty.cc @@ -33,6 +33,9 @@ #define NOTIFY_LOCAL_TTY_CC #include "victrix-abyssi.hh" #include "monsters.hh" +#include "objects.hh" +#include "player.hh" +#include "map.hh" #include #include #include diff --git a/objects.cc b/objects.cc index bb44f9c..a812346 100644 --- a/objects.cc +++ b/objects.cc @@ -28,6 +28,7 @@ #define OBJECTS_CC #include "victrix-abyssi.hh" +#include "objects.hh" #include "monsters.hh" Obj objects[100]; diff --git a/objects.hh b/objects.hh index 53c7f9e..6792b54 100644 --- a/objects.hh +++ b/objects.hh @@ -29,55 +29,13 @@ #ifndef OBJECTS_HH #define OBJECTS_HH -/*! \brief Quality level of object. - */ -enum Item_quality -{ - Quality_bad, //!< Useless or hypothetically actively harmful - Quality_normal, //!< Useful - Quality_good, - Quality_excellent, - Quality_legendary -}; - -/* XXX enum poclass_num */ -/* Categories of permanent object. */ -enum poclass_num { - POCLASS_NONE = 0, POCLASS_WEAPON, POCLASS_POTION, - POCLASS_SCROLL, POCLASS_FLASK, POCLASS_ARMOUR, POCLASS_RING, - POCLASS_FOOD, POCLASS_CARRION -}; - -#include "pobj_id.hh" - -#define POBJ_FLAG_WORDS 1 - -// POF field 0 -#define POF_NOTIFY_EQUIP 0x00000001u // item has special messages when changing equip status -#define POF_ACTIVATABLE 0x00000002u // item can be activated when equipped -#define POF_STACKABLE 0x00000004u // item can stack -#define POF_DAMAGEABLE 0x00000008u // track durability -#define POF_BREAK_REACT 0x00000010u // item reacts to breakage attempts -#define POF_DRESS 0x00010000u - -/*! \brief The 'permanent object' database */ -struct Permobj { - char const *name; //!< English-language name of item - char const *plural; //!< English-language plural of item - char const *description; //!< English-language description of item - enum poclass_num poclass; //!< Category of item - int rarity; //!< Chance in 100 of being thrown away and regen'd. - char sym; //!< must be in range 32...126 - char const *unicode; //!< must be a C-style string in UTF-8 encoding - Gamecolour colour; //!< colour used for terminal display - int power; //!< first POCLASS-specific data field - int power2; //!< second POCLASS-specific data field - int depth; //!< shallowest depth at which item can be randomly gen'd - uint32_t flags[POBJ_FLAG_WORDS]; -}; -#define NO_POBJ (-1) +#ifndef CORE_HH +#include "core.hh" +#endif -extern Permobj permobjs[NUM_OF_PERMOBJS]; +#ifndef PERMOBJ_HH +#include "permobj.hh" +#endif /* XXX Obj */ #define OBJ_MAX_DUR 100 @@ -104,6 +62,8 @@ extern void describe_object(int obj); extern int create_obj(int po_idx, int quantity, bool with_you, Coord c); extern bool consume_obj(int obj); extern int create_obj_class(enum poclass_num pocl, int quantity, bool with_you, Coord c); +extern void damage_obj(int obj); +extern int evasion_penalty(int obj); extern Action_cost drop_obj(int inv_idx); extern Action_cost put_on_ring(int obj); @@ -118,11 +78,12 @@ extern Action_cost emanate_armour(void); extern Action_cost zap_weapon(void); extern Action_cost player_unwield(Noisiness noisy = Noise_std); extern Action_cost player_wield(int slot, Noisiness noisy = Noise_std); +extern void attempt_pickup(void); extern Pass_fail ring_removal_unsafe(Noisiness noisy = Noise_std); extern Pass_fail armour_removal_unsafe(Noisiness noisy = Noise_std); #endif -/* objects.h */ +/* objects.hh */ // vim:cindent diff --git a/permobj.hh b/permobj.hh new file mode 100644 index 0000000..84fe02d --- /dev/null +++ b/permobj.hh @@ -0,0 +1,93 @@ +/*! \file permobj.hh + * \brief permobj-related header for Victrix Abyssi + */ + +/* Copyright 2014 Martin Read + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef PERMOBJ_HH +#define PERMOBJ_HH + +#ifndef CORE_HH +#include "core.hh" +#endif + +#include "pobj_id.hh" + +/*! \brief Quality level of object. + */ +enum Item_quality +{ + Quality_bad, //!< Useless or hypothetically actively harmful + Quality_normal, //!< Useful + Quality_good, + Quality_excellent, + Quality_legendary +}; + +/* XXX enum poclass_num */ +/* Categories of permanent object. */ +enum poclass_num { + POCLASS_NONE = 0, POCLASS_WEAPON, POCLASS_POTION, + POCLASS_SCROLL, POCLASS_FLASK, POCLASS_ARMOUR, POCLASS_RING, + POCLASS_FOOD, POCLASS_CARRION +}; + +#include "pobj_id.hh" + +#define POBJ_FLAG_WORDS 1 + +// POF field 0 +#define POF_NOTIFY_EQUIP 0x00000001u // item has special messages when changing equip status +#define POF_ACTIVATABLE 0x00000002u // item can be activated when equipped +#define POF_STACKABLE 0x00000004u // item can stack +#define POF_DAMAGEABLE 0x00000008u // track durability +#define POF_BREAK_REACT 0x00000010u // item reacts to breakage attempts +#define POF_DRESS 0x00010000u + +/*! \brief The 'permanent object' database */ +struct Permobj { + char const *name; //!< English-language name of item + char const *plural; //!< English-language plural of item + char const *description; //!< English-language description of item + enum poclass_num poclass; //!< Category of item + int rarity; //!< Chance in 100 of being thrown away and regen'd. + char sym; //!< must be in range 32...126 + char const *unicode; //!< must be a C-style string in UTF-8 encoding + Gamecolour colour; //!< colour used for terminal display + int power; //!< first POCLASS-specific data field + int power2; //!< second POCLASS-specific data field + int depth; //!< shallowest depth at which item can be randomly gen'd + uint32_t flags[POBJ_FLAG_WORDS]; +}; +#define NO_POBJ (-1) + +extern Permobj permobjs[NUM_OF_PERMOBJS]; +extern bool po_is_stackable(int po); + +#endif + +/* permobj.hh */ +// vim:cindent + diff --git a/permon.hh b/permon.hh new file mode 100644 index 0000000..aac0697 --- /dev/null +++ b/permon.hh @@ -0,0 +1,106 @@ +/*! \file permon.hh + * \brief permon-related header + */ + +/* Copyright 2014 Martin Read + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef PERMON_HH +#define PERMON_HH + +#ifndef CORE_HH +#include "core.hh" +#endif + +/* XXX struct permon */ +#include "pmon_id.hh" + +#define PMF_RESIST_FIRE 0x00000001 +#define PMF_RESIST_COLD 0x00000002 +#define PMF_RESIST_ELEC 0x00000004 +#define PMF_RESIST_POIS 0x00000008 +#define PMF_RESIST_NECR 0x00000010 +#define PMF_RESIST_SLAM 0x00000020 +#define PMF_RESIST_DRWN 0x00000040 +#define PMF_UNDEAD 0x00010000 +#define PMF_DEMONIC 0x00020000 +#define PMF_MAGICIAN 0x00040000 +#define PMF_ARCHER 0x00080000 +#define PMF_SMART 0x00100000 +#define PMF_STUPID 0x00200000 +#define PMF_ETHEREAL 0x00400000 +#define PMF_FLYING 0x00800000 + +#define PERMON_FLAG_FIELDS 1 +struct Permon { + char const *name; + char const *plural; + char const *description; + char sym; + char const *unicode; + int colour; + int rarity; /* Chance in 100 of being thrown back and regen'd. */ + int power; /* Used to determine OOD rating. */ + /* All OOD-improved stats cap out at base + (power * base) */ + int hp; /* Improved by OOD rating at 1:1. */ + int mtohit; /* Improved by OOD rating at 1:3. */ + int rtohit; /* Improved by OOD rating at 1:3. */ + int mdam; /* Improved by OOD rating at 1:5. */ + int rdam; /* Improved by OOD rating at 1:5. */ + Damtyp rdtyp; /* type of damage used by ranged attack. */ + char const *shootverb; /* shooting verb e.g. "fires an arrow", "breathes". */ + int defence; /* Improved by OOD rating at 1:3. */ + int exp; /* Unaffected by OOD rating. */ + int speed; /* 0 = slow; 1 = normal; 2 = quick */ + uint32_t flags[PERMON_FLAG_FIELDS]; /* resistances, AI settings, etc. */ +}; +extern struct Permon permons[NUM_OF_PERMONS]; + +#define NO_ATK (-1) +#define NO_PMON (-1) + +enum AI_mode { + AI_charger, AI_archer, AI_dodger, AI_drunk, AI_seeker, AI_chaser +}; + +/* XXX pmon2.c data and funcs */ +extern bool pmon_is_archer(int pm); +extern bool pmon_is_magician(int pm); +extern bool pmon_is_smart(int pm); +extern bool pmon_is_stupid(int pm); +extern bool pmon_is_undead(int pm); +extern bool pmon_resists_cold(int pm); +extern bool pmon_resists_fire(int pm); +extern bool pmon_resists_poison(int pm); +extern bool pmon_resists_necro(int pm); +extern bool pmon_resists_elec(int pm); +extern bool pmon_resists_drowning(int pm); +extern bool pmon_can_fly(int pm); +extern bool pmon_is_ethereal(int pm); +extern bool pmon_resists_knockback(int pm); + +#endif + +/* permon.hh */ +// vim:cindent:expandtab diff --git a/player.hh b/player.hh index d4322c5..17c2693 100644 --- a/player.hh +++ b/player.hh @@ -71,6 +71,10 @@ public: { return martial() || rotten() || thanatoic() || sybaritic(); } }; +#define MIN_FOOD (-1950) +#define SLOT_CANCEL (-1) +#define SLOT_NOTHING (-2) + /* XXX u.c data and funcs */ extern void u_init(char const *name); extern void write_char_dump(void); diff --git a/pmon_comp b/pmon_comp index fbd3f3d..ac55ef8 100755 --- a/pmon_comp +++ b/pmon_comp @@ -345,7 +345,7 @@ print "\n"; open(HEADERFILE, ">", "pmon_id.hh") or die "pmon_comp: could not open pmon_id.hh for write: $!"; open(SOURCEFILE, ">", "permons.cc") or die "pmon_comp: could not open permons.cc for write: $!"; print HEADERFILE "// pmon_id.hh\n// This file is autogenerated from $input_fname\n// and is subject to the same copyright licensing terms as that file.\n// Do not edit this file directly; edit $input_fname\n// then use pmon_comp to regenerate this file and permons.cc\n#pragma once\nenum Pmon_id {\n"; -print SOURCEFILE "// permons.cc\n// This file is autogenerated from $input_fname\n// and is subject to the same copyright licensing terms as that file.\n// Do not edit this file directly; edit $input_fname then use pmon_comp to\n// regenreate this file and pmon_id.hh\n#include \"victrix-abyssi.hh\"\nPermon permons[NUM_OF_PERMONS] = {\n"; +print SOURCEFILE "// permons.cc\n// This file is autogenerated from $input_fname\n// and is subject to the same copyright licensing terms as that file.\n// Do not edit this file directly; edit $input_fname then use pmon_comp to\n// regenreate this file and pmon_id.hh\n#include \"core.hh\"\n#include \"permon.hh\"\nPermon permons[NUM_OF_PERMONS] = {\n"; my $phref; my $i; my $total_mons = 0; diff --git a/pobj_comp b/pobj_comp index e9d82d3..cf02534 100755 --- a/pobj_comp +++ b/pobj_comp @@ -339,7 +339,7 @@ print "\n"; open(HEADERFILE, ">", "pobj_id.hh") or die "pobj_comp: could not open pobj_id.hh for write: $!"; open(SOURCEFILE, ">", "permobj.cc") or die "pobj_comp: could not open permobj.cc for write: $!"; print HEADERFILE "// pobj_id.hh\n// This file is autogenerated from $input_fname\n// and is subject to the same copyright licensing terms as that file.\n// Do not edit this file directly; edit $input_fname\n// then use pobj_comp to regenerate this file and permobj.cc\n#pragma once\nenum Pobj_id {\n"; -print SOURCEFILE "// permobj.cc\n// This file is autogenerated from $input_fname\n// and is subject to the same copyright licensing terms as that file.\n// Do not edit this file directly; edit $input_fname then use pobj_comp to\n// regenreate this file and pobj_id.hh\n#include \"victrix-abyssi.hh\"\nPermobj permobjs[NUM_OF_PERMOBJS] = {\n"; +print SOURCEFILE "// permobj.cc\n// This file is autogenerated from $input_fname\n// and is subject to the same copyright licensing terms as that file.\n// Do not edit this file directly; edit $input_fname then use pobj_comp to\n// regenreate this file and pobj_id.hh\n#include \"core.hh\"\n#include \"permobj.hh\"\nPermobj permobjs[NUM_OF_PERMOBJS] = {\n"; my $phref; my $i; my $total_objs = 0; diff --git a/u.cc b/u.cc index 8defccb..88f3b83 100644 --- a/u.cc +++ b/u.cc @@ -29,6 +29,7 @@ #include "victrix-abyssi.hh" #include "combat.hh" +#include "objects.hh" #include #include #include diff --git a/victrix-abyssi.hh b/victrix-abyssi.hh index 03adfc3..ed7ffd1 100644 --- a/victrix-abyssi.hh +++ b/victrix-abyssi.hh @@ -39,138 +39,19 @@ #include #include -#ifndef COORD_HH -#include "coord.hh" -#endif - -#ifndef RNG_HH -#include "rng.hh" -#endif - -#define ALPHA_LEVEL 1 - -enum Comparison -{ - Lesser = -1, - Equal = 0, - Greater = 1 -}; - -enum Pass_fail -{ - You_fail = -1, - You_pass = 0 -}; - -enum Action_cost -{ - Cost_none = 0, - Cost_std = 1 -}; - -enum Noisiness -{ - Noise_silent, - Noise_low, - Noise_std -}; - +#include "core.hh" /* change WIZARD_MODE to 1 if you want the wizard mode commands. */ #define WIZARD_MODE 0 -#define is_vowel(ch) (((ch) == 'a') || ((ch) == 'e') || ((ch) == 'i') || ((ch) == 'o') || ((ch) == 'u')) - -/* XXX ENUMERATED TYPES XXX */ - -/*! \brief Defines the displayable colour of things in the game. - * - * Game colours after Gcol_l_cyan may alias to a colour in the range l_grey - * through l_cyan depending on your display. - */ -enum Gamecolour -{ - /* l_cyan is the last "core" colour. Colours after it may alias to one - * of the core colours depending on the nature of your display. */ - Gcol_l_grey, Gcol_d_grey, Gcol_red, Gcol_blue, - Gcol_green, Gcol_purple, Gcol_brown, Gcol_cyan, - Gcol_white, Gcol_l_red, Gcol_l_blue, Gcol_l_green, - Gcol_l_purple, Gcol_yellow, Gcol_l_cyan, - /* Fancy colours now! */ - Gcol_iron, Gcol_gold, Gcol_silver, - /* UI customizable colours */ - Gcol_prio_low, Gcol_prio_normal, Gcol_prio_alert, Gcol_prio_warn, Gcol_prio_bug -}; -#define LAST_CORE_COLOUR Gcol_l_cyan -#define LAST_FIXED_COLOUR Gcol_silver -#define LAST_COLOUR Gcol_prio_bug - -/* XXX enum damtyp - types of damage. */ -enum Damtyp { - DT_PHYS = 0, DT_COLD, DT_FIRE, DT_NECRO, - DT_ELEC, DT_HELLFIRE, DT_POISON, - DT_KNOCKBACK, DT_DROWNING -}; -#define DT_COUNT (1 + DT_DROWNING) - -/* XXX enum Game_cmd - player actions. */ -enum Game_cmd { - WALK, STAND_STILL, GO_DOWN_STAIRS, ATTACK, - GET_ITEM, DROP_ITEM, - WIELD_WEAPON, WEAR_ARMOUR, TAKE_OFF_ARMOUR, PUT_ON_RING, REMOVE_RING, - QUAFF_POTION, READ_SCROLL, THROW_FLASK, EAT_FOOD, - EMANATE_ARMOUR, ZAP_WEAPON, MAGIC_RING, - USE_ACTIVE_SKILL, ALLOCATE_SKILL_POINT, - SAVE_GAME, QUIT, - WIZARD_LEVELUP, WIZARD_DESCEND -}; - -/* XXX enum Death */ -/* Sadly, there are not 52 kinds of way to die. */ -enum Death { - DEATH_KILLED, DEATH_KILLED_MON, DEATH_BODY, DEATH_AGILITY, - DEATH_LASH, DEATH_RIBBONS -}; - -enum Fell_powers { - FePo_iron, // boosted by ironguard armour, hellglaive - FePo_decay, // boosted by foetid vestments, - FePo_bone, // boosted by lich's robe, vampire ring - FePo_flesh // boosted by t's lash or the ribbons, -}; - -#define TOTAL_FELL_POWERS (1 + FePo_flesh) - -#define RESIST_MASK_TEMPORARY 0x0000FFFFu -#define RESIST_MASK_PERM_EQUIP 0xFFFF0000u -#define RESIST_RING 0x00010000u -#define RESIST_ARMOUR 0x00020000u -/* XXX STRUCTURES XXX */ - #ifndef PLAYER_HH #include "player.hh" #endif -/*! \brief Represent an in-game action in more detail than Game_cmd - */ -struct Action -{ - Game_cmd cmd; - uint32_t details[8]; -}; - -#define MIN_FOOD (-1950) -#define SLOT_CANCEL (-1) -#define SLOT_NOTHING (-2) - #ifndef MONSTERS_HH #include "monsters.hh" #endif -#ifndef OBJECTS_HH -#include "objects.hh" -#endif - #ifndef DISPLAY_HH #include "display.hh" #endif @@ -198,11 +79,6 @@ extern void new_game(char const *name); /* XXX misc.c data and funcs */ extern char const *damtype_names[DT_COUNT]; -extern void attempt_pickup(void); -extern bool po_is_stackable(int po); -extern void damage_obj(int obj); -extern int evasion_penalty(int obj); - /* XXX log.cc */ extern void log_death(Death d, char const *what); extern void load_config(void);