/* ================ rvWeaponGauntlet::CleanupWeapon ================ */ void rvWeaponGauntlet::CleanupWeapon( void ) { if ( impactEffect ) { impactEffect->Stop( ); impactEffect = NULL; } impactMaterial = -1; PlayLoopSound( LOOP_NONE ); }
void rvWeaponGauntlet::Attack ( void ) { trace_t tr; idEntity* ent; int knockback; bool it; // Cast a ray out to the lock range // RAVEN BEGIN // ddynerman: multiple clip worlds gameLocal.TracePoint( owner, tr, playerViewOrigin, playerViewOrigin + playerViewAxis[0] * 100, MASK_SHOT_RENDERMODEL, owner ); // RAVEN END owner->WeaponFireFeedback( &weaponDef->dict ); if ( tr.fraction >= 1.0f ) { if ( impactEffect ) { impactEffect->Stop ( ); impactEffect = NULL; } impactMaterial = -1; PlayLoopSound( LOOP_NONE ); return; } // Entity we hit? ent = gameLocal.entities[tr.c.entityNum]; // If the impact material changed then stop the impact effect if ( (tr.c.materialType && tr.c.materialType->Index ( ) != impactMaterial) || (!tr.c.materialType && impactMaterial != -1) ) { if ( impactEffect ) { impactEffect->Stop ( ); impactEffect = NULL; } impactMaterial = -1; } // In singleplayer-- the gauntlet never effects marine AI if( !gameLocal.isMultiplayer ) { idActor* actor_ent = 0; //ignore both the body and the head. if (ent->IsType( idActor::GetClassType()) ) { actor_ent = static_cast<idActor*>(ent); } else if (ent->IsType ( idAFAttachment::GetClassType()) ) { actor_ent = static_cast<idActor*>(ent->GetBindMaster()); } if ( actor_ent && actor_ent->team == gameLocal.GetLocalPlayer()->team ) { PlayLoopSound( LOOP_NONE ); return; } } //multiplayer-- don't gauntlet dead stuff if( gameLocal.isMultiplayer ) { idPlayer * player; if ( ent->IsType( idPlayer::GetClassType() )) { player = static_cast< idPlayer* >(ent); if (player->health <= 0) { return; } } } if ( !impactEffect ) { impactMaterial = tr.c.materialType ? tr.c.materialType->Index() : -1; impactEffect = gameLocal.PlayEffect ( gameLocal.GetEffect ( spawnArgs, "fx_impact", tr.c.materialType ), tr.endpos, tr.c.normal.ToMat3(), true ); } else { impactEffect->SetOrigin ( tr.endpos ); impactEffect->SetAxis ( tr.c.normal.ToMat3() ); } // Do damage? if ( gameLocal.time > nextAttackTime ) { if ( ent ) { if ( ent->fl.takedamage ) { float dmgScale = 20.0f; knockback *= 100; dmgScale *= owner->PowerUpModifier( PMOD_MELEE_DAMAGE ); if(ent->IsType( idPlayer::GetClassType() ) && (static_cast < idPlayer * >( ent )->it == false && owner->it == true))//ROCCORICCIARDI { ent->Damage ( owner, owner, playerViewAxis[0], spawnArgs.GetString ( "def_damage" ), 0.01f, 0 ); owner->it = false; owner->ClearPowerUps(); static_cast < idPlayer * >( ent )->it = true; static_cast < idPlayer * >( ent )->GivePowerUp( POWERUP_QUADDAMAGE, SEC2MS( 30.0f ) );//ROCCORICCIARDI } StartSound( "snd_hit", SND_CHANNEL_ANY, 0, false, NULL ); if ( ent->spawnArgs.GetBool( "bleed" ) ) { PlayLoopSound( LOOP_FLESH ); } else { PlayLoopSound( LOOP_WALL ); } } else { PlayLoopSound( LOOP_WALL ); } } else { PlayLoopSound( LOOP_NONE ); } nextAttackTime = gameLocal.time + fireRate; } }
//------------------------------------------------------------------------- // 功能: 各种物件的处理 //------------------------------------------------------------------------- void KObj::Activate() { if ( m_nIndex <= 0 ) return; #ifdef _SERVER int nEnemyIndex, x, y; #else int nMask = IPOT_RL_OBJECT | IPOT_RL_INFRONTOF_ALL; #endif switch(m_nKind) { #ifndef _SERVER case Obj_Kind_MapObj: // 地图物件动画 if (m_nState == 0) // 地图物件动画循环播放 m_cImage.GetNextFrame(); nMask = IPOT_RL_OBJECT | IPOT_RL_INFRONTOF_ALL; break; case Obj_Kind_Light: // 光源 if (m_nState == 0) m_cImage.GetNextFrame(); nMask = IPOT_RL_OBJECT | IPOT_RL_INFRONTOF_ALL; break; case Obj_Kind_LoopSound: // 循环音效 PlayLoopSound(); break; case Obj_Kind_RandSound: // 随机音效 PlayRandSound(); break; case Obj_Kind_Body: // 尸体逐渐消失 m_cImage.GetNextFrame(FALSE); // 尸体动画单方向播放 m_nLifeTime--; if (m_nLifeTime <= 0) Remove(FALSE); nMask = IPOT_RL_COVER_GROUND | IPOT_RL_INFRONTOF_ALL; break; #endif case Obj_Kind_Box: // 宝箱 #ifdef _SERVER if (m_nState == OBJ_BOX_STATE_OPEN) // 宝箱关闭重生 { m_nBornTime--; if (m_nBornTime <= 0) SetState(OBJ_BOX_STATE_CLOSE); } #else if (m_nState == OBJ_BOX_STATE_CLOSE)// 宝箱关闭状态 m_cImage.GetPrevFrame(FALSE); else// if (m_nState == OBJ_BOX_STATE_OPEN)// 宝箱打开状态 m_cImage.GetNextFrame(FALSE); nMask = IPOT_RL_OBJECT | IPOT_RL_INFRONTOF_ALL; #endif break; case Obj_Kind_Door: // 门 #ifdef _SERVER #else if (m_nState == OBJ_DOOR_STATE_CLOSE)// 门关闭状态 m_cImage.GetPrevFrame(FALSE); else// if (m_nState == OBJ_DOOR_STATE_OPEN)// 门打开状态 m_cImage.GetNextFrame(FALSE); nMask = IPOT_RL_OBJECT | IPOT_RL_INFRONTOF_ALL; #endif break; case Obj_Kind_Item: // 装备动画循环播放 #ifdef _SERVER if (m_nBelong >= 0) { m_nBelongTime--; if (m_nBelongTime <= 0) { m_nBelongTime = 0; m_nBelong = -1; } } m_nLifeTime--; if (m_nLifeTime <= 0) Remove(FALSE); #else if (this->m_nDropState == 1) // 物品掉出动画 { if (m_cImageDrop.GetNextFrame(FALSE)) { if (m_cImageDrop.CheckEnd()) { m_nDropState = 0; // 物品掉出动画播放完了,改为放置循环动画 m_Image.uImage = 0; } } nMask = IPOT_RL_OBJECT | IPOT_RL_INFRONTOF_ALL; } else { if (this->m_nDropState == 2) { if (m_cImage.GetNextFrame(FALSE)) { if (m_cImage.CheckEnd()) this->m_nDropState = 0; } } else { if (g_Random(40) == 0) { m_nDropState = 2; } else { m_cImage.SetDirStart(); } } nMask = IPOT_RL_COVER_GROUND | IPOT_RL_INFRONTOF_ALL; } m_nLifeTime--; if (m_nLifeTime <= -100) Remove(FALSE); #endif break; case Obj_Kind_Money: #ifdef _SERVER if (m_nBelong >= 0) { m_nBelongTime--; if (m_nBelongTime <= 0) { m_nBelongTime = 0; m_nBelong = -1; } } m_nLifeTime--; if (m_nLifeTime <= 0) Remove(FALSE); #else m_cImage.GetNextFrame(); nMask = IPOT_RL_COVER_GROUND | IPOT_RL_INFRONTOF_ALL; m_nLifeTime--; if (m_nLifeTime <= -100) Remove(FALSE); #endif break; case Obj_Kind_Prop: #ifdef _SERVER if (m_nState == OBJ_PROP_STATE_HIDE) // 道具隐藏状态 { m_nBornTime--; if (m_nBornTime <= 0) SetState(OBJ_PROP_STATE_DISPLAY);// 道具重生 } #else if (m_nState == OBJ_PROP_STATE_DISPLAY) { m_cImage.GetNextFrame(); nMask = IPOT_RL_OBJECT | IPOT_RL_INFRONTOF_ALL; } #endif break; /* case Obj_Kind_Trap: switch (m_cSkill.m_nKind) { case ObjTrap_Kind_Cycle_Image_Static: if (m_nState == OBJ_TRAP_STATE_STOP) { if (m_nWaitTime > 0) { m_nWaitTime--; if (m_nWaitTime <= 0) { m_nWaitTime = 0; SetState(OBJ_TRAP_STATE_ACTIVE); } } #ifdef _SERVER m_cImage.SetDirStart(); #else m_cImage.SetDirStart(); #endif } else// if (m_nState == OBJ_TRAP_STATE_ACTIVE) { #ifdef _SERVER // 朝自身位置发射技能 // if (m_cImage.GetCurDirFrameNo() == m_cSkill.m_nCastTime) // Skill[][].cast() m_cImage.GetNextFrame(); #else // 朝自身位置发射技能 // if (m_cImage.GetCurDirFrameNo() == m_cSkill.m_nCastTime) // Skill[][].cast() m_cImage.GetNextFrame(); #endif } break; case ObjTrap_Kind_Cycle_Image_Dir: if (m_nState == OBJ_TRAP_STATE_STOP) { if (m_nWaitTime > 0) { m_nWaitTime--; if (m_nWaitTime <= 0) { m_nWaitTime = 0; SetState(OBJ_TRAP_STATE_ACTIVE); } } #ifdef _SERVER m_cImage.SetDirStart(); #else m_cImage.SetDirStart(); #endif } else// if (m_nState == OBJ_TRAP_STATE_ACTIVE) { #ifdef _SERVER // 朝固定方向发射技能 // if (m_cImage.GetCurDirFrameNo() == m_cSkill.m_nCastTime) // Skill[][].cast() m_cImage.GetNextFrame(); #else // 朝固定方向发射技能 // if (m_cImage.GetCurDirFrameNo() == m_cSkill.m_nCastTime) // Skill[][].cast() m_cImage.GetNextFrame(); #endif } break; case ObjTrap_Kind_Auto_Image_Static: if (m_nState == OBJ_TRAP_STATE_STOP) break; #ifdef _SERVER if (m_nState == OBJ_TRAP_STATE_ACTIVE) { nEnemyIndex = FindEnemy(); if (nEnemyIndex > 0) { Npc[nEnemyIndex].GetMpsPos(&x, &y); m_cSkill.m_nTarX = x; m_cSkill.m_nTarY = y; m_nState = OBJ_TRAP_STATE_ACTING; m_cImage.SetDirStart(); // 通知客户端 TrapAct(); } } else if (m_nState == OBJ_TRAP_STATE_ACTING) { // 朝固定位置发射技能 // if (m_cImage.m_nCurFrame == m_cSkill.m_nCastTime) // Skill[][].cast m_cImage.GetNextFrame(FALSE); if (m_cImage.CheckEnd()) { m_nState = OBJ_TRAP_STATE_ACTIVE; m_cImage.SetDirStart(); } } #else if (m_nState == OBJ_TRAP_STATE_ACTING) { // 朝自身位置发射技能 // if (m_cImage.GetCurDirFrameNo() == m_cSkill.m_nCastTime) // Skill[][].cast() m_cImage.GetNextFrame(FALSE); if (m_cImage.CheckEnd()) { m_nState = OBJ_TRAP_STATE_ACTIVE; m_cImage.SetDirStart(); } } #endif break; case ObjTrap_Kind_Auto_Image_Dir: if (m_nState == OBJ_TRAP_STATE_STOP) break; #ifdef _SERVER if (m_nState == OBJ_TRAP_STATE_ACTIVE) { nEnemyIndex = FindEnemy(); if (nEnemyIndex > 0) { Npc[nEnemyIndex].GetMpsPos(&x, &y); m_cSkill.m_nTarX = x; m_cSkill.m_nTarY = y; m_nState = OBJ_TRAP_STATE_ACTING; m_cImage.SetDirStart(); // 通知客户端 TrapAct(); } } else if (m_nState == OBJ_TRAP_STATE_ACTING) { // 朝固定方向发射技能 // if (m_cImage.m_nCurFrame == m_cSkill.m_nCastTime) // Skill[][].cast m_cImage.GetNextFrame(FALSE); if (m_cImage.CheckEnd()) { m_nState = OBJ_TRAP_STATE_ACTIVE; m_cImage.SetDirStart(); } } #else if (m_nState == OBJ_TRAP_STATE_ACTING) { // 朝固定方向发射技能 // if (m_cImage.GetCurDirFrameNo() == m_cSkill.m_nCastTime) // Skill[][].cast() m_cImage.GetNextFrame(FALSE); if (m_cImage.CheckEnd()) { m_nState = OBJ_TRAP_STATE_ACTIVE; m_cImage.SetDirStart(); } } #endif break; case ObjTrap_Kind_Auto_Image_Target: if (m_nState == OBJ_TRAP_STATE_STOP) break; #ifdef _SERVER if (m_nState == OBJ_TRAP_STATE_ACTIVE) { nEnemyIndex = FindEnemy(); if (nEnemyIndex > 0) { Npc[nEnemyIndex].GetMpsPos(&x, &y); m_cSkill.m_nTarX = x; m_cSkill.m_nTarY = y; m_nState = OBJ_TRAP_STATE_ACTING; m_cImage.SetDirStart(); // 通知客户端 TrapAct(); } } else if (m_nState == OBJ_TRAP_STATE_ACTING) { // 朝目标点发射技能 // if (m_cImage.m_nCurFrame == m_cSkill.m_nCastTime) // Skill[][].cast m_cImage.GetNextFrame(FALSE); if (m_cImage.CheckEnd()) { m_nState = OBJ_TRAP_STATE_ACTIVE; m_cImage.SetDirStart(); } } #else if (m_nState == OBJ_TRAP_STATE_ACTING) { // 朝目标点发射技能 // if (m_cImage.GetCurDirFrameNo() == m_cSkill.m_nCastTime) // Skill[][].cast() m_cImage.GetNextFrame(FALSE); if (m_cImage.CheckEnd()) { m_nState = OBJ_TRAP_STATE_ACTIVE; m_cImage.SetDirStart(); } } #endif break; case ObjTrap_Kind_Auto_Delay_Static: if (m_nState == OBJ_TRAP_STATE_STOP) break; #ifdef _SERVER if (m_nState == OBJ_TRAP_STATE_ACTIVE) { if (m_nWaitTime > 0) { m_nWaitTime--; } else { nEnemyIndex = FindEnemy(); if (nEnemyIndex > 0) { Npc[nEnemyIndex].GetMpsPos(&x, &y); m_cSkill.m_nTarX = x; m_cSkill.m_nTarY = y; m_nState = OBJ_TRAP_STATE_ACTING; // 通知客户端 TrapAct(); // 朝自身位置发射技能 //Skill[][].cast(); m_nState = OBJ_TRAP_STATE_ACTIVE; m_nWaitTime = m_cSkill.m_nCastTime; } } } #else if (m_nState == OBJ_TRAP_STATE_ACTING) { // 朝自身位置发射技能 // Skill[][].cast() m_nState = OBJ_TRAP_STATE_ACTIVE; } m_cImage.GetNextFrame(); #endif break; case ObjTrap_Kind_Auto_Delay_Dir: if (m_nState == OBJ_TRAP_STATE_STOP) break; #ifdef _SERVER if (m_nState == OBJ_TRAP_STATE_ACTIVE) { if (m_nWaitTime > 0) { m_nWaitTime--; } else { nEnemyIndex = FindEnemy(); if (nEnemyIndex > 0) { Npc[nEnemyIndex].GetMpsPos(&x, &y); m_cSkill.m_nTarX = x; m_cSkill.m_nTarY = y; m_nState = OBJ_TRAP_STATE_ACTING; // 通知客户端 TrapAct(); // 朝固定方向发射技能 //Skill[][].cast(); m_nState = OBJ_TRAP_STATE_ACTIVE; m_nWaitTime = m_cSkill.m_nCastTime; } } } #else if (m_nState == OBJ_TRAP_STATE_ACTING) { // 朝固定方向发射技能 // Skill[][].cast() m_nState = OBJ_TRAP_STATE_ACTIVE; } m_cImage.GetNextFrame(); #endif break; case ObjTrap_Kind_Auto_Delay_Target: if (m_nState == OBJ_TRAP_STATE_STOP) break; #ifdef _SERVER if (m_nState == OBJ_TRAP_STATE_ACTIVE) { if (m_nWaitTime > 0) { m_nWaitTime--; } else { nEnemyIndex = FindEnemy(); if (nEnemyIndex > 0) { Npc[nEnemyIndex].GetMpsPos(&x, &y); m_cSkill.m_nTarX = x; m_cSkill.m_nTarY = y; m_nState = OBJ_TRAP_STATE_ACTING; // 通知客户端 TrapAct(); // 朝目标点发射技能 //Skill[][].cast(); m_nState = OBJ_TRAP_STATE_ACTIVE; m_nWaitTime = m_cSkill.m_nCastTime; } } } #else if (m_nState == OBJ_TRAP_STATE_ACTING) { // 朝目标点发射技能 // Skill[][].cast() m_nState = OBJ_TRAP_STATE_ACTIVE; } m_cImage.GetNextFrame(); #endif break; } break; */ } #ifndef _SERVER int nMpsX, nMpsY; SubWorld[m_nSubWorldID].Map2Mps(m_nRegionIdx, m_nMapX, m_nMapY, m_nOffX, m_nOffY, &nMpsX, &nMpsY); g_ScenePlace.MoveObject(CGOG_OBJECT, m_nIndex, nMpsX, nMpsY, 0, m_SceneID, nMask); #endif }