Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

char_history and fun player stat tracking #267

Merged
merged 4 commits into from
Jun 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 68 additions & 50 deletions scripts/globals/status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2821,60 +2821,78 @@ xi.itemCheck =
-----------------------------------
xi.emote =
{
POINT = 0,
BOW = 1,
SALUTE = 2,
KNEEL = 3,
LAUGH = 4,
CRY = 5,
NO = 6,
YES = 7,
WAVE = 8,
GOODBYE = 9,
WELCOME = 10,
JOY = 11,
CHEER = 12,
CLAP = 13,
PRAISE = 14,
SMILE = 15,
POKE = 16,
SLAP = 17,
STAGGER = 18,
SIGH = 19,
COMFORT = 20,
SURPRISED = 21,
AMAZED = 22,
STARE = 23,
BLUSH = 24,
ANGRY = 25,
DISGUSTED = 26,
MUTED = 27,
DOZE = 28,
PANIC = 29,
GRIN = 30,
DANCE = 31,
THINK = 32,
FUME = 33,
DOUBT = 34,
SULK = 35,
PSYCH = 36,
HUH = 37,
SHOCKED = 38,
LOGGING = 40, -- Only used for HELM
POINT = 0,
BOW = 1,
SALUTE = 2,
KNEEL = 3,
LAUGH = 4,
CRY = 5,
NO = 6,
YES = 7,
WAVE = 8,
GOODBYE = 9,
WELCOME = 10,
JOY = 11,
CHEER = 12,
CLAP = 13,
PRAISE = 14,
SMILE = 15,
POKE = 16,
SLAP = 17,
STAGGER = 18,
SIGH = 19,
COMFORT = 20,
SURPRISED = 21,
AMAZED = 22,
STARE = 23,
BLUSH = 24,
ANGRY = 25,
DISGUSTED = 26,
MUTED = 27,
DOZE = 28,
PANIC = 29,
GRIN = 30,
DANCE = 31,
THINK = 32,
FUME = 33,
DOUBT = 34,
SULK = 35,
PSYCH = 36,
HUH = 37,
SHOCKED = 38,
LOGGING = 40, -- Only used for HELM
EXCAVATION = 41, -- Only used for HELM
HARVESTING = 42, -- Only used for HELM
HURRAY = 43,
TOSS = 44,
DANCE1 = 65,
DANCE2 = 66,
DANCE3 = 67,
DANCE4 = 68,
JOB = 74
HURRAY = 43,
TOSS = 44,
DANCE1 = 65,
DANCE2 = 66,
DANCE3 = 67,
DANCE4 = 68,
JOB = 74,
}

xi.emoteMode =
{
ALL = 0,
TEXT = 1,
MOTION = 2
ALL = 0,
TEXT = 1,
MOTION = 2,
}

xi.history =
{
ENEMIES_DEFEATED = 0,
TIMES_KNOCKED_OUT = 1,
MH_ENTRANCES = 2,
JOINED_PARTIES = 3,
JOINED_ALLIANCES = 4,
SPELLS_CAST = 5,
ABILITIES_USED = 6,
WS_USED = 7,
ITEMS_USED = 8,
CHATS_SENT = 9,
NPC_INTERACTIONS = 10,
BATTLES_FOUGHT = 11,
GM_CALLS = 12,
DISTANCE_TRAVELLED = 13,
}
23 changes: 23 additions & 0 deletions sql/char_history.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--
-- Table structure for table `char_history`
--

DROP TABLE IF EXISTS `char_history`;
CREATE TABLE `char_history` (
`charid` int(10) unsigned NOT NULL,
`enemies_defeated` int(10) unsigned NOT NULL DEFAULT '0',
`times_knocked_out` int(10) unsigned NOT NULL DEFAULT '0',
`mh_entrances` int(10) unsigned NOT NULL DEFAULT '0',
`joined_parties` int(10) unsigned NOT NULL DEFAULT '0',
`joined_alliances` int(10) unsigned NOT NULL DEFAULT '0',
`spells_cast` int(10) unsigned NOT NULL DEFAULT '0',
`abilities_used` int(10) unsigned NOT NULL DEFAULT '0',
`ws_used` int(10) unsigned NOT NULL DEFAULT '0',
`items_used` int(10) unsigned NOT NULL DEFAULT '0',
`chats_sent` int(10) unsigned NOT NULL DEFAULT '0',
`npc_interactions` int(10) unsigned NOT NULL DEFAULT '0',
`battles_fought` int(10) unsigned NOT NULL DEFAULT '0',
`gm_calls` int(10) unsigned NOT NULL DEFAULT '0',
`distance_travelled` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`charid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6 changes: 4 additions & 2 deletions sql/triggers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ BEGIN
DELETE FROM `char_effects` WHERE `charid` = OLD.charid;
DELETE FROM `char_equip` WHERE `charid` = OLD.charid;
DELETE FROM `char_exp` WHERE `charid` = OLD.charid;
DELETE FROM `char_history` WHERE `charid` = OLD.charid;
DELETE FROM `char_inventory` WHERE `charid` = OLD.charid;
DELETE FROM `char_jobs` WHERE `charid` = OLD.charid;
DELETE FROM `char_job_points` WHERE `charid` = OLD.charid;
Expand Down Expand Up @@ -78,11 +79,12 @@ CREATE TRIGGER char_insert
BEGIN
INSERT INTO `char_equip` SET `charid` = NEW.charid;
INSERT INTO `char_exp` SET `charid` = NEW.charid;
INSERT INTO `char_history` SET `charid` = NEW.charid;
INSERT INTO `char_inventory` SET `charid` = NEW.charid;
INSERT INTO `char_jobs` SET `charid` = NEW.charid;
INSERT INTO `char_pet` SET `charid` = NEW.charid;
INSERT INTO `char_points` SET `charid` = NEW.charid;
INSERT INTO `char_unlocks` SET `charid` = NEW.charid;
INSERT INTO `char_profile` SET `charid` = NEW.charid;
INSERT INTO `char_storage` SET `charid` = NEW.charid;
INSERT INTO `char_inventory` SET `charid` = NEW.charid;
INSERT INTO `char_unlocks` SET `charid` = NEW.charid;
END $$
5 changes: 5 additions & 0 deletions src/map/ai/states/ability_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ bool CAbilityState::Update(time_point tick)

if (IsCompleted() && tick > GetEntryTime() + m_castTime + m_PAbility->getAnimationTime())
{
if (m_PEntity->objtype == TYPE_PC)
{
CCharEntity* PChar = static_cast<CCharEntity*>(m_PEntity);
PChar->m_charHistory.abilitiesUsed++;
}
m_PEntity->PAI->EventHandler.triggerListener("ABILITY_STATE_EXIT", CLuaBaseEntity(m_PEntity), CLuaAbility(m_PAbility.get()));
return true;
}
Expand Down
5 changes: 5 additions & 0 deletions src/map/ai/states/item_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ bool CItemState::Update(time_point tick)
}
else if (IsCompleted() && tick > GetEntryTime() + m_castTime + m_animationTime)
{
if (m_PEntity->objtype == TYPE_PC)
{
CCharEntity* PChar = static_cast<CCharEntity*>(m_PEntity);
PChar->m_charHistory.itemsUsed++;
}
m_PEntity->PAI->EventHandler.triggerListener("ITEM_STATE_EXIT", CLuaBaseEntity(m_PEntity), CLuaItem(m_PItem));
return true;
}
Expand Down
5 changes: 5 additions & 0 deletions src/map/ai/states/magic_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ bool CMagicState::Update(time_point tick)
}
else if (IsCompleted() && tick > GetEntryTime() + m_castTime + std::chrono::milliseconds(m_PSpell->getAnimationTime()))
{
if (m_PEntity->objtype == TYPE_PC)
{
CCharEntity* PChar = static_cast<CCharEntity*>(m_PEntity);
PChar->m_charHistory.spellsCast++;
}
m_PEntity->PAI->EventHandler.triggerListener("MAGIC_STATE_EXIT", CLuaBaseEntity(m_PEntity), CLuaSpell(m_PSpell.get()));
return true;
}
Expand Down
5 changes: 5 additions & 0 deletions src/map/ai/states/weaponskill_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ bool CWeaponSkillState::Update(time_point tick)
}
else if (tick > m_finishTime)
{
if (m_PEntity->objtype == TYPE_PC)
{
CCharEntity* PChar = static_cast<CCharEntity*>(m_PEntity);
PChar->m_charHistory.wsUsed++;
}
m_PEntity->PAI->EventHandler.triggerListener("WEAPONSKILL_STATE_EXIT", CLuaBaseEntity(m_PEntity), m_PSkill->getID());
return true;
}
Expand Down
6 changes: 4 additions & 2 deletions src/map/alliance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ void CAlliance::addParty(CParty* party)

for (uint8 i = 0; i < party->members.size(); ++i)
{
party->ReloadTreasurePool((CCharEntity*)party->members.at(i));
charutils::SaveCharStats((CCharEntity*)party->members.at(i));
CCharEntity* PChar = static_cast<CCharEntity*>(party->members.at(i));
party->ReloadTreasurePool(PChar);
charutils::SaveCharStats(PChar);
PChar->m_charHistory.joinedAlliances++;
}
Sql_Query(SqlHandle, "UPDATE accounts_parties SET allianceid = %u, partyflag = partyflag | %d WHERE partyid = %u;", m_AllianceID, newparty,
party->GetPartyID());
Expand Down
3 changes: 3 additions & 0 deletions src/map/entities/charentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ void CCharEntity::OnEngage(CAttackState& state)
{
CBattleEntity::OnEngage(state);
PLatentEffectContainer->CheckLatentsTargetChange();
this->m_charHistory.battlesFought++;
}

void CCharEntity::OnDisengage(CAttackState& state)
Expand Down Expand Up @@ -1766,6 +1767,8 @@ void CCharEntity::Die(duration _duration)
m_hasRaise = 1;
}

this->m_charHistory.timesKnockedOut++;

CBattleEntity::Die();
}

Expand Down
40 changes: 40 additions & 0 deletions src/map/entities/charentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,42 @@ struct GearSetMod_t
uint16 modValue;
};

enum CHAR_HISTORY
{
ENEMIES_DEFEATED = 0,
TIMES_KNOCKED_OUT,
MH_ENTRANCES,
JOINED_PARTIES,
JOINED_ALLIANCES,
SPELLS_CAST,
ABILITIES_USED,
WS_USED,
ITEMS_USED,
CHATS_SENT,
NPC_INTERACTIONS,
BATTLES_FOUGHT,
GM_CALLS,
DISTANCE_TRAVELLED,
};

struct CharHistory_t
{
uint32 enemiesDefeated = 0;
uint32 timesKnockedOut = 0;
uint32 mhEntrances = 0;
uint32 joinedParties = 0;
uint32 joinedAlliances = 0;
uint32 spellsCast = 0;
uint32 abilitiesUsed = 0;
uint32 wsUsed = 0;
uint32 itemsUsed = 0;
uint32 chatsSent = 0;
uint32 npcInteractions = 0;
uint32 battlesFought = 0;
uint32 gmCalls = 0;
uint32 distanceTravelled = 0;
};

enum CHAR_SUBSTATE
{
SUBSTATE_NONE = 0,
Expand Down Expand Up @@ -330,6 +366,8 @@ class CCharEntity : public CBattleEntity
uint8 m_hasAutoTarget; // возможность использования AutoTarget функции
position_t m_StartActionPos; // позиция начала действия (использование предмета, начало стрельбы, позиция tractor)

location_t m_previousLocation;

uint32 m_PlayTime;
uint32 m_SaveTime;

Expand All @@ -343,6 +381,8 @@ class CCharEntity : public CBattleEntity
uint32 m_moghouseID;
uint16 m_moghancementID;

CharHistory_t m_charHistory;

int8 getShieldSize();

bool getWeaponSkillKill() const;
Expand Down
1 change: 1 addition & 0 deletions src/map/entities/mobentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ void CMobEntity::DistributeRewards()
{
PChar->setWeaponSkillKill(false);
StatusEffectContainer->KillAllStatusEffect();
PChar->m_charHistory.enemiesDefeated++;

// NOTE: this is called for all alliance / party members!
luautils::OnMobDeath(this, PChar);
Expand Down
Loading