// Object.cpp: implementation of the CObject class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Object.h"
#include "MoveManager.h"
#include "ObjectManager.h"
#include "GameIn.h"
#include "ObjectStateManager.h"
#include "./interface/cWindowManager.h"
#include "./Interface/cScriptManager.h"
#include "ObjectBalloon.h"
#include "OBalloonChat.h"
#include "OBalloonName.h"
#include "StreetStallTitleTip.h"
#include "StunState.h"
#include "AmplifiedPower.h"
#include "ObjectGuagen.h"
#include "GameResourceManager.h"
#include "Status.h"
#include "MOTIONDESC.h"
#include "Hero.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CObject::CObject()
{
m_pSpecialState[eSpecialState_Stun] = new CStunState(this);
m_pSpecialState[eSpecialState_AmplifiedPowerPhy] = new CAmplifiedPowerPhy(this);
m_pSpecialState[eSpecialState_AmplifiedPowerAtt] = new CAmplifiedPowerAtt(this);
m_pObjectBalloon = NULL;
m_bObjectBalloonBits = 0;
m_StateEffectList.Initialize(1);
m_pMotionDESC = NULL;
m_bSelected = FALSE;
m_ObjectKind = 0;
}
CObject::~CObject()
{
Release();
for(int n=0;n delete m_pSpecialState[n];
}
BOOL CObject::Init(EObjectKind kind,BASEOBJECT_INFO* pBaseObjectInfo)
{
for(int n=0;n m_pSpecialState[n]->Init();
m_bMoveSkipCount = 0;
m_bIsYMoving = FALSE;
memcpy(&m_BaseObjectInfo,pBaseObjectInfo,sizeof(m_BaseObjectInfo));
m_ObjectKind = kind;
m_ObjectState.bEndState = FALSE;
SetFlag(FALSE);
//m_bDieFlag = FALSE;
m_bInited = TRUE;
return TRUE;
}
void CObject::InitObjectBalloon(BYTE bitFlag)
{
m_pObjectBalloon = new CObjectBalloon;
m_bObjectBalloonBits = bitFlag;
if(GetObjectKind() == eObjectKind_Player)
{
// 巢磊, 趣篮 咯磊
m_pObjectBalloon->InitBalloon(this, 170, bitFlag);
}
else if(GetObjectKind() & eObjectKind_Monster)
{
m_pObjectBalloon->InitBalloon(this, ((CMonster *)this)->GetSInfo()->Tall, bitFlag);
}
else
{
m_pObjectBalloon->InitBalloon(this, 180, bitFlag);
}
if(bitFlag & ObjectBalloon_Name)
{
m_pObjectBalloon->GetOBalloonName()->InitName(m_BaseObjectInfo.ObjectName);
// m_pObjectBalloon->GetOBalloonName()->SetTall(-20); // -20?
if(GetObjectKind() == eObjectKind_Player)
{
// if( ((CPlayer*)this)->GetMunpaMemberRank() > MUNPA_SEMIMEMBER )
// SetMunpaMark();
if( ((CPlayer*)this)->GetGuildMarkName() > 0 )
SetGuildMark();
}
}
if(bitFlag & ObjectBalloon_Chat)
{
// chat
cImage top1;
cImage top2;
cImage top3;
cImage middle1;
cImage middle2;
cImage middle3;
cImage bottom1;
cImage bottom2;
cImage bottom3;
cImage tail;
SCRIPTMGR->GetImage(66, &top1);
SCRIPTMGR->GetImage(67, &top2);
SCRIPTMGR->GetImage(68, &top3);
SCRIPTMGR->GetImage(69, &middle1);
SCRIPTMGR->GetImage(70, &middle2);
SCRIPTMGR->GetImage(71, &middle3);
SCRIPTMGR->GetImage(72, &bottom1);
SCRIPTMGR->GetImage(73, &bottom2);
SCRIPTMGR->GetImage(74, &bottom3);
SCRIPTMGR->GetImage(75, &tail);
m_pObjectBalloon->GetOBalloonChat()->InitBalloon(&top1, &top3, &bottom1, &bottom3, &middle1, &middle3, &top2, &bottom2, &middle2, &tail, 8);
// m_pObjectBalloon->GetOBalloonChat()->SetTall(-50);
// RaMa - 04.11.29 ->盲泼苞 畴痢惑篮 3锅狼 坊歹肺 嘛绰促.
cImage left1;
cImage left2;
cImage left3;
cImage center1;
cImage center2;
cImage center3;
cImage right1;
cImage right2;
cImage right3;
SCRIPTMGR->GetImage(99, &left1);
SCRIPTMGR->GetImage(100, ¢er1);
SCRIPTMGR->GetImage(101, &right1);
SCRIPTMGR->GetImage(102, &left2);
SCRIPTMGR->GetImage(103, ¢er2);
SCRIPTMGR->GetImage(104, &right2);
SCRIPTMGR->GetImage(105, &left3);
SCRIPTMGR->GetImage(106, ¢er3);
SCRIPTMGR->GetImage(107, &right3);
m_pObjectBalloon->GetOBalloonChat()->InitBalloonForChat(&left1, ¢er1, &right1,
&left2, ¢er2, &right2, &left3, ¢er3, &right3, 8);
}
if( bitFlag & ObjectBalloon_Title)
{
// StreetStall Title
cImage top1;
cImage top2;
cImage top3;
cImage middle1;
cImage middle2;
cImage middle3;
cImage bottom1;
cImage bottom2;
cImage bottom3;
SCRIPTMGR->GetImage(66, &top1);
SCRIPTMGR->GetImage(67, &top2);
SCRIPTMGR->GetImage(68, &top3);
SCRIPTMGR->GetImage(69, &middle1);
SCRIPTMGR->GetImage(70, &middle2);
SCRIPTMGR->GetImage(71, &middle3);
SCRIPTMGR->GetImage(72, &bottom1);
SCRIPTMGR->GetImage(73, &bottom2);
SCRIPTMGR->GetImage(74, &bottom3);
m_pObjectBalloon->GetSSTitleTip()->InitBalloon(&top1, &top3, &bottom1, &bottom3, &middle1, &middle3, &top2, &bottom2, &middle2, NULL, 8);
// m_pObjectBalloon->GetSSTitleTip()->SetTall(0);
// RaMa - 04.11.29 ->盲泼苞 畴痢惑篮 3锅狼 坊歹肺 嘛绰促.
cImage left1;
cImage left2;
cImage left3;
cImage center1;
cImage center2;
cImage center3;
cImage right1;
cImage right2;
cImage right3;
SCRIPTMGR->GetImage(99, &left1);
SCRIPTMGR->GetImage(100, ¢er1);
SCRIPTMGR->GetImage(101, &right1);
SCRIPTMGR->GetImage(102, &left2);
SCRIPTMGR->GetImage(103, ¢er2);
SCRIPTMGR->GetImage(104, &right2);
SCRIPTMGR->GetImage(105, &left3);
SCRIPTMGR->GetImage(106, ¢er3);
SCRIPTMGR->GetImage(107, &right3);
m_pObjectBalloon->GetSSTitleTip()->InitBalloonForChat(&left1, ¢er1, &right1,
&left2, ¢er2, &right2, &left3, ¢er3, &right3, 8);
}
}
//void CObject::AddChatBalloon( char * chatMsg )
//{
// ShowChatBalloon( TRUE, chatMsg );
//}
//-----
void CObject::SetOverInfoOption( DWORD dwOption )
{
if( m_pObjectBalloon )
m_pObjectBalloon->SetOverInfoOption( dwOption );
}
void CObject::SetMunpaMark()
{
if( m_pObjectBalloon )
m_pObjectBalloon->SetMunpaMark( ((CPlayer*)this)->GetMunpaIdx() );
}
void CObject::SetGuildMark()
{
if( m_pObjectBalloon )
m_pObjectBalloon->SetGuildMark( ((CPlayer*)this)->GetGuildMarkName() );
}
void CObject::ShowObjectName( BOOL bShow, DWORD dwColor ) //show/hide
{
if( !m_pObjectBalloon ) return;
if( !(m_bObjectBalloonBits & ObjectBalloon_Name) ) return;
m_pObjectBalloon->ShowObjectName( bShow, dwColor );
}
void CObject::ShowChatBalloon( BOOL bShow, char* chatMsg, DWORD dwColor, DWORD dwAliveTime )
{
if( !m_pObjectBalloon ) return;
if( !(m_bObjectBalloonBits & ObjectBalloon_Chat) ) return;
m_pObjectBalloon->ShowChatBalloon( bShow, chatMsg, dwColor, dwAliveTime );
}
//-----
void CObject::InitMove(BASEMOVE_INFO* pMoveInfo)
{
memset(&m_MoveInfo,0,sizeof(MOVE_INFO));
memcpy(&m_MoveInfo,pMoveInfo,sizeof(BASEMOVE_INFO));
}
void CObject::Release()
{
m_StatusList.RemoveAll();
for(int n=0;n m_pSpecialState[n]->EndState();
m_bMoveSkipCount = 0;
m_bInited = FALSE;
if(m_ShadowObj.IsInited())
{
m_ShadowObj.Release();
}
RemoveAllObjectEffect();
m_ObjectKind = 0;
m_BaseObjectInfo.ObjectState = -1;
m_EngineObject.Release();
SAFE_DELETE( m_pObjectBalloon );
m_bObjectBalloonBits = 0;
}
void CObject::GetBaseObjectInfo(BASEOBJECT_INFO* pRtInfo)
{
memcpy(pRtInfo,&m_BaseObjectInfo,sizeof(BASEOBJECT_INFO));
}
void CObject::GetBaseMoveInfo(BASEMOVE_INFO* pRtInfo)
{
memcpy(pRtInfo,&m_MoveInfo,sizeof(BASEMOVE_INFO));
}
void CObject::Process()
{
SpecialStateProcess(gTickTime);
OBJECTSTATEMGR->StateProcess(this);
MOVEMGR->MoveProcess(this);
if(m_ShadowObj.IsInited())
m_ShadowObj.SetEngObjPosition(&GetCurPosition());
/*
HEFFPROC hEff;
m_StateEffectList.SetPositionHead();
while(hEff = m_StateEffectList.GetData())
EFFECTMGR->Process(gCurTime,hEff);
*/
}
void CObject::SetFlag(BOOL val)
{
m_bDieFlag = val;
}
void CObject::SetDieFlag()
{
m_DiedTime = gCurTime;
// 磷菌阑锭狼 贸府
SetFlag(TRUE);
// m_bDieFlag = TRUE;
MOVEMGR->MoveStop(this);
HERO->ClearTarget(this);
// LBS 03.11.21
if( OBJECTMGR->GetSelectedObjectID() == GetID() )
{
OBJECTMGR->SetSelectedObjectID(0);
//KES 眠啊 //咯扁辑 窍绰霸 捞惑窍促. 阁胶磐霸捞瘤甫 混妨滴扁困秦辑 粱 部看促.
OnDeselected();
if( OBJECTMGR->CanOverInfoChange( this ) )
ShowObjectName( FALSE );
else
ShowObjectName( TRUE, OBJECTMGR->GetObjectNameColor(this) );
//
}
// OBJECTSTATEMGR->StartObjectState(this, eObjectState_Die);
//CHATMGR->AddMsg( CTC_TOWHOLE, CHATMGR->GetChatMsg(133), );
// 磷栏搁 努腐 救登霸 窃
m_EngineObject.DisablePick();
}
void CObject::Revive(VECTOR3* pRevivePos)
{
SetFlag(FALSE);
// m_bDieFlag = FALSE;
MOVEMGR->SetPosition(this,pRevivePos);
}
void CObject::SetState(BYTE State)
{
SetMotionInState(State);
if(m_ObjectState.State_Start_Motion != -1)
{
// if(State != m_BaseObjectInfo.ObjectState)
ChangeMotion(m_ObjectState.State_Start_Motion,FALSE);
if(m_ObjectState.State_Ing_Motion != -1)
ChangeBaseMotion(m_ObjectState.State_Ing_Motion);
}
m_ObjectState.BeforeState = m_BaseObjectInfo.ObjectState;
m_BaseObjectInfo.ObjectState = State;
m_ObjectState.State_Start_Time = gCurTime;
m_ObjectState.bEndState = FALSE;
}
BYTE CObject::GetState()
{
return m_BaseObjectInfo.ObjectState;
}
void CObject::SetPosition(VECTOR3* pPos)
{
GetEngineObject()->SetEngObjPosition(pPos);
}
void CObject::SetAngle(float AngleRad)
{
GetEngineObject()->SetEngObjAngle(AngleRad);
}
void CObject::GetPosition(VECTOR3* pPos)
{
GetEngineObject()->GetEngObjPosition(pPos);
ASSERTMSG(pPos->x > -1000,"捞 皋技瘤 档 辣龋茄抛 楷遏阑...");
ASSERTMSG(pPos->z > -1000,"捞 皋技瘤 档 辣龋茄抛 楷遏阑...");
}
float CObject::GetAngle()
{
return GetEngineObject()->GetEngObjAngle();
}
DIRINDEX CObject::GetDirectionIndex()
{
float angleRad = GetAngle();
DIRINDEX dir = RADTODIR(angleRad);
while(dir >= MAX_DIRECTION_INDEX)
dir -= MAX_DIRECTION_INDEX;
return dir;
}
void CObject::AddStatus(CStatus* pStatus)
{
m_StatusList.AddTail(pStatus);
}
void CObject::RemoveStatus(CStatus* pStatus)
{
BOOL rt = m_StatusList.Remove(pStatus);
}
void CObject::ChangeMotion(int motion,BOOL bRoop)
{
GetEngineObject()->ChangeMotion(motion,bRoop);
}
void CObject::ChangeBaseMotion(int motion)
{
GetEngineObject()->ChangeBaseMotion(motion);
}
float CObject::GetAttDefense(WORD Attrib)
{
if(Attrib == ATTR_NOATTR) // 公加己篮 加己规绢仿捞 0捞促.
return 0;
float Ori = DoGetAttDefense(Attrib);
float Up = 0,Down = 0;
PTRLISTSEARCHSTART(m_StatusList,CStatus*,pSL)
pSL->GetAttDefense(Attrib,Ori,Up,Down);
PTRLISTSEARCHEND;
float res = STATUSCALC(Ori,Up,Down);
if(res > 1)
res = 1;
return res;
}
void CObject::OnSelected()
{
GetEngineObject()->EnableSelfIllumin();
m_bSelected = TRUE;
}
void CObject::OnDeselected()
{
GetEngineObject()->DisableSelfIllumin();
m_bSelected = FALSE;
}
void CObject::SetBattle(DWORD BattleID,BYTE Team)
{
m_BaseObjectInfo.BattleID = BattleID;
m_BaseObjectInfo.BattleTeam = Team;
}
void CObject::AddObjectEffect(DWORD KeyValue,OBJECTEFFECTDESC* EffectNumArray,WORD NumOfEffect)
{
// test
if(GetState() == eObjectState_Die)
{
int a=0;
}
HEFFPROC heff;
// 扁粮俊 乐带 捞棋飘甫 茫绰促.
BOOL bFound = FALSE;
m_StateEffectList.StartGetMultiData(KeyValue);
while(heff = (HEFFPROC)m_StateEffectList.GetMultiData())
{
EFFECTMGR->IncEffectRefCount(heff);
bFound = TRUE;
}
// 乐菌栏搁 府畔 //kes***
if(bFound == TRUE)
return;
// 绝菌栏搁 货肺 父电促.
for(int n=0;n {
if(EffectNumArray[n].Effect == 0)
continue;
heff = EFFECTMGR->StartSkillMainTainEffect(
EffectNumArray[n].Effect,this,EffectNumArray[n].Flag,&EffectNumArray[n].Position);
if(heff == NULL)
continue;
m_StateEffectList.Add((void*)heff,KeyValue);
}
}
void CObject::RemoveObjectEffect(DWORD KeyValue)
{
HEFFPROC heff;
// 扁粮俊 乐带 捞棋飘甫 茫绰促.
BOOL bFound = FALSE;
m_StateEffectList.StartGetMultiData(KeyValue);
while(heff = (HEFFPROC)m_StateEffectList.GetMultiData())
{
if(EFFECTMGR->ForcedEndEffect(heff) == TRUE)
m_StateEffectList.RemoveCurMultiData();
}
}
void CObject::RemoveAllObjectEffect()
{
HEFFPROC heff;
m_StateEffectList.SetPositionHead();
while(heff = (HEFFPROC)m_StateEffectList.GetData())
{
while(EFFECTMGR->ForcedEndEffect(heff) == FALSE)
{}
}
m_StateEffectList.RemoveAll(); //KES 府胶飘俊辑 瘤况档 登唱? forceEnd啊 救等版快绰..confirm
}
int CObject::GetMotionIDX(int mainMotion, int subMotion)
{
return m_pMotionDESC->GetMotionIDX(mainMotion, subMotion);
}
void CObject::Die(CObject* pAttacker,BOOL bFatalDamage,BOOL bCritical)
{
for(int n=0;n m_pSpecialState[n]->EndState();
// RemoveAllObjectEffect();
// m_StatusList.RemoveAll();
}
void CObject::StartSpecialState(DWORD SpecialStateKind,DWORD Time,
WORD wParam1,WORD wParam2,float fParam3,
WORD EffectNum,WORD StateIcon)
{
m_pSpecialState[SpecialStateKind]->StartState(Time,wParam1,wParam2,fParam3,EffectNum,StateIcon);
}
void CObject::EndSpecialState(DWORD SpecialStateKind)
{
m_pSpecialState[SpecialStateKind]->EndState();
}
BOOL CObject::IsInSpecialState(DWORD SpecialStateKind)
{
return m_pSpecialState[SpecialStateKind]->IsInState();
}
void CObject::SpecialStateProcess(DWORD TickTime)
{
for(int n=0;n {
m_pSpecialState[n]->Process(TickTime);
}
}
WORD CObject::GetSpecialStateParam1(DWORD SpecialStateKind)
{
return m_pSpecialState[SpecialStateKind]->GetParam1();
}
WORD CObject::GetSpecialStateParam2(DWORD SpecialStateKind)
{
return m_pSpecialState[SpecialStateKind]->GetParam2();
}
BOOL CObject::IsNpcMark( DWORD dwValue )
{
HEFFPROC heff = (HEFFPROC)m_StateEffectList.GetData( dwValue );
if( heff )
return TRUE;
return FALSE;
}