?? cbevent.cpp
字號:
/////////////////////////
// CBEvent.cpp : v0010
// Written by : Liu Gang
// Compiler : Microsoft Visual C++ 4.2
// v0010 : Jun.9.1997
/////////////////////////
// 觸發(fā)事件處理
#include "stdafx.h"
#include "CBEvent.h"
#include "Assert.h"
#include "CBGame.h"
#include "CBMap.h"
#include "interfac.h"
#include "DDCompo.h" // Oct.6.1997, DDC_UpdateScreen()
#include "CBDraw.h" // Oct.6.1997, DRAW_UpdateScreen()
#include "CBEyes.h" // Oct.8.1997, EYE_IfFocusOnUnit()
#include "CBPrompt.h" // Oct.8.1997, FACE_UpdateMorale()
#include "CBRDelay.h" // Oct.13.1997, RUN_MOULUE_nConsume[CTRL_JIMOU_MAX];
#include "CBCtrl.h" // Oct.13.1997, CTRL_TASK_DeployByComputer()
#include "CBRun.h"
//added by tian yue
#include "temperor.h"
#define ISINREVOLT 100
#define ISMIZHU 101
#define ISZHAOYUN 102
#define JUIADOU 103
#define L14SCUESS 104
#define LEVELSCUESS 105
//第 5 關(guān):EventPos[5][0] == 1 魏延反叛
//第 8 關(guān):EventPos[8][0] == 1 糜竺回到右下角
//EventPos[8][1] == 1 救阿斗
//EventPos[8][2] == 1 趙云返回右下角 此關(guān)結(jié)束
//第14 關(guān):EventPos[5][0] == 1 遇到趙云
//EventPos[5][1] == 1 遇到張飛
//EventPos[5][2] == 1 遇到關(guān)羽 此關(guān)結(jié)束
WORD EventPos[34][5];
//define the spectial pos.
// 第5關(guān)
// 魏延反叛
#define SAFEAREA5_1EX 56
#define SAFEAREA5_1EY 135
// 到達(dá)目的地
#define SAFEAREA5_2EX 96
#define SAFEAREA5_2EY 275
// 第8關(guān)
// 糜竺回到右下角
#define SAFEAREA8_1EX 100
#define SAFEAREA8_1EY 300
// 救阿斗
#define SAFEAREA8_2EX 10
#define SAFEAREA8_2EY 85
// 趙云返回右下角
#define SAFEAREA8_3EX 100
#define SAFEAREA8_3EY 300
// 張飛所在的位置
#define SAFEAREA8_4EX 91
#define SAFEAREA8_4EY 273
// 曹操部隊所在的位置
#define SAFEAREA8_5EX 87
#define SAFEAREA8_5EY 262
// 第14關(guān)
#define SAFEAREA14_EX 20
#define SAFEAREA14_EY 43
// 第19關(guān)
// 到該地點就放火
#define SAFEAREA19_EX 50
#define SAFEAREA19_EY 60
// 第20關(guān)
// 到該地點就放火
#define SAFEAREA20_EX 63
#define SAFEAREA20_EY 241
// 第29關(guān)
// 到該地點就放火
#define SAFEAREA29_EX 54
#define SAFEAREA29_EY 171
// 第30關(guān)
#define SAFEAREA30_EX 20
#define SAFEAREA30_EY 43
// 初始化
void EVENT_Init()
{
memset( EventPos, 0, sizeof( EventPos ) );
}
int TY_Event(WORD Level);
inline BOOL EVENT_Main( int nGameID )
{
//5 蔡冒降曹
//8 救阿斗
//8 張飛喝斷長坂
//8 趙云返回右下角
//14 遇到趙云
//14 遇到張飛
//14 遇到關(guān)羽
return TY_Event( nGameID );
}
void TY_BateMorale( int nPlayer, int num )
{
WORD i;
UNIT_STRUCT * Pobject;
for (i=0;i<PLAYER_GROUP_MAX;i++)
{
if (i >= GAME.Players[nPlayer].wGroupCounter)
{
return;
}
if (GAME.Players[nPlayer].wGroup[i] != MAP_DATA_NONE)
{
Pobject=MAP_GetUnit(GAME.Players[nPlayer].wGroup[i]);
if (EYE_IfUnitIsDead(Pobject) != TRUE)
{
Pobject->Gen.nMorale+=num;
if ( EYE_IfFocusOnUnit( Pobject ) )
{
FACE_UpdateMorale( EYE_GetMorale( Pobject ) ) ;
}
}
}
}
}
inline BOOL EVENT_Fire( int nGameID, int nPlayer, int nX, int nY )
{
WORD codeG = MAP_GetGroundData( 0, nX, nY );
Assert( codeG != MAP_DATA_NONE );
struct MAP_GROUND_CODE_STRUCT stctG;
MAP_GroundDeCode( codeG, &stctG );
int nFlag = -1;
// 該事件已經(jīng)發(fā)生過,退出
if( EventPos[nGameID][0] == 1 )
return FALSE;
switch( nGameID )
{
case 2:
// 曹軍在博望遭到火攻,損失慘重,士氣大降。
if( GAME.nMe == nPlayer && stctG.nFile != 2 ) // 在野外放火
{
nFlag = 1;
TY_BateMorale( AIPlayer, -40);
EventPos[nGameID][0] = 1;
}
break;
case 3:
// 曹軍在新野城內(nèi)被火燒,士氣降低
if( GAME.nMe == nPlayer && stctG.nFile == 2 ) // 在城內(nèi)放火
{
nFlag = 2;
TY_BateMorale(AIPlayer, -20);
EventPos[nGameID][0] = 1;
}
break;
case 13:
if( GAME.nMe == nPlayer && stctG.nFile == 3 ) // 在水里放火
{// 黃蓋詐降,曹軍疏于防備。
nFlag = 8;
TY_BateMorale(AIPlayer, -20);
EventPos[nGameID][0] = 1;
}
break;
case 19:
if( EventPos[nGameID][1] == 1 )
{ // 曹操中火計,曹軍在博望遭到火攻,損失慘重,士氣大降。
nFlag = 1;
TY_BateMorale(GAME.nMe, -20);
EventPos[nGameID][0] = 1;
}
break;
case 20:
if( EventPos[nGameID][1] == 1 )
{ // 曹操中火計,曹軍在新野城內(nèi)被火燒,士氣降低
nFlag = 2;
TY_BateMorale(GAME.nMe, -20);
EventPos[nGameID][0] = 1;
}
break;
case 29:
if( EventPos[nGameID][1] == 1 )
{ // 曹操中火計,黃蓋詐降,曹軍疏于防備,連鎖戰(zhàn)船被燒。
nFlag = 8;
// 曹操君主是3
TY_BateMorale(GAME.nMe, -20);
EventPos[nGameID][0] = 1;
}
break;
}
if( nFlag != -1 )
{
//FACE_ShowEvent( nFlag );
// Nov.21.1997
PostMessage( hwndGame, WM_SHOW_EVENT, nFlag, 0 );
return TRUE;
}
return FALSE;
}
int TY_Event(WORD Level)
{
UNIT_STRUCT *pUnit = NULL;
WORD i;
int ret = 0;
switch (Level)
{
case 5:
{
if (EventPos[Level][0] == 1)
break;
int bGet = FALSE;
// 劉備走到襄陽城外,蔡冒降曹 //魏延反叛
for ( i=0; i<PLAYER_GROUP_MAX; i++ )
{
if ( GAME.Players[GAME.nMe].wGroup[i] != MAP_DATA_NONE )
{
pUnit = MAP_GetUnit( GAME.Players[GAME.nMe].wGroup[i] );
Assert( pUnit );
Assert( EYE_IfUnitIsGen( pUnit ) );
if( EYE_IfUnitIsDead( pUnit ) == TRUE )
continue;
bGet = TRUE;
//劉備
if ( pUnit->Gen.nID == 40 )
{
if (pUnit->Draw.nX < SAFEAREA5_1EX+10
&&pUnit->Draw.nX > SAFEAREA5_1EX-10
&&pUnit->Draw.nY < SAFEAREA5_1EY+10
&&pUnit->Draw.nY > SAFEAREA5_1EY-10
)
{
EventPos[Level][0]=1;
//FACE_ShowEvent(3);
// Nov.21.1997
PostMessage( hwndGame, WM_SHOW_EVENT, 3, 0 );
TY_BateMorale(AIPlayer, -50);
//TY_Conspiracy();
}
break;
}
}
}
// 劉備到達(dá)江陵,本關(guān)游戲結(jié)束
if( bGet == TRUE )
{
if (pUnit->Draw.nX < SAFEAREA5_2EX+10
&&pUnit->Draw.nX > SAFEAREA5_2EX-10
&&pUnit->Draw.nY < SAFEAREA5_2EY+10
&&pUnit->Draw.nY > SAFEAREA5_2EY-10
)
{
ret = 1;
}
}
}
break;
case 8:
//Oct.6.1997
// 糜竺回到右下角
/*
if (EventPos[Level][0] == 0)
{
for (i=0;i<PLAYER_GROUP_MAX;i++)
{
if ( GAME.Players[GAME.nMe].wGroup[i] != MAP_DATA_NONE )
{
pUnit = MAP_GetUnit( GAME.Players[GAME.nMe].wGroup[i] );
Assert( pUnit );
Assert( EYE_IfUnitIsGen( pUnit ) );
// 糜竺
if ( !EYE_IfUnitIsDead( pUnit )
&& pUnit->Gen.nID == 45 )
{
if (pUnit->Draw.nX < SAFEAREA8_1EX+10
&&pUnit->Draw.nX > SAFEAREA8_1EX-10
&&pUnit->Draw.nY < SAFEAREA8_1EY+10
&&pUnit->Draw.nY > SAFEAREA8_1EY-10
)
{
EventPos[Level][0]=1;
//FACE_ShowEvent(4);
// Nov.21.1997
PostMessage( hwndGame, WM_SHOW_EVENT, 4, 0 );
//return (ISMIZHU);
}
}
}
}
}
*/
// 救阿斗
if (EventPos[Level][1] == 0)
{
for (i=0;i<PLAYER_GROUP_MAX;i++)
{
if ( GAME.Players[GAME.nMe].wGroup[i] != MAP_DATA_NONE )
{
pUnit = MAP_GetUnit( GAME.Players[GAME.nMe].wGroup[i] );
Assert( pUnit );
Assert( EYE_IfUnitIsGen( pUnit ) );
//趙云
if ( !EYE_IfUnitIsDead( pUnit )
&& pUnit->Gen.nID == 34 )
{
if (pUnit->Draw.nX < SAFEAREA8_2EX+10
&&pUnit->Draw.nX > SAFEAREA8_2EX-10
&&pUnit->Draw.nY < SAFEAREA8_2EY+10
&&pUnit->Draw.nY > SAFEAREA8_2EY-10
)
{
EventPos[Level][1]=1;
//FACE_ShowEvent(6);
// Nov.21.1997
PostMessage( hwndGame, WM_SHOW_EVENT, 6, 0 );
SAFEPOS=1;
// 把枯井刪除
MAP_SetGroundData( 1, 10, 84, MAP_DATA_NONE );
MAP_SetGroundData( 1, 11, 84, MAP_DATA_NONE );
MAP_SetGroundData( 1, 10, 83, MAP_DATA_NONE );
MAP_SetGroundData( 1, 10, 85, MAP_DATA_NONE );
DRAW_UpdateScreen();
//return (JUIADOU);
}
break;
}
else
{
pUnit = NULL;
}
}
}
}
// 趙云返回右下角,游戲結(jié)束
if (EventPos[Level][2] == 0
&& EventPos[Level][1] == 1) // 第個事件(救阿斗)已經(jīng)發(fā)生
{
for (i=0;i<PLAYER_GROUP_MAX;i++)
{
if ( GAME.Players[GAME.nMe].wGroup[i] != MAP_DATA_NONE )
{
pUnit = MAP_GetUnit( GAME.Players[GAME.nMe].wGroup[i] );
Assert( pUnit );
Assert( EYE_IfUnitIsGen( pUnit ) );
//趙云
if ( !EYE_IfUnitIsDead( pUnit )
&& pUnit->Gen.nID == 34 )
{
if (pUnit->Draw.nX < SAFEAREA8_3EX+10
&&pUnit->Draw.nX > SAFEAREA8_3EX-10
&&pUnit->Draw.nY < SAFEAREA8_3EY+10
&&pUnit->Draw.nY > SAFEAREA8_3EY-10
)
{
EventPos[Level][2]=1;
ret = 1;
}
break;
}
}
}
}
// 張飛喝斷長坂橋
// 當(dāng)敵人接近某橋頭,而張飛在另一個橋頭的時候,士氣降為30
if (EventPos[Level][3] == 0 )
//&& EventPos[Level][1] == 1) // 第個事件(救阿斗)已經(jīng)發(fā)生
{
BOOL bEvent = FALSE;
for (i=0;i<PLAYER_GROUP_MAX;i++)
{
// 曹操方的部隊
if ( GAME.Players[AIPlayer].wGroup[i] != MAP_DATA_NONE )
{
pUnit = MAP_GetUnit( GAME.Players[AIPlayer].wGroup[i] );
Assert( pUnit );
Assert( EYE_IfUnitIsGen( pUnit ) );
// 所有部隊
if ( !EYE_IfUnitIsDead( pUnit ) )
{
if (pUnit->Draw.nX < SAFEAREA8_5EX+10
&&pUnit->Draw.nX > SAFEAREA8_5EX-10
&&pUnit->Draw.nY < SAFEAREA8_5EY+10
&&pUnit->Draw.nY > SAFEAREA8_5EY-10
)
{
bEvent = TRUE;
break;
}
}
}
}
if( bEvent == FALSE )
break;
for (i=0;i<PLAYER_GROUP_MAX;i++)
{
if ( GAME.Players[GAME.nMe].wGroup[i] != MAP_DATA_NONE )
{
pUnit = MAP_GetUnit( GAME.Players[GAME.nMe].wGroup[i] );
Assert( pUnit );
Assert( EYE_IfUnitIsGen( pUnit ) );
//張飛
if ( !EYE_IfUnitIsDead( pUnit )
&& pUnit->Gen.nID == 35 )
{
if (pUnit->Draw.nX < SAFEAREA8_4EX+10
&&pUnit->Draw.nX > SAFEAREA8_4EX-10
&&pUnit->Draw.nY < SAFEAREA8_4EY+10
&&pUnit->Draw.nY > SAFEAREA8_4EY-10
)
{
EventPos[Level][3]=1;
TY_BateMorale( AIPlayer, -40);
// 在長坂橋上張飛三喝,曹軍畏懼撤軍。
//FACE_ShowEvent( 7 );
// Nov.21.1997
PostMessage( hwndGame, WM_SHOW_EVENT, 7, 0 );
}
break;
}
}
}
}
break;
case 14:
{
UNIT_STRUCT * Pobject1;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -