📄 cbevent.cpp
字号:
/////////////////////////
// CBEvent.cpp : v0010
// Written by : Liu Gang
// Compiler : Microsoft Visual C++ 4.2
// v0010 : Jun.9.1997
/////////////////////////
// 触发事件处理
#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 关:EventPos[5][0] == 1 魏延反叛
//第 8 关:EventPos[8][0] == 1 糜竺回到右下角
//EventPos[8][1] == 1 救阿斗
//EventPos[8][2] == 1 赵云返回右下角 此关结束
//第14 关:EventPos[5][0] == 1 遇到赵云
//EventPos[5][1] == 1 遇到张飞
//EventPos[5][2] == 1 遇到关羽 此关结束
WORD EventPos[34][5];
//define the spectial pos.
// 第5关
// 魏延反叛
#define SAFEAREA5_1EX 56
#define SAFEAREA5_1EY 135
// 到达目的地
#define SAFEAREA5_2EX 96
#define SAFEAREA5_2EY 275
// 第8关
// 糜竺回到右下角
#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关
#define SAFEAREA14_EX 20
#define SAFEAREA14_EY 43
// 第19关
// 到该地点就放火
#define SAFEAREA19_EX 50
#define SAFEAREA19_EY 60
// 第20关
// 到该地点就放火
#define SAFEAREA20_EX 63
#define SAFEAREA20_EY 241
// 第29关
// 到该地点就放火
#define SAFEAREA29_EX 54
#define SAFEAREA29_EY 171
// 第30关
#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 遇到关羽
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;
// 该事件已经发生过,退出
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:
// 曹军在新野城内被火烧,士气降低
if( GAME.nMe == nPlayer && stctG.nFile == 2 ) // 在城内放火
{
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 )
{ // 曹操中火计,曹军在新野城内被火烧,士气降低
nFlag = 2;
TY_BateMorale(GAME.nMe, -20);
EventPos[nGameID][0] = 1;
}
break;
case 29:
if( EventPos[nGameID][1] == 1 )
{ // 曹操中火计,黄盖诈降,曹军疏于防备,连锁战船被烧。
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;
}
}
}
// 刘备到达江陵,本关游戏结束
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;
}
}
}
}
// 赵云返回右下角,游戏结束
if (EventPos[Level][2] == 0
&& EventPos[Level][1] == 1) // 第个事件(救阿斗)已经发生
{
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;
}
}
}
}
// 张飞喝断长坂桥
// 当敌人接近某桥头,而张飞在另一个桥头的时候,士气降为30
if (EventPos[Level][3] == 0 )
//&& EventPos[Level][1] == 1) // 第个事件(救阿斗)已经发生
{
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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -