bool CMobs::Attacked(CMapObject *Obj) { if (Player.Attacking) { if (Collision.TextureToTexture(Obj, this)) { ChangeHP(1, true, false); return true; } return false; } return false; }
void CMobs::Respawn() { ChangeHP(MaxHP, false, false); ChangeMP(MaxMP, false, false); }
void Enemy::Update( Character players[2], int soundTimer, int soundTimer2, float gameTimer, SAMPLE* sndAttack, SAMPLE* sndDamage, int MaxText, TextEffect txteffect[] ) { if ( deadTimer > 0 ) { deadTimer -= 0.1; if ( deadTimer <= 0 ) { Reset(); } } if ( exists ) { collisionRegion.X( position.x + 5 ); collisionRegion.Y( position.y + 5 ); collisionRegion.W( 24 ); collisionRegion.H( 24 ); if ( atkCounter > 0 ) { atkCounter -= 0.5; } else { atkCounter = -1; action = WALKING; } for ( int p = 0; p < 2; p++ ) { if ( Exists() == true && players[p].Exists() && IsCollision( &players[p] ) ) { if ( players[p].Is() == ATTACKING ) { if ( soundTimer <= 0 ) { play_sample( sndAttack, 255, 128, 1000, false ); soundTimer = 5.0; ChangeHP( players[p].StrengthFloat() ); if ( hp <= 0 ) { players[p].Exp( Exp() ); } bool foundText = false; //Setup fancy text crap for ( int j=0; j<MaxText; j++ ) { if ( foundText == false ) { if ( txteffect[j].inUse == false ) { txteffect[j].Setup( players[p].StrengthString().c_str(), X()+3, Y(), 255, 100, 75 ); foundText = true; } } } } }//attacking //enemy attack if ( soundTimer2 <= 0 && gameTimer > 20 ) { play_sample( sndDamage, 255, 128, 1000, false ); soundTimer2 = 10.0; players[p].AddHP( -0.1 ); bool foundText = false; //Setup fancy text crap for ( int j=0; j<MaxText; j++ ) { if ( foundText == false ) { if ( txteffect[j].inUse == false ) { txteffect[j].Setup( "-2", players[p].X()+3, players[p].Y(), 255, 0, 0 ); foundText = true; } } } }//not attacking }//if ( enemy[i].Exists() == true && IsCollision( &player, &enemy[i] ) ) } if ( hp <= 0 ) { exists = false; SetDeadTimer(); } } }
int FrameMove() { int ret; E3DGetKeyboardCnt( keybuf ); if( gameflag == 0 ){ ret = MoveChara( CHARA_RED, CHARA_BLUE, VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT, 'B', 'N', 'M' ); if( ret ){ _ASSERT( 0 ); return 1; } ret = MoveChara( CHARA_BLUE, CHARA_RED, 'W', 'S', 'A', 'D', 'Z', 'X', 'C' ); if( ret ){ _ASSERT( 0 ); return 1; } ret = MoveCamera(); if( ret ){ _ASSERT( 0 ); return 1; } } int stat; ret = E3DChkInView( scid, groundhsid, &stat ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DChkInView( scid, ci[CHARA_RED].hsid, &stat ); if( ret ){ _ASSERT( 0 ); return 1; } ret = E3DChkInView( scid, ci[CHARA_BLUE].hsid, &stat ); if( ret ){ _ASSERT( 0 ); return 1; } if( gameflag == 0 ){ ret = ChkConfChara(); if( ret ){ _ASSERT( 0 ); return 1; } ret = ChangeHP( CHARA_RED, CHARA_BLUE ); if( ret ){ _ASSERT( 0 ); return 1; } ret = ChangeHP( CHARA_BLUE, CHARA_RED ); if( ret ){ _ASSERT( 0 ); return 1; } ret = ChkGameOver(); if( ret ){ _ASSERT( 0 ); return 1; } } return 0; }