📄 hero.cpp
字号:
// Hero.cpp: implementation of the CHero class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Hero.h"
#include "GameIn.h"
#include "MHCamera.h"
#include "ObjectManager.h"
#include "MoveManager.h"
#include "ObjectStateManager.h"
#include "MinimapDialog.h"
#include "ItemManager.h"
#include "StatsCalcManager.h"
#include "SkillManager_Client.h"
#include "KyungGongManager.h"
#include "TacticManager.h"
#include "PartyManager.h"
#include "MugongManager.h"
#include "ObjectGuagen.h"
#include "./Audio/MHAudioManager.h"
#include "StreetStallManager.h"
#include "CheatMsgParser.h"
#include "interface/cWindowManager.h"
#include "OptionManager.h"
#include "WantedManager.h"
#include "ChatManager.h"
#include "MixDialog.h"
#include "ReinforceDlg.h"
#include "UpgradeDlg.h"
#include "DissolutionDialog.h"
#ifdef _DEBUG
#include "interface\cFont.h"
#include "ChatManager.h"
#endif
#include "WindowIdEnum.h"
#include "ReviveDialog.h"
#include "CharacterDialog.h"
#include "InventoryExDialog.h"
#include "DealDialog.h"
#include "CharStateDialog.h"
#include "mhMap.h"
#include "GameEventManager.h"
#include "BattleSystem_Client.h"
#include "NpcScriptDialog.h"
#include "CommonCalcFunc.h"
#include "AppearanceManager.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
VECTOR3 gHeroPos;
CHero::CHero()
{
m_NextAction.Clear();
m_CurComboNum = 0;
m_maxExpPoint = 0;
m_PyogukNum = 0;
m_bUngiFlag = FALSE;
m_AbilityGroup.SetOwenerObject(this);
}
CHero::~CHero()
{
Release();
}
void CHero::InitHero(HERO_TOTALINFO * pHeroTotalInfo)
{
m_DelayGroup.Init();
m_bSkillCooling = 0;
m_MovingAction.Clear();
m_NextAction.Clear();
m_SkillStartAction.Clear();
m_bIsAutoAttackMode = TRUE;
m_bIsAutoAttacking = FALSE;
m_bIsKyungGongMode = FALSE;
memcpy(&m_HeroTotalInfo, pHeroTotalInfo, sizeof(HERO_TOTALINFO));
m_maxExpPoint = GAMERESRCMNGR->GetMaxExpPoint(GetLevel());
// m_HeroTotalInfo.KyungGongGrade = OPTIONMGR->GetKyungGongIdx(); //***
// m_bIsKyungGongMode = OPTIONMGR->GetKyungGongMode(); //***
//牢磐其捞胶俊 利侩
//ApplyInterface(); RegisterHero肺 颗辫
STATSMGR->Clear(&m_itemStats);
}
#define SKILL_PERSUIT_TICK 1000
void CHero::Process()
{
static DWORD dwSkillPersuitTime = 0;
CPlayer::Process();
CAMERA->Process(); //? Gamin狼 橇肺技胶俊 乐促. KES 040406 //卿.. 咯扁辑 救窍聪 墨皋扼啊 如甸赴促.
if(m_MovingAction.HasAction())
{
if(m_MovingAction.CheckTargetDistance(&GetCurPosition()) == TRUE)
{
MOVEMGR->HeroMoveStop();
m_MovingAction.ExcuteAction(this);
m_MovingAction.Clear();
}
else
{
if( m_MovingAction.GetActionKind() == eActionKind_Skill )
{
if( gCurTime - dwSkillPersuitTime > SKILL_PERSUIT_TICK )
{
m_MovingAction.ExcuteAction(this);
dwSkillPersuitTime = gCurTime;
}
}
else if( MOVEMGR->IsMoving(this) == FALSE )
{
m_MovingAction.Clear();
}
// if(MOVEMGR->IsMoving(this) == FALSE)
// {
// if(m_MovingAction.GetActionKind() == eActionKind_Skill)
// {
// m_MovingAction.ExcuteAction(this);
// }
// else
// m_MovingAction.Clear();
// }
}
}
else
{
if(m_bIsAutoAttacking)
{
if(m_NextAction.HasAction() == FALSE)
{
if(GetCurComboNum() < 2 || GetCurComboNum() == SKILL_COMBO_NUM) // 磊悼傍拜篮 霓焊 2鳖瘤父 12/3老 雀狼 搬苞 3俊辑 2肺 官柴
{
if(SKILLMGR->OnSkillCommand(this,&m_AutoAttackTarget,FALSE) == FALSE)
DisableAutoAttack();
}
}
}
}
SKILLMGR->UpdateSkillObjectTargetList(this);
// 版傍
if(m_bIsKyungGongMode)
{
if( MOVEMGR->IsMoving(this) &&
m_MoveInfo.KyungGongIdx == 0 &&
GetKyungGongGrade() &&
GetMoveSpeed() != 0 &&
GetState() != eObjectState_Ungijosik)
{
if(m_MoveInfo.m_bEffectMoving == FALSE)
{
CKyungGongInfo* pKGInfo = KYUNGGONGMGR->GetKyungGongInfo(GetKyungGongGrade());
DWORD ElapsedTime = gCurTime - m_ObjectState.State_Start_Time;
if(ElapsedTime > pKGInfo->GetChangeTime())
{
MOVEMGR->ToggleHeroKyungGongMode();
}
}
}
}
// 胶懦 酿鸥烙
if(m_bSkillCooling)
{
if(gCurTime - m_SkillCoolTimeStart > m_SkillCoolTimeDuration)
m_bSkillCooling = FALSE;
}
VECTOR3 pos;
float angle;
GetPosition(&pos);
angle = GetAngle();
// 弊覆磊侩 扼捞飘 捞悼阑 困秦
MAP->SetShadowPivotPos(&pos);
// 3D 荤款靛狼 Listener 汲沥阑 困秦
AUDIOMGR->SetListenerPosition(&pos,angle);
// 磷菌阑锭 老沥茄 矫埃捞 瘤唱搁 芒 剁款促.
// if(GetState() == eObjectState_Die)
// {
// if( gCurTime - GetStateStartTime() > PLAYERREVIVE_TIME ) //老沥 矫埃父 甸绢啊霸
// {
//if( ) 厚公肺 磷菌促. 酒聪促.
//犬牢夸噶! confirm //process啊 蠢啡促搁 NONE老 荐档 乐促.
// if( BATTLESYSTEM->GetBattle(this)->GetBattleKind() == eBATTLE_KIND_NONE )
// {
// WANTEDMGR->SetActiveDialog();
// }
// }
// }
if(GetState() == eObjectState_SkillUsing)
{
if(gCurTime - GetStateStartTime() > 10000)
{
OBJECTSTATEMGR->EndObjectState(this,eObjectState_SkillUsing);
}
}
gHeroPos = pos;
// Play Time 扁废
m_HeroTotalInfo.Playtime += gTickTime/1000;
}
void CHero::GetHeroTotalInfo(HERO_TOTALINFO * info)
{
ASSERT(info);
memcpy(info, &m_HeroTotalInfo, sizeof(HERO_TOTALINFO));
}
void CHero::ApplyInterface()
{
#ifndef _TESTCLIENT_
SetMoney(m_HeroTotalInfo.Money);
SetLevel(m_CharacterInfo.Level);
SetMaxLife(m_CharacterInfo.MaxLife);
SetLife(m_CharacterInfo.Life, 0);
SetMaxNaeRyuk(m_HeroTotalInfo.wMaxNaeRyuk);
SetNaeRyuk(m_HeroTotalInfo.wNaeRyuk, 0);
SetMaxExpPoint(m_maxExpPoint);
SetExpPoint(m_HeroTotalInfo.ExpPoint);
SetGenGol(m_HeroTotalInfo.wGenGol);
SetMinChub(m_HeroTotalInfo.wMinChub);
SetCheRyuk(m_HeroTotalInfo.wCheRyuk);
SetSimMek(m_HeroTotalInfo.wSimMek);
SetPartyIdx(m_HeroTotalInfo.PartyID);
SetMunpaMemberRank(m_CharacterInfo.PositionInMunpa);
SetMunpaID(m_CharacterInfo.MunpaID);
SetMunpaName(m_HeroTotalInfo.MunpaName);
SetGuageName(m_BaseObjectInfo.ObjectName);
SetMunpa();
SetBadFame(m_CharacterInfo.BadFame);
#endif
}
void CHero::SetGuageName(char * szName)
{
cStatic* ps = (cStatic *)GAMEIN->GetGuageDlg()->GetWindowForID(CG_GUAGENAME);
if( ps ) ps->SetStaticText( szName );
}
void CHero::SetMaxLife(DWORD maxlife)
{
CPlayer::SetMaxLife(maxlife);
DWORD newMaxLife = GetMaxLife();
if(newMaxLife == 0)
{
newMaxLife = 1;
}
((CObjectGuagen*)GAMEIN->GetGuageDlg()->GetWindowForID(CG_GUAGELIFE))->SetValue(
(float)m_CharacterInfo.Life/(float)newMaxLife, 0 );
// 牢磐其捞胶 霸捞瘤 函版
GAMEIN->GetCharacterDialog()->SetLife(m_CharacterInfo.Life);
// 牢磐其捞胶 : 荐摹 钎矫
char szValue[50];
sprintf( szValue, "%d / %d", GetLife(), newMaxLife );
cStatic* ps = (cStatic *)GAMEIN->GetGuageDlg()->GetWindowForID(CG_GUAGELIFETEXT);
if( ps ) ps->SetStaticText( szValue );
}
void CHero::SetMaxShield(DWORD maxShield)
{
CPlayer::SetMaxShield(maxShield);
DWORD newMaxShield = GetMaxShield();
if(newMaxShield == 0)
{
newMaxShield = 1;
}
((CObjectGuagen*)GAMEIN->GetGuageDlg()->GetWindowForID(CG_GUAGESHIELD))->SetValue(
(float)m_CharacterInfo.Shield/(float)newMaxShield, 0 );
// 牢磐其捞胶 霸捞瘤 函版
GAMEIN->GetCharacterDialog()->SetShield(m_CharacterInfo.Shield);
// 牢磐其捞胶 : 荐摹 钎矫
char szValue[50];
sprintf( szValue, "%d / %d", GetShield(), newMaxShield );
cStatic* ps = (cStatic *)GAMEIN->GetGuageDlg()->GetWindowForID(CG_GUAGESHIELDTEXT);
if( ps ) ps->SetStaticText( szValue );
}
void CHero::Heal(CObject* pHealer,BYTE HealKind,DWORD HealVal)
{
ChangeLife(HealVal);
}
void CHero::ChangeLife(int changeval)
{
DWORD newlife = GetLife() + changeval;
SetLife(newlife);
if( m_bUngiFlag == FALSE )
if( newlife )
if( (GetMaxLife()/newlife) > 2 )
{
GAMEEVENTMGR->AddEvent(eGameEvent_Ability, 401);
m_bUngiFlag = TRUE;
}
}
void CHero::ChangeShield(int changeval)
{
if(changeval < 0)
{
ASSERT((int)GetShield() >= (-changeval));
}
DWORD newShield = GetShield() + changeval;
DWORD maxShield = GetMaxShield();
SetShield(newShield);
}
void CHero::SetLife(DWORD life, BYTE type)
{
CPlayer::SetLife(life);
// 牢磐其捞胶 霸捞瘤 函版
DWORD MaxLife = GetMaxLife();
if(MaxLife == 0)
{
MaxLife = 1;
}
if(GetState() == eObjectState_Die)
life = 0;
((CObjectGuagen*)GAMEIN->GetGuageDlg()->GetWindowForID(CG_GUAGELIFE))->SetValue(
(float)life/(float)MaxLife,
(type == 0 ? 0 : (2000/MaxLife)*life) );
GAMEIN->GetCharacterDialog()->SetLife(life);
// 牢磐其捞胶 : 荐摹 钎矫
char szValue[50];
sprintf( szValue, "%d / %d", life, GetMaxLife() );
cStatic* ps = (cStatic *)GAMEIN->GetGuageDlg()->GetWindowForID(CG_GUAGELIFETEXT);
if( ps ) ps->SetStaticText( szValue );
}
void CHero::SetShield(DWORD Shield, BYTE type)
{
CPlayer::SetShield(Shield);
// 牢磐其捞胶 霸捞瘤 函版
DWORD MaxShield = GetMaxShield();
if(MaxShield == 0)
{
MaxShield = 1;
}
if(GetState() == eObjectState_Die)
Shield = 0;
((CObjectGuagen*)GAMEIN->GetGuageDlg()->GetWindowForID(CG_GUAGESHIELD))->SetValue(
(float)Shield/(float)MaxShield,
(type == 0 ? 0 : (2000/MaxShield)*Shield) );
GAMEIN->GetCharacterDialog()->SetShield(Shield);
// 牢磐其捞胶 : 荐摹 钎矫
char szValue[50];
sprintf( szValue, "%d / %d", Shield, GetMaxShield() );
cStatic* ps = (cStatic *)GAMEIN->GetGuageDlg()->GetWindowForID(CG_GUAGESHIELDTEXT);
if( ps ) ps->SetStaticText( szValue );
}
void CHero::SetMoney(MONEYTYPE Money)
{
m_HeroTotalInfo.Money = Money;
if(GAMEIN->GetInventoryDialog())
GAMEIN->GetInventoryDialog()->SetMoney(Money);
}
void CHero::SetKyungGongGrade(WORD grade)
{
m_HeroTotalInfo.KyungGongGrade = grade;
// if(grade != 0)
// OPTIONMGR->SetKyungGongIdx(HERO->GetKyungGongGrade());//***
GAMEIN->GetCharacterDialog()->UpdateData();
}
void CHero::SetMaxExpPoint(EXPTYPE dwPoint)
{
m_maxExpPoint = dwPoint;
float value = (float)GetExpPoint()/(float)m_maxExpPoint;
((CObjectGuagen*)GAMEIN->GetGuageDlg()->GetWindowForID(CG_GUAGEEXPPOINT))->SetValue( value, 0 );
GAMEIN->GetCharacterDialog()->SetExpPointPercent( value*100 );
// 牢磐其捞胶 : 荐摹 钎矫
char szValue[50];
sprintf( szValue, "%d / %d", GetExpPoint(), dwPoint );
cStatic* ps = (cStatic *)GAMEIN->GetGuageDlg()->GetWindowForID(CG_GUAGEEXPPOINTTEXT);
if( ps ) ps->SetStaticText( szValue );
}
void CHero::SetExpPoint(EXPTYPE dwPoint, BYTE type)
{
m_HeroTotalInfo.ExpPoint = dwPoint;
// 牢磐其捞胶 霸捞瘤 函版
float value = (float)dwPoint/(float)m_maxExpPoint;
DWORD valueTime = (type == 0)? 0 : (2000/m_maxExpPoint)*dwPoint;
if(GetLevel() == 99 || type == 0 )
((CObjectGuagen*)GAMEIN->GetGuageDlg()->GetWindowForID(CG_GUAGEEXPPOINT))->SetValue( 1, 0 );
else
((CObjectGuagen*)GAMEIN->GetGuageDlg()->GetWindowForID(CG_GUAGEEXPPOINT))->SetValue( value, valueTime );
// 牢磐其捞胶 : 某腐磐 芒
CObjectGuagen* ps = (CObjectGuagen *)GAMEIN->GetCharacterDialog()->GetWindowForID(CI_EXPPOINTGUAGE);
if( ps )
{
if(type == 0)
ps->SetValue( value, 0 );
else
ps->SetValue( value, valueTime );
}
GAMEIN->GetCharacterDialog()->SetExpPointPercent(value*100);
// 牢磐其捞胶 : 荐摹 钎矫
char szValue[50];
if(GetLevel() >= 99)
sprintf( szValue, "[ %s ]", CHATMGR->GetChatMsg(179) ); //"[ 枨 ]"
else
sprintf( szValue, "%.2f%%", value*100 );
#ifdef _CHEATENABLE_
if(CHEATMGR->IsCheatEnable())
{
char buf1[66];
wsprintf(buf1, " %d/%d", dwPoint, GetMaxExpPoint());
strcat(szValue, buf1);
}
#endif
cStatic* ps2 = (cStatic *)GAMEIN->GetGuageDlg()->GetWindowForID(CG_GUAGEEXPPOINTTEXT);
if( ps2 ) ps2->SetStaticText( szValue );
}
void CHero::SetLevel(LEVELTYPE level)
{
// 牢磐其捞胶 芒 钎矫 荐摹 函版
GAMEIN->GetCharacterDialog()->SetLevel(level);
cStatic* ps = (cStatic *)GAMEIN->GetGuageDlg()->GetWindowForID(CG_GUAGELEVEL);
if( ps ) ps->SetStaticValue( level );
// 饭骇诀矫 捞棋飘钎矫
if(level > CPlayer::GetLevel())
{
EFFECTMGR->StartEffectProcess(eEffect_LevelUpSentence,HERO,NULL,0,0);
}
CPlayer::SetLevel(level);
//祸 函券
ITEMMGR->RefreshAllItem();
}
void CHero::SetMaxNaeRyuk(DWORD val)
{
m_HeroTotalInfo.wMaxNaeRyuk = val;
// 牢磐其捞胶 霸捞瘤 函版
DWORD newMaxNaeRyuk = GetMaxNaeRyuk();
if(newMaxNaeRyuk == 0)
{
newMaxNaeRyuk = 1;
}
((CObjectGuagen*)GAMEIN->GetGuageDlg()->GetWindowForID(CG_GUAGENAERYUK))->SetValue(
(float)m_HeroTotalInfo.wNaeRyuk/(float)newMaxNaeRyuk, 0 );
GAMEIN->GetCharacterDialog()->SetNaeRyuk(m_HeroTotalInfo.wNaeRyuk);
// 牢磐其捞胶 : 荐摹 钎矫
char szValue[50];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -