2019-07-07 20:56:15 +00:00
# include <StdAfx.h>
2018-03-29 17:01:57 -04:00
# include "EmoteManager.h"
# include "WeenieObject.h"
# include "ChatMsgs.h"
# include "World.h"
# include "WeenieFactory.h"
# include "Player.h"
# include "SpellcastingManager.h"
# include "Config.h"
# include "GameEventManager.h"
# include "MonsterAI.h"
2018-07-12 14:41:21 -07:00
EmoteManager : : EmoteManager ( CWeenieObject * weenie )
2018-03-29 17:01:57 -04:00
{
2018-05-29 23:47:16 +01:00
_weenie = weenie ;
2018-03-29 17:01:57 -04:00
}
2019-07-07 20:56:15 +00:00
bool EmoteManager : : ChanceExecuteEmoteSet ( EmoteCategory category , std : : string msg , uint32_t target_id )
2018-03-29 17:01:57 -04:00
{
2018-07-12 14:41:21 -07:00
PackableList < EmoteSet > * emoteCategory = _weenie - > m_Qualities . _emote_table - > _emote_table . lookup ( category ) ;
2018-03-29 17:01:57 -04:00
if ( ! emoteCategory )
return false ;
float diceRoll = Random : : RollDice ( 0.0 , 1.0 ) ;
for ( auto & entry : * emoteCategory )
{
2019-09-03 14:18:02 +00:00
if ( ! stricmp ( entry . quest . c_str ( ) , msg . c_str ( ) ) & & diceRoll < = entry . probability )
2018-03-29 17:01:57 -04:00
{
ExecuteEmoteSet ( entry , target_id ) ;
return true ;
}
}
return false ;
}
2019-07-07 20:56:15 +00:00
bool EmoteManager : : ChanceExecuteEmoteSet ( EmoteCategory category , uint32_t target_id )
2018-03-29 17:01:57 -04:00
{
2018-07-12 14:41:21 -07:00
PackableList < EmoteSet > * emoteCategory = _weenie - > m_Qualities . _emote_table - > _emote_table . lookup ( category ) ;
2018-03-29 17:01:57 -04:00
if ( ! emoteCategory )
return false ;
float diceRoll = Random : : RollDice ( 0.0 , 1.0 ) ;
for ( auto & entry : * emoteCategory )
{
2019-09-03 14:18:02 +00:00
if ( diceRoll < = entry . probability )
2018-03-29 17:01:57 -04:00
{
ExecuteEmoteSet ( entry , target_id ) ;
return true ;
}
}
return false ;
}
2019-07-07 20:56:15 +00:00
void EmoteManager : : ExecuteEmoteSet ( const EmoteSet & emoteSet , uint32_t target_id )
2018-03-29 17:01:57 -04:00
{
if ( _emoteEndTime < Timer : : cur_time )
_emoteEndTime = Timer : : cur_time ;
double totalEmoteSetTime = 0.0 ;
for ( auto & emote : emoteSet . emotes )
{
totalEmoteSetTime + = emote . delay ;
QueuedEmote qe ;
qe . _data = emote ;
qe . _target_id = target_id ;
qe . _executeTime = Timer : : cur_time + totalEmoteSetTime ;
_emoteQueue . push_back ( qe ) ;
}
}
2019-07-07 20:56:15 +00:00
std : : string EmoteManager : : ReplaceEmoteText ( const std : : string & text , uint32_t target_id , uint32_t source_id )
2018-03-29 17:01:57 -04:00
{
std : : string result = text ;
if ( result . find ( " %s " ) ! = std : : string : : npos )
{
std : : string targetName ;
if ( ! g_pWorld - > FindObjectName ( target_id , targetName ) )
return " " ; // Couldn't resolve name, don't display this message.
while ( ReplaceString ( result , " %s " , targetName ) ) ;
}
if ( result . find ( " %tn " ) ! = std : : string : : npos )
{
std : : string targetName ;
if ( ! g_pWorld - > FindObjectName ( target_id , targetName ) )
return " " ; // Couldn't resolve name, don't display this message.
while ( ReplaceString ( result , " %tn " , targetName ) ) ;
}
if ( result . find ( " %n " ) ! = std : : string : : npos )
{
std : : string sourceName ;
if ( ! g_pWorld - > FindObjectName ( source_id , sourceName ) )
return " " ; // Couldn't resolve name, don't display this message.
while ( ReplaceString ( result , " %n " , sourceName ) ) ;
}
if ( result . find ( " %mn " ) ! = std : : string : : npos )
{
std : : string sourceName ;
if ( ! g_pWorld - > FindObjectName ( source_id , sourceName ) )
return " " ; // Couldn't resolve name, don't display this message.
while ( ReplaceString ( result , " %mn " , sourceName ) ) ;
}
2018-10-05 02:46:41 +00:00
if ( result . find ( " %CDtime " ) ! = std : : string : : npos | | result . find ( " %tqt " ) ! = std : : string : : npos )
2018-03-29 17:01:57 -04:00
{
2018-09-01 04:22:24 +00:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
2018-10-05 02:46:41 +00:00
2018-10-04 22:25:06 -05:00
if ( ! target )
return " " ; // Couldn't find target, don't display this message.
2018-10-05 02:46:41 +00:00
std : : string questString = target - > Ktref ( result . c_str ( ) ) ; //trims the "@TEXTSUFFIX" off of the quest name and returns the questflag to validate the quest timer against.
2018-09-01 04:22:24 +00:00
if ( target - > InqQuest ( questString . c_str ( ) ) )
{
int timeTilOkay = target - > InqTimeUntilOkayToComplete ( questString . c_str ( ) ) ;
if ( timeTilOkay > 0 )
{
2018-10-05 02:46:41 +00:00
std : : string cdTime = TimeToString ( timeTilOkay ) ; //Converts time to string.
if ( result . find ( " %tqt " ) ! = std : : string : : npos )
{
result = " You must wait " + cdTime + " to complete this quest again. " ; //standard uncustomized msg returned when using wild card %tqt somewhere in the string. Should follow format "QuestStampToCheck@%tqt"
}
else
2018-11-29 16:52:15 -05:00
{
2018-10-05 02:46:41 +00:00
std : : size_t prefixPos = result . find ( " @ " ) + 1 ;
std : : string questText = result . substr ( prefixPos ) ; //Trims queststamp prefix from message string.
while ( ReplaceString ( questText , " %CDtime " , cdTime ) ) ; //Should follow format "QuestStampToCheck@Your message %CDtime more of your message." NOTE: Text message portion of string can be any sequence but must contain at least one instance of %CDtime.
result = questText ;
}
2018-09-01 04:22:24 +00:00
}
2018-09-05 11:21:52 -04:00
else
{
2018-10-05 02:46:41 +00:00
return " " ; //Quest timer has expired so return blank cooldown message OR no timer has been tracked in quests.json! Could set this to return a quest cooldown has expired message in the future.
2018-09-05 11:21:52 -04:00
}
2018-09-01 04:22:24 +00:00
}
2018-03-29 17:01:57 -04:00
}
return result ;
}
2018-07-22 00:24:45 +00:00
2019-07-07 20:56:15 +00:00
void EmoteManager : : ExecuteEmote ( const Emote & emote , uint32_t target_id )
2018-03-29 17:01:57 -04:00
{
2018-08-22 21:05:31 -07:00
_weenie - > m_Qualities . SetBool ( EXECUTING_EMOTE , true ) ;
2018-03-29 17:01:57 -04:00
switch ( emote . type )
{
default :
2018-11-29 16:52:15 -05:00
{
2018-03-29 17:01:57 -04:00
# ifndef PUBLIC_BUILD
2018-11-29 16:52:15 -05:00
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
if ( ! target | | ! target - > IsAdmin ( ) )
break ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
target - > SendText ( csprintf ( " Unhandled emote %s (%u) " , Emote : : EmoteTypeToName ( emote . type ) , emote . type ) , LTT_DEFAULT ) ;
2018-03-29 17:01:57 -04:00
# endif
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case Act_EmoteType :
{
2018-07-12 14:41:21 -07:00
std : : string text = ReplaceEmoteText ( emote . msg , target_id , _weenie - > GetID ( ) ) ;
2018-03-29 17:01:57 -04:00
if ( ! text . empty ( ) )
{
BinaryWriter * textMsg = ServerText ( text . c_str ( ) , LTT_EMOTE ) ;
2018-07-12 14:41:21 -07:00
std : : list < CWeenieObject * > results ;
g_pWorld - > EnumNearbyPlayers ( _weenie - > GetPosition ( ) , 30.0f , & results ) ;
2018-03-29 17:01:57 -04:00
for ( auto target : results )
{
2018-07-12 14:41:21 -07:00
if ( target = = _weenie )
2018-03-29 17:01:57 -04:00
continue ;
target - > SendNetMessage ( textMsg - > GetData ( ) , textMsg - > GetSize ( ) , PRIVATE_MSG , 0 ) ;
}
delete textMsg ;
}
break ;
}
case LocalBroadcast_EmoteType :
2018-11-29 16:52:15 -05:00
{
std : : string text = ReplaceEmoteText ( emote . msg , target_id , _weenie - > GetID ( ) ) ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
if ( ! text . empty ( ) )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
BinaryWriter * textMsg = ServerText ( text . c_str ( ) , LTT_DEFAULT ) ;
g_pWorld - > BroadcastPVS ( _weenie , textMsg - > GetData ( ) , textMsg - > GetSize ( ) , PRIVATE_MSG , 0 , false ) ;
delete textMsg ;
}
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
break ;
}
case WorldBroadcast_EmoteType :
{
std : : string text = ReplaceEmoteText ( emote . msg , target_id , _weenie - > GetID ( ) ) ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
if ( ! text . empty ( ) )
{
BinaryWriter * textMsg = ServerText ( text . c_str ( ) , LTT_DEFAULT ) ;
g_pWorld - > BroadcastGlobal ( textMsg - > GetData ( ) , textMsg - > GetSize ( ) , PRIVATE_MSG , 0 , false ) ;
delete textMsg ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case AdminSpam_EmoteType :
{
2018-07-12 14:41:21 -07:00
std : : string text = ReplaceEmoteText ( emote . msg , target_id , _weenie - > GetID ( ) ) ;
2018-03-29 17:01:57 -04:00
if ( ! text . empty ( ) )
{
BinaryWriter * textMsg = ServerText ( text . c_str ( ) , LTT_ALL_CHANNELS ) ;
g_pWorld - > BroadcastGlobal ( textMsg - > GetData ( ) , textMsg - > GetSize ( ) , PRIVATE_MSG , 0 , false ) ;
delete textMsg ;
}
break ;
}
case Activate_EmoteType :
2018-11-29 16:52:15 -05:00
{
2019-07-07 20:56:15 +00:00
if ( uint32_t activation_target_id = _weenie - > InqIIDQuality ( ACTIVATION_TARGET_IID , 0 ) )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
CWeenieObject * target = g_pWorld - > FindObject ( activation_target_id ) ;
if ( target )
target - > Activate ( target_id ) ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case CastSpellInstant_EmoteType :
2018-11-29 16:52:15 -05:00
{
if ( target_id = = 0 )
target_id = _weenie - > GetID ( ) ;
_weenie - > MakeSpellcastingManager ( ) - > CastSpellInstant ( target_id , emote . spellid ) ;
break ;
}
2018-03-29 17:01:57 -04:00
case CastSpell_EmoteType :
2018-11-29 16:52:15 -05:00
{
if ( target_id = = 0 )
target_id = _weenie - > GetID ( ) ;
_weenie - > MakeSpellcastingManager ( ) - > CreatureBeginCast ( target_id , emote . spellid ) ;
break ;
}
2018-03-29 17:01:57 -04:00
case AwardXP_EmoteType :
2018-11-29 16:52:15 -05:00
{
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
if ( ! target )
break ;
2018-03-29 17:01:57 -04:00
2019-07-07 20:56:15 +00:00
int64_t amount = emote . amount64 ;
2018-03-29 17:01:57 -04:00
2020-04-29 00:15:00 -07:00
amount = ( int64_t ) ( amount * g_pConfig - > GetRewardXPMultiplier ( ) ) ;
2018-03-29 17:01:57 -04:00
2018-12-27 12:46:16 -06:00
// If the amount is negative, we take the xp from the target.
2018-11-29 16:52:15 -05:00
if ( amount < 0 )
2018-12-27 12:46:16 -06:00
{
2019-07-07 20:56:15 +00:00
int64_t available = target - > m_Qualities . GetInt64 ( AVAILABLE_EXPERIENCE_INT64 , 0 ) ;
2018-12-27 12:46:16 -06:00
if ( available - - amount > = 0 )
{
target - > m_Qualities . SetInt64 ( AVAILABLE_EXPERIENCE_INT64 , available - - amount ) ;
target - > NotifyInt64StatUpdated ( AVAILABLE_EXPERIENCE_INT64 ) ;
break ;
}
2019-01-20 12:29:38 -08:00
2018-12-27 12:46:16 -06:00
}
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
target - > GiveSharedXP ( amount , true ) ;
break ;
}
2018-03-29 17:01:57 -04:00
case AwardNoShareXP_EmoteType :
2018-11-29 16:52:15 -05:00
{
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
if ( ! target )
break ;
2018-03-29 17:01:57 -04:00
2019-07-07 20:56:15 +00:00
int64_t amount = emote . amount64 ;
2018-03-29 17:01:57 -04:00
2020-04-29 00:15:00 -07:00
amount = ( int64_t ) ( amount * g_pConfig - > GetRewardXPMultiplier ( ) ) ;
2018-03-29 17:01:57 -04:00
2018-12-27 12:46:16 -06:00
// If the amount is negative, we take the xp from the target.
2018-11-29 16:52:15 -05:00
if ( amount < 0 )
2018-12-27 12:46:16 -06:00
{
2019-07-07 20:56:15 +00:00
int64_t available = target - > m_Qualities . GetInt64 ( AVAILABLE_EXPERIENCE_INT64 , 0 ) ;
2018-03-29 17:01:57 -04:00
2018-12-27 12:46:16 -06:00
if ( available - - amount > = 0 )
{
target - > m_Qualities . SetInt64 ( AVAILABLE_EXPERIENCE_INT64 , available - - amount ) ;
target - > NotifyInt64StatUpdated ( AVAILABLE_EXPERIENCE_INT64 ) ;
break ;
}
}
2019-07-30 02:19:05 +00:00
target - > GiveXP ( amount , ExperienceHandlingType : : QuestXpNoShare , true ) ;
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case AwardSkillXP_EmoteType :
2018-11-29 16:52:15 -05:00
{
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
if ( ! target )
2018-03-29 17:01:57 -04:00
break ;
2018-11-29 16:52:15 -05:00
2018-12-26 02:13:09 -06:00
Skill skill ;
target - > m_Qualities . InqSkill ( ( STypeSkill ) emote . stat , skill ) ;
2019-07-07 20:56:15 +00:00
uint32_t amount = emote . amount ;
2019-01-20 12:29:38 -08:00
2019-07-07 20:56:15 +00:00
//const uint32_t amountNeededForMaxXp = skill.GetXpNeededForMaxXp();
2018-12-28 19:45:39 -06:00
//amount = min(amount, amountNeededForMaxXp);
2018-12-26 02:13:09 -06:00
2018-12-28 19:45:39 -06:00
//if (amount > 0)
2019-01-20 12:29:38 -08:00
target - > GiveSkillXP ( ( STypeSkill ) emote . stat , amount , false ) ;
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case AwardLevelProportionalSkillXP_EmoteType :
{
2018-07-12 14:41:21 -07:00
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
2018-03-29 17:01:57 -04:00
if ( ! target )
break ;
Skill skill ;
target - > m_Qualities . InqSkill ( ( STypeSkill ) emote . stat , skill ) ;
if ( skill . _sac < TRAINED_SKILL_ADVANCEMENT_CLASS )
break ;
int currentLevel = skill . _level_from_pp ;
if ( currentLevel < = 10 )
currentLevel + = 5 - ( currentLevel * 0.4 ) ;
2019-07-07 20:56:15 +00:00
uint64_t xp_to_next_level = ExperienceSystem : : ExperienceToSkillLevel ( TRAINED_SKILL_ADVANCEMENT_CLASS , currentLevel + 1 ) - ExperienceSystem : : ExperienceToSkillLevel ( TRAINED_SKILL_ADVANCEMENT_CLASS , currentLevel ) ;
2018-03-29 17:01:57 -04:00
2019-07-07 20:56:15 +00:00
uint64_t xp_to_give = ( uint64_t ) round ( ( double ) xp_to_next_level * emote . percent ) ;
2018-03-29 17:01:57 -04:00
if ( emote . min > 0 )
2018-08-27 15:47:05 -05:00
xp_to_give = max ( xp_to_give , emote . min64 ) ;
2018-03-29 17:01:57 -04:00
if ( emote . max > 0 )
2018-08-27 15:47:05 -05:00
xp_to_give = min ( xp_to_give , emote . max64 ) ;
2018-03-29 17:01:57 -04:00
2019-07-07 20:56:15 +00:00
//const uint64_t amountNeededForMaxXp = skill.GetXpNeededForMaxXp();
2018-12-28 19:45:39 -06:00
//xp_to_give = min(xp_to_give, amountNeededForMaxXp);
2018-12-26 02:13:09 -06:00
2018-12-28 19:45:39 -06:00
//if (xp_to_give > 0)
2019-01-20 12:29:38 -08:00
target - > GiveSkillXP ( ( STypeSkill ) emote . stat , xp_to_give , false ) ;
2018-03-29 17:01:57 -04:00
break ;
}
case AwardSkillPoints_EmoteType :
2018-11-29 16:52:15 -05:00
{
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
if ( ! target )
2018-03-29 17:01:57 -04:00
break ;
2018-11-29 16:52:15 -05:00
target - > GiveSkillPoints ( ( STypeSkill ) emote . stat , emote . amount ) ;
break ;
}
case AwardTrainingCredits_EmoteType :
{
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
if ( ! target )
2018-03-29 17:01:57 -04:00
break ;
2018-11-29 16:52:15 -05:00
2019-02-02 00:46:49 -08:00
target - > GiveSkillCredit ( emote . amount ) ;
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case AwardLevelProportionalXP_EmoteType :
2018-11-29 16:52:15 -05:00
{
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
if ( ! target )
break ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
int current_level = target - > m_Qualities . GetInt ( LEVEL_INT , 1 ) ;
if ( current_level = = 275 )
2018-03-29 17:01:57 -04:00
{
2019-07-30 02:19:05 +00:00
target - > GiveXP ( emote . max64 , ExperienceHandlingType : : QuestXpNoShare , true ) ;
2018-03-29 17:01:57 -04:00
break ;
}
2018-11-29 16:52:15 -05:00
else
2018-03-29 17:01:57 -04:00
{
2019-07-07 20:56:15 +00:00
uint64_t xp_to_next_level = ExperienceSystem : : ExperienceToRaiseLevel ( current_level , current_level + 1 ) ;
2018-11-29 16:52:15 -05:00
2019-07-07 20:56:15 +00:00
uint64_t xp_to_give = ( uint64_t ) round ( ( double ) xp_to_next_level * emote . percent ) ;
2018-11-29 16:52:15 -05:00
if ( emote . min64 > 0 )
xp_to_give = max ( xp_to_give , emote . min64 ) ;
if ( emote . max64 > 0 )
xp_to_give = min ( xp_to_give , emote . max64 ) ;
2019-07-30 02:19:05 +00:00
target - > GiveXP ( xp_to_give , ExperienceHandlingType : : QuestXpNoShare , true ) ;
2018-03-29 17:01:57 -04:00
break ;
}
2018-11-29 16:52:15 -05:00
}
case Give_EmoteType :
{
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
if ( ! target )
2018-03-29 17:01:57 -04:00
break ;
2018-11-29 16:52:15 -05:00
_weenie - > SimulateGiveObject ( target , emote . cprof . wcid , emote . cprof . stack_size , emote . cprof . palette , emote . cprof . shade , emote . cprof . try_to_bond ) ;
break ;
}
case Motion_EmoteType :
{
_weenie - > DoAutonomousMotion ( OldToNewCommandID ( emote . motion ) ) ;
break ;
}
case ForceMotion_EmoteType :
{
_weenie - > DoForcedMotion ( OldToNewCommandID ( emote . motion ) ) ;
break ;
}
2018-03-29 17:01:57 -04:00
case PhysScript_EmoteType :
{
2018-07-12 14:41:21 -07:00
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
2018-03-29 17:01:57 -04:00
if ( target )
target - > EmitEffect ( emote . pscript , 1.0 ) ;
break ;
}
case Say_EmoteType :
{
2018-07-12 14:41:21 -07:00
std : : string text = ReplaceEmoteText ( emote . msg , target_id , _weenie - > GetID ( ) ) ;
2018-03-29 17:01:57 -04:00
if ( ! text . empty ( ) )
2018-07-12 14:41:21 -07:00
_weenie - > SpeakLocal ( text . c_str ( ) , LTT_EMOTE ) ;
2018-03-29 17:01:57 -04:00
break ;
}
case Sound_EmoteType :
{
2018-07-12 14:41:21 -07:00
_weenie - > EmitSound ( emote . sound , 1.0 ) ;
2018-03-29 17:01:57 -04:00
break ;
}
case Tell_EmoteType :
2018-11-29 16:52:15 -05:00
{
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
if ( target )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
std : : string text = ReplaceEmoteText ( emote . msg , target_id , _weenie - > GetID ( ) ) ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
if ( ! text . empty ( ) )
target - > SendNetMessage ( DirectChat ( text . c_str ( ) , _weenie - > GetName ( ) . c_str ( ) , _weenie - > GetID ( ) , target - > GetID ( ) , LTT_SPEECH_DIRECT ) , PRIVATE_MSG , TRUE ) ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case InflictVitaePenalty_EmoteType :
2018-11-29 16:52:15 -05:00
{
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
if ( target )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
target - > UpdateVitaePool ( 0 ) ;
target - > ReduceVitae ( ( float ) emote . amount / 100.f ) ;
target - > UpdateVitaeEnchantment ( ) ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case TellFellow_EmoteType :
2018-11-29 16:52:15 -05:00
{
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
if ( target )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
std : : string text = ReplaceEmoteText ( emote . msg , target_id , _weenie - > GetID ( ) ) ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
if ( text . empty ( ) )
break ;
2018-03-29 17:01:57 -04:00
2019-09-03 14:18:02 +00:00
fellowship_ptr_t fellow = target - > GetFellowship ( ) ;
2018-11-29 16:52:15 -05:00
if ( ! fellow )
{
target - > SendNetMessage ( DirectChat ( text . c_str ( ) , _weenie - > GetName ( ) . c_str ( ) , _weenie - > GetID ( ) , target - > GetID ( ) , LTT_SPEECH_DIRECT ) , PRIVATE_MSG , TRUE ) ;
}
else
{
for ( auto & entry : fellow - > _fellowship_table )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
if ( CWeenieObject * member = g_pWorld - > FindPlayer ( entry . first ) )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
member - > SendNetMessage ( DirectChat ( text . c_str ( ) , _weenie - > GetName ( ) . c_str ( ) , _weenie - > GetID ( ) , target - > GetID ( ) , LTT_SPEECH_DIRECT ) , PRIVATE_MSG , TRUE ) ;
2018-03-29 17:01:57 -04:00
}
}
}
}
2018-04-24 02:24:54 -05:00
2018-11-29 16:52:15 -05:00
break ;
}
2018-04-24 02:24:54 -05:00
case LockFellow_EmoteType :
{
2018-07-12 14:41:21 -07:00
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
2018-04-24 02:24:54 -05:00
if ( target )
{
2019-09-03 14:18:02 +00:00
fellowship_ptr_t fellow = target - > GetFellowship ( ) ;
2018-04-24 02:24:54 -05:00
if ( fellow )
fellow - > _locked = true ;
}
break ;
}
2018-03-29 17:01:57 -04:00
case TextDirect_EmoteType :
2018-11-29 16:52:15 -05:00
{
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
if ( target )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
std : : string text = ReplaceEmoteText ( emote . msg , target_id , _weenie - > GetID ( ) ) ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
if ( ! text . empty ( ) )
target - > SendNetMessage ( ServerText ( text . c_str ( ) , LTT_DEFAULT ) , PRIVATE_MSG , TRUE ) ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case DirectBroadcast_EmoteType :
2018-11-29 16:52:15 -05:00
{
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
if ( target )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
std : : string text = ReplaceEmoteText ( emote . msg , target_id , _weenie - > GetID ( ) ) ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
if ( ! text . empty ( ) )
target - > SendNetMessage ( ServerText ( text . c_str ( ) , LTT_DEFAULT ) , PRIVATE_MSG , TRUE ) ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case BLog_EmoteType :
{
2018-07-12 14:41:21 -07:00
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
2018-03-29 17:01:57 -04:00
if ( target )
{
2018-07-12 14:41:21 -07:00
std : : string text = ReplaceEmoteText ( emote . msg , target_id , _weenie - > GetID ( ) ) ;
2018-03-29 17:01:57 -04:00
if ( ! text . empty ( ) )
target - > SendNetMessage ( ServerText ( text . c_str ( ) , LTT_COMBAT ) , PRIVATE_MSG , TRUE ) ;
}
break ;
}
case FellowBroadcast_EmoteType :
2018-11-29 16:52:15 -05:00
{
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
if ( target )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
std : : string text = ReplaceEmoteText ( emote . msg , target_id , _weenie - > GetID ( ) ) ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
if ( text . empty ( ) )
break ;
2018-03-29 17:01:57 -04:00
2019-09-03 14:18:02 +00:00
fellowship_ptr_t fellow = target - > GetFellowship ( ) ;
2018-11-29 16:52:15 -05:00
if ( ! fellow )
{
target - > SendNetMessage ( ServerText ( text . c_str ( ) , LTT_DEFAULT ) , PRIVATE_MSG , TRUE ) ;
}
else
{
for ( auto & entry : fellow - > _fellowship_table )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
if ( CWeenieObject * member = g_pWorld - > FindPlayer ( entry . first ) )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
member - > SendNetMessage ( ServerText ( text . c_str ( ) , LTT_DEFAULT ) , PRIVATE_MSG , TRUE ) ;
2018-03-29 17:01:57 -04:00
}
}
}
}
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case TurnToTarget_EmoteType :
2018-11-29 16:52:15 -05:00
{
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
2018-03-29 17:01:57 -04:00
{
MovementParameters params ;
2018-11-29 16:52:15 -05:00
_weenie - > TurnToObject ( target_id , & params ) ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
break ;
}
case Turn_EmoteType :
{
MovementParameters params ;
params . desired_heading = emote . frame . get_heading ( ) ;
params . speed = 1.0f ;
params . action_stamp = + + _weenie - > m_wAnimSequence ;
params . modify_interpreted_state = 0 ;
_weenie - > last_move_was_autonomous = false ;
_weenie - > cancel_moveto ( ) ;
_weenie - > TurnToHeading ( & params ) ;
break ;
}
2018-03-29 17:01:57 -04:00
case TeachSpell_EmoteType :
2018-11-29 16:52:15 -05:00
{
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
target - > LearnSpell ( emote . spellid , true ) ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case InqEvent_EmoteType :
2018-11-29 16:52:15 -05:00
{
bool success = g_pGameEventManager - > IsEventStarted ( emote . msg . c_str ( ) ) ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
ChanceExecuteEmoteSet ( success ? EventSuccess_EmoteCategory : EventFailure_EmoteCategory , emote . msg , target_id ) ;
break ;
}
2018-03-29 17:01:57 -04:00
case StartEvent_EmoteType :
2018-11-29 16:52:15 -05:00
{
g_pGameEventManager - > StartEvent ( emote . msg . c_str ( ) ) ;
break ;
}
2018-03-29 17:01:57 -04:00
case StopEvent_EmoteType :
2018-11-29 16:52:15 -05:00
{
g_pGameEventManager - > StopEvent ( emote . msg . c_str ( ) ) ;
break ;
}
2018-03-29 17:01:57 -04:00
case InqQuest_EmoteType :
2018-11-29 16:52:15 -05:00
{
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
{
bool success = target - > InqQuest ( emote . msg . c_str ( ) ) ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
ChanceExecuteEmoteSet ( success ? QuestSuccess_EmoteCategory : QuestFailure_EmoteCategory , emote . msg , target_id ) ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case InqFellowNum_EmoteType :
2018-11-29 16:52:15 -05:00
{
2018-07-12 14:41:21 -07:00
if ( ! _weenie - > m_Qualities . _emote_table )
2018-03-29 17:01:57 -04:00
{
break ;
}
2018-07-12 14:41:21 -07:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
2018-03-29 17:01:57 -04:00
if ( target )
{
2019-09-03 14:18:02 +00:00
fellowship_ptr_t fellow = target - > GetFellowship ( ) ;
2018-03-29 17:01:57 -04:00
if ( ! fellow )
ChanceExecuteEmoteSet ( TestNoFellow_EmoteCategory , emote . msg , target_id ) ;
else
{
bool success = false ;
int numberOfMembers = ( int ) fellow - > _fellowship_table . size ( ) ;
if ( numberOfMembers > = emote . min & & numberOfMembers < = emote . max )
success = true ;
ChanceExecuteEmoteSet ( success ? NumFellowsSuccess_EmoteCategory : NumFellowsFailure_EmoteCategory , emote . msg , target_id ) ;
}
}
break ;
}
case InqFellowQuest_EmoteType :
2018-11-29 16:52:15 -05:00
{
if ( ! _weenie - > m_Qualities . _emote_table )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
{
2019-09-03 14:18:02 +00:00
fellowship_ptr_t fellow = target - > GetFellowship ( ) ;
2018-11-29 16:52:15 -05:00
if ( ! fellow )
ChanceExecuteEmoteSet ( QuestNoFellow_EmoteCategory , emote . msg , target_id ) ;
else
2018-03-29 17:01:57 -04:00
{
2019-09-03 14:18:02 +00:00
bool success = fellow - > InqQuest ( emote . msg . c_str ( ) ) ;
2018-03-29 17:01:57 -04:00
ChanceExecuteEmoteSet ( success ? QuestSuccess_EmoteCategory : QuestFailure_EmoteCategory , emote . msg , target_id ) ;
}
2018-11-29 16:52:15 -05:00
}
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
break ;
}
case UpdateQuest_EmoteType :
{
if ( ! _weenie - > m_Qualities . _emote_table )
2018-03-29 17:01:57 -04:00
break ;
2018-11-29 16:52:15 -05:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
{
bool success = target - > UpdateQuest ( emote . msg . c_str ( ) ) ;
ChanceExecuteEmoteSet ( success ? QuestSuccess_EmoteCategory : QuestFailure_EmoteCategory , emote . msg , target_id ) ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case StampQuest_EmoteType :
2018-11-29 16:52:15 -05:00
{
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target & & emote . msg . find ( " @#kt " ) ! = std : : string : : npos ) //if @#kt found in quest string this is a killtask call collect data pass to killtask func.
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
auto kCountName = target - > Ktref ( emote . msg . c_str ( ) ) ; //trims the @#kt off of the quest name and returns the questflag used by the quest for stamping/validation
2018-07-22 00:24:45 +00:00
2018-11-29 16:52:15 -05:00
std : : string mobName ;
_weenie - > m_Qualities . InqString ( ( STypeString ) 1 , mobName ) ;
2018-07-22 00:24:45 +00:00
2018-11-29 16:52:15 -05:00
killTask ( mobName , kCountName . c_str ( ) , target_id ) ;
break ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
if ( target )
{
target - > StampQuest ( emote . msg . c_str ( ) ) ;
}
}
break ;
2018-07-22 00:24:45 +00:00
2018-03-29 17:01:57 -04:00
case StampFellowQuest_EmoteType :
2018-11-29 16:52:15 -05:00
{
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
2018-03-29 17:01:57 -04:00
{
2019-09-03 14:18:02 +00:00
fellowship_ptr_t fellow = target - > GetFellowship ( ) ;
2018-11-29 16:52:15 -05:00
if ( fellow )
{
2019-09-03 14:18:02 +00:00
fellow - > StampQuest ( emote . msg . c_str ( ) ) ;
2018-03-29 17:01:57 -04:00
}
}
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case UpdateFellowQuest_EmoteType :
2018-11-29 16:52:15 -05:00
{
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
2018-03-29 17:01:57 -04:00
{
2019-09-03 14:18:02 +00:00
fellowship_ptr_t fellow = target - > GetFellowship ( ) ;
2018-11-29 16:52:15 -05:00
if ( ! fellow )
ChanceExecuteEmoteSet ( QuestNoFellow_EmoteCategory , emote . msg , target_id ) ;
else
2018-03-29 17:01:57 -04:00
{
2019-09-03 14:18:02 +00:00
bool success = fellow - > UpdateQuest ( emote . msg . c_str ( ) ) ;
ChanceExecuteEmoteSet ( success ? QuestSuccess_EmoteCategory : QuestFailure_EmoteCategory , emote . msg , target_id ) ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
}
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
break ;
}
case IncrementQuest_EmoteType :
{
if ( ! _weenie - > m_Qualities . _emote_table )
2018-03-29 17:01:57 -04:00
break ;
2018-11-29 16:52:15 -05:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
{
2019-07-07 20:58:01 +00:00
target - > IncrementQuest ( emote . msg . c_str ( ) , emote . amount ) ;
2018-11-29 16:52:15 -05:00
}
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
break ;
}
case DecrementQuest_EmoteType :
{
if ( ! _weenie - > m_Qualities . _emote_table )
2018-03-29 17:01:57 -04:00
break ;
2018-11-29 16:52:15 -05:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
{
2019-08-05 21:41:35 -04:00
target - > DecrementQuest ( emote . msg . c_str ( ) , emote . amount ) ;
2018-11-29 16:52:15 -05:00
}
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
break ;
}
case EraseQuest_EmoteType :
{
if ( ! _weenie - > m_Qualities . _emote_table )
2018-03-29 17:01:57 -04:00
break ;
2018-11-29 16:52:15 -05:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
target - > EraseQuest ( emote . msg . c_str ( ) ) ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
break ;
}
case Goto_EmoteType :
{
ChanceExecuteEmoteSet ( GotoSet_EmoteCategory , emote . msg , target_id ) ;
2019-01-20 12:29:38 -08:00
break ;
2018-11-29 16:52:15 -05:00
}
2018-03-29 17:01:57 -04:00
case InqBoolStat_EmoteType :
{
2018-07-12 14:41:21 -07:00
if ( ! _weenie - > m_Qualities . _emote_table )
2018-03-29 17:01:57 -04:00
break ;
2018-07-12 14:41:21 -07:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
2018-03-29 17:01:57 -04:00
if ( target )
{
bool success = false ;
bool hasQuality = false ;
int boolStat ;
if ( target - > m_Qualities . InqBool ( ( STypeBool ) emote . stat , boolStat ) )
{
hasQuality = true ;
if ( boolStat > 0 )
success = true ;
}
if ( ! hasQuality & & ChanceExecuteEmoteSet ( TestNoQuality_EmoteCategory , emote . msg , target_id ) )
break ; //if we have a TestNoQuality_EmoteCategory break otherwise try the categories below.
ChanceExecuteEmoteSet ( success ? TestSuccess_EmoteCategory : TestFailure_EmoteCategory , emote . msg , target_id ) ;
}
break ;
}
case InqIntStat_EmoteType :
2018-11-29 16:52:15 -05:00
{
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
bool success = false ;
bool hasQuality = false ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
int intStat ;
if ( target - > m_Qualities . InqInt ( ( STypeInt ) emote . stat , intStat ) )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
hasQuality = true ;
if ( intStat > = emote . min & & intStat < = emote . max )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
success = true ;
2018-03-29 17:01:57 -04:00
}
}
2018-11-29 16:52:15 -05:00
if ( ! hasQuality & & ChanceExecuteEmoteSet ( TestNoQuality_EmoteCategory , emote . msg , target_id ) )
break ; //if we have a TestNoQuality_EmoteCategory break otherwise try the categories below.
ChanceExecuteEmoteSet ( success ? TestSuccess_EmoteCategory : TestFailure_EmoteCategory , emote . msg , target_id ) ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case InqFloatStat_EmoteType :
{
2018-07-12 14:41:21 -07:00
if ( ! _weenie - > m_Qualities . _emote_table )
2018-03-29 17:01:57 -04:00
break ;
2018-07-12 14:41:21 -07:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
2018-03-29 17:01:57 -04:00
if ( target )
{
bool success = false ;
bool hasQuality = false ;
double floatStat ;
if ( target - > m_Qualities . InqFloat ( ( STypeFloat ) emote . stat , floatStat ) )
{
hasQuality = true ;
if ( floatStat > = emote . fmin & & floatStat < = emote . fmax )
success = true ;
}
if ( ! hasQuality & & ChanceExecuteEmoteSet ( TestNoQuality_EmoteCategory , emote . msg , target_id ) )
break ; //if we have a TestNoQuality_EmoteCategory break otherwise try the categories below.
ChanceExecuteEmoteSet ( success ? TestSuccess_EmoteCategory : TestFailure_EmoteCategory , emote . msg , target_id ) ;
}
break ;
}
case InqStringStat_EmoteType :
{
2018-07-12 14:41:21 -07:00
if ( ! _weenie - > m_Qualities . _emote_table )
2018-03-29 17:01:57 -04:00
break ;
2018-07-12 14:41:21 -07:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
2018-03-29 17:01:57 -04:00
if ( target )
{
bool success = false ;
bool hasQuality = false ;
std : : string stringStat ;
if ( target - > m_Qualities . InqString ( ( STypeString ) emote . stat , stringStat ) )
{
hasQuality = true ;
if ( stringStat = = emote . teststring )
success = true ;
}
if ( ! hasQuality & & ChanceExecuteEmoteSet ( TestNoQuality_EmoteCategory , emote . msg , target_id ) )
break ; //if we have a TestNoQuality_EmoteCategory break otherwise try the categories below.
ChanceExecuteEmoteSet ( success ? TestSuccess_EmoteCategory : TestFailure_EmoteCategory , emote . msg , target_id ) ;
}
break ;
}
case InqAttributeStat_EmoteType :
{
2018-07-12 14:41:21 -07:00
if ( ! _weenie - > m_Qualities . _emote_table )
2018-03-29 17:01:57 -04:00
break ;
2018-07-12 14:41:21 -07:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
2018-03-29 17:01:57 -04:00
if ( target )
{
bool success = false ;
bool hasQuality = false ;
2019-07-07 20:56:15 +00:00
uint32_t attributeStat ;
2018-03-29 17:01:57 -04:00
if ( target - > m_Qualities . InqAttribute ( ( STypeAttribute ) emote . stat , attributeStat , FALSE ) )
{
hasQuality = true ;
if ( attributeStat > = emote . min & & attributeStat < = emote . max )
success = true ;
}
if ( ! hasQuality & & ChanceExecuteEmoteSet ( TestNoQuality_EmoteCategory , emote . msg , target_id ) )
break ; //if we have a TestNoQuality_EmoteCategory break otherwise try the categories below.
ChanceExecuteEmoteSet ( success ? TestSuccess_EmoteCategory : TestFailure_EmoteCategory , emote . msg , target_id ) ;
}
break ;
}
case InqRawAttributeStat_EmoteType :
{
2018-07-12 14:41:21 -07:00
if ( ! _weenie - > m_Qualities . _emote_table )
2018-03-29 17:01:57 -04:00
break ;
2018-07-12 14:41:21 -07:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
2018-03-29 17:01:57 -04:00
if ( target )
{
bool success = false ;
bool hasQuality = false ;
2019-07-07 20:56:15 +00:00
uint32_t attributeStat ;
2018-03-29 17:01:57 -04:00
if ( target - > m_Qualities . InqAttribute ( ( STypeAttribute ) emote . stat , attributeStat , TRUE ) )
{
hasQuality = true ;
if ( attributeStat > = emote . min & & attributeStat < = emote . max )
success = true ;
}
if ( ! hasQuality & & ChanceExecuteEmoteSet ( TestNoQuality_EmoteCategory , emote . msg , target_id ) )
break ; //if we have a TestNoQuality_EmoteCategory break otherwise try the categories below.
ChanceExecuteEmoteSet ( success ? TestSuccess_EmoteCategory : TestFailure_EmoteCategory , emote . msg , target_id ) ;
}
break ;
}
case InqSecondaryAttributeStat_EmoteType :
{
2018-07-12 14:41:21 -07:00
if ( ! _weenie - > m_Qualities . _emote_table )
2018-03-29 17:01:57 -04:00
break ;
2018-07-12 14:41:21 -07:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
2018-03-29 17:01:57 -04:00
if ( target )
{
bool success = false ;
bool hasQuality = false ;
2019-07-07 20:56:15 +00:00
uint32_t attribute2ndStat ;
2018-03-29 17:01:57 -04:00
if ( target - > m_Qualities . InqAttribute2nd ( ( STypeAttribute2nd ) emote . stat , attribute2ndStat , FALSE ) )
{
hasQuality = true ;
if ( attribute2ndStat > = emote . min & & attribute2ndStat < = emote . max )
success = true ;
}
if ( ! hasQuality & & ChanceExecuteEmoteSet ( TestNoQuality_EmoteCategory , emote . msg , target_id ) )
break ; //if we have a TestNoQuality_EmoteCategory break otherwise try the categories below.
ChanceExecuteEmoteSet ( success ? TestSuccess_EmoteCategory : TestFailure_EmoteCategory , emote . msg , target_id ) ;
}
break ;
}
case InqRawSecondaryAttributeStat_EmoteType :
{
2018-07-12 14:41:21 -07:00
if ( ! _weenie - > m_Qualities . _emote_table )
2018-03-29 17:01:57 -04:00
break ;
2018-07-12 14:41:21 -07:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
2018-03-29 17:01:57 -04:00
if ( target )
{
bool success = false ;
bool hasQuality = false ;
2019-07-07 20:56:15 +00:00
uint32_t attribute2ndStat ;
2018-03-29 17:01:57 -04:00
if ( target - > m_Qualities . InqAttribute2nd ( ( STypeAttribute2nd ) emote . stat , attribute2ndStat , TRUE ) )
{
hasQuality = true ;
if ( attribute2ndStat > = emote . min & & attribute2ndStat < = emote . max )
success = true ;
}
if ( ! hasQuality & & ChanceExecuteEmoteSet ( TestNoQuality_EmoteCategory , emote . msg , target_id ) )
break ; //if we have a TestNoQuality_EmoteCategory break otherwise try the categories below.
ChanceExecuteEmoteSet ( success ? TestSuccess_EmoteCategory : TestFailure_EmoteCategory , emote . msg , target_id ) ;
}
break ;
}
case InqSkillTrained_EmoteType :
2018-11-29 16:52:15 -05:00
{
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
{
bool success = false ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
SKILL_ADVANCEMENT_CLASS sac = SKILL_ADVANCEMENT_CLASS : : UNTRAINED_SKILL_ADVANCEMENT_CLASS ;
bool hasQuality = target - > m_Qualities . InqSkillAdvancementClass ( ( STypeSkill ) emote . stat , sac ) ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
if ( sac = = TRAINED_SKILL_ADVANCEMENT_CLASS | | sac = = SPECIALIZED_SKILL_ADVANCEMENT_CLASS )
success = true ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
if ( ! hasQuality & & ChanceExecuteEmoteSet ( TestNoQuality_EmoteCategory , emote . msg , target_id ) )
break ; //if we have a TestNoQuality_EmoteCategory break otherwise try the categories below.
ChanceExecuteEmoteSet ( success ? TestSuccess_EmoteCategory : TestFailure_EmoteCategory , emote . msg , target_id ) ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
break ;
}
case InqSkillSpecialized_EmoteType :
{
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
{
bool success = false ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
SKILL_ADVANCEMENT_CLASS sac = SKILL_ADVANCEMENT_CLASS : : UNTRAINED_SKILL_ADVANCEMENT_CLASS ;
bool hasQuality = target - > m_Qualities . InqSkillAdvancementClass ( ( STypeSkill ) emote . stat , sac ) ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
if ( sac = = SPECIALIZED_SKILL_ADVANCEMENT_CLASS )
success = true ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
if ( ! hasQuality & & ChanceExecuteEmoteSet ( TestNoQuality_EmoteCategory , emote . msg , target_id ) )
break ; //if we have a TestNoQuality_EmoteCategory break otherwise try the categories below.
ChanceExecuteEmoteSet ( success ? TestSuccess_EmoteCategory : TestFailure_EmoteCategory , emote . msg , target_id ) ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case InqSkillStat_EmoteType :
2018-11-29 16:52:15 -05:00
{
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
bool success = false ;
bool hasQuality = false ;
2018-03-29 17:01:57 -04:00
2019-07-07 20:56:15 +00:00
uint32_t skillStat ;
2018-11-29 16:52:15 -05:00
if ( target - > m_Qualities . InqSkill ( ( STypeSkill ) emote . stat , skillStat , FALSE ) )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
hasQuality = true ;
if ( skillStat > = emote . min & & skillStat < = emote . max )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
success = true ;
2018-03-29 17:01:57 -04:00
}
}
2018-11-29 16:52:15 -05:00
if ( ! hasQuality & & ChanceExecuteEmoteSet ( TestNoQuality_EmoteCategory , emote . msg , target_id ) )
break ; //if we have a TestNoQuality_EmoteCategory break otherwise try the categories below.
ChanceExecuteEmoteSet ( success ? TestSuccess_EmoteCategory : TestFailure_EmoteCategory , emote . msg , target_id ) ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case InqRawSkillStat_EmoteType :
2018-11-29 16:52:15 -05:00
{
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
bool success = false ;
bool hasQuality = false ;
2018-03-29 17:01:57 -04:00
2019-07-07 20:56:15 +00:00
uint32_t skillStat ;
2018-11-29 16:52:15 -05:00
if ( target - > m_Qualities . InqSkill ( ( STypeSkill ) emote . stat , skillStat , TRUE ) )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
hasQuality = true ;
if ( skillStat > = emote . min & & skillStat < = emote . max )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
success = true ;
2018-03-29 17:01:57 -04:00
}
}
2018-11-29 16:52:15 -05:00
if ( ! hasQuality & & ChanceExecuteEmoteSet ( TestNoQuality_EmoteCategory , emote . msg , target_id ) )
break ; //if we have a TestNoQuality_EmoteCategory break otherwise try the categories below.
ChanceExecuteEmoteSet ( success ? TestSuccess_EmoteCategory : TestFailure_EmoteCategory , emote . msg , target_id ) ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
break ;
}
case InqQuestSolves_EmoteType :
{
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
{
bool success = false ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
int intQuestSolves = target - > InqQuestSolves ( emote . msg . c_str ( ) ) ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
if ( intQuestSolves > = emote . min & & intQuestSolves < = emote . max )
success = true ;
2018-03-29 17:01:57 -04:00
2018-11-29 16:52:15 -05:00
ChanceExecuteEmoteSet ( success ? QuestSuccess_EmoteCategory : QuestFailure_EmoteCategory , emote . msg , target_id ) ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case SetIntStat_EmoteType :
2018-11-29 16:52:15 -05:00
{
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
target - > m_Qualities . SetInt ( ( STypeInt ) emote . stat , emote . amount ) ;
target - > NotifyIntStatUpdated ( ( STypeInt ) emote . stat , FALSE ) ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case IncrementIntStat_EmoteType :
2018-11-29 16:52:15 -05:00
{
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
2018-03-29 17:01:57 -04:00
{
2018-11-29 16:52:15 -05:00
int intStat = target - > InqIntQuality ( ( STypeInt ) emote . stat , 0 , TRUE ) + 1 ;
target - > m_Qualities . SetInt ( ( STypeInt ) emote . stat , intStat ) ;
target - > NotifyIntStatUpdated ( ( STypeInt ) emote . stat , FALSE ) ;
2018-03-29 17:01:57 -04:00
}
2018-11-29 16:52:15 -05:00
break ;
}
2018-03-29 17:01:57 -04:00
case DecrementIntStat_EmoteType :
{
2018-07-12 14:41:21 -07:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
2018-03-29 17:01:57 -04:00
if ( target )
{
int intStat = target - > InqIntQuality ( ( STypeInt ) emote . stat , 0 , TRUE ) - 1 ;
target - > m_Qualities . SetInt ( ( STypeInt ) emote . stat , intStat ) ;
2018-08-07 07:38:30 -05:00
target - > NotifyIntStatUpdated ( ( STypeInt ) emote . stat , FALSE ) ;
2018-03-29 17:01:57 -04:00
}
break ;
}
case CreateTreasure_EmoteType :
{
2018-07-12 14:41:21 -07:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
2018-03-29 17:01:57 -04:00
if ( target & & target - > AsContainer ( ) )
target - > AsContainer ( ) - > SpawnTreasureInContainer ( ( eTreasureCategory ) emote . treasure_type , emote . wealth_rating , emote . treasure_class ) ;
break ;
}
case ResetHomePosition_EmoteType :
{
2018-07-12 14:41:21 -07:00
CMonsterWeenie * monster = _weenie - > AsMonster ( ) ;
2018-03-29 17:01:57 -04:00
if ( monster & & monster - > m_MonsterAI )
monster - > m_MonsterAI - > SetHomePosition ( monster - > m_Position ) ;
2018-07-12 14:41:21 -07:00
_weenie - > SetInitialPosition ( _weenie - > m_Position ) ;
2018-03-29 17:01:57 -04:00
break ;
}
case MoveHome_EmoteType :
{
2020-08-11 19:58:15 -07:00
Position destination ;
_weenie - > m_Qualities . InqPosition ( INSTANTIATION_POSITION , destination ) ;
if ( destination . objcell_id )
2018-03-29 17:01:57 -04:00
{
2020-08-11 19:58:15 -07:00
MovementParameters params ;
params . desired_heading = destination . frame . get_heading ( ) ;
MovementStruct mvs ;
mvs . type = MovementTypes : : MoveToPosition ;
mvs . pos = destination ;
mvs . params = & params ;
mvs . motion = Motion_WalkForward ;
_weenie - > last_move_was_autonomous = false ;
_weenie - > movement_manager - > PerformMovement ( mvs ) ;
2018-03-29 17:01:57 -04:00
}
2020-08-11 19:58:15 -07:00
//todo: make creatures that do not normally have an AI(vendors/etc) move home.
//Position initialPos;
//if (_weenie->m_Qualities.InqPosition(INSTANTIATION_POSITION, initialPos) && initialPos.objcell_id)
//{
// _weenie->Movement_Teleport(initialPos, false);
//}
2018-03-29 17:01:57 -04:00
break ;
}
case Move_EmoteType :
{
2020-08-11 19:58:15 -07:00
Position destination = _weenie - > m_Position . add_offset ( emote . frame . m_origin ) ;
if ( emote . frame . m_origin . x = = 0 )
destination . frame . m_origin . x + = Random : : GenFloat ( - emote . frame . m_angles . x , emote . frame . m_angles . x ) ;
if ( emote . frame . m_origin . y = = 0 )
destination . frame . m_origin . y + = Random : : GenFloat ( - emote . frame . m_angles . y , emote . frame . m_angles . y ) ;
destination . frame . m_origin . z = CalcSurfaceZ ( destination . objcell_id , destination . frame . m_origin . x , destination . frame . m_origin . y ) ;
2018-03-29 17:01:57 -04:00
2020-08-11 19:58:15 -07:00
MovementParameters params ;
params . desired_heading = emote . frame . get_heading ( ) ;
2018-03-29 17:01:57 -04:00
2020-08-11 19:58:15 -07:00
MovementStruct mvs ;
mvs . type = MovementTypes : : MoveToPosition ;
mvs . pos = destination ;
mvs . params = & params ;
if ( emote . extent > 0 )
mvs . motion = Motion_RunForward ;
else
mvs . motion = Motion_WalkForward ;
2018-03-29 17:01:57 -04:00
2020-08-11 19:58:15 -07:00
_weenie - > last_move_was_autonomous = false ;
_weenie - > movement_manager - > PerformMovement ( mvs ) ;
2018-03-29 17:01:57 -04:00
break ;
}
case SetSanctuaryPosition_EmoteType :
{
2018-07-12 14:41:21 -07:00
if ( ! emote . mPosition )
2018-03-29 17:01:57 -04:00
{
2018-07-12 14:41:21 -07:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
2018-06-25 17:31:54 -04:00
{
target - > SetInitialPosition ( target - > m_Position ) ;
target - > m_Qualities . SetPosition ( SANCTUARY_POSITION , target - > m_Position ) ;
}
2018-07-12 14:41:21 -07:00
}
else
{
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
2018-06-25 17:31:54 -04:00
{
target - > m_Qualities . SetPosition ( SANCTUARY_POSITION , emote . mPosition ) ;
}
2018-03-29 17:01:57 -04:00
}
2018-06-25 17:31:54 -04:00
2018-03-29 17:01:57 -04:00
break ;
}
2018-04-08 09:55:50 -04:00
case InqInt64Stat_EmoteType :
{
2018-07-12 14:41:21 -07:00
if ( ! _weenie - > m_Qualities . _emote_table )
2018-04-08 09:55:50 -04:00
break ;
2018-07-12 14:41:21 -07:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
2018-04-08 09:55:50 -04:00
if ( target )
{
bool success = false ;
bool hasQuality = false ;
2019-07-07 20:56:15 +00:00
int64_t intStat64 ;
2018-04-08 09:55:50 -04:00
if ( target - > m_Qualities . InqInt64 ( ( STypeInt64 ) emote . stat , intStat64 ) )
{
hasQuality = true ;
if ( intStat64 > = emote . min64 & & intStat64 < = emote . max64 )
{
success = true ;
}
}
if ( ! hasQuality & & ChanceExecuteEmoteSet ( TestNoQuality_EmoteCategory , emote . msg , target_id ) )
break ; //if we have a TestNoQuality_EmoteCategory break otherwise try the categories below.
ChanceExecuteEmoteSet ( success ? TestSuccess_EmoteCategory : TestFailure_EmoteCategory , emote . msg , target_id ) ;
}
break ;
}
2018-07-22 00:24:45 +00:00
case SetQuestCompletions_EmoteType :
2018-10-04 23:06:09 -04:00
{
2018-07-22 00:24:45 +00:00
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
2018-10-04 23:06:09 -04:00
2018-07-22 00:24:45 +00:00
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
{
target - > SetQuestCompletions ( emote . msg . c_str ( ) , emote . amount ) ;
}
2018-10-04 23:06:09 -04:00
break ;
2018-07-22 00:24:45 +00:00
}
2018-10-05 02:45:14 +00:00
case Generate_EmoteType : //type:72 adds from generator table attached to weenie. Sets init value of generator table and calls weenie factory to begin generation. Can use same emote with value of 0 in amount field to disable generator.
2018-07-22 00:24:45 +00:00
{
2018-10-05 02:45:14 +00:00
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
2020-02-08 12:15:07 -05:00
BOOL disabled = FALSE ;
if ( _weenie - > m_Qualities . InqBool ( GENERATOR_DISABLED_BOOL , disabled ) )
{
_weenie - > m_Qualities . SetBool ( GENERATOR_DISABLED_BOOL , ( emote . amount = = 0 ) ? TRUE : FALSE ) ;
}
else
{
_weenie - > m_Qualities . SetInt ( INIT_GENERATED_OBJECTS_INT , emote . amount ) ;
}
2018-10-05 02:45:14 +00:00
_weenie - > GenerateOnDemand ( emote . amount ) ;
2018-07-22 00:24:45 +00:00
break ;
}
2018-09-17 22:55:33 -05:00
case PopUp_EmoteType : //type: 68 causes a popup message to appear with a with the text from emote.msg and an OK dialog button.
{
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
{
BinaryWriter popupMessage ;
2019-07-07 20:56:15 +00:00
popupMessage . Write < uint32_t > ( 0x4 ) ;
2018-09-17 22:55:33 -05:00
popupMessage . WriteString ( emote . msg ) ;
target - > SendNetMessage ( & popupMessage , PRIVATE_MSG , TRUE , FALSE ) ;
}
break ;
}
case InqYesNo_EmoteType : //type: 75 causes a popup message to appear with a with the text from emote.msg and Yes/No dialog buttons.
{
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
{
BinaryWriter yesnoMessage ;
2019-07-07 20:56:15 +00:00
yesnoMessage . Write < uint32_t > ( 0x274 ) ; // Message Type
yesnoMessage . Write < uint32_t > ( 0x07 ) ; // Confirm type (Yes/No)
2018-09-17 22:55:33 -05:00
yesnoMessage . Write < int > ( _weenie - > id ) ; // Sequence number ?? context id
yesnoMessage . WriteString ( emote . teststring ) ;
target - > SendNetMessage ( & yesnoMessage , PRIVATE_MSG , TRUE , FALSE ) ;
2018-10-04 21:23:45 -05:00
_confirmMsgList [ target_id ] = emote . msg ;
2018-09-17 22:55:33 -05:00
}
break ;
}
case InqOwnsItems_EmoteType : //type: 76 checks to see if a particular item and count exists in pack.
{
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
2019-07-07 20:56:15 +00:00
uint32_t itemWCID = emote . cprof . wcid ;
2018-09-17 22:55:33 -05:00
int itemAmount = emote . cprof . stack_size ;
bool success = false ;
if ( target )
{
if ( target - > GetItemCount ( itemWCID ) > = itemAmount )
success = true ;
ChanceExecuteEmoteSet ( success ? TestSuccess_EmoteCategory : TestFailure_EmoteCategory , emote . msg , target_id ) ;
}
break ;
}
case TakeItems_EmoteType : //type: 74 removes items from pack.
{
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
2019-07-07 20:56:15 +00:00
uint32_t itemWCID = emote . cprof . wcid ;
2018-11-29 16:52:15 -05:00
unsigned int itemAmount = emote . cprof . stack_size ;
2018-10-09 21:39:43 -05:00
CWeenieObject * dummyitem = g_pWeenieFactory - > CreateWeenieByClassID ( itemWCID , NULL , false ) ;
std : : string dummyname = " " ;
std : : string substring = " " ;
2018-09-17 22:55:33 -05:00
2018-10-10 19:08:10 +00:00
if ( target & & dummyitem )
2018-09-17 22:55:33 -05:00
{
2018-11-29 16:52:15 -05:00
unsigned int targetCnt = target - > GetItemCount ( itemWCID ) ;
if ( targetCnt > = itemAmount | | itemAmount = = - 1 )
2018-10-09 21:39:43 -05:00
{
2018-11-29 16:52:15 -05:00
target - > ConsumeItem ( std : : min ( targetCnt , itemAmount ) , itemWCID ) ;
2018-10-09 21:39:43 -05:00
if ( itemAmount > 1 )
{
dummyname = dummyitem - > GetPluralName ( ) ;
2018-11-29 16:52:15 -05:00
if ( itemAmount = = - 1 )
substring = " all of your " ;
else
substring = csprintf ( " %d of your " , itemAmount ) ;
2018-10-09 21:39:43 -05:00
}
else
{
dummyname = dummyitem - > GetName ( ) ;
substring = " a " ;
}
target - > SendText ( csprintf ( " You hand over %s %s. " , substring . c_str ( ) , dummyname . c_str ( ) ) , LTT_DEFAULT ) ;
}
2018-09-22 20:09:45 -05:00
}
2018-11-29 16:52:15 -05:00
if ( dummyitem )
dummyitem - > Destroy ( ) ;
2018-09-22 20:09:45 -05:00
break ;
2019-02-10 01:02:56 +00:00
}
case AddCharacterTitle_EmoteType :
{
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
if ( ! target )
break ;
target - > AddTitle ( emote . amount ) ;
break ;
2018-11-29 16:52:15 -05:00
}
2018-09-22 20:09:45 -05:00
case UntrainSkill_EmoteType : //type: 110 changes skill to untrained and returns the approriate number of skill credits. Acts like a skill lowering gem with minor tweaks.
{
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
CWeenieObject * player = g_pWorld - > FindObject ( target_id ) - > AsPlayer ( ) ;
STypeSkill skillToAlter = ( STypeSkill ) emote . stat ;
if ( player )
{
Skill skill ;
if ( ! player - > m_Qualities . InqSkill ( skillToAlter , skill ) )
{
break ;
}
int numSkillCredits = player - > InqIntQuality ( AVAILABLE_SKILL_CREDITS_INT , 0 , TRUE ) ;
2018-11-29 16:52:15 -05:00
2019-01-19 22:29:15 +00:00
SKILL_ADVANCEMENT_CLASS debugSkillSacInit = skill . _sac ; //for validation logging.
int debugInitAvailCredits = numSkillCredits ; //for validation logging.
2018-09-22 20:09:45 -05:00
switch ( skill . _sac )
{
default :
2019-01-19 22:29:15 +00:00
{
2018-09-22 20:09:45 -05:00
break ;
2019-01-19 22:29:15 +00:00
}
2018-09-22 20:09:45 -05:00
case SPECIALIZED_SKILL_ADVANCEMENT_CLASS :
2018-11-29 16:52:15 -05:00
{
SkillTable * pSkillTable = SkillSystem : : GetSkillTable ( ) ;
const SkillBase * pSkillBase = pSkillTable - > GetSkillBase ( skillToAlter ) ;
if ( pSkillBase ! = NULL )
2018-09-22 20:09:45 -05:00
{
2019-01-19 22:29:15 +00:00
//Captures no train cost skills (Arcane Lore, Jump, Loyalty, Magic Defense & Run) here. These drop ONLY to trained sac. Salvaging is a unique case.
if ( ( pSkillBase - > _trained_cost < = 0 & & skillToAlter ! = SALVAGING_SKILL ) | | skillToAlter = = ARCANE_LORE_SKILL )
2018-11-29 16:52:15 -05:00
{
2019-07-07 20:56:15 +00:00
uint64_t xpToAward = skill . _pp ;
2019-01-19 22:29:15 +00:00
skill . _sac = TRAINED_SKILL_ADVANCEMENT_CLASS ;
skill . _pp = 526 ;
skill . _level_from_pp = 5 ;
skill . _init_level = 0 ;
player - > m_Qualities . SetSkill ( skillToAlter , skill ) ;
player - > NotifySkillStatUpdated ( skillToAlter ) ;
2018-11-29 16:52:15 -05:00
2019-01-19 22:29:15 +00:00
numSkillCredits + = pSkillBase - > _specialized_cost - pSkillBase - > _trained_cost ;
player - > m_Qualities . SetInt ( AVAILABLE_SKILL_CREDITS_INT , numSkillCredits ) ;
player - > NotifyIntStatUpdated ( AVAILABLE_SKILL_CREDITS_INT ) ;
2018-09-22 20:09:45 -05:00
2019-01-19 22:29:15 +00:00
if ( xpToAward > 0 )
{
player - > m_Qualities . SetInt64 ( AVAILABLE_EXPERIENCE_INT64 , player - > InqInt64Quality ( AVAILABLE_EXPERIENCE_INT64 , 0 ) + xpToAward ) ;
player - > NotifyInt64StatUpdated ( AVAILABLE_EXPERIENCE_INT64 ) ;
2018-11-29 16:52:15 -05:00
}
2018-09-22 20:09:45 -05:00
2019-01-19 22:29:15 +00:00
player - > SendText ( csprintf ( " Your %s skill has been reset. All the experience that you spent on this skill have been refunded to you. " , pSkillBase - > _name . c_str ( ) ) , LTT_DEFAULT ) ;
break ;
2018-11-29 16:52:15 -05:00
}
2019-01-19 22:29:15 +00:00
if ( pSkillBase - > _trained_cost > 0 & & skillToAlter ! = ARCANE_LORE_SKILL ) //all the other skills except salvaging and Arcane Lore. Lore's _trained_cost is actually 4 but should be treated as if it was 0.
2018-11-29 16:52:15 -05:00
{
2019-01-19 22:29:15 +00:00
bool isTinker = ( skillToAlter = = WEAPON_APPRAISAL_SKILL | |
2018-11-29 16:52:15 -05:00
skillToAlter = = ARMOR_APPRAISAL_SKILL | |
skillToAlter = = MAGIC_ITEM_APPRAISAL_SKILL | |
skillToAlter = = ITEM_APPRAISAL_SKILL ) ;
2018-09-22 20:09:45 -05:00
2018-11-29 16:52:15 -05:00
if ( isTinker )
{
2019-01-08 17:50:31 +00:00
numSkillCredits + = pSkillBase - > _trained_cost ; // We only want to return the trained cost (as there was no credit cost to spec tinkering skills).
2018-09-22 20:09:45 -05:00
}
else
{
2018-11-29 16:52:15 -05:00
numSkillCredits + = pSkillBase - > _specialized_cost ;
}
2019-01-08 17:50:31 +00:00
player - > m_Qualities . SetInt ( AVAILABLE_SKILL_CREDITS_INT , numSkillCredits ) ;
player - > NotifyIntStatUpdated ( AVAILABLE_SKILL_CREDITS_INT ) ;
2018-11-29 16:52:15 -05:00
2019-07-07 20:56:15 +00:00
uint64_t xpToAward = 0 ;
2018-09-22 20:09:45 -05:00
2018-11-29 16:52:15 -05:00
xpToAward = skill . _pp ;
skill . _sac = UNTRAINED_SKILL_ADVANCEMENT_CLASS ;
skill . _pp = 0 ;
skill . _level_from_pp = ExperienceSystem : : SkillLevelFromExperience ( skill . _sac , skill . _pp ) ;
skill . _init_level = 0 ;
2018-09-22 20:09:45 -05:00
2018-11-29 16:52:15 -05:00
player - > m_Qualities . SetSkill ( skillToAlter , skill ) ;
player - > NotifySkillStatUpdated ( skillToAlter ) ;
if ( xpToAward > 0 )
{
player - > m_Qualities . SetInt64 ( AVAILABLE_EXPERIENCE_INT64 , player - > InqInt64Quality ( AVAILABLE_EXPERIENCE_INT64 , 0 ) + xpToAward ) ;
player - > NotifyInt64StatUpdated ( AVAILABLE_EXPERIENCE_INT64 ) ;
2018-09-22 20:09:45 -05:00
}
2018-11-29 16:52:15 -05:00
player - > SendText ( csprintf ( " Your specialized %s skill has been removed. All the experience and skill credits that you spent on this skill have been refunded to you. " , pSkillBase - > _name . c_str ( ) ) , LTT_DEFAULT ) ;
2019-01-19 22:29:15 +00:00
break ;
2018-09-22 20:09:45 -05:00
}
2019-01-19 22:29:15 +00:00
//Salvaging is NEVER unspec'd once spec'd (no credit skill - just xp. So only return xp on unspec).
if ( skillToAlter = = SALVAGING_SKILL )
2018-11-29 16:52:15 -05:00
{
2019-07-07 20:56:15 +00:00
uint64_t xpToAward = skill . _pp ;
2019-01-19 22:29:15 +00:00
skill . _init_level = 10 ;
skill . _pp = 526 ;
skill . _level_from_pp = 5 ;
2018-11-29 16:52:15 -05:00
player - > m_Qualities . SetSkill ( skillToAlter , skill ) ;
player - > NotifySkillStatUpdated ( skillToAlter ) ;
if ( xpToAward > 0 )
{
player - > m_Qualities . SetInt64 ( AVAILABLE_EXPERIENCE_INT64 , player - > InqInt64Quality ( AVAILABLE_EXPERIENCE_INT64 , 0 ) + xpToAward ) ;
player - > NotifyInt64StatUpdated ( AVAILABLE_EXPERIENCE_INT64 ) ;
}
2018-09-22 20:09:45 -05:00
2018-11-29 16:52:15 -05:00
player - > SendText ( csprintf ( " Your %s skill has been reset. All the experience that you spent on this skill have been refunded to you. " , pSkillBase - > _name . c_str ( ) ) , LTT_DEFAULT ) ;
}
2018-09-22 20:09:45 -05:00
}
2018-11-29 16:52:15 -05:00
break ;
}
2018-09-22 20:09:45 -05:00
case TRAINED_SKILL_ADVANCEMENT_CLASS :
2018-11-29 16:52:15 -05:00
{
SkillTable * pSkillTable = SkillSystem : : GetSkillTable ( ) ;
const SkillBase * pSkillBase = pSkillTable - > GetSkillBase ( skillToAlter ) ;
if ( pSkillBase ! = NULL )
2018-09-22 20:09:45 -05:00
{
2018-11-29 16:52:15 -05:00
HeritageGroup_CG * heritageGroup = CachedCharGenData - > mHeritageGroupList . lookup ( player - > InqIntQuality ( HERITAGE_GROUP_INT , 0 , true ) ) ;
if ( heritageGroup )
2018-09-22 20:09:45 -05:00
{
2018-11-29 16:52:15 -05:00
//first we check our heritage specific skills as we cannot untrain those.
2019-07-07 20:56:15 +00:00
for ( uint32_t i = 0 ; i < heritageGroup - > mSkillList . num_used ; i + + )
2018-09-22 20:09:45 -05:00
{
2018-11-29 16:52:15 -05:00
if ( heritageGroup - > mSkillList . array_data [ i ] . skillNum = = skillToAlter )
2018-09-22 20:09:45 -05:00
{
2019-07-07 20:56:15 +00:00
uint64_t xpToAward = skill . _pp ;
2018-11-29 16:52:15 -05:00
skill . _pp = 526 ;
skill . _level_from_pp = 5 ;
skill . _init_level = 0 ;
player - > m_Qualities . SetSkill ( skillToAlter , skill ) ;
player - > NotifySkillStatUpdated ( skillToAlter ) ;
if ( xpToAward > 0 )
2018-09-22 20:09:45 -05:00
{
2018-11-29 16:52:15 -05:00
player - > m_Qualities . SetInt64 ( AVAILABLE_EXPERIENCE_INT64 , player - > InqInt64Quality ( AVAILABLE_EXPERIENCE_INT64 , 0 ) + xpToAward ) ;
player - > NotifyInt64StatUpdated ( AVAILABLE_EXPERIENCE_INT64 ) ;
2018-09-22 20:09:45 -05:00
}
2018-11-29 16:52:15 -05:00
player - > SendText ( csprintf ( " Your %s skill has been reset. All the experience that you spent on this skill have been refunded to you. " , pSkillBase - > _name . c_str ( ) ) , LTT_DEFAULT ) ;
break ;
}
2018-09-22 20:09:45 -05:00
}
2018-11-29 16:52:15 -05:00
if ( skillToAlter = = ARCANE_LORE_SKILL )
break ;
}
2018-09-22 20:09:45 -05:00
2018-11-29 16:52:15 -05:00
if ( pSkillBase - > _trained_cost > 0 )
{
numSkillCredits + = pSkillBase - > _trained_cost ;
player - > m_Qualities . SetInt ( AVAILABLE_SKILL_CREDITS_INT , numSkillCredits ) ;
player - > NotifyIntStatUpdated ( AVAILABLE_SKILL_CREDITS_INT ) ;
2018-09-22 20:09:45 -05:00
2019-07-07 20:56:15 +00:00
uint64_t xpToAward = skill . _pp ;
2018-11-29 16:52:15 -05:00
skill . _pp = 0 ;
2018-09-22 20:09:45 -05:00
2018-11-29 16:52:15 -05:00
skill . _sac = UNTRAINED_SKILL_ADVANCEMENT_CLASS ;
skill . _level_from_pp = ExperienceSystem : : SkillLevelFromExperience ( skill . _sac , skill . _pp ) ;
skill . _init_level = 0 ;
player - > m_Qualities . SetSkill ( skillToAlter , skill ) ;
player - > NotifySkillStatUpdated ( skillToAlter ) ;
2018-09-22 20:09:45 -05:00
2018-11-29 16:52:15 -05:00
if ( xpToAward > 0 )
2018-09-22 20:09:45 -05:00
{
2018-11-29 16:52:15 -05:00
player - > m_Qualities . SetInt64 ( AVAILABLE_EXPERIENCE_INT64 , player - > InqInt64Quality ( AVAILABLE_EXPERIENCE_INT64 , 0 ) + xpToAward ) ;
player - > NotifyInt64StatUpdated ( AVAILABLE_EXPERIENCE_INT64 ) ;
}
2018-09-22 20:09:45 -05:00
2018-11-29 16:52:15 -05:00
player - > SendText ( csprintf ( " Your trained %s skill has been removed. All the experience and skill credits that you spent on this skill have been refunded to you. " , pSkillBase - > _name . c_str ( ) ) , LTT_DEFAULT ) ;
2018-09-22 20:09:45 -05:00
}
2018-11-29 16:52:15 -05:00
else
{
2019-07-07 20:56:15 +00:00
uint64_t xpToAward = skill . _pp ;
2019-01-19 22:29:15 +00:00
skill . _pp = 526 ;
2018-11-29 16:52:15 -05:00
skill . _level_from_pp = 5 ;
skill . _init_level = 0 ;
player - > m_Qualities . SetSkill ( skillToAlter , skill ) ;
player - > NotifySkillStatUpdated ( skillToAlter ) ;
if ( xpToAward > 0 )
{
player - > m_Qualities . SetInt64 ( AVAILABLE_EXPERIENCE_INT64 , player - > InqInt64Quality ( AVAILABLE_EXPERIENCE_INT64 , 0 ) + xpToAward ) ;
player - > NotifyInt64StatUpdated ( AVAILABLE_EXPERIENCE_INT64 ) ;
}
2018-09-22 20:09:45 -05:00
2018-11-29 16:52:15 -05:00
player - > SendText ( csprintf ( " Your %s skill has been reset. All the experience that you spent on this skill have been refunded to you. " , pSkillBase - > _name . c_str ( ) ) , LTT_DEFAULT ) ;
}
2018-09-22 20:09:45 -05:00
}
2018-11-29 16:52:15 -05:00
break ;
}
2018-09-22 20:09:45 -05:00
}
2019-01-19 22:29:15 +00:00
SkillRefundValidationLog ( target_id , skillToAlter , debugSkillSacInit , debugInitAvailCredits ) ;
2018-09-22 20:09:45 -05:00
2018-09-17 22:55:33 -05:00
}
break ;
}
2018-10-04 21:23:45 -05:00
case SpendLuminance_EmoteType : //type: 112 spends luminance.
{
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
2019-07-07 20:56:15 +00:00
int64_t amount = emote . heroxp64 ;
int64_t lum = target - > m_Qualities . GetInt64 ( AVAILABLE_LUMINANCE_INT64 , 0 ) ;
2018-10-04 21:23:45 -05:00
if ( target )
{
2018-11-29 16:52:15 -05:00
if ( lum < amount )
2018-10-04 21:23:45 -05:00
break ;
2018-11-29 16:52:15 -05:00
2018-10-04 21:23:45 -05:00
target - > m_Qualities . SetInt64 ( AVAILABLE_LUMINANCE_INT64 , lum - amount ) ;
target - > NotifyInt64StatUpdated ( AVAILABLE_LUMINANCE_INT64 , false ) ;
2018-09-30 19:28:51 -05:00
}
2018-10-04 21:23:45 -05:00
break ;
}
2018-12-18 17:02:31 -06:00
case AwardLuminance_EmoteType :
{
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
if ( ! target )
break ;
2019-07-07 20:56:15 +00:00
int64_t amount = emote . heroxp64 ;
2018-12-18 17:02:31 -06:00
if ( amount < 0 )
amount = 0 ;
2020-04-29 20:27:46 -04:00
target - > GiveLum ( amount , true ) ;
2018-12-18 17:02:31 -06:00
break ;
}
2018-10-04 21:23:45 -05:00
case SetInt64Stat_EmoteType :
{
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
{
target - > m_Qualities . SetInt64 ( ( STypeInt64 ) emote . stat , emote . amount ) ;
target - > NotifyInt64StatUpdated ( ( STypeInt64 ) emote . stat , FALSE ) ;
}
break ;
}
2018-10-04 23:06:09 -04:00
case DeleteSelf_EmoteType :
{
2019-01-15 21:36:45 +00:00
if ( ! _weenie - > m_Qualities . _emote_table | | _weenie - > AsPlayer ( ) ) //don't know how we'd find ourselves deleting a player weenie...but just in case.
2018-10-04 23:06:09 -04:00
break ;
2019-01-15 21:36:45 +00:00
_weenie - > Remove ( ) ;
2018-10-04 23:06:09 -04:00
break ;
}
case KillSelf_EmoteType :
{
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
CMonsterWeenie * monster = _weenie - > AsMonster ( ) ;
if ( monster & & ! monster - > IsDead ( ) & & ! monster - > IsInPortalSpace ( ) & & ! monster - > IsBusyOrInAction ( ) )
{
monster - > SetHealth ( 0 , true ) ;
monster - > OnDeath ( monster - > GetID ( ) ) ;
}
break ;
}
case SetBoolStat_EmoteType :
{
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
if ( emote . extent = = 2 ) //if extent is 2 then set bool on self.
{
_weenie - > m_Qualities . SetBool ( ( STypeBool ) emote . stat , emote . amount ) ;
_weenie - > NotifyBoolStatUpdated ( ( STypeBool ) emote . stat , FALSE ) ;
}
else
{
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
{
target - > m_Qualities . SetBool ( ( STypeBool ) emote . stat , emote . amount ) ;
target - > NotifyBoolStatUpdated ( ( STypeBool ) emote . stat , FALSE ) ;
}
}
break ;
}
2018-10-20 16:09:06 -04:00
case InqPackSpace_EmoteType :
{
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
CPlayerWeenie * target = g_pWorld - > FindPlayer ( target_id ) ;
if ( target )
{
bool success = false ;
if ( target - > Container_GetNumFreeMainPackSlots ( ) > = emote . amount )
success = true ;
2018-10-04 23:06:09 -04:00
2018-10-20 16:09:06 -04:00
ChanceExecuteEmoteSet ( success ? TestSuccess_EmoteCategory : TestFailure_EmoteCategory , emote . msg , target_id ) ;
}
break ;
}
2018-10-20 19:23:44 -04:00
case TeleportTarget_EmoteType :
{
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
{
target - > Movement_Teleport ( emote . mPosition , false ) ;
}
break ;
}
case TeleportSelf_EmoteType :
{
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
_weenie - > Movement_Teleport ( emote . mPosition , false ) ;
break ;
}
case SetFloatStat_EmoteType :
{
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
if ( emote . extent = = 2 ) //if extent is 2 then set float on self.
{
2018-10-20 19:45:04 -04:00
_weenie - > m_Qualities . SetFloat ( ( STypeFloat ) emote . stat , emote . percent ) ;
2018-10-20 19:23:44 -04:00
_weenie - > NotifyFloatStatUpdated ( ( STypeFloat ) emote . stat , FALSE ) ;
}
else
{
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
{
2018-10-20 19:45:04 -04:00
target - > m_Qualities . SetFloat ( ( STypeFloat ) emote . stat , emote . percent ) ;
2018-10-20 19:23:44 -04:00
target - > NotifyFloatStatUpdated ( ( STypeFloat ) emote . stat , FALSE ) ;
}
}
2019-01-20 12:29:38 -08:00
break ;
2018-11-12 00:31:10 -06:00
}
case StartBarber_EmoteType :
{
if ( ! _weenie - > m_Qualities . _emote_table )
break ;
CWeenieObject * player = g_pWorld - > FindObject ( target_id ) - > AsPlayer ( ) ;
if ( player )
{
BinaryWriter writer ;
2019-07-07 20:56:15 +00:00
writer . Write < uint32_t > ( 0x75 ) ;
writer . Write < uint32_t > ( player - > InqDIDQuality ( PALETTE_BASE_DID , 0 ) ) ;
writer . Write < uint32_t > ( player - > InqDIDQuality ( HEAD_OBJECT_DID , 0 ) ) ;
writer . Write < uint32_t > ( 0 ) ; // Head Texture - TODO find where this is stored.
writer . Write < uint32_t > ( 0 ) ; // Default Head Texture - TODO find where this is stored.
writer . Write < uint32_t > ( player - > InqDIDQuality ( EYES_TEXTURE_DID , 0 ) ) ;
writer . Write < uint32_t > ( player - > InqDIDQuality ( DEFAULT_EYES_TEXTURE_DID , 0 ) ) ;
writer . Write < uint32_t > ( player - > InqDIDQuality ( NOSE_TEXTURE_DID , 0 ) ) ;
writer . Write < uint32_t > ( player - > InqDIDQuality ( DEFAULT_NOSE_TEXTURE_DID , 0 ) ) ;
writer . Write < uint32_t > ( player - > InqDIDQuality ( MOUTH_TEXTURE_DID , 0 ) ) ;
writer . Write < uint32_t > ( player - > InqDIDQuality ( DEFAULT_MOUTH_TEXTURE_DID , 0 ) ) ;
writer . Write < uint32_t > ( player - > InqDIDQuality ( SKIN_PALETTE_DID , 0 ) ) ;
writer . Write < uint32_t > ( player - > InqDIDQuality ( HAIR_PALETTE_DID , 0 ) ) ;
writer . Write < uint32_t > ( player - > InqDIDQuality ( EYES_PALETTE_DID , 0 ) ) ;
writer . Write < uint32_t > ( player - > InqDIDQuality ( SETUP_DID , 0 ) ) ;
2018-11-12 00:31:10 -06:00
if ( player - > m_Qualities . GetInt ( HERITAGE_GROUP_INT , 0 ) = = Empyrean_HeritageGroup )
{
2018-11-29 16:52:15 -05:00
if ( player - > m_Qualities . GetDID ( MOTION_TABLE_DID , 0 ) = = 0x900020D )
2018-11-12 00:31:10 -06:00
writer . Write < int > ( 1 ) ;
else
writer . Write < int > ( 0 ) ;
}
else if ( player - > m_Qualities . GetInt ( HERITAGE_GROUP_INT , 0 ) = = Undead_HeritageGroup )
{
// Option1 for Undead - TODO check for head flame enabled, if yes, send 1, else 0.
writer . Write < int > ( 0 ) ;
}
else
writer . Write < int > ( 0 ) ;
writer . Write < int > ( 0 ) ; // Option2 - Unused?
player - > SendNetMessage ( & writer , PRIVATE_MSG , FALSE , FALSE ) ;
}
2018-10-20 19:23:44 -04:00
break ;
}
2019-09-03 14:18:02 +00:00
case LocalSignal_EmoteType :
_weenie - > DoLocalSignal ( emote . msg ) ;
break ;
2018-10-04 21:23:45 -05:00
}
_weenie - > m_Qualities . SetBool ( EXECUTING_EMOTE , false ) ;
2018-03-29 17:01:57 -04:00
}
2018-10-04 23:06:09 -04:00
2018-03-29 17:01:57 -04:00
bool EmoteManager : : IsExecutingAlready ( )
{
2018-08-22 21:05:31 -07:00
return _weenie - > m_Qualities . GetBool ( EXECUTING_EMOTE , false ) ;
2018-03-29 17:01:57 -04:00
}
2018-09-30 19:28:51 -05:00
bool EmoteManager : : HasQueue ( )
{
return ! _emoteQueue . empty ( ) ;
}
2018-03-29 17:01:57 -04:00
void EmoteManager : : Tick ( )
{
if ( _emoteQueue . empty ( ) )
return ;
for ( std : : list < QueuedEmote > : : iterator i = _emoteQueue . begin ( ) ; i ! = _emoteQueue . end ( ) ; )
{
2018-07-12 14:41:21 -07:00
if ( i - > _executeTime > Timer : : cur_time | | _weenie - > IsBusyOrInAction ( ) | | _weenie - > IsMovingTo ( ) )
2018-03-29 17:01:57 -04:00
break ;
ExecuteEmote ( i - > _data , i - > _target_id ) ;
2018-10-04 23:06:09 -04:00
//Check if emote queue is empty due to KillSelf_emoteType
if ( _emoteQueue . empty ( ) )
return ;
2018-03-29 17:01:57 -04:00
i = _emoteQueue . erase ( i ) ;
if ( i ! = _emoteQueue . end ( ) )
2018-10-04 23:06:09 -04:00
i - > _executeTime = Timer : : cur_time + i - > _data . delay ;
2018-03-29 17:01:57 -04:00
}
}
void EmoteManager : : Cancel ( )
{
_emoteQueue . clear ( ) ;
}
2019-07-07 20:56:15 +00:00
void EmoteManager : : OnDeath ( uint32_t killer_id )
2018-03-29 17:01:57 -04:00
{
Cancel ( ) ;
2018-07-12 14:41:21 -07:00
if ( _weenie - > m_Qualities . _emote_table )
2018-03-29 17:01:57 -04:00
ChanceExecuteEmoteSet ( Death_EmoteCategory , killer_id ) ;
}
2019-07-07 20:56:15 +00:00
void EmoteManager : : killTask ( std : : string mobName , std : : string kCountName , uint32_t target_id )
2018-07-22 00:24:45 +00:00
{
{
CWeenieObject * target = g_pWorld - > FindObject ( target_id ) ;
if ( target )
{
2019-09-03 14:18:02 +00:00
fellowship_ptr_t fellow = target - > GetFellowship ( ) ; //are we in a fellowship
2018-07-22 00:24:45 +00:00
if ( ! fellow ) //nope
{
bool success = target - > InqQuest ( kCountName . c_str ( ) ) ; //are we flagged for this quest?
if ( success )
{
killTaskSub ( mobName , kCountName , target ) ; //execute stamping and messaging.
}
}
else //We are in a fellow
{
CWorldLandBlock * block = target - > GetBlock ( ) ; //set mob killed location.
for ( auto & entry : fellow - > _fellowship_table ) //for each entry of the fellow table.
{
if ( CWeenieObject * member = g_pWorld - > FindObject ( entry . first ) )
{
if ( member - > GetBlock ( ) = = block ) //are we local to the killed mob?
{
bool success = member - > InqQuest ( kCountName . c_str ( ) ) ; //are we flagged for this quest?
if ( success )
{
killTaskSub ( mobName , kCountName , member ) ; //execute stamping and messaging for this member of the fellow.
}
}
}
}
}
}
}
}
void EmoteManager : : killTaskSub ( std : : string & mobName , std : : string & kCountName , CWeenieObject * targormember )
{
targormember - > StampQuest ( kCountName . c_str ( ) ) ; //yes, stamp quest
int intQuestSolves = targormember - > InqQuestSolves ( kCountName . c_str ( ) ) ; //set quest solves to variable
auto strQuestSolves = std : : to_string ( intQuestSolves ) ; //convert int to string (we need integer value and string value)
2018-03-29 17:01:57 -04:00
2018-07-22 00:24:45 +00:00
int intMaxQsolves = targormember - > InqQuestMax ( kCountName . c_str ( ) ) ; //what is this quests max solves?
auto strMaxQsolves = std : : to_string ( intMaxQsolves ) ; //Convert to string (we need integer value and string value)
std : : string text ;
if ( intQuestSolves < intMaxQsolves ) //if quest solves are less than max execute inprogress msg.
{
text = " You have killed " + strQuestSolves + " " + mobName + " s. You must kill " + strMaxQsolves + " to complete your task! " ;
}
else //send msg quest complete msg
{
text = " You have killed " + strMaxQsolves + " " + mobName + " s. Your task is complete! " ; //NOTE: that the stamping functionality will exceed the max. so using questSolves instead of maxQsolves is prone to irregular numbers at completion.
}
if ( ! text . empty ( ) ) //send message
{
targormember - > SendNetMessage ( ServerText ( text . c_str ( ) , LTT_DEFAULT ) , PRIVATE_MSG , TRUE ) ;
}
2018-09-17 22:55:33 -05:00
}
2019-07-07 20:56:15 +00:00
void EmoteManager : : ConfirmationResponse ( bool accepted , uint32_t target_id )
2018-09-17 22:55:33 -05:00
{
2018-10-04 21:23:45 -05:00
if ( ! _confirmMsgList . empty ( ) )
{
if ( _confirmMsgList . find ( target_id ) ! = _confirmMsgList . end ( ) )
{
ChanceExecuteEmoteSet ( accepted ? TestSuccess_EmoteCategory : TestFailure_EmoteCategory , _confirmMsgList [ target_id ] , target_id ) ;
_confirmMsgList . erase ( target_id ) ;
}
}
2019-01-19 22:29:15 +00:00
}
2019-07-07 20:56:15 +00:00
void EmoteManager : : SkillRefundValidationLog ( uint32_t target_id , STypeSkill skillToAlter , SKILL_ADVANCEMENT_CLASS debugSkillSacInit , int debugInitAvailCredits )
2019-01-19 22:29:15 +00:00
{
//---------Validation Logging---------------
CPlayerWeenie * player = g_pWorld - > FindPlayer ( target_id ) ;
if ( ! player )
return ;
Skill skill ;
if ( ! player - > m_Qualities . InqSkill ( skillToAlter , skill ) )
return ;
if ( debugSkillSacInit ! = skill . _sac ) //Only do a credit report if the Skill Advancement Class changes. This is an indication we should have a change in credits. If a report generates 0 credit refund. We have a problem.
{
SkillTable * pSkillTable = SkillSystem : : GetSkillTable ( ) ;
int refundedCredits = player - > InqIntQuality ( AVAILABLE_SKILL_CREDITS_INT , 0 , TRUE ) - debugInitAvailCredits ;
SERVER_INFO < < " Char: " < < player - > GetName ( ) < < " Skill: " < < pSkillTable - > GetSkillName ( skillToAlter ) < < " Sac_Change: " < < Skill : : SkillSacToName ( debugSkillSacInit ) < < " -> " < < Skill : : SkillSacToName ( skill . _sac ) < < " Credit_Refund: " < < refundedCredits ;
}
if ( skillToAlter = = 54 ) //Last skill tested by Fianhe (1-54). Will suffice as an end of skill reset trigger.
{
//Insure that the default skills are back at trained (or specialized in the case of salvaging)
2019-01-20 12:29:38 -08:00
std : : list < STypeSkill > defaultSkillGroup = { ARCANE_LORE_SKILL , RUN_SKILL , JUMP_SKILL , MAGIC_DEFENSE_SKILL , LOYALTY_SKILL , SALVAGING_SKILL } ;
2019-01-19 22:29:15 +00:00
std : : string PassFail = " PASS " ;
for ( auto skillName : defaultSkillGroup )
{
SkillTable * pSkillTable = SkillSystem : : GetSkillTable ( ) ;
const SkillBase * pSkillBase = pSkillTable - > GetSkillBase ( skillName ) ;
if ( pSkillBase ! = NULL )
{
Skill skill ;
if ( ! player - > m_Qualities . InqSkill ( skillName , skill ) )
continue ;
if ( skill . _sac ! = TRAINED_SKILL_ADVANCEMENT_CLASS & & skillName ! = SALVAGING_SKILL )
{
PassFail = " FAIL " ;
break ;
}
2019-01-20 12:29:38 -08:00
if ( skillName = = SALVAGING_SKILL & & ! ( skill . _sac = = TRAINED_SKILL_ADVANCEMENT_CLASS | | skill . _sac = = SPECIALIZED_SKILL_ADVANCEMENT_CLASS ) )
2019-01-19 22:29:15 +00:00
{
PassFail = " FAIL " ;
break ;
}
}
}
2019-01-20 12:29:38 -08:00
SERVER_INFO < < " Char: " < < player - > GetName ( ) < < " DefaultSkills: " < < PassFail < < " Level: " < < player - > InqIntQuality ( LEVEL_INT , 0 , TRUE ) < < " Credits: " < < player - > GetTotalSkillCredits ( ) < < " Expected: " < < player - > GetExpectedSkillCredits ( ) ;
2019-01-19 22:29:15 +00:00
}
2019-01-20 12:29:38 -08:00
2019-07-30 02:19:05 +00:00
}