📄 npc_pattern.cpp
字号:
ty = n->y / TILE_SIZE;
switch( dir )
{
case 0 : ty +=how; break;
case 1 : tx -=how; ty +=how; break;
case 2 : tx -=how; break;
case 3 : tx -=how; ty -=how; break;
case 4 : ty -=how; break;
case 5 : tx +=how; ty -=how; break;
case 6 : tx +=how; break;
case 7 : tx +=how; ty +=how; break;
}
NPC_MakePathBumn( n, tx, ty, how );
}
}
break;
case NPC_PATTERN_ACCESS_PC_38_ :
{
if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch )
{
n->aitimedelay = g_ClientTime;
n->aidelayhowmuch = PCFINDACCESS(n); // 0813 NPC KHS
if( NPC_IsMoving( n ) )
{
LPCHARACTER tempch = ReturnCharacterPoint( n->targetid );
if( tempch )
if( !IsDead( tempch ) )
{
if( NPC_IsAttackableRange( n ) )
{
SendModifyPositionNPC( n->id );
SendNPCAttack( n->id );
n->attackcount ++;
n->aitimedelay = g_ClientTime; // 捞霸 绝栏聪鳖.. 楷鸥啊 唱柯促.
n->aidelayhowmuch = ATTACKACCESS(n) + (rand()%300);
n->patterntype = NPC_PATTERN_ATTACK_PC_38_;
break;
}
}
}
else
{
// if( NPC_Hostile( n ) ) // 傍拜葛靛捞搁...
LPCHARACTER tempch = ReturnCharacterPoint( n->targetid );
if( tempch )
if( !IsDead( tempch ) )
{
if( NPC_IsAttackableRange( n ) )// 傍拜 啊瓷茄 芭府鳖瘤 吭唱 ?
{
SendNPCAttack( n->id );
n->attackcount ++;
n->aitimedelay = g_ClientTime; // 捞霸 绝栏聪鳖.. 楷鸥啊 唱柯促.
n->aidelayhowmuch = ATTACKACCESS(n) + (rand()%600);
n->patterntype = NPC_PATTERN_ATTACK_PC_38_;
break;
}
else // 傍拜啊瓷茄 芭府啊 酒聪搁 辟贸鳖瘤 埃促.
{
if( NPC_NearCh( n, tempch, &ex, &ey ) )
{
n->MoveP = 60 + Random(30 );
if( NPC_MakePath( n, ex, ey, Random(6) + 2 ) )
{
n->patterntype = NPC_PATTERN_ATTACK_PC_38_;
}
else
{
n->patterntype = NPC_PATTERN_WANDER_38_;
}
}
else
{
n->patterntype = NPC_PATTERN_WANDER_38_;
// n->bossid = -1;
// n->server_id = -1;
}
}
}
else
{
n->patterntype = NPC_PATTERN_WANDER_38_;
n->targetid = -1;
break;
}
}
}
}
break;
case NPC_PATTERN_ATTACK_PC_38_ :
{
LPCHARACTER tempch;
if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch )
{
n->aitimedelay = g_ClientTime;
n->aidelayhowmuch = ATTACKACCESS(n) + (rand()%600);
}
else break;
if( NPC_IsMoving(n) ) // 泅犁 捞悼吝捞搁
{
LPCHARACTER tempch = ReturnCharacterPoint( n->targetid );
if( tempch )
if( !IsDead( tempch ) )
if( NPC_IsAttackableRange( n ) ) // 捞悼 档吝 傍拜措惑某腐甫 傍拜且荐 乐促搁 傍拜茄促.
{
goto ATTACK_38_NEXT__;
}
break;
}
tempch = ReturnCharacterPoint( n->targetid );
if( NPC_IsAttackableRange( n ) )// 傍拜 啊瓷茄 芭府鳖瘤 吭唱 ?
{
ATTACK_38_NEXT__:
if( NPC_StillAttack(n) )
{
SendNPCAttack( n->id );
n->attackcount ++;
//n->patterntype = NPC_PATTERN_WANDER_38_;
}
else
{
if( NPC_NearBackCh( n, tempch, &ex, &ey, 5 ) )
{
n->MoveP = 70 + Random(30 );
if( NPC_MakePath( n, ex, ey, Random(2)+2 ) )
{
n->patterntype =NPC_PATTERN_ACCESS_PC_38_; //WANDER_8_;
}
else
{
n->targetid = -1;
n->patterntype =NPC_PATTERN_WANDER_38_; //WANDER_8_;
}
}
else
{
n->patterntype =NPC_PATTERN_ACCESS_PC_38_; //WANDER_8_;
}
}
}
else
{
if( n->targetid != -1 )
{
if( !IsDead( tempch ) )
{
if( tempch == NULL )
{
n->patterntype =NPC_PATTERN_WANDER_38_; //WANDER_8_;
}
else if( NPC_NearCh( n, tempch, &ex, &ey ) )
{
//if( NPC_EnemyOnMyWay(
// 聪刀匙 傍拜惑措俊霸 立辟窍扁 困茄 风凭阑 持绰促. ( 'ぁ' 'い'栏肺
n->MoveP = 60 + Random(30 );
if( NPC_MakePath( n, ex, ey, Random(6)+2 ) )
{
n->patterntype =NPC_PATTERN_ACCESS_PC_38_; //WANDER_8_;
}
else
{
n->targetid = -1;
n->patterntype =NPC_PATTERN_WANDER_38_; //WANDER_8_;
}
}
else
{
n->targetid = -1;
n->patterntype = NPC_PATTERN_WANDER_38_;
// n->bossid = -1;
// n->server_id = -1;
// JustMessage( " %d狼 Pattern锅龋 %d ", n->server_id, n->patterntype );
// JustMessage( " %d狼 Pattern锅龋 %d ", n->patterntype );
}
}
else
{
n->patterntype =NPC_PATTERN_WANDER_38_; //WANDER_8_;
}
}
else
{
n->patterntype =NPC_PATTERN_WANDER_38_; //WANDER_8_;
}
}
break;
}
case NPC_PATTERN_BACKDRAW_PC_38_ :
{
if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch )
{
n->aitimedelay = g_ClientTime;
n->aidelayhowmuch = 500 + (rand()%500);
LPCHARACTER tempch = ReturnCharacterPoint( n->targetid );
if( NPC_IsMoving( n ) )
{
}
else
{
if( n->targetid != -1 )
{
if( InDistance( n, tempch, TILE_SIZE * 10 ) ) // 弊 PC啊 10 鸥老救俊 乐促搁.
{
n->patterntype = NPC_PATTERN_WANDER_38_;
if( NPC_NearBackCh( n, tempch, &ex, &ey, 10 ) )
{
n->MoveP = 60 + Random(30 );
NPC_MakePath( n, ex, ey, Random(10)+5 );
}
else
{
}
}
else // 面盒洒 钢府乐焙.
{
n->patterntype = NPC_PATTERN_WANDER_38_;
}
}
else
{
n->patterntype = NPC_PATTERN_WANDER_38_;
}
}
}
break;
}
}
}
void Check_NPC_Pattern( LPCHARACTER n )
{
if( n->type != SPRITETYPE_MONSTER ) return;
if( IsDead( n ) ) return;
switch( n->patterntype )
{
//------------------------------------------------------------------------------------------------------------
case NPC_PATTERN_WANDER_8_ :
case NPC_PATTERN_IAM_BOSS_8_ :
case NPC_PATTERN_TOBOSS_8_ :
case NPC_PATTERN_MURI_8_ :
case NPC_PATTERN_ACCESS_PC_8_ :
case NPC_PATTERN_ATTACK_PC_8_ :
case NPC_PATTERN_BACKDRAW_8_ : NPC_Pattern_8(n);
break;
case NPC_PATTERN_IAM_BOSS_28_ :
case NPC_PATTERN_TOBOSS_28_ :
case NPC_PATTERN_WANDER_28_ :
case NPC_PATTERN_MURI_28_ :
case NPC_PATTERN_BACKDRAW_PC_28_ : NPC_Pattern_28(n);
break;
case NPC_PATTERN_ACCESS_PC_38_ :
case NPC_PATTERN_ATTACK_PC_38_ :
case NPC_PATTERN_WANDER_38_ :
case NPC_PATTERN_MURI_38_ :
case NPC_PATTERN_BACKDRAW_PC_38_ : NPC_Pattern_38(n);
break;
case NPC_PATTERN_IAM_BOSS_GUARD_ :
case NPC_PATTERN_TOBOSS_GUARD_ :
case NPC_PATTERN_WANDER_GUARD_ :
case NPC_PATTERN_MURI_GUARD_ :
case NPC_PATTERN_ACCESS_PC_GUARD_ :
case NPC_PATTERN_ATTACK_PC_GUARD_ :
case NPC_PATTERN_BACKDRAW_PC_GUARD_: NPC_Pattern_GUARD(n);
break;
case NPC_PATTERN_TAME_ : NPC_Pattern_Tammed(n);
break;
case NPC_PATTERN_EVENTING_MAUL_ :
case NPC_PATTERN_WANDER_MAUL_ : NPC_Pattern_MAUL(n);
break;
case NPC_PATTERN_SEALSTONE_NO_OPERATE_ :
case NPC_PATTERN_SEALSTONE_ATTACK_ : NPC_Pattern_SealStone( n );
break;
}
}
void RecvNK( int id, int nk3, int nk4, int nk6 )
{
LPCHARACTER ch = ReturnCharacterPoint( id );
if( ch == NULL ) return;
ch->nk3 = nk3;
ch->nk4 = nk4;
ch->nk6 = nk6;
ch->dummy_pk = 0;
}
void RecvServerKillPc( int id, int killpc )
{
LPCHARACTER ch = ReturnCharacterPoint( id );
if( ch == NULL ) return;
ch->killpc = killpc;
}
// 扁瓷 NPC阑 PK且锭 某腐栏捞 dummy_pk逢 利侩茄促.
void CheckNPCPk( int aid, int did )
{
LPCHARACTER dch = ReturnCharacterPoint( did );
if( dch == NULL ) return;
switch (dch->nRace)
{ //< CSD-TW-030606
case GUARD:
{
LPCHARACTER ach = ReturnCharacterPoint(aid);
if (ach && ach->id < 10000)
{
if (IsNK( ach, MapInfo[MapNumber].nation ) < 5)
{
if (ach->name_status.nation == MapInfo[MapNumber].nation)
{
++ach->dummy_pk;
char* temp = NULL;
switch (dch->id%10)
{
case 0:
{
if( ach->dummy_pk == rand()%3 ) { temp = lan->OutputMessage(4,41); }//lsw
else if( ach->dummy_pk == rand()%3 +1 ) { temp = lan->OutputMessage(4,42); }
else if( ach->dummy_pk == rand()%3 + 2 ) { temp = lan->OutputMessage(4,43); }
else if( ach->dummy_pk == rand()%3 + 3 ) { temp = lan->OutputMessage(4,44); }
else if( ach->dummy_pk == rand()%3 + 4 ) { temp = lan->OutputMessage(4,45); }
else if( ach->dummy_pk == rand()%3 + 5 ) { temp = lan->OutputMessage(4,46) ; }
else if( ach->dummy_pk == rand()%3 + 6 ) { temp = lan->OutputMessage(4,47); ach->dummy_pk += 10; }
else if( ach->dummy_pk == rand()%3 + 8 ) { temp = lan->OutputMessage(4,48); ach->dummy_pk += 10; }
else if( ach->dummy_pk >= rand()%3 + 8 ) { temp = lan->OutputMessage(4,49); ach->dummy_pk += 10; }//lsw
break;
}
case 2:
{
if( ach->dummy_pk == rand()%3 ) { temp = lan->OutputMessage(4,51); }//lsw
else if( ach->dummy_pk == rand()%3 +1 ) { temp = lan->OutputMessage(4,52); }
else if( ach->dummy_pk == rand()%3 + 2 ) { temp = lan->OutputMessage(4,53); }
else if( ach->dummy_pk == rand()%3 + 3 ) { temp = lan->OutputMessage(4,54); }
else if( ach->dummy_pk == rand()%3 + 4 ) { temp = lan->OutputMessage(4,55); }
else if( ach->dummy_pk == rand()%3 + 5 ) { temp = lan->OutputMessage(4,56); }
else if( ach->dummy_pk == rand()%3 + 6 ) { temp = lan->OutputMessage(4,57); ach->dummy_pk += 10; }
else if( ach->dummy_pk == rand()%3 + 8 ) { temp = lan->OutputMessage(4,58) ; ach->dummy_pk += 10; }
else if( ach->dummy_pk >= rand()%3 + 8 ) { temp = lan->OutputMessage(4,59); ach->dummy_pk += 10; }
break;
}
case 3:
{
if( ach->dummy_pk == rand()%3 ) { temp = lan->OutputMessage(4,61); }//lsw
else if( ach->dummy_pk == rand()%3 +1 ) { temp = lan->OutputMessage(4,62); }
else if( ach->dummy_pk == rand()%3 + 2 ) { temp = lan->OutputMessage(4,63); }
else if( ach->dummy_pk == rand()%3 + 3 ) { temp = lan->OutputMessage(4,64); }
else if( ach->dummy_pk == rand()%3 + 4 ) { temp = lan->OutputMessage(4,65); }
else if( ach->dummy_pk == rand()%3 + 8 ) { temp = lan->OutputMessage(4,66); ach->dummy_pk += 10; }
else if( ach->dummy_pk >= rand()%3 + 8 ) { temp = lan->OutputMessage(4,67); ach->dummy_pk += 10; }//lsw
break;
}
}
// 0810 KHS
if (temp && (rand()%25) == 0)
{
SendNPCChatArea(dch->id, temp);
}
}
else // 辑肺 促弗 唱扼老版快.. 版厚绰..
{
ach->dummy_pk += 2;
if( (rand()%100) < 50 )
{
switch (MapInfo[MapNumber].nation)
{
case N_VYSEUS:
{
switch (rand()%5)
{
case 0: SendNPCChatArea(dch->id, lan->OutputMessage(4,71) ); break;//lsw
case 1: SendNPCChatArea(dch->id, lan->OutputMessage(4,72) ); break;
}
break;
}
case N_ZYPERN:
{
switch (rand()%5)
{
case 0: SendNPCChatArea(dch->id, lan->OutputMessage(4,73)); break;
case 1: SendNPCChatArea(dch->id, lan->OutputMessage(4,74)); break;//lsw
}
break;
}
}
}
}
}
}
break;
}
} //> CSD-TW-030606
}
// 0811 NPC KHS
void SaveNPCAcessTable( void )
{
FILE *fp = Fopen("./char/011105.spr","wb" );
if( fp )
{
fwrite( NPCAccessTable, sizeof( short ) * 400 * 4, 1, fp );
fclose(fp);
}
FILE *wp = Fopen( "./char/011105.txt", "wt" );
if( wp )
{
for( int i = 0 ; i < 400 ; i ++)
{ //< CSD-030419
fprintf(fp, "%3d(%20s): %3d %3d %3d %3d \n",
i,
GetNpcName(i),
NPCAccessTable[i][0],
NPCAccessTable[i][1],
NPCAccessTable[i][2],
NPCAccessTable[i][3]);
} //> CSD-030419
fclose(wp );
}
}
void LoadNPCAccessTable( void )
{
FILE *fp = Fopen("./char/011105.spr","rb" );
if( fp )
{
fread( NPCAccessTable, sizeof( short ) * 400 * 4, 1, fp );
fclose(fp);
}
}
void Recv_CMD_SERVER_NPC_ACCESS_TABLE_RELOAD( t_packet *p )
{
memcpy( &NPCAccessTable[ 0][0] ,p->u.server_npc_access_table_reload.data, sizeof( short )* 400 );
}
void Recv_CMD_SERVER_NPC_ACCESS_TABLE_RELOAD2( t_packet *p )
{
memcpy( &NPCAccessTable[100][0] ,p->u.server_npc_access_table_reload.data, sizeof( short )* 400 );
}
void Recv_CMD_SERVER_NPC_ACCESS_TABLE_RELOAD3( t_packet *p )
{
memcpy( &NPCAccessTable[200][0] ,p->u.server_npc_access_table_reload.data, sizeof( short )* 400 );
}
void Recv_CMD_SERVER_NPC_ACCESS_TABLE_RELOAD4( t_packet *p )
{
memcpy( &NPCAccessTable[300][0] ,p->u.server_npc_access_table_reload.data, sizeof( short )* 400 );
SaveNPCAcessTable();
}
static char monname_temp[ 17];
char *LoadMonNameTable( int namenumber )
{
FILE *fp = Fopen( "./Data/Mon_Name.bin", "rb" );
if( fp == NULL ) return "";
fseek( fp, namenumber * 17, SEEK_SET );
fread( monname_temp, 17, 1, fp );
fclose(fp);
return (((char*)monname_temp)?(char*)monname_temp:"");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -