From 850fa1c0e128a4fe05ffdbdabc9dad25a7530a3f Mon Sep 17 00:00:00 2001 From: fusion32 Date: Thu, 5 Jun 2025 12:33:58 -0300 Subject: declare all creature types --- reference/enums.hh | 10 --- reference/types.hh | 56 +-------------- src/cr.hh | 203 +++++++++++++++++++++++++++++++++++------------------ src/crmain.cc | 2 +- src/enums.hh | 10 +++ 5 files changed, 147 insertions(+), 134 deletions(-) diff --git a/reference/enums.hh b/reference/enums.hh index ed42c26..7707e73 100644 --- a/reference/enums.hh +++ b/reference/enums.hh @@ -1,14 +1,4 @@ -enum STATE: int { - SLEEPING=0, - IDLE=1, - UNDERATTACK=2, - TALKING=3, - LEAVING=4, - ATTACKING=5, - PANIC=6 -}; - enum ActionType: int { ACTION_CREATEONMAP=0, ACTION_CREATE=1, diff --git a/reference/types.hh b/reference/types.hh index c970e35..6840fc3 100644 --- a/reference/types.hh +++ b/reference/types.hh @@ -56,13 +56,6 @@ struct TPlayerIndexLeafNode { struct TPlayerIndexEntry Entry[10]; }; -struct TNode { - int Type; - int Data; - struct TNode *Left; - struct TNode *Right; -}; - struct THouseGuest { char Name[60]; }; @@ -117,11 +110,6 @@ struct TAttackWave { struct vector ExtraItem; }; -struct TNonplayer { - struct TCreature super_TCreature; // INHERITANCE? - enum STATE State; -}; - struct TReportedStatement { ulong StatementID; ulong TimeStamp; @@ -165,13 +153,7 @@ struct TMonsterhome { int Timer; }; -struct TCondition { - int Type; - ulong Text; - struct TNode *Expression; - int Property; - int Number; -}; + struct TChannel { ulong Moderator; @@ -214,22 +196,6 @@ struct TMoveUseCondition { int Parameters[5]; }; -struct TAction { - int Type; - ulong Text; - int Number; - struct TNode *Expression; - struct TNode *Expression2; - struct TNode *Expression3; -}; - -struct TBehaviour { - struct vector Condition; - struct vector Action; - int Conditions; - int Actions; -}; - struct THouseArea { ushort ID; int SQMPrice; @@ -366,26 +332,6 @@ struct TReaderThreadReply { int Size; }; -struct TNPC { - struct TNonplayer super_TNonplayer; - ulong Interlocutor; - int Topic; - int Price; - int Amount; - int TypeID; - ulong Data; - ulong LastTalk; - struct vector QueuedPlayers; - struct vector QueuedAddresses; - int QueueLength; - struct TBehaviourDatabase *Behaviour; -}; - -struct TBehaviourDatabase { - struct vector Behaviour; - int Behaviours; -}; - struct TQueryManagerConnection { int BufferSize; uchar *Buffer; diff --git a/src/cr.hh b/src/cr.hh index 2d4115e..dc9bd7b 100644 --- a/src/cr.hh +++ b/src/cr.hh @@ -4,11 +4,12 @@ #include "common.hh" #include "connection.hh" #include "containers.hh" +#include "enums.hh" #include "map.hh" struct TCreature; -// TRaceData +// Creature Data // ============================================================================= struct TOutfit{ int OutfitID; @@ -51,6 +52,8 @@ struct TSpellData { struct TRaceData { TRaceData(void); + // DATA + // ================= char Name[30]; char Article[3]; TOutfit Outfit; @@ -90,6 +93,66 @@ struct TRaceData { vector Spell; }; +struct TPlayerData { + uint32 CharacterID; + pid_t Locked; + int Sticky; + bool Dirty; + int Race; + TOutfit OriginalOutfit; + TOutfit CurrentOutfit; + time_t LastLoginTime; + time_t LastLogoutTime; + int startx; + int starty; + int startz; + int posx; + int posy; + int posz; + int Profession; + int PlayerkillerEnd; + int Actual[25]; + int Maximum[25]; + int Minimum[25]; + int DeltaAct[25]; + int MagicDeltaAct[25]; + int Cycle[25]; + int MaxCycle[25]; + int Count[25]; + int MaxCount[25]; + int AddLevel[25]; + int Experience[25]; + int FactorPercent[25]; + int NextLevel[25]; + int Delta[25]; + uint8 SpellList[256]; + int QuestValues[500]; + int MurderTimestamps[20]; + uint8 *Inventory; + int InventorySize; + uint8 *Depot[9]; + int DepotSize[9]; + uint32 AccountID; + int Sex; + char Name[30]; + uint8 Rights[12]; + char Guild[31]; + char Rank[31]; + char Title[31]; + int Buddies; + uint32 Buddy[100]; + char BuddyName[100][30]; + uint32 EarliestYellRound; + uint32 EarliestTradeChannelRound; + uint32 EarliestSpellTime; + uint32 EarliestMultiuseTime; + uint32 TalkBufferFullTime; + uint32 MutingEndRound; + uint32 Addressees[20]; + uint32 AddresseesTimes[20]; + int NumberOfMutings; +}; + // TSkillBase // ============================================================================= struct TSkill{ @@ -317,7 +380,6 @@ struct TCombat{ // TCreature // ============================================================================= - struct TToDoEntry { ToDoType Code; union{ @@ -446,85 +508,91 @@ struct TCreature: TSkillBase { // TNonPlayer // ============================================================================= +struct TNonplayer: TCreature { + //TNonplayer(void); + + // DATA + // ================= + //TCreature super_TCreature; // IMPLICIT + STATE State; +}; // TNPC // ============================================================================= +// TODO(fusion): Most of these are probably contained in `crnonpl.cc` because +// `TNPC` has a pointer to `TBehaviourDatabase`. +struct TNode { + int Type; + int Data; + TNode *Left; + TNode *Right; +}; + +struct TCondition { + int Type; + uint32 Text; + TNode *Expression; + int Property; + int Number; +}; + +struct TAction { + int Type; + uint32 Text; + int Number; + TNode *Expression; + TNode *Expression2; + TNode *Expression3; +}; + +struct TBehaviour { + vector Condition; + vector Action; + int Conditions; + int Actions; +}; + +struct TBehaviourDatabase { + vector Behaviour; + int Behaviours; +}; + +struct TNPC { + //TNPC(void); + + // DATA + // ================= + //TNonplayer super_TNonplayer; // IMPLICIT + uint32 Interlocutor; + int Topic; + int Price; + int Amount; + int TypeID; + uint32 Data; + uint32 LastTalk; + vector QueuedPlayers; + vector QueuedAddresses; + int QueueLength; + TBehaviourDatabase *Behaviour; +}; // TMonster // ============================================================================= -#if 0 struct TMonster: TNonplayer { + //TMonster(void); // DATA - int Home; - uint32 Master; - uint32 Target; + //TNonplayer super_TNonplayer; // IMPLICIT + int Home; + uint32 Master; + uint32 Target; }; -#endif // TPlayer // ============================================================================= -struct TPlayerData { - uint32 CharacterID; - pid_t Locked; - int Sticky; - bool Dirty; - int Race; - TOutfit OriginalOutfit; - TOutfit CurrentOutfit; - time_t LastLoginTime; - time_t LastLogoutTime; - int startx; - int starty; - int startz; - int posx; - int posy; - int posz; - int Profession; - int PlayerkillerEnd; - int Actual[25]; - int Maximum[25]; - int Minimum[25]; - int DeltaAct[25]; - int MagicDeltaAct[25]; - int Cycle[25]; - int MaxCycle[25]; - int Count[25]; - int MaxCount[25]; - int AddLevel[25]; - int Experience[25]; - int FactorPercent[25]; - int NextLevel[25]; - int Delta[25]; - uint8 SpellList[256]; - int QuestValues[500]; - int MurderTimestamps[20]; - uint8 *Inventory; - int InventorySize; - uint8 *Depot[9]; - int DepotSize[9]; - uint32 AccountID; - int Sex; - char Name[30]; - uint8 Rights[12]; - char Guild[31]; - char Rank[31]; - char Title[31]; - int Buddies; - uint32 Buddy[100]; - char BuddyName[100][30]; - uint32 EarliestYellRound; - uint32 EarliestTradeChannelRound; - uint32 EarliestSpellTime; - uint32 EarliestMultiuseTime; - uint32 TalkBufferFullTime; - uint32 MutingEndRound; - uint32 Addressees[20]; - uint32 AddresseesTimes[20]; - int NumberOfMutings; -}; - struct TPlayer: TCreature { + //TPlayer(void); + uint8 GetRealProfession(void); uint8 GetEffectiveProfession(void); uint8 GetActiveProfession(void); @@ -592,7 +660,6 @@ struct TPlayer: TCreature { // Creature API // ============================================================================= - #define MAX_RACES 512 // crmain.cc diff --git a/src/crmain.cc b/src/crmain.cc index 31d93fb..d962bf9 100644 --- a/src/crmain.cc +++ b/src/crmain.cc @@ -462,7 +462,7 @@ int TCreature::Damage(TCreature *Attacker, int Damage, int DamageType){ return Damage; } -// Creature +// Creature Management // ============================================================================= bool IsCreaturePlayer(uint32 CreatureID){ return CreatureID < 0x40000000; diff --git a/src/enums.hh b/src/enums.hh index 21194dd..8257677 100644 --- a/src/enums.hh +++ b/src/enums.hh @@ -484,6 +484,16 @@ enum SpellImpactType: int { IMPACT_SUMMON = 7, }; +enum STATE: int { + SLEEPING = 0, + IDLE = 1, + UNDERATTACK = 2, + TALKING = 3, + LEAVING = 4, + ATTACKING = 5, + PANIC = 6, +}; + enum TALK_MODE: int { TALK_SAY = 1, TALK_WHISPER = 2, -- cgit v1.2.3