stoneage8.5/石器时代8.5客户端最新源代码/石器源码/system/pattern.cpp

271 lines
7.7 KiB
C++
Raw Normal View History

2020-06-23 15:27:59 +08:00
/************************/
/* pattern.cpp */
/************************/
/* ENT : ACTION *a0 ,
: ???????<EFBFBD>L<EFBFBD>T???????????<EFBFBD>L<EFBFBD>T??
: ????????????????????????????
RET : ?<EFBFBD><EFBFBD>????????
: ?<EFBFBD><EFBFBD>?????
*/
#include "../systeminc/version.h"
#include "../systeminc/system.h"
#include "../systeminc/loadrealbin.h"
#include "../systeminc/loadsprbin.h"
#include "../systeminc/anim_tbl.h"
#include "../systeminc/t_music.h"
#ifdef _NPC_PICTURE
extern BOOL g_bUseAlpha;
void picture_play( ACTION *a0 )
{
//int i,j;
int pictable[9]={100388,100841,101178,100854,101570,100353,101759,101424,101489};
if( a0->picture != 0 ){
int picture1 = ((((a0->picture)&0xff000000)>>24)&0x000000ff);
int picture2 = ((((a0->picture)&0x00ff0000)>>16)&0x000000ff);
int picture3 = ((((a0->picture)&0x0000ff00)>>8 )&0x000000ff);
int picture4 = ( (a0->picture)&0x000000ff );
//a0->anim_no = ANIM_WALK;
if( picture1 == 1 ){//<2F><><EFBFBD>ϱ<EFBFBD><CFB1><EFBFBD>
if( a0->anim_chr_no == 101936 ){
a0->anim_chr_no = 101863;
return;
}
else if( a0->anim_chr_no == 101863 ){
a0->anim_chr_no = pictable[a0->picturetemp];
}
else
a0->anim_chr_no = 101863;
++a0->picturetemp;
if(a0->picturetemp == 9 )
a0->picturetemp = 0;
}
else if( picture1 == 2 ){//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><C4B3>ͼ<EFBFBD><CDBC>
if( a0->anim_chr_no != pictable[picture2] ){
if( a0->anim_chr_no == 101863 )
a0->anim_chr_no = pictable[a0->picturetemp];
else
a0->anim_chr_no = 101863;
}
else{
if( a0->anim_no == 0 )//<2F><EFBFBD><E8B6A8><EFBFBD><EFBFBD>
a0->anim_no = 3;
else
a0->anim_no = 0;
}
++a0->picturetemp;
if(a0->picturetemp == 9 )
a0->picturetemp = 0;
}
else if( picture1 == 3 ){
if(g_bUseAlpha) a0->anim_chr_no = 101805; else a0->anim_chr_no = 101858;
a0->picture = (((1)<<24)&0xff000000)
|(((picture2)<<16)&0x00ff0000)
|(((picture3)<< 8)&0x0000ff00)
|( (picture4) &0x000000ff);
}
}
}
#endif
/*---------- ????????? ----------*/
// Return 1:<3A><><EFBFBD><EFBFBD><EFBFBD>˴˶<CBB4><CBB6><EFBFBD>( <20><><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD>ŵ<EFBFBD>״<EFBFBD><D7B4><EFBFBD><EFBFBD> )
// Return 0:<3A><><EFBFBD>Ŵ˶<C5B4><CBB6><EFBFBD><EFBFBD><EFBFBD>
int pattern( ACTION *a0, int anim_spd, int loop_flg)
{
ANIMLIST *ptAnimlist;
FRAMELIST *ptFramelist;
int i;
short dx,dy;
int BmpNo;
U4 chrNo;
extern int getCharType(ACTION *ptAct);
if(getCharType(a0)){
if(ATR_PAT_NO(a0)){
ATR_PAT_BAK_NO(a0) = ATR_PAT_NO(a0);
ATR_PAT_NO(a0) = 0;
}
return 0;
}else{
if(!ATR_PAT_NO(a0) && ATR_PAT_BAK_NO(a0)) ATR_PAT_NO(a0) = ATR_PAT_BAK_NO(a0);
}
if(ATR_CHR_ACT_OLD(a0) != ATR_CHR_ACT(a0) ||
ATR_CHR_ANG(a0) != ATR_CHR_ANG_OLD(a0) ||
ATR_CHR_NO(a0) != ATR_CHR_NO_OLD(a0)){
ATR_CHR_NO_OLD(a0) = ATR_CHR_NO(a0); /*<2A><>????????????*/
ATR_CHR_ACT_OLD(a0) = ATR_CHR_ACT(a0); /*<2A><>??<3F>h????*/
ATR_CHR_ANG_OLD(a0) = ATR_CHR_ANG(a0); /*<2A><>???????*/
ATR_CHR_TIM(a0) = 0;//frame counter<65><72>Ϊһ
ATR_CHR_CNT(a0) = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵڼ<C4B5><DABC><EFBFBD>ͼ
}
if(ATR_CHR_TIM(a0)){
ATR_CHR_TIM(a0)--; //frame counter<65><72>һ
return 0;
}
if(ATR_CHR_NO(a0) <= CG_INVISIBLE){
ATR_PAT_NO(a0) = 0; //ָ<><D6B8>Ϊ<EFBFBD><CEAA>0<EFBFBD><30>ͼ
#ifdef _NPC_PICTURE
picture_play(a0);
#endif
return 0;
}
if(ATR_CHR_NO(a0) < SPRSTART){ //<2F><><EFBFBD><EFBFBD>sprite
realGetNo( ATR_CHR_NO(a0) , (U4 *)&BmpNo );
realGetPos( BmpNo , &dx, &dy);
ATR_PAT_NO(a0) = BmpNo; //BMP<4D><50>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#ifdef _FIX_CG_ATR_ICON
if (ATR_CHR_NO(a0)>= CG_ATR_ICON_EARTH_BATTLE && ATR_CHR_NO(a0)<=CG_ATR_ICON_WIND_BATTLE){
ATR_CHR_H_POS(a0) = dx - 20; //X<><58><EFBFBD><EFBFBD>
}else{
ATR_CHR_H_POS(a0) = dx; //X<><58><EFBFBD><EFBFBD>
}
#else
ATR_CHR_H_POS(a0) = dx; //X<><58><EFBFBD><EFBFBD>
#endif
ATR_CHR_V_POS(a0) = dy; //Y<><59><EFBFBD><EFBFBD>
ATR_CHR_TIM(a0)=0x7fffffff;
//cary
if( ATR_CHR_ACT(a0) == ANIM_ATTACK && ATR_CHR_CNT(a0) == 0){
ATR_CHR_TIM(a0)=0;
ATR_HIT(a0) = 10000;
ATR_CHR_CNT(a0) = 1;
#ifdef _NPC_PICTURE
picture_play(a0);
#endif
return 0;
}
ATR_CHR_CNT(a0) = 0;
ATR_CHR_ACT(a0) = ANIM_STAND;
if( loop_flg == ANM_NO_LOOP){
#ifdef _NPC_PICTURE
picture_play(a0);
#endif
return 1;
}
//cary end
#ifdef _NPC_PICTURE
picture_play(a0);
#endif
return 0;
}
if(ATR_CHR_NO(a0) > SPRSTART + mxSPRITE){
#ifdef _NPC_PICTURE
picture_play(a0);
#endif
return 0; //<2F><><EFBFBD><EFBFBD>sprite<74>ķ<EFBFBD>Χ
}
chrNo = ATR_CHR_NO(a0) - SPRSTART;
ptAnimlist = SpriteData[chrNo].ptAnimlist;
if( SpriteData[chrNo].animSize == 0 ){
#ifdef _NPC_PICTURE
picture_play(a0);
#endif
return 0; //<2F>޶<EFBFBD><DEB6><EFBFBD>
}
//ѡ<><D1A1><EFBFBD><EFBFBD>Ҫ<EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD>
for(i=0 ; i < SpriteData[chrNo].animSize; i++){
if( ATR_CHR_ANG(a0) == ptAnimlist[i].dir && ptAnimlist[i].no == ATR_CHR_ACT(a0) )
break;
}
if( i >= SpriteData[chrNo].animSize ){
// shan remark
// i = 0;
for( int sh_i=0 ; sh_i < SpriteData[chrNo].animSize; sh_i++){
if( ATR_CHR_ANG(a0) == ptAnimlist[sh_i].dir && ptAnimlist[sh_i].no == ANIM_STAND){
i = sh_i;
break;
}else{
i = 0;
}
}
}
ptFramelist = ptAnimlist[i].ptFramelist;
if(anim_spd) //<2F><>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
ATR_CHR_TIM(a0) = anim_spd;
else
ATR_CHR_TIM(a0) = ptAnimlist[i].dtAnim;
#ifdef _NPC_PICTURE
if( a0->picture != 0 ){
int pictable[9]={100388,100841,101178,100854,101570,100353,101759,101424,101489};
/*if( (((a0->picture&0xff000000)>>24) & 0x000000ff) == 1
|| (((a0->picture&0xff000000)>>24) & 0x000000ff) == 3
|| ( (((a0->picture&&0xff000000)>>24) & 0x000000ff) == 2
&& ( a0->anim_chr_no != pictable[(((a0->picture&0x00ff0000)>>16)&0x000000ff)] ) ) )
ATR_CHR_TIM(a0) = 1;//<2F><><EFBFBD><EFBFBD>npc<70>ٶȵ<D9B6><C8B5><EFBFBD><EFBFBD><EFBFBD>
*/
if( a0->anim_chr_no != pictable[(((a0->picture&0x00ff0000)>>16)&0x000000ff)]
|| (((a0->picture&0xff000000)>>24) & 0x000000ff) == 1
|| (((a0->picture&0xff000000)>>24) & 0x000000ff) == 3 )
if( a0->anim_chr_no != 101805 && a0->anim_chr_no != 101858 && a0->anim_chr_no != 101936 )
ATR_CHR_TIM(a0) = 1;//<2F><><EFBFBD><EFBFBD>npc<70>ٶȵ<D9B6><C8B5><EFBFBD><EFBFBD><EFBFBD>
}
#endif
if((U4)ATR_CHR_CNT(a0) >= ptAnimlist[i].frameCnt){ //????????????
#ifdef _NPC_PICTURE
picture_play(a0);
#endif
if(loop_flg == ANM_NO_LOOP){ //???<3F><>??
ATR_CHR_TIM(a0) = 255;
return 1; //???????<3F><>?
} else
ATR_CHR_CNT(a0) = 0; //<2F>I<EFBFBD>d???
}
//????<3F><>??
if( ptFramelist[ATR_CHR_CNT(a0)].SoundNo != 0 ){
if(ptFramelist[ATR_CHR_CNT(a0)].SoundNo < 10000)
play_se( ptFramelist[ATR_CHR_CNT(a0)].SoundNo, ATR_H_POS(a0), ATR_V_POS(a0) );
else
ATR_HIT(a0) = ptFramelist[ATR_CHR_CNT(a0)].SoundNo;
}
#ifdef _PROFESSION_ADDSKILL
else{
if(ATR_CHR_NO(a0) >= 101769 && ATR_CHR_NO(a0) <= 101797){
int soundnum = 0;
switch(ATR_PAT_NO(a0)){
case 156+OLD_GRAPHICS_START:
soundnum = 390;break;//ˮ<><CBAE><EFBFBD><EFBFBD>390
case 193+OLD_GRAPHICS_START:
soundnum = 390;break;//ˮ<><CBAE><EFBFBD><EFBFBD>390
case 304+OLD_GRAPHICS_START:
soundnum = 327;break;//<2F>ؽ<EFBFBD><D8BD><EFBFBD>
case 341+OLD_GRAPHICS_START:
soundnum = 327;break;//<2F>ؽ<EFBFBD><D8BD><EFBFBD>
case 231+OLD_GRAPHICS_START:
soundnum = 395;break;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
case 268+OLD_GRAPHICS_START:
soundnum = 268;break;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
case 380+OLD_GRAPHICS_START:
soundnum = 154;break;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
case 417+OLD_GRAPHICS_START:
soundnum = 154;break;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
case 75+OLD_GRAPHICS_START:
soundnum = 324;break;//<2F>ƽ<EFBFBD><C6BD><EFBFBD>
case 97+OLD_GRAPHICS_START:
soundnum = 324;break;//<2F>ƽ<EFBFBD><C6BD><EFBFBD>
case 117+OLD_GRAPHICS_START:
soundnum = 385;break;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ
case 137+OLD_GRAPHICS_START:
soundnum = 385;break;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ
case 60+OLD_GRAPHICS_START:
soundnum = 388;break;//<2F><>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD>
}
play_se(soundnum,ATR_H_POS(a0),ATR_V_POS(a0));
}
}
#endif
ATR_PAT_NO(a0) = ptFramelist[ATR_CHR_CNT(a0)].BmpNo; //???<3F>k????
realGetPos(ptFramelist[ATR_CHR_CNT(a0)].BmpNo, &dx, &dy); //??????????<3F><><EFBFBD><EFBFBD>?<3F><>?
ATR_CHR_H_POS(a0) = ptFramelist[ATR_CHR_CNT(a0)].PosX + dx; //??<3F><>????????
ATR_CHR_V_POS(a0) = ptFramelist[ATR_CHR_CNT(a0)].PosY + dy; //??<3F><>????????
ATR_CHR_CNT(a0)++;
ATR_CHR_TIM(a0)--;
return 0;
}