/* ....[@@@..[@@@..............[@.................. MUD++ is a written from ....[@..[@..[@..[@..[@..[@@@@@....[@......[@.... scratch multi-user swords and ....[@..[@..[@..[@..[@..[@..[@..[@@@@@..[@@@@@.. sorcery game written in C++. ....[@......[@..[@..[@..[@..[@....[@......[@.... This server is an ongoing ....[@......[@..[@@@@@..[@@@@@.................. development project. All ................................................ contributions are welcome. ....Copyright(C).1995.Melvin.Smith.............. Enjoy. ------------------------------------------------------------------------------ Melvin Smith (aka Fusion) msmith@hom.net MUD++ development mailing list mudpp@van.ml.org ------------------------------------------------------------------------------ char.h */ #ifndef _CHAR_H #define _CHAR_H #include "thing.h" #include "streamable.h" #include "object.h" #include "combat.h" #include "index.h" #include "bit.h" #include "action.h" #include "mudobj.h" #include "trigs.h" const int POS_DEAD = 0; const int POS_MORTAL = 1; const int POS_STUNNED = 2; const int POS_SLEEPING = 3; const int POS_RESTING = 4; const int POS_SITTING = POS_RESTING; const int POS_STANDING = 5; const int POS_FLOATING = 6; const int POS_FLYING = 7; const int POS_SWIMMING = 8; // Char base class flags ( common to NPC, PC, etc. ) // Char::char_bits const int CHAR_UNDEFINED = 0; const int CHAR_FROZEN = 1; const int CHAR_SNEAKING = 2; const int NEUTER = 0; const int MALE = 1; const int FEMALE = 2; extern const bitType race_list[]; const int RACE_GENERIC = 0; const int RACE_HUMAN = 1; const int RACE_ELF = 2; const int RACE_TROLL = 3; const int RACE_FAERIE = 4; // winged const int RACE_DWARF = 5; const int RACE_GNOME = 6; const int RACE_HALFLING = 7; const int RACE_MINOTAUR = 8; const int RACE_HOBGOBLIN = 9; const int RACE_OGRE = 10; const int RACE_GYOSHA = 11; // winged const int RACE_TRITON = 12; // aquatic const int MAX_RACE = 12; class Affect; class Modifier; class Object; class Exit; class Social; const int CLASS_WIZARD = 0; const int MAX_CHAR_BIT_FIELDS = 1; const int MAX_LANG_BIT_FIELDS = 1; const int MAX_EQ_BIT_FIELDS = 1; const int MAX_FOOD = 100; const int MAX_DRINK = 100; class Char : public Thing, public Streamable { protected: String edesc; unsigned long char_bits[ MAX_CHAR_BIT_FIELDS ]; unsigned long language_bits[ MAX_LANG_BIT_FIELDS ]; unsigned long eq_bits[ MAX_EQ_BIT_FIELDS ]; // Optimize class to share skill arrays (copy-on-write) // for npcs that do nothing special. unsigned char * skills; unsigned short level; unsigned short classnow; long exp; unsigned short race; short hunger; short thirst; unsigned long copper; unsigned long silver; unsigned long gold; short damroll; short hitroll; short armor; short max_hp; short hp; short max_mana; short mana; short anger; short frustration; short adrenaline; short strength; short intel; short wis; short charisma; short con; short dex; short speed; short position; short sex; short carried_weight; short carried_count; short magic_resistance; short orientation; // navigation (lost or not) Char * fighting; Index room_index; public: //LList <Affect> affects; LList <Attack> attacks; LList <Object> inv; LList <Object> wearlist; Action * doing; Char() : skills(0), level(1), classnow(4), exp(0), race(0), hunger(0), thirst(0), copper(0), silver(0), gold(0), damroll(0), hitroll(0), armor(0), max_hp(12), hp(12), max_mana(12), mana(12), anger(0), frustration(0), adrenaline(0), strength(20), intel(20), wis(20), charisma(20), con(20), dex(20), speed(20), position(POS_STANDING), sex(NEUTER), carried_weight(0), carried_count(0), magic_resistance(0), orientation(0), fighting(0), doing(0) { memset( char_bits, 0, sizeof( char_bits[0] ) * MAX_CHAR_BIT_FIELDS ); memset( language_bits, 0, sizeof( language_bits[0] ) * MAX_LANG_BIT_FIELDS ); memset( eq_bits, 0, sizeof( eq_bits[0] ) * MAX_EQ_BIT_FIELDS ); } Char( const Char & x ) : Thing( x ), // propagate up the hierarchy skills(0), level( x.level ), classnow( x.classnow ), exp( x.exp ), race( x.race ), hunger(0), thirst(0), copper( x.copper ), silver( x.silver ), gold( x.gold ), damroll( x.damroll ), hitroll( x.hitroll ), armor( x.armor ), max_hp( x.max_hp ), hp( x.hp ), max_mana( x.max_mana ), mana( x.mana ), anger( x.anger ), frustration( x.frustration ), adrenaline( x.adrenaline ), strength(20), intel(20), wis(20), charisma(20), con(20), dex(20), speed(20), position( x.position ), sex( x.sex ), carried_weight( x.carried_weight ), carried_count( x.carried_count ), magic_resistance( x.magic_resistance ), orientation(0), fighting(0) // for now only copy affects list, never copy inv and wear // affects( x.affects ) { memcpy( (void *)char_bits, (void *)x.char_bits, sizeof( char_bits[0] ) * MAX_CHAR_BIT_FIELDS ); memcpy( (void *)language_bits, (void *)x.language_bits, sizeof( language_bits[0] ) * MAX_LANG_BIT_FIELDS ); memset( eq_bits, 0, sizeof( eq_bits[0] ) * MAX_EQ_BIT_FIELDS ); } virtual ~Char(); virtual vmtype getVMType() { return VMT_CHAR; } // // Interface // virtual Char * asChar() { return this; } void out( const char * ) = 0; void out( const String & ) = 0; void interp( const String &, Char *, Char *, Object *, Object * ); virtual bool pulse() = 0; // convert all actions to return bool on success bool open( Exit * ); bool close( Exit * ); int getSkill( int x ) { return (int)skills[ x ]; } void setSkill( int x, int y ) { skills[ x ] = (char)y; } void setRace( int x ) { race = x; } int getRace() { return race; } int getHunger() const { return hunger; } int getThirst() const { return thirst; } void setHunger( int x ) { hunger = x; } void setThirst( int x ) { hunger = x; } bool eat( Object * ); bool wear( Object *, int ); bool equip( Object *, int ); bool wield( Object *, int ); // int param for left/right bool remove( Object * ); int canWear( Object *, int ); void addObjInv( Object * obj ); Object * getObjInvWear( const String & ); Object * getObjInvWear( countedThing & ); Object * getObjInvWear( int ); Object * getObjInv( const String & ); Object * getObjInv( countedThing & ); Object * getObjInv( int ); void rmObjInv( Object * ); Object * getObjWear( const String & ); Object * getObjWear( countedThing & ); Object * getObjWear( int pos ); /* void addAffect( Affect * ); void rmAffect( int ); Affect * getAffect( int ); */ void modify( Modifier *, bool ); virtual void addAttack( int, int, int ); virtual void rmAttack( int ); bool isFighting() const { return (bool)fighting; } Char * getFighting() const { return fighting; } void setFighting( Char * x ) { fighting = x; } void stopFighting() { fighting = 0; } int attack( Char *, int ); // returns # of successful hits int hit( Char *, Attack * ); virtual void makeCorpse() {} virtual bool die( MudObject * ); // Stop all fights on that char, make corpse... int damage( int, int ); void damMessg( Char *, int, int ); // Preliminary only void cast( const SpellType *, MudObject *, const String & ); int getSex() { return sex; } void setSex( int x ) { sex = x; } virtual int gainExp( int ); int getExp() const { return exp; } void setMaxHP( int x ) { max_hp = x; } void setHP( int x ) { hp = x; } int getMaxHP() const { return max_hp; } int getHP() const { return hp; } void setMaxMana( int x ) { max_mana = x; } void setMana( int x ) { mana = x; } int getMaxMana() const { return max_mana; } int getMana() const { return mana; } virtual int getLevel() const { return level; } void setLevel( int x ) { level = x; } int getStr() const { return strength; } int getInt() const { return intel; } int getWis() const { return wis; } int getDex() const { return dex; } int getCon() const { return con; } int getSpd() const { return speed; } int getCharisma() const { return charisma; } void setCharisma( int x ) { charisma = x; } void setStr( int x ) { strength = x; } void setInt( int x ) { intel = x; } void setWis( int x ) { wis = x; } void setDex( int x ) { dex = x; } void setCon( int x ) { con = x; } void setSpd( int x ) { speed = x; } int getCopper() const { return copper; } void setCopper( int coins ) { copper = coins; } int getSilver() const { return silver; } void setSilver( int coins ) { silver = coins; } int getGold() const { return gold; } void setGold( int coins ) { gold = coins; } int getArmor() const { return armor; } void setArmor( int x ) { armor = x; } int getDamRoll() const { return damroll; } int getHitRoll() const { return hitroll; } int getCarriedWeight() const { return carried_weight; } int getCarriedCount() const { return carried_count; } int getOrientation() const { return orientation; } void setOrientation( int x ) { orientation = x; } int getMagicResistance() const { return magic_resistance; } void setMagicResistance( int x ) { magic_resistance = x; } virtual void say( const String & ) = 0; virtual void look( Object * ) = 0; virtual void look( Char * ) = 0; virtual bool get( Object *, Object *); virtual bool get( Object * ); virtual bool drop( Object * ); virtual bool give( Object *, Char * ); virtual bool put( Object *, Object * ); virtual bool quaff( Object * ); virtual void fromWorld() {} virtual void toWorld() {} virtual void toRoom( Room * ); virtual void fromRoom(); const Index & getWasInRoom() { return room_index; } void setWasInRoom( const Index & x ) { room_index = x; } virtual bool moveDir( int dir ); virtual void describeItself( String &); bool isNPC() const { return false; } bool isPC() const { return false; } bool isShopKeeper() const { return false; } bool isChar() const { return true; } virtual bool isBusy( void ) const { return (doing?true:false); } // Triggers part bool TgCreated( Room * where, Repop * by ); bool TgUpdate(); bool TgGivenGold( Char * caller, int amount ); bool TgGivenObject( Char * caller, Object * what ); bool TgTold( Char * caller, const char * what ); bool TgTold( Char * caller, const String & what ); bool TgAttacked( Char * caller ); bool TgHit( Char *who, Attack *attack ); bool TgKilled( MudObject * killer ); bool TgSocialed( Char * caller, const Social * social ); bool TgLookedAt( Char * caller ); }; inline const char * lookupRaceName( int x ) { return lookupBitName( race_list, x ); } inline int lookupRace( const char * x ) { return lookupBit( race_list, x ); } #endif