void Minions::NomalUpdate(void) { if (_Time + _PatTime < TIMEMANAGER->GetTotalTime()) { _Time = TIMEMANAGER->GetTotalTime(); int Pick = rand() & 3; if (Pick == 0) { Play("Wait"); _Patten = NOMAL_WAIT; PickSound(); } else if (Pick == 1) { Play("Unarmedwait"); _Patten = NOMAL_WAIT2; PickSound(); } else if (Pick == 2) { Play("Walk"); _Patten = NOMAL_WALK; _Angle = RandomFloatRange(-0.01, 0.01); } if (_PrevPatten != _Patten) { _PrevPatten = _Patten; } else { _Patten = NOMAL_WALK; _PrevPatten = NOMAL_NULL; Play("Walk"); _Angle = RandomFloatRange(-0.01, 0.01); } } switch (_Patten) { case Minions::NOMAL_WAIT: break; case Minions::NOMAL_WAIT2: break; case Minions::NOMAL_WALK: _MainTrans->MovePositionSelf(0, 0, Speed); _MainTrans->RotateSelf(0, _Angle, 0); break; default: break; } float Len = calculateLen(_MainTrans->GetWorldPosition(), _TargetTrans->GetWorldPosition()); if (Len < 20) { _State = FIND; Play("Walk"); PickSound(); } }
void CItem::ItemTouch( CBaseEntity *pOther ) { //removed this limitation for monsters if ( !pOther->IsPlayer() ) return; CBasePlayer *pPlayer = (CBasePlayer *)pOther; if (!UTIL_IsMasterTriggered(m_sMaster, pPlayer)) return; if (pPlayer->pev->deadflag != DEAD_NO) return; if (AddItem( pPlayer ) != -1 ) { UTIL_FireTargets( pev->target, pOther, this, USE_TOGGLE ); SetTouch( NULL ); if( IsItem() && gmsg.ItemPickup ) { //show icon for item MESSAGE_BEGIN( MSG_ONE, gmsg.ItemPickup, NULL, pPlayer->pev ); WRITE_STRING( STRING(pev->classname) ); MESSAGE_END(); } // play pickup sound EMIT_SOUND( pPlayer->edict(), CHAN_ITEM, (char *)PickSound(), 1, ATTN_NORM ); // tell the owner item was taken if (!FNullEnt( pev->owner )) pev->owner->v.impulse = 0; // enable respawn in multiplayer if ( g_pGameRules->IsMultiplayer() && !FBitSet( pev->spawnflags, SF_NORESPAWN )) Respawn(); else UTIL_Remove( this ); } else if ( gEvilImpulse101 ) UTIL_Remove( this ); }
void Minions::SetHP(float Atk) { if (!_Life)return; _HP -= Atk; if (_MaxHP * 0.15 < Atk) { _Patten = FIGHT_HIT; Play("Hit"); PickSound(); } }
void Minions::FindUpdate(void) { //D3DXVECTOR3 Look; //D3DXVec3Cross(&Look, &_TargetTrans->GetForwa rd(), &_MainTrans->GetWorldPosition()); _MainTrans->LookPosition(_TargetTrans->GetWorldPosition(), 0.02); _MainTrans->LookDirection(_MainTrans->GetForward(),D3DXVECTOR3(0,1,0)); D3DXVECTOR3 Look = _TargetTrans->GetWorldPosition() - _MainTrans->GetWorldPosition(); D3DXVECTOR3 NomalLook; D3DXVec3Normalize(&NomalLook, &Look); float Angle = D3DXVec3Dot(&NomalLook, &_MainTrans->GetForward()); if (Angle > 0.85) { _State = FIGHT; _Patten = FIGHT_RUN; Play("Run"); Speed *= 4; PickSound(); } }
void Minions::FightUpdate(void) { switch (_Patten) { case Minions::FIGHT_NOMAL: break; case Minions::FIGHT_RUN: if (!PHYSICS_MGR->IsOverlap(_MainBox->BoxTrans, _MainBox->Box, _TargetTrans, _PlayerBox)) { _MainTrans->LookPosition(_TargetTrans->GetWorldPosition(), 0.05); _MainTrans->LookDirection(_MainTrans->GetForward(), D3DXVECTOR3(0, 1, 0)); _MainTrans->MovePositionSelf(0, 0, Speed); } else { int Pick = rand() % 2; if (Pick == 0) { _Patten = FIGHT_ATK1; Play("Atk1"); PickSound(); } else { _Patten = FIGHT_ATK2; Play("Atk2"); PickSound(); } } break; case Minions::FIGHT_ATK1:case Minions::FIGHT_ATK2: _MainTrans->LookPosition(_TargetTrans->GetWorldPosition(), 0.05); _MainTrans->LookDirection(_MainTrans->GetForward(), D3DXVECTOR3(0, 1, 0)); if (isFinishAni()) { _Patten = FIGHT_WAIT; Play("Wait"); _Hit = false; } SetAtkBox(); break; case Minions::FIGHT_WAIT: if (isFinishAni()) { if (!PHYSICS_MGR->IsOverlap(_MainBox->BoxTrans, _MainBox->Box, _TargetTrans, _PlayerBox)) { _Patten = FIGHT_RUN; Play("Run"); PickSound(); } else { int Pick = rand() % 2; if (Pick == 0) { _Patten = FIGHT_ATK1; Play("Atk1"); PickSound(); } else { _Patten = FIGHT_ATK2; Play("Atk2"); PickSound(); } } } break; case Minions::FIGHT_HIT: if (isFinishAni()) { _Patten = FIGHT_WAIT; Play("Wait"); } break; default: break; } if (_HP <= 0) { _HP = 0; _State = DIE; PlayOneHold("Death"); _Life = false; QuestCount(); PickSound(); } }
void CItem::Precache( void ) { UTIL_PrecacheModel( pev->model, Model() ); UTIL_PrecacheSound( PickSound()); UTIL_PrecacheSound( FallSound()); }