20 #ifndef __PSCHARACTER_H__ 21 #define __PSCHARACTER_H__ 25 #include <csutil/sysfunc.h> 38 #include "../icachedobject.h" 39 #include "../playergroup.h" 104 #define PSCHARACTER_BULK_COUNT INVENTORY_BULK_COUNT 105 #define PSCHARACTER_BANK_BULK_COUNT 16 184 #define PSCHARACTER_EQUIPMENTFLAG_AUTOATTACK 0x00000001 185 #define PSCHARACTER_EQUIPMENTFLAG_SINGLEATTACK 0x00000002 187 #define PSCHARACTER_EQUIPMENTFLAG_ATTACKIFEMPTY 0x00000004 211 characterId = charID;
220 bool AddBuddy(PID buddyID, csString &name);
227 void RemoveBuddy(PID buddyID);
235 bool IsBuddy(PID buddyID);
242 void AddBuddyOf(PID buddyID);
249 void RemoveBuddyOf(PID buddyID);
271 csArray<psBuddyManager::Buddy> buddyList;
272 csArray<PID> buddyOfList;
290 virtual void OnChange();
365 void Train(
int yIncrease);
397 bool Practice(
unsigned int amount,
unsigned int &actuallyAdded,
psCharacter* user);
437 void SetSkillPractice(
PSSKILL which,
int z_value);
448 void SetSkillKnowledge(
PSSKILL which,
int y_value);
460 void SetSkillRank(
PSSKILL which,
unsigned int rank,
bool recalculatestats =
true);
485 void CheckDoRank(
PSSKILL skill);
497 void Train(
PSSKILL skill,
int yIncrease);
514 unsigned int GetSkillKnowledge(
PSSKILL skill);
522 unsigned int GetSkillPractice(
PSSKILL skill);
534 bool AddToSkillPractice(
PSSKILL skill,
unsigned int val,
unsigned int &added);
539 int AddSkillPractice(
psSkillInfo* skill,
unsigned int val);
544 int AddSkillPractice(
PSSKILL skill,
unsigned int val);
552 unsigned int GetBestSkillSlot(
bool withBuff);
557 #define ALWAYS_IMPERVIOUS 1 558 #define TEMPORARILY_IMPERVIOUS 2 597 charVariable(csString name, csString value) : name(name), value(value), dirty(false)
599 intBuff.
SetBase(strtoul(value.GetDataSafe(),NULL,0));
601 charVariable(csString name, csString value,
bool dirty) : name(name), value(value), dirty(dirty)
603 intBuff.
SetBase(strtoul(value.GetDataSafe(),NULL,0));
640 virtual void OnChange();
671 bool Load(iResultRow &row);
702 void SetMoney(
psItem* &moneyObject);
712 void SetMoney(
psItemStats* MoneyObject,
int amount);
714 void AdjustMoney(
psMoney m,
bool bank);
716 void SaveMoney(
bool bank);
724 return (helpEventFlags & (1 << which))==0;
730 helpEventFlags |= (1 << which);
774 return joinNotifications;
779 joinNotifications = notifications;
815 bool QuickLoad(iResultRow &row,
bool noInventory);
817 void LoadIntroductions();
819 void LoadActiveSpells();
821 bool Store(
const char* location,
const char* slot,
psItem* what);
834 return npcMasterId ? npcMasterId : pid;
848 SetFullName(newName,lastname.GetData());
852 SetFullName(name.GetData(),newLastName);
854 void SetFullName(
const char* newFirstName,
const char* newLastName);
857 this->oldlastname = oldLastName;
862 return name.GetData();
866 return lastname.GetData();
870 return fullName.GetData();
874 return oldlastname.GetData();
879 bool Knows(PID charid);
882 return (c ? Knows(c->
GetPID()) :
false);
891 return characterType;
900 return characterTypeName[characterType];
906 void SetLastLoginTime();
911 csString GetLastLoginTime()
const;
916 void SetPetElapsedTime(
double elapsedTime);
921 double GetPetElapsedTime()
const;
926 void SetSpouseName(
const char* name);
935 return spouseName.GetData();
985 float GetScaleValue();
992 bool AddExploredArea(PID explored);
999 bool HasExploredArea(PID explored);
1008 lootCategoryId = id;
1012 return lootCategoryId;
1024 psItem* RemoveLootItem(
int id);
1035 csArray<psItem*> RemoveLootItems(csArray<csString> categories = csArray<csString>());
1042 void AddLootItem(
psItem* item);
1047 size_t GetLootItems(
psLootMessage &msg, EID entity,
int cnum);
1058 return lastResponse;
1062 lastResponse=response;
1064 bool CheckResponsePrerequisite(
NpcResponse* resp);
1066 void CombatDrain(
int);
1074 bool HasVariableDefined(
const csString &name);
1082 csString GetVariableValue(
const csString &name);
1092 Buffable<int> &GetBuffableVariable(
const csString &name,
const csString &value =
"0");
1100 void SetVariable(
const csString &name,
const csString &value);
1108 void SetVariable(
const csString &name);
1114 void UnSetVariable(
const csString &name);
1119 csHash<charVariable, csString>::ConstGlobalIterator GetVariables()
const;
1121 unsigned int GetExperiencePoints();
1122 void SetExperiencePoints(
unsigned int W);
1123 unsigned int AddExperiencePoints(
unsigned int W);
1124 unsigned int AddExperiencePointsNotify(
unsigned int W);
1125 unsigned int CalculateAddExperience(
PSSKILL skill,
unsigned int awardedPoints,
float modifier = 1);
1126 unsigned int GetProgressionPoints();
1127 void SetProgressionPoints(
unsigned int X,
bool save);
1128 void UseProgressionPoints(
unsigned int X);
1131 int GetMaxAllowedRealm(
PSSKILL skill);
1134 return skills.GetSkillRank(skill);
1140 if(!attacker) suicides++;
1170 void DropItem(
psItem* &item, csVector3 pos = 0,
const csVector3 &rot = csVector3(0),
bool guarded =
true,
bool transient =
true,
bool inplace =
false);
1174 float GetStamina(
bool pys);
1176 void SetHitPoints(
float v);
1177 void SetMana(
float v);
1178 void SetStamina(
float v,
bool pys);
1180 void AdjustHitPoints(
float adjust);
1181 void AdjustMana(
float adjust);
1182 void AdjustStamina(
float adjust,
bool pys);
1194 void SetStaminaRegenerationNone(
bool physical =
true,
bool mental =
true);
1195 void SetStaminaRegenerationWalk(
bool physical =
true,
bool mental =
true);
1196 void SetStaminaRegenerationSitting();
1197 void SetStaminaRegenerationStill(
bool physical =
true,
bool mental =
true);
1198 void SetStaminaRegenerationWork(
int skill);
1203 void CalculateMaxStamina();
1208 unsigned int GetStatsDirtyFlags()
const;
1213 void SetAllStatsDirty();
1218 void ClearStatsDirtyFlags(
unsigned int dirtyFlags);
1222 return helmGroup.GetData();
1226 return BracerGroup.GetData();
1230 return BeltGroup.GetData();
1234 return CloakGroup.GetData();
1243 BracerGroup = Group;
1255 void AssignGMEvent(
int id,
bool playerIsGM);
1256 void CompleteGMEvent(
bool playerIsGM);
1257 void RemoveGMEvent(
int id,
bool playerIsGM=
false);
1268 bool UpdateFaction(
Faction* faction,
int delta);
1273 bool CheckFaction(
Faction* faction,
int value);
1286 void EndSong(csTicks bonusTime);
1293 return songExecutionTime;
1313 void RecalculateStats();
1342 return familiarsId.GetSize() >
id ? familiarsId.Get(
id) : 0;
1344 void SetFamiliarID(PID v);
1347 return familiarsId.GetSize();
1351 return canSummonFamiliar.Current() > 0;
1355 return canSummonFamiliar;
1359 return animalAffinity.GetDataSafe();
1379 this->hired = hired;
1382 bool UpdateStatDRData(csTicks now);
1383 bool SendStatDRMessage(uint32_t clientnum, EID eid,
int flags, csRef<PlayerGroup> group = NULL);
1395 void ResetSwings(csTicks timeofattack);
1404 float GetTotalTargetedBlockValue();
1405 float GetTotalUntargetedBlockValue();
1407 float GetDodgeValue();
1411 return attackModifier;
1415 return defenseModifier;
1420 void PracticeWeaponSkills(
unsigned int practice);
1421 void PracticeWeaponSkills(
psItem* weapon,
unsigned int practice);
1426 void GetLocationInWorld(
InstanceID &instance,
psSectorInfo* §orinfo,
float &loc_x,
float &loc_y,
float &loc_z,
float &loc_yrot);
1427 void SetLocationInWorld(
InstanceID instance,
psSectorInfo* sectorinfo,
float loc_x,
float loc_y,
float loc_z,
float loc_yrot);
1428 void SaveLocationInWorld();
1431 void MakeTextureString(csString &textureString);
1434 void MakeEquipmentString(csString &equipmentString);
1437 unsigned int GetCharLevel(
bool physical);
1441 return (merchantInfo != NULL);
1445 return merchantInfo;
1449 return (trainerInfo != NULL);
1461 this->trainer = trainer;
1484 void Train(
PSSKILL skill,
int yIncrease);
1490 void SetSkillRank(
PSSKILL which,
unsigned int rank);
1492 psSpell* GetSpellByName(
const csString &spellName);
1493 psSpell* GetSpellByIdx(
int index);
1506 return tradingStatus;
1510 tradingStatus = trading;
1511 this->merchant = merchant;
1520 bool SetTradingStopped(
bool stopped);
1522 bool ReadyToExchange();
1527 return (csGetTicks() - startTimeThisSession)/1000;
1533 return timeconnected + GetOnlineTimeThisSession();
1539 return timeconnected;
1546 const char* GetDescription();
1552 void SetDescription(
const char* newValue);
1558 const char* GetOOCDescription();
1564 void SetOOCDescription(
const char* newValue);
1570 const char* GetCreationInfo();
1576 void SetCreationInfo(
const char* newValue);
1583 bool GetFactionEventsDescription(csString &factionDescription);
1589 const char* GetLifeDescription();
1595 void SetLifeDescription(
const char* newValue);
1599 double CalcFunction(
MathEnvironment* env,
const char* functionName,
const double* params);
1602 return fullName.GetData();
1617 imperviousToAttack=newValue;
1621 return imperviousToAttack;
1624 void CalculateEquipmentModifiers();
1632 return npcSpawnRuleId;
1641 return buddyManager;
1645 return questManager;
1649 void*
operator new(size_t);
1651 void operator delete(
void*);
1688 bool LoadSpells(PID use_id);
1689 bool LoadAdvantages(PID use_id);
1690 bool LoadSkills(PID use_id);
1691 bool LoadTraits(PID use_id);
1692 bool LoadRelationshipInfo(PID pid);
1694 bool LoadMarriageInfo(
Result &result);
1697 bool LoadFactions(PID pid);
1699 void UpdateFactions();
1705 bool LoadVariables(PID pid);
1710 void UpdateVariables();
1712 bool LoadExploration(
Result &exploration);
1713 bool LoadGMEvents();
1813 static const char* characterTypeName[];
1830 void CalculateArmorForSlot(
INVENTORY_SLOT_NUMBER slot,
float &heavy_p,
float &med_p,
float &light_p);
1833 int FindGlyphSlot(
const csArray<glyphSlotInfo> &slots,
psItemStats* glyphType,
int purifyStatus);
1835 csTicks songExecutionTime;
1847 csString BracerGroup;
1859 csString CloakGroup;
virtual void * RecoverObject()
csHash< charVariable, csString > charVariables
Used to store character variables for this character.
PID GetFamiliarID(size_t id)
csTicks startTimeThisSession
void SetGuild(psGuildInfo *g)
Set the active guild for the character.
void SetCharType(unsigned int v)
void SetOldLastName(const char *oldLastName)
int GetLootCategory() const
void KilledBy(psCharacter *attacker)
This class controls loading and saving Characters and Character specific data to and from an iDatabas...
This class handles the details behind a character's inventory system.
Structure for assigned GM Events.
const char * GetBeltGroup()
csArray< psSpell * > spellList
float overrideMaxMana
These values are loaded from base_hp_max,base_mana_max in the db and < should prevent normal HP calcu...
Buffable< int > & GetBuffable()
bool IsMount()
Used to determine if this NPC is a mount.
void Initialize(PID charID)
Setup the buddy manager.
void SetImperviousToAttack(int newValue)
psSectorInfo * loc_sector
csArray< PID > exploredAreas
A bitfield which contains the notifications the player will get if a guild or alliance member login/l...
virtual ~OverridableRace()
Destructor.
Represents a skill an NPC, player or pet can learn.
csArray< Skill > skills
Array to store all the skills.
psSkillInfo * info
Database information about the skill.
void SetAllianceNotifications(bool enabled)
Sets if the client should receive notifications about alliance members logging in.
SkillStatBuffable SkillRank
csArray< psSpell * > & GetSpellList()
A specific MathEnvironment to be used in a MathScript.
csArray< psItem * > lootPending
Array of items waiting to be looted.
bool IsGettingAllianceNotifications()
Returns if the client should receive notifications about alliance members logging in...
A MathScript is a mini-program to run.
Buffable< int > & GetCanSummonFamiliar()
Buffable< int > canSummonFamiliar
int runningEventID
Player Running GM Event.
OverridableRace race
Holds the race of this character and it's overriden values.
st_location GetSpawnLocation()
Get the character spawn location.
void SetIsMarried(bool married)
void SetCharacter(psCharacter *psChar)
Sets which character owns this overridableRace.
gemActor * actor
The current game entity object this characater is attached to.
unsigned int timeconnected
Total number of seconds online. Updated at logoff.
GMEventsAssignment assignedEvents
csString progressionScriptText
flat string loaded from the DB.
const char * GetBracerGroup()
This class holds all information for one quest with its reference to parent quest, list of steps, lockoutime, sub quests, ...
bool dirty
Says if the variable was modified.
INVENTORY_SLOT_NUMBER
Holds a list of the possible socket identifiers that items can be attached to.
bool IsPlayer()
Used to determine if this character is a player.
A special form of buffable that is clamped to always return a positive number.
csArray< int > completedEventIDs
completed GM events
unsigned short z
Practice value.
A queue to hold attacks in order of execution.
csArray< psBuddyManager::Buddy > GetBuddyList()
int runningEventIDAsGM
GM controlling running GM Event.
The structure of 1 queue entry (pointer to a message)
Multiplier & AttackModifier()
This class is a set of faction structures.
unsigned int GetSuicides() const
Message sent from server to client if login was valid.
const char * GetHelmGroup()
psBuddyManager buddyManager
SkillRank & GetSkillRank(PSSKILL skill)
int GetKillExperience()
The exp to be handed out when this actor dies.
Multiplier defenseModifier
Defense value is multiplied by this.
csString name
Character name of buddy.
psSkillCache * GetSkillCache()
Returns a pointer to the skill cache for this character.
CharacterAttribute(psCharacter *character)
csRef< psAttackQueue > attackQueue
csString value
The value assigned to this variable.
PSCHARACTER_JOINNOTIFICATION
enum containing the notification status (a bitfield)
psTrainerInfo * GetTrainerInfo()
bool isStatue
Says if this npc is a statue.
Defines a level inside a guild.
PID playerId
The PID of the player that is the buddy.
const char * GetCharLastName() const
psCharacter * trainer
The current character that is being trained?
PSTRAIT_LOCATION
Define the player controled base customization that their model can have.
void SetBeltGroup(const char *Group)
Buffables for vitals, which automatically update the dirty flag as necessary.
void SetPID(PID characterID)
Defines a guild member in a guild.
SkillRank rank
Skill rank (buffable)
Defines characteristics of a race associated to an NPC, player or pet.
csSet< PID > acquaintances
Represent a visual feature of character customization like hair style, color of eyes, skin color, ...
void SetAccount(AccountID id)
csString oocdescription
Player OOC description.
void SetLastResponse(int response)
Server side of the character vitals manager.
const char * GetOldLastName() const
virtual void DeleteSelf()
The psSkillCache class implements the skill cache both on the server and on the client.
Any semi-autonomous object, either a player or an NPC.
csTicks GetSongStartTime() const
Gets the starting time of the song that the player is currently playing.
PID pid
Current PID for this characater ( or is it the above entity? )
unsigned short yCostNext
Cost in y points of next level.
void SetNotifications(int notifications)
sets the notification bitfield directly: to be used only by the loader functon
unsigned short yCost
Cost in y points.
csRef< psMerchantInfo > merchantInfo
Character's merchant info.
csArray< PID > familiarsId
A structure that holds the knowledge/practice/rank of each player skill.
Class to manager a characters quest details.
bool IsPet()
Used to determine if this NPC is a pet.
void NPC_SetSpawnRuleID(int v)
void SetTradingStatus(TradingStatus trading, psCharacter *merchant)
Multiplier attackModifier
Attack value is multiplied by this.
int GetLastResponse()
The last_response given by an npc to this player.
psMerchantInfo * GetMerchantInfo()
psCharacterQuestManager questManager
bool IsGettingGuildNotifications()
Returns if the client should receive notifications about guild members logging in.
Sends messages to the client listing the assigned quests for the player.
TradingStatus tradingStatus
See the enum for the various status.
void SetHelmGroup(const char *Group)
int GetImperviousToAttack()
bool dirtyFlag
Flag if this was changed after load from database.
Holds information about the skills a character (usually NPC) can teach.
psGuildInfo * GetGuild()
Return the active guild, if any for this character.
unsigned int helpEventFlags
Bitfield for which help events a character has already encountered.
int npcSpawnRuleId
NPC specific data. Should this go here?
psCharacterInventory & Inventory()
csString lifedescription
Custom life events informations.
st_location GetLocation() const
Get the character location.
void SetName(const char *newName)
PID GetMasterNPCID() const
This is used to char a charVariable.
csString lastLoginTime
String value copied from the database containing the last login time.
psBuddyManager & GetBuddyMgr()
bool IsStorage() const
Check if the character is a storage.
Sends messages to the client listing the available loot on a mob.
This is a wrapper class for result sets which makes syntax for getting at the data easier and also us...
int lootMoney
Amount of money ready to be looted.
unsigned short zCostNext
Cost in Z points of next level.
csArray< PID > GetBuddyOfList()
int lootCategoryId
Id of Loot category to use if this char has extra loot.
void Kills(psCharacter *target)
bool GetIsMarried() const
void SetCloakGroup(const char *Group)
unsigned int GetTimeConnected()
TradingStatus GetTradingStatus()
bool Knows(psCharacter *c)
psCharacterQuestManager & GetQuestMgr()
void SetAnimialAffinity(const char *v)
unsigned int characterType
void CompleteHelpEvent(int which)
Sets a bit field complete for a specified flag from the enum in tutorialmanager.h.
csString name
The name of the variable.
OverridableRace(psRaceInfo *race)
Constructor, wants a.
psCharacter * merchant
The merchant this charcter trade with.
void SetGuildNotifications(bool enabled)
Sets if the client should receive notifications about guild members logging in.
PSCHARACTER_WORKSTATE
This enumeration and structure tracks the players trade skill efforts.
unsigned int GetTotalOnlineTime()
Number of seconds online ever including this session in seconds.
psMoney money
Current cash set on player.
const char * GetAnimalAffinity()
void SetBracerGroup(const char *Group)
void SetHired(bool hired)
unsigned int GetCharType() const
charVariable(csString name, csString value)
psAttackQueue * GetAttackQueue()
Get the attack queue.
unsigned short y
Knowledge Level.
This class holds several possible responses and an action script for the npc to run whenever an appro...
void SetLootCategory(int id)
virtual void ProcessCacheTimeout()
required for iCachedObject but not used here
unsigned int GetKills() const
int lastResponse
Last response of an NPC to this character (not saved)
This huge class stores all the properties of any object a player can have in the game.
charVariable(csString name, csString value, bool dirty)
This class holds the master list of all trade processes possible in the game.
csRef< psTrainerInfo > trainerInfo
Character's trainer information.
void SetKillExperience(int newValue)
csString description
Player description.
psCharacter * GetTrainer()
csArray< int > completedEventIDsAsGM
completed GM events as the GM.
csString creationinfo
Creation manager informations.
int GetNotifications()
gets the notification bitfield directly: to be used only by the save functon
FactionSet * GetFactions()
const char * GetCharFullName() const
Buffable< int > intBuff
A buffable interpretation of the variable.
AccountID GetAccount() const
Contains information about sectors from the server perspective.
bool NeedsHelpEvent(int which)
Checks the bit field for a bit flag from the enum in TutorialManager.h.
psCharacterInventory inventory
Character's inventory handler.
Base class for several other classes which hold character attributes of different sorts...
bool IsBanker() const
Check if the character is a banker.
This class retrieves the merchant categories for an NPC.
double lastSavedPetElapsedTime
Store time for when the petElapsedTime was last saved to db.
unsigned int GetDeaths() const
Multiplier & DefenseModifier()
const char * GetCharName() const
void Initialize(psCharacter *c)
psCharacter * GetMerchant()
const char * GetSpouseName() const
Gets Spouse Name of a character.
const char * GetCharTypeName()
AccountID GetAccountId()
Get the account ID that this character is attached to.
void SetLastName(const char *newLastName)
unsigned int GetOnlineTimeThisSession()
Number of seconds online this session in seconds.
const char * GetCloakGroup()
bool CanTrain()
Checks to see if this skill can be trained any more at the current rank.
void SetTrainer(psCharacter *trainer)
psMoney bankMoney
Money stored in the players bank account.
AccountID accountid
Account ID that this characater is attached to.
This class embodies item instances in the game.
unsigned short zCost
Cost in Z points.
csString NormalizeCharacterName(const csString &name)
"Normalizes" name of character i.e.
psCharacter * character
Pointer to the psCharacter owning this overridable class.
void AddLootMoney(int money)