Files
2026-06-01 12:46:52 +02:00

553 lines
17 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include "K3DTypes.h"
#include "KObject.h"
#include "ArcadiaClient.h"
#include <toolkit/IQueue.h>
#include "SGameObject.h"
//#include <vector>
//이것들은 나중에 한 곳으로 몰자~
#define DEFAULT_ACTIVE 0
#define GAME_TYPE_01 0
#define GAME_TYPE_02 1
#define GAME_TYPE_03 2
#define GAME_TYPE_04 3
#define GAME_TYPE_05 4
#define GAME_TYPE_06 5
#define GAME_TYPE_07 6
#define GAME_TYPE_08 7
#define GAME_TYPE_09 8
#define GAME_TYPE_10 9
class KSequencer;
class K3DCamera;
class K3DRenderDeviceDX;
class KViewportObject;
class SSoundManager;
class K3DTexture;
class KTextureManager;
class KNX3Manager;
class SGameMilesSoundMgr;
class SGameLoad;
class SGameEffect;
class SGameViewPort;
class SShadowViewPort;
class SGameVM;
class SGameInterface;
class KUIGenWnd;
//Game DB
struct SBASICSTAT_DATA;
struct SCREATURE_DATA;
struct SITEM_DATA;
struct SJOB_DATA;
struct SMONSTER_DATA;
struct SSKILL_DATA;
struct STENACITY_DATA;
struct SGameMessage;
struct STMSG_TIMESYNC;
struct SMSG_LOGIN;
struct TS_MESSAGE;
struct TS_MOVE;
struct TS_MOVE_ACK;
struct TS_REGION_ACK;
struct TS_LEAVE;
struct TS_ENTER;
struct TS_LOGIN_RESULT;
struct TS_TIMESYNC;
#define RAMADAN_PRAY_ROOM1 10000
#define RAMADAN_PRAY_ROOM2 10001
#define RAMADAN_PRAY_ROOM_X 1
#define RAMADAN_PRAY_ROOM_Y 0
/// [sonador] SWeatherAttr forward declaratino
namespace env_fx {
#ifdef DISTANCE_VIEW
struct SSkyBoxAttr;
struct SDistanceViewAttr;
#endif
struct SWeatherAttr;
struct SWeatherInfo;
struct SThunderAttr;
struct SLightningAttr;
}
/** SGame 초기화 지시
"GAMECREATE" */
struct KCreateGameMessage : public KArg
{
KCreateGameMessage( float _x, float _y ) : x( _x ), y( _y ) { }
float x, y;
};
struct FX_DATA
{
FX_DATA()
{
nFX_ID = 0;
nEffPos = 0;
owner = 0;
attack = 0;
target = 0;
nMode = 0;
//NORMAL Mode
nPlayID = 0;
fPlayRate = 1.f;
//STATE Mode
nStateCode = 0;
end_time = 0; ///< 상태 이상 종료 시간
state_handle = 0; ///< 상태 이상 핸들
bIsLoop = false; ///< 반복되는 Fx인가
keyhandleid = -1;
keytime = -1;
bDir = true;
}
//공통
int nFX_ID;
int nEffPos;
AR_HANDLE owner;
AR_HANDLE attack;
AR_HANDLE target;
int nMode;
//--NORMAL Mode
int nPlayID;
float fPlayRate;
//--STATE Mode
unsigned short nStateCode; ///< 상태 이상 코드
AR_TIME end_time; ///< 상태 이상 종료 시간
unsigned short state_handle;///< 상태 이상 핸들
bool bIsLoop;
int keyhandleid;
int keytime;
bool bDir;
};
struct FX_DATA_EX
{
FX_DATA_EX( const char* pEffectName, int nFlag, AR_HANDLE hOwner, AR_HANDLE hCaster, AR_HANDLE hTarget, int nUseBoneIndex, bool bOwnerDir = false, int nAniType = 0, float fPlayRate = 4.8f, AR_TIME end_time = 0)
{
m_pEffectName = pEffectName;
m_nFlag = nFlag;
m_owner = hOwner;
m_caster = hCaster;
m_target = hTarget;
m_nUseBoneIndex = nUseBoneIndex;
m_nAniType = nAniType;
m_fPlayRate = fPlayRate;
m_end_time = end_time;
m_bIsOwnerDir = bOwnerDir;
}
const char * m_pEffectName;
int m_nFlag; ///< 1이면 따라감 2이면 활 공격
AR_HANDLE m_owner;
AR_HANDLE m_caster;
AR_HANDLE m_target;
int m_nUseBoneIndex;
int m_nAniType;
float m_fPlayRate;
AR_TIME m_end_time;
bool m_bIsOwnerDir;
};
struct ATTACK_FX_DATA
{
ATTACK_FX_DATA() : nFX_ID(0),
hAttack(0),
hTarget(0)
{
}
int nFX_ID;
AR_HANDLE hAttack;
AR_HANDLE hTarget;
};
enum
{
GAME_TYPE_LOAD = 0, // Loading screen
GAME_TYPE_TUTORIAL, // Tutorial
GAME_TYPE_LOGIN, // Login
GAME_TYPE_SELECT, // Character selection
GAME_TYPE_WORLD, // World
GAME_TYPE_MOVIE, // Cinematic/movie
GAME_TYPE_END, // Ended/terminated game
};
struct STRUCT_CREATURE_CMD_SCRIPT
{
enum C_CMD_SCRIPT
{
CMD_NONE = 0,
CMD_STANDBY,
CMD_IDLE,
CMD_MOVE,
CMD_ATTACK,
CMD_SKILL
};
AR_HANDLE mHandle;
AR_HANDLE cHandle;
AR_HANDLE tHandle;
C_CMD_SCRIPT nCmdScipt;
short nSlotNum;
short nCreaturePosition;
};
enum GET_PLAYER_INFO
{
GET_HP = 0,
GET_MP,
GET_MAXHP,
GET_MAXMP,
GET_PERCENTHP,
GET_PERCENTMP,
};
//===============================================================================
/// SGame : Game 하나~
class SGame : public SGameObject
{
public:
enum
{
STAGE_NOTHING = 0, // Nothing
STAGE_LOADING, // Loading data
STAGE_MAP_LOAD_BUFFER, // Screen transition before map loading
STAGE_MAP_PRELOAD, // Preload map
STAGE_MAP_LOADING, // The meaning isnt perfect… lets use it together.
STAGE_MAP_LOADING_AFTER, // Process messages accumulated after map loading completes
STAGE_ING, // Processing
STAGE_FADE_IN, // Fade In
STAGE_FADE_IN_END, // Fade In Finished
STAGE_FADE_OUT, // Fade Out
STAGE_FADE_OUT_END, // Fade Out Finished
STAGE_EVENT_SCENE, // Playing an event scene
STAGE_WARP_COMPLETE, // Warp complete
STAGE_END, // End, move to next Stage
};
SGame( class SGameManager*, int nGameType, K3DRenderDeviceDX *pRenderDevice, SSoundManager * pSoundMng,
KTextureManager * pTextureMng, KNX3Manager * pNX3Mng, SGameMilesSoundMgr* pMSoundMgr );
virtual ~SGame(void);
virtual unsigned char GetGameObjectType( AR_HANDLE objHandle ){ assert(0); return 0; };
virtual void ApplyOption( int nOptionType ) {};
virtual void ToggleHelpWindow() {};
virtual void SetViewPort( class SGameViewPort* pViewPort );
virtual void SetRenderFlag( int nFlag ) { assert(0); };
virtual bool Render( unsigned long uRenderBitVector, KViewportObject** ppViewPortList, int nViewportCount );
virtual bool Process( DWORD time, unsigned long uProcessBitVector=0 );
virtual void AfterRender( unsigned long uRenderBitVector ) {};
virtual void AssistTarget( AR_HANDLE handle ) { assert(0); };
virtual void DropItem( AR_HANDLE handle ) { assert(0); };
virtual void ProcConsole( struct SGameMessage* pGameMsg );
virtual void *Perform( KID id, KArg& msg ) { return (void*)0; }
virtual void AddSummon( class SGameAvatarEx * pSummon, struct SMSG_ENTER* pEnterMsg ) { assert(0); };
virtual void LeaveSummon( AR_HANDLE hLeaveHandle ) { assert(0); };
virtual void DelSummon( AR_HANDLE hCreature ) { assert(0); };
virtual void EvolutionSummon( struct SMSG_SUMMON_EVOLUTION* pMsg ) { assert(0); }
virtual void AddSkillProp( class SGameAvatarEx * pSkillProp ) { assert(0); }
virtual void SetPlayerAttack( class SGameAvatarEx * pTarget ) {};
virtual struct DATA_CREATURE * IsLocalCreature( AR_HANDLE handle ) { return NULL; }
virtual SGameAvatarEx* IsSummonCreature( AR_HANDLE handle ) { return NULL; }
// { sonador 10.2.1 팻 시스템 구현
/// if there exists a local pet has the handle which has passed through, return it's data structure
virtual struct DATA_PET* IsLocalPet( AR_HANDLE handle ) { return NULL; }
/// 이 팻이 소환되어 있는 상태인가?
virtual SGameAvatarEx* IsSummonPet( AR_HANDLE handle ) { return NULL; }
/// 로컬 팻우리인가? 그렇다면, 해당 데이터를 반환한다.
virtual struct DATA_PET* IsLocalPetCage( AR_HANDLE handle ) { return NULL; }
/// add pet whose master is local player
virtual void AddPet( class SGameAvatarEx* pet, struct SMSG_ENTER* enterMsg ) { assert( 0 ); }
/// remove pet whose master is local player
virtual void RemovePet( AR_HANDLE handle ) { assert( 0 ); }
// }
//Effect==========================================================================
virtual int AddEffectTest( const char * pFileName, AR_HANDLE hOwner );
virtual int AddEffect( FX_DATA * pFX_data );
virtual int AddEffect( FX_DATA_EX * pFX_data );
virtual int AddEffect( AR_HANDLE hAttacker, AR_HANDLE hTarget, AR_HANDLE hOwner, int nEffectID, int nEffectPos, bool bIsLoopFx );
virtual int AddAttackEffect( FX_DATA * fxdata );
virtual void DelEffect( int nEffectID );
virtual void DelOwnerEffect( AR_HANDLE hOwner );
virtual void EndLoopFx( int nEffectID );
virtual void OnDamage( AR_HANDLE target, struct SGameMessage* pDamage ) {}
virtual void OnSkillDamage( AR_HANDLE caster, AR_HANDLE target, struct SGameMessage* pDamage ) {}
virtual void OnDotDamage( struct SMSG_DAMAGE* pDamage, bool bFinalDmg = false ) {}
virtual void OnDisplayDamage( struct SMSG_DAMAGE* pDamage ) {}
virtual void OnUISync( AR_HANDLE caster, AR_HANDLE target ) {}
virtual void AddStateEffect( SGameMessage * pGameMsg );
virtual void UpdateStateEffect( SGameMessage * pGameMsg );
virtual void DelStateEffect( SGameMessage * pGameMsg );
virtual void DelStateEffect( int nDelObjType );
/// 인터페이스 메니저로 바로 처리
virtual void SendGameInterfaceMsg( struct SGameMessage * game_msg );
//Particle========================================================================
virtual int AddEnhanceEffect( class SGameAvatarEx* pAvatar, int nWeaponEffectPos, struct EnhanceFX* pEnhanceFx, int nItemClass );
virtual void RemoveEnhanceEffect( int nEnhanceFxID );
virtual void SetRenderEnhanceFx( int nEnhanceFxID, bool bRender );
/// Network 설정====================================================================
virtual void SetNet( ArcadiaClient * pObject )
{
m_pArObject = pObject;
}
const ArPosition & GetTargetPos() { return m_pArObject->GetTargetPos(); }
virtual void ProcMsgAtStatic( SGameMessage * pGameMsg );
virtual bool onLeave( _Object *pPtr ) { return true; };
//Send 메세지~
virtual void PendMessage( const TS_MESSAGE * pMessage );
virtual void SendMsg( SGameObject *pGO, const TS_MESSAGE *msg );
virtual void SendMsg( const TS_MESSAGE *msg );
virtual void ReqMove( AR_HANDLE handle, const ArPosition & target, const ArPosition * targetposdata, int count, bool bSpeedSync );
virtual void Bot_Accept( int nSelect, const char * pName ) {}
/// 프로세스, 네트웍 Send 까지 모두 막는다.
virtual void StopProcess() { m_bStopProc = true; }
bool IsStopProcess() { return m_bStopProc; }
bool IsUIWindowOpened( int nWindowID );
bool IsWebPageWndOpened();
/// Game 상태 관련
void SetGameRef( int nGameRef );
int GetGameRef() { return m_nGameRef; }
/// 더 이상 사용 안 함
void SetGameTypeEnd() { m_nGameType = GAME_TYPE_END; }
int GetGameType() { return m_nGameType; }
int GetNextGameType() { return m_nNextGameType; }
/// Game이나, 맵엔진 쪽으로 빼야 한다.
K3DTexture * CreateBump(K3DRenderDeviceDX *pDevice);
K3DCamera* GetCamera() { return m_pCamera; }
SGameViewPort* GetViewPort() { return m_pViewPort; }
virtual void OnSysCommand( const char *pChat, std::vector< std::string > & vToken );
//게임 옵션 관련
virtual void WarpComplete( struct SGameMessage * pMsg ) {};
virtual void Game_LensFlare ( BOOL bFlag ) {};
virtual void Game_Cloud ( BOOL bFlag ) {};
virtual void Game_Prop ( BOOL bFlag ) {};
virtual void Game_Effect ( BOOL bFlag ) {};
virtual void Game_Sound ( BOOL bFlag ) {};
virtual void Game_Music ( BOOL bFlag ) {};
virtual void Game_Resolution ( int nResolution ) {};
virtual void Game_FSAA ( int nSize ) {};
virtual void Game_Cloud_vis ( float fVisibility ) {};
virtual void Game_Cloud_speed( float fSpeed ) {};
virtual void Game_Camera_fov ( float fFov ) {};
virtual void Game_Mip_Range ( float fRange ) {};
virtual void Game_Mip_Bias ( float fMipBias ) {};
virtual void Game_Sky_Color ( int nR, int nG, int nB, int nA ) {};
virtual void Game_Fog_Color ( int nR, int nG, int nB, int nA ) {};
virtual void Game_Target_CamPos( int nX, int nY, int nZ ) {};
virtual void Game_Sound_Set_Volume( int nVolume );
virtual void Game_Env_Off ( bool bOnOff );
virtual void Game_Music_Off( bool bOnOff );
virtual void Game_Light ( int type, K3DColor col ) {};
virtual void Game_Light_Pos ( int nX, int nY, int nZ ) {};
virtual void Game_Fog_Height_Start( float nUnit ) {};
virtual void Game_Fog_Height_End ( float nUnit ) {};
virtual void Game_Fog_Linear_Start( float nUnit ) {};
virtual void Game_Fog_Linear_End ( float nUnit ) {};
virtual void Game_Sky_Color_Start( int nR, int nG, int nB ) {};
virtual void Game_Sky_Color_Mid ( int nR, int nG, int nB ) {};
virtual void Game_Sky_Color_End ( int nR, int nG, int nB ) {};
virtual void Game_Sky_Color_MaxHeight( int nMaxHeight ) {};
virtual void Game_Sky_Color_MidHeightPercent( float fMidHeightPercent ) {};
virtual void Game_Sky_Color_MinHeight( int nMinHeight ) {};
virtual void Game_Cloud_Color( int nR, int nG, int nB, int nA ) {};
virtual void Game_Terrain_Specular( float fSpecular ) {};
virtual void Game_CharSkin_Color( float fAmbiant, float fDiffuse ) {};
virtual void Game_DryWet_Volume( float fDryVol, float fWetVol ) {};
virtual void Game_Effect_Light( int type, K3DColor col ) {};
virtual void Game_Effect_Light_Range( int nRange ) {};
virtual void Game_Effect_Light_Attenuation( float fAttenuation ) {};
virtual void SetUI_TargetActiveInfo( AR_HANDLE handle, int nType ) {};
virtual bool IsAttack(class SGameAvatarEx* pPickObject, int nSkillID = 0) { return false; }
//virtual bool IsAttack( class SGameAvatarEx * pPickObject ) { return false; }
virtual void AddGameInput( class SGameInput * pInput ) {};
void SetCheatMode( int nMode );
int GetCheatMode() { return m_nCheatMode; }
enum
{
CHEAT_NONE,
CHEAT_MODE01,
CHEAT_MODE02,
CHEAT_MODE03,
};
/// 크리처 스크립 명령어
virtual void SendCreatureCmdScript( STRUCT_CREATURE_CMD_SCRIPT &sCCmdScr ){};
virtual int GetSelectedState( AR_HANDLE handle, GET_PLAYER_INFO nInfo ){ return 0; };
/// { [sonador] 날씨 스크립 명령어
virtual int GetWeatherTheme() const { return 0; }
virtual void SetWeatherTheme( env_fx::SWeatherInfo* pInfo ) {}
virtual void ChangeWeatherState( int nState ) {}
virtual void SetThunderAttribute( env_fx::SThunderAttr* pAttr ) {}
virtual void SetLightningAttribute( env_fx::SLightningAttr* pAttr ) {}
// }
#ifdef DISTANCE_VIEW
virtual env_fx::SSkyBoxAttr* GetSkyThemeInfo() const { return 0; }
virtual void SetSkyThemeInfo( env_fx::SSkyBoxAttr* pAttr ) {}
virtual env_fx::SDistanceViewAttr* GetDistanceViewInfo() const { return 0; }
virtual void SetDistanceViewInfo( env_fx::SDistanceViewAttr* pDistanceViewInfo ) {}
virtual bool ChangeDistanceView( int local_id ) { return 1; }
#endif
/// 자동이동 명령
virtual K3DVector* GetWayPoint( int& nWayPointID ){ return NULL; }
///지역 관련 명령
virtual void SetLocalInfo( int nLocalID ) {}
virtual void SetWorldInfo() {}
int GetEnhanceRecycleID();
/// 파티클 치트키
void ParticleQuality( int nQuality );
void ParticleLifeTime( DWORD dwLifeTime );
void ParticleMoveSpeed( float fSpeed );
void ParticleSize( float fStartSize, float fEndSize );
void ParticleEmitRadius( K3DVector vEmitRadius );
void ParticleEmitRate( float fMin, float fMax );
void ParticleCreateInterval( float fInterval );
void ParticleMinDirection( K3DVector vMinDirection );
void ParticleMaxDirection( K3DVector vMaxDirection );
void EnhanceFxType( int nType );
int IsFriend( AR_HANDLE Handle, unsigned char& rType );
bool CheckCameraDistance( SGameObject* pObject );
SGameManager* GetGameManager() { return m_pGameMng; } // 2011.07.07 - servantes
virtual class CTerrainMapEngine* getTerrainMapEngine() const { return NULL; }
protected:
SGameEffect* CreateEffect( const char * pEffectName, int nFlag, AR_HANDLE owner, AR_HANDLE caster, AR_HANDLE target, int nUseBoneIndex, int nAniType, float fPlayRate, AR_TIME end_time, bool bIsOwnerDir );
void _AllDelEffect();
void AllDelParticle();
bool m_bStopProc;
ArcadiaClient m_Object;
DWORD m_dwTime;
FLOAT m_fTime; ///< Current time in seconds
float m_fAccumTime; ///< the global time - Speed Tree
FLOAT m_fElapsedTime; ///< Time elapsed since last frame
//Select Character Index
int m_nCurSelect;
int m_nSpecialSelect;
//Render
K3DRenderDeviceDX* m_pRenderDevice;
SSoundManager* m_pSoundMng;
KTextureManager* m_pTextureMng;
KNX3Manager* m_pNX3Mng;
SGameMilesSoundMgr* m_pMSoundMgr;
K3DCamera* m_pCamera;
SGameViewPort* m_pViewPort;
//Effect
std::vector< class SGameEffect* > m_vEffectList;
int m_nEffectID; ///< 순차 Effect ID 발급
std::vector< class SGameEffectEx* > m_vNewEffectList;
int m_nNewEffectID; ///< 순차 Effect ID 발급
std::vector< class SGameAttackEffect* > m_vAttackEffectList;
int m_nAttackEffectID;
//파티클
std::vector< class SGameEnhanceFx* > m_vEnhanceFxList;
int m_nNewEnhanceFxID;
queue< int > m_RecycleID; ///< 재사용할 파티클 아이디
//Network
ArcadiaClient * m_pArObject;
int m_nDeltaX;
int m_nDeltaY;
int m_nDeltaSpeed;
int m_nGameRef; ///< 게임 상태 참조
int m_nGameType; ///< 게임 타입
int m_nNextGameType; ///< 다음 예약 게임 타입
class SGameManager * m_pGameMng; //
int m_nCheatMode; //
};