📄 npc_pattern.cpp
字号:
if( !IsDead( tempch ) && tempch->type == SPRITETYPE_MONSTER )
{
if( n->sprno == tempch->sprno )
{
ex = tempch->x; ey = tempch->y;
dis = (ex-x)*(ex-x)+(ey-y)*(ey-y);
if( dis < (DWORD)(TILE_SIZE * 10)*(DWORD)(TILE_SIZE * 10) )
{
c++;
if( tempch->Exp > maxexp )
{
maxexp = tempch->Exp;
bossid = tempch->id;
}
}
}
}
tempch = tempch->lpNext;
}
if( c == 1 ) bossid = -1; // 唱观俊 Checkking捞 登瘤 臼疽促绰 娟扁 ............
return bossid;
}
int NPC_WhoIsBlocking( int sx, int sy )
{
LPCHARACTER tempch = Hero;
while( tempch )
{
if( !IsDead( tempch ) )
{
if( tempch->x / TILE_SIZE && tempch->y/ TILE_SIZE )
{
return tempch->id;
}
}
tempch = tempch->lpNext;
}
return -1;
}
CHARACTER *NPC_ReturnCharListPoint( int id )
{
if( id < 0 ) return NULL;
LPCHARACTER tempch = ReturnCharacterPoint( id );
if( tempch == NULL ) return NULL;
if( IsDead( tempch) ) return NULL;
return tempch;
}
CHARACTER *ReturnCharListPoint( char *name )
{
if( name == NULL ) return NULL;
LPCHARACTER tempch = Hero;
while( tempch )
{
if( strcmp( tempch->name, name ) == 0 && tempch->type != SPRITETYPE_MONSTER )
{
return tempch;
}
tempch = tempch->lpNext;
}
return NULL;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// User Functions.....
//
void NPC_Pattern_28( LPCHARACTER n)
{
int ex, ey;
switch( n->patterntype )
{
case NPC_PATTERN_WANDER_28_ :
int bossid;
if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch )
{
n->aitimedelay = g_ClientTime;
n->aidelayhowmuch = 1000 + (rand()%1000);
}
else break;
// 弊成 硅雀茄促.
if( NPC_IsMoving( n ) )
{
}
else
{
int targetid = NPC_IsWhoNearPC( n, 10 );
if( targetid != -1 )
{
if( n->bossid == -1 )
{
n->patterntype = NPC_PATTERN_BACKDRAW_PC_28_;
n->targetid = targetid;
break;
}
else
{
LPCHARACTER tempch = Hero;
while( tempch )
{
if( tempch->patterntype != NPC_PATTERN_TAME_ )
if( !IsDead( tempch ) && tempch->type == SPRITETYPE_MONSTER )
{
if( tempch->bossid == n->bossid )
{
tempch->targetid = n->targetid;
tempch->patterntype = NPC_PATTERN_BACKDRAW_PC_28_;
}
}
tempch = tempch->lpNext;
}
break;
}
}
else
{
bossid = NPC_WhoIsBoss( n );
if( bossid != -1 ) // Yes.. 焊胶甫 茫疽绢!!
{
if( bossid != n->id ) // 澜. 唱焊促 Exp啊 臭篮 仇捞 乐焙..
{
n->bossid = bossid;
SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, bossid );
n->patterntype = NPC_PATTERN_TOBOSS_28_;
n->targetid = -1;
break;
}
else // 郴啊 Boss捞促.
{
n->bossid = bossid;
SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, bossid );
n->patterntype = NPC_PATTERN_IAM_BOSS_28_;
n->targetid = -1;
break;
}
}
else // 雷. 焊胶啊 绝绢...
{
int dir;
int how;
int tx, ty;
dir = Random(8);
how = Random(8)+2;
tx = n->x / TILE_SIZE;
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_IAM_BOSS_28_ :
{
int bossid;
if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch )
{
n->aitimedelay = g_ClientTime;
n->aidelayhowmuch = 1000 + (rand()%1000);
if( NPC_IsMoving( n ) )
{
}
else
{
bossid = NPC_WhoIsBoss( n );
if( bossid == -1 ) // 唱去磊焙..
{
n->patterntype = NPC_PATTERN_WANDER_28_;
n->targetid = -1;
n->bossid = -1;
SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, -1);
SendNPC_parameter( n->id, NPC_PARAMETER_TARGETID, -1);
break;
}
else if( bossid != n->id ) // dld澜. 唱焊促 Exp啊 臭篮 仇捞 乐焙..
{
n->bossid = bossid;
SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, bossid );
n->patterntype = NPC_PATTERN_TOBOSS_28_;
break;
}
else // 开浆 郴啊 Boss促 ! 弊烦 焊胶狼 老阑 秦具瘤.
{
n->bossid = bossid;
int attacker = NPC_WhoIsAttackMyBaby( n );
if( attacker != -1) // 郴 酒啊甸吝 嘎绰局啊 乐栏搁..
{
LPCHARACTER tempch = Hero;
while( tempch )
{
if( !IsDead( tempch ) && tempch->type == SPRITETYPE_MONSTER && tempch != n )
{
if( tempch->bossid == n->bossid )
{
tempch->targetid = n->targetid;
SendNPC_parameter( n->id, NPC_PARAMETER_TARGETID,n->targetid );
tempch->patterntype = NPC_PATTERN_BACKDRAW_PC_28_;
}
}
tempch = tempch->lpNext;
}
break;
}
else
{
n->targetid = NPC_IsWhoNearPC( n, 6 );
LPCHARACTER tempch = ReturnCharacterPoint( n->targetid );
if( n->targetid == -1 )
{
if( (Random(15)) == 0 )
{// 焊胶瘤父 距埃究 巩流牢促.
int dir;
int how;
int tx, ty;
dir = Random(8);
how = Random(2)+2;
tx = n->x / TILE_SIZE;
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;
}
//n->MoveP = Random(50) + 50;
NPC_MakePathBumn( n, tx, ty, how );
}
}
else
{
if( IsDead( tempch ) )
{
n->targetid = -1;
}
else
{
if( InDistance( n, tempch, TILE_SIZE * 7 ) ) // 弊 PC啊 5 鸥老救俊 乐促搁.
{
LPCHARACTER tempch = Hero;
while( tempch )
{
if( !IsDead( tempch ) && tempch->type == SPRITETYPE_MONSTER && tempch != n )
{
if( tempch->bossid == n->bossid )
{
tempch->targetid = n->targetid;
SendNPC_parameter( n->id, NPC_PARAMETER_TARGETID, n->targetid );
tempch->patterntype = NPC_PATTERN_BACKDRAW_PC_28_;
}
}
tempch = tempch->lpNext;
}
}
}
}
}
}
}
}
}
break;
case NPC_PATTERN_TOBOSS_28_ :
{
int ex, ey;
int bossid;
if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch )
{
n->aitimedelay = g_ClientTime;
n->aidelayhowmuch = 5000 + (rand()%2000);
if( NPC_IsMoving( n ) )
{
}
else
{
int targetid = NPC_IsWhoNearPC( n, 10 );
if( targetid != -1 )
{
n->patterntype = NPC_PATTERN_BACKDRAW_PC_28_;
n->targetid = targetid;
break;
}
if( NPC_IsInBossRange( n ) ) // Boss救俊 甸绢吭栏搁..
{
bossid = NPC_WhoIsBoss( n );
if( bossid != -1 ) // 去磊扼绰 娟扁.
{
if( bossid != n->id ) // 澜. 唱焊促 Exp啊 臭篮 仇捞 乐焙..
{
n->bossid = bossid;
SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, bossid);
n->patterntype = NPC_PATTERN_TOBOSS_28_;
goto TO_BOSS_;
}
else // 郴啊 Boss捞促.
{
n->bossid = bossid;
n->patterntype = NPC_PATTERN_IAM_BOSS_28_;
n->targetid = -1;
SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, bossid);
SendNPC_parameter( n->id, NPC_PARAMETER_TARGETID, -1 );
}
}
else
{
n->patterntype = NPC_PATTERN_WANDER_28_;
n->targetid = -1;
n->bossid = -1;
SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, -1 );
SendNPC_parameter( n->id, NPC_PARAMETER_TARGETID, -1 );
break;
}
}
else // Boss扮栏肺 啊具瘤...
{
TO_BOSS_: if( n->bossid != -1 )
{
LPCHARACTER tempch = ReturnCharacterPoint( n->bossid );
if( NPC_NearPosition( n, tempch, &ex, &ey ))
{
NPC_MakePath( n, ex, ey, Random(6));
break;
}
}
else
{
n->patterntype = NPC_PATTERN_MURI_28_;
n->targetid = -1;
break;
}
}
}
}
}
break;
// 公府瘤绢促囱促... 28
case NPC_PATTERN_MURI_28_ :
{
int bossid = -1;
if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch )
{
n->aitimedelay = g_ClientTime;
n->aidelayhowmuch = 2000 + (rand()%1000);
if( NPC_IsMoving( n ) )
{
}
else
{
bossid = NPC_WhoIsBoss( n );
if( bossid != -1 ) // 去磊扼绰 娟扁.
{
if( bossid != n->id ) // 澜. 唱焊促 Exp啊 臭篮 仇捞 乐焙..
{
n->bossid = bossid;
SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, bossid);
n->patterntype = NPC_PATTERN_TOBOSS_28_;
}
else // 郴啊 Boss捞促.
{
n->bossid = bossid;
n->patterntype = NPC_PATTERN_IAM_BOSS_28_;
n->targetid = -1;
SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, bossid);
SendNPC_parameter( n->id, NPC_PARAMETER_TARGETID, -1 );
}
}
else
{
n->patterntype = NPC_PATTERN_WANDER_28_;
n->bossid = -1;
n->targetid = -1;
SendNPC_parameter( n->id, NPC_PARAMETER_BOSSID, -1);
SendNPC_parameter( n->id, NPC_PARAMETER_TARGETID, -1);
}
}
}
}
break;
case NPC_PATTERN_BACKDRAW_PC_28_ :
{
if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch )
{
n->aitimedelay = g_ClientTime;
n->aidelayhowmuch = 1000 + (rand()%400);
if( NPC_IsMoving( n ) )
{
}
else
{
if( n->targetid != -1 )
{
LPCHARACTER tempch = ReturnCharacterPoint( n->targetid );
if( InDistance( n, tempch, TILE_SIZE * 10 ) ) // 弊 PC啊 10 鸥老救俊 乐促搁.
{
if( NPC_NearBackCh( n, tempch, &ex, &ey, 10 ) )
{
n->MoveP = 140 + Random(120);
if( NPC_MakePath( n, ex, ey, Random(10)+5 ) )
{
}
else
{
n->targetid = -1;
n->patterntype = NPC_PATTERN_WANDER_28_;
}
}
else
{
}
}
else // 面盒洒 钢府乐焙.
{
n->patterntype = NPC_PATTERN_WANDER_28_;
}
}
else
{
n->patterntype = NPC_PATTERN_WANDER_28_;
}
}
}
break;
}
}
}
void NPC_Pattern_38( LPCHARACTER n)
{
int ex, ey;
switch( n->patterntype )
{
case NPC_PATTERN_WANDER_38_ :
if( g_ClientTime - n->aitimedelay > n->aidelayhowmuch )
{
n->aitimedelay = g_ClientTime;
n->aidelayhowmuch = 2000 + (rand()%500);
}
else break;
// 弊成 硅雀茄促.
if( NPC_IsMoving( n ) )
{
}
else
{
int targetid = NPC_IsWhoNearPC( n, 15 );
if( targetid != -1 )
{
n->patterntype = NPC_PATTERN_ACCESS_PC_38_;
n->targetid = targetid;
}
else
{
int dir;
int how;
int tx, ty;
dir = Random(8);
how = Random(8)+2;
tx = n->x / TILE_SIZE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -