示例#1
0
xrServer::EConnect xrServer::Connect(shared_str &session_name)
{
#ifdef DEBUG
	Msg						("* sv_Connect: %s",	*session_name);
#endif

	// Parse options and create game
	if (0==strchr(*session_name,'/'))
		return				ErrConnect;

	string1024				options;
	R_ASSERT2(xr_strlen(session_name) <= sizeof(options), "session_name too BIIIGGG!!!");
	strcpy					(options,strchr(*session_name,'/')+1);
	
	// Parse game type
	string1024				type;
	R_ASSERT2(xr_strlen(options) <= sizeof(type), "session_name too BIIIGGG!!!");
	strcpy					(type,options);
	if (strchr(type,'/'))	*strchr(type,'/') = 0;
	game					= NULL;

	CLASS_ID clsid			= game_GameState::getCLASS_ID(type,true);
	game					= smart_cast<game_sv_GameState*> (NEW_INSTANCE(clsid));

	// Options
	if (0==game)			return ErrConnect;
	csPlayers.Enter			();
//	game->type				= type_id;
#ifdef DEBUG
	Msg("* Created server_game %s",game->type_name());
#endif

	game->Create			(session_name);
	csPlayers.Leave			();
	
#ifdef BATTLEYE
	if ( game->get_option_i( *session_name, "battleye", 1) != 0 ) // default => battleye enable (always)
	{
		// if level exist & if server in internet
		if ( g_pGameLevel && (game->get_option_i( *session_name, "public", 0) != 0)  )
		{
			if ( Level().battleye_system.server )
			{
				Msg( "Warning: BattlEye already loaded!" );
			}
			else
			{
				if ( !Level().battleye_system.LoadServer( this ) )
				{
					return ErrBELoad;
				}
			}
		}//g_pGameLevel
	}
/*	if ( g_pGameLevel && Level().battleye_system.server )
	{
		if ( game->get_option_i( *session_name, "battleye_update", 1) != 0 ) // default => battleye auto_update enable (always)
		{
			Level().battleye_system.auto_update = 1;
		}
		else
		{
			Level().battleye_system.auto_update = 0;
		}
	}*/
#endif // BATTLEYE
	
	return IPureServer::Connect(*session_name);
}
示例#2
0
#include "LevelSelectScene.h"

Level LevelSelectScene::LEVELS[] =
{
		Level(101, 2, 10.0f, 20, 30), // level 1
		Level(102, 5, 10.0f, 20, 30), // level 2
		Level(103, 3, 10.0f, 20, 40), // level 3
		Level(104, 4, 11.0f, 20, 30), // level 4
		Level(105, 6, 12.0f, 20, 40), // level 5
		Level(106, 3, 13.0f, 20, 50), // level 6
		Level(107, 5, 20.0f, 20, 60), // level 7
		Level(108, 8, 15.0f, 20, 30), // level 8
		Level(109, 9, 14.0f, 20, 30), // level 9
		Level(110, 7, 14.0f, 20, 30), // level 10
		Level(111, 6, 16.0f, 20, 60), // level 11
		Level(112, 4, 17.0f, 20, 50), // level 12
		Level(113, 7, 15.0f, 20, 50), // level 13
		Level(114, 9, 14.5f, 20, 50), // level 14
		Level(115, 7, 17.0f, 20, 80)  // level 15
};
const int LevelSelectScene::LEVEL_NR = 15;

LevelSelectScene::LevelSelectScene() : mMenu(nullptr)
{
	cocos2d::log("level select scene constructed");
}

LevelSelectScene::~LevelSelectScene()
{
	cocos2d::log("level select scene destructed");
}
示例#3
0
bool CUIGameSP::IR_OnKeyboardPress(int dik) 
{
	if(inherited::IR_OnKeyboardPress(dik)) return true;

	if( Device.Paused()		) return false;

	CActor *pActor = smart_cast<CActor*>(Level().CurrentEntity());
	if(!pActor)								return false;
	if( pActor && !pActor->g_Alive() )		return false;

	switch ( get_binded_action(dik) )
	{
	case kINVENTORY:
		if( !MainInputReceiver() || MainInputReceiver()==InventoryMenu){
			m_game->StartStopMenu(InventoryMenu,true);
			return true;
		}break;

	case kACTIVE_JOBS:
#if defined(UI_LOCK_PDA_WITHOUT_PDA_IN_SLOT)
		if (pActor->inventory().m_slots[PDA_SLOT].m_pIItem)
#endif
		if( !MainInputReceiver() || MainInputReceiver()==PdaMenu){
			PdaMenu->SetActiveSubdialog(eptQuests);
			m_game->StartStopMenu(PdaMenu,true);
			return true;
		}break;

	case kMAP:
#if defined(UI_LOCK_PDA_WITHOUT_PDA_IN_SLOT)
		if (pActor->inventory().m_slots[PDA_SLOT].m_pIItem)
#endif
		if( !MainInputReceiver() || MainInputReceiver()==PdaMenu){
			PdaMenu->SetActiveSubdialog(eptMap);
			m_game->StartStopMenu(PdaMenu,true);
			return true;
		}break;

	case kCONTACTS:
#if defined(UI_LOCK_PDA_WITHOUT_PDA_IN_SLOT)
		if (pActor->inventory().m_slots[PDA_SLOT].m_pIItem)
#endif
		if( !MainInputReceiver() || MainInputReceiver()==PdaMenu){
			PdaMenu->SetActiveSubdialog(eptContacts);
			m_game->StartStopMenu(PdaMenu,true);
			return true;
		}break;

	case kSCORES:
		{
			SDrawStaticStruct* ss	= AddCustomStatic("main_task", true);
			SGameTaskObjective* o	= pActor->GameTaskManager().ActiveObjective();
			if(!o)
				ss->m_static->SetTextST	("st_no_active_task");
			else
				ss->m_static->SetTextST	(*(o->description));

		}break;
	}
	return false;
}
示例#4
0
void CActorCondition::UpdateCondition()
{
	if(psActorFlags.test(AF_GODMODE_RT))
	{
		UpdateSatiety();
		UpdateBoosters();

		m_fAlcohol		+= m_fV_Alcohol*m_fDeltaTime;
		clamp			(m_fAlcohol,			0.0f,		1.0f);
		if(IsGameTypeSingle())
		{
			CEffectorCam* ce = Actor()->Cameras().GetCamEffector((ECamEffectorType)effAlcohol);
			if(ce)
				RemoveEffector(m_object,effAlcohol);
		}
	}

	if (GodMode())				return;
	if (!object().g_Alive())	return;
	if (!object().Local() && m_object != Level().CurrentViewEntity())		return;	
	
	float base_weight			= object().MaxCarryWeight();
	float cur_weight			= object().inventory().TotalWeight();

	if ((object().mstate_real&mcAnyMove))
	{
		ConditionWalk( cur_weight / base_weight,
			isActorAccelerated( object().mstate_real,object().IsZoomAimingMode() ),
			(object().mstate_real&mcSprint) != 0 );
	}
	else
	{
		ConditionStand( cur_weight / base_weight );
	}
	
	if ( IsGameTypeSingle() )
	{
		float k_max_power = 1.0f;
		if( true )
		{
			k_max_power = 1.0f + _min(cur_weight, base_weight) / base_weight
				+ _max(0.0f, (cur_weight - base_weight) / 10.0f);
		}
		else
		{
			k_max_power = 1.0f;
		}
		SetMaxPower		(GetMaxPower() - m_fPowerLeakSpeed * m_fDeltaTime * k_max_power);
	}


	m_fAlcohol		+= m_fV_Alcohol*m_fDeltaTime;
	clamp			(m_fAlcohol,			0.0f,		1.0f);

	if ( IsGameTypeSingle() )
	{	
		CEffectorCam* ce = Actor()->Cameras().GetCamEffector((ECamEffectorType)effAlcohol);
		if	((m_fAlcohol>0.0001f) ){
			if(!ce){
				AddEffector(m_object,effAlcohol, "effector_alcohol", GET_KOEFF_FUNC(this, &CActorCondition::GetAlcohol));
			}
		}else{
			if(ce)
				RemoveEffector(m_object,effAlcohol);
		}

		
		string512			pp_sect_name;
		shared_str ln		= Level().name();
		if(ln.size())
		{
			CEffectorPP* ppe	= object().Cameras().GetPPEffector((EEffectorPPType)effPsyHealth);
			

			strconcat			(sizeof(pp_sect_name),pp_sect_name, "effector_psy_health", "_", *ln);
			if(!pSettings->section_exist(pp_sect_name))
				xr_strcpy			(pp_sect_name, "effector_psy_health");

			if	( !fsimilar(GetPsyHealth(), 1.0f, 0.05f) )
			{
				if(!ppe)
				{
					AddEffector(m_object,effPsyHealth, pp_sect_name, GET_KOEFF_FUNC(this, &CActorCondition::GetPsy));
				}
			}else
			{
				if(ppe)
					RemoveEffector(m_object,effPsyHealth);
			}
		}
//-		if(fis_zero(GetPsyHealth()))
//-			SetHealth( 0.0f );
	};

	UpdateSatiety();
	UpdateBoosters();

	inherited::UpdateCondition();

	if( IsGameTypeSingle() )
		UpdateTutorialThresholds();

	if(GetHealth()<0.05f && m_death_effector==NULL && IsGameTypeSingle())
	{
		if(pSettings->section_exist("actor_death_effector"))
			m_death_effector = xr_new<CActorDeathEffector>(this, "actor_death_effector");
	}
	if(m_death_effector && m_death_effector->IsActual())
	{
		m_death_effector->UpdateCL	();

		if(!m_death_effector->IsActual())
			m_death_effector->Stop();
	}

	AffectDamage_InjuriousMaterialAndMonstersInfluence();
}
示例#5
0
void CGrenade::OnH_A_Independent() 
{
	m_dwGrenadeIndependencyTime			= Level().timeServer();
	inherited::OnH_A_Independent		();	
}
示例#6
0
void	CActor::PickupModeUpdate_COD	()
{
	if (Level().CurrentViewEntity() != this || !g_b_COD_PickUpMode) return;
		
	if (!g_Alive() || eacFirstEye != cam_active) 
	{
		HUD().GetUI()->UIMainIngameWnd->SetPickUpItem(NULL);
		return;
	};
	
	CFrustum frustum;
	frustum.CreateFromMatrix(Device.mFullTransform,FRUSTUM_P_LRTB|FRUSTUM_P_FAR);

	//---------------------------------------------------------------------------
	ISpatialResult.clear_not_free	();
	g_SpatialSpace->q_frustum(ISpatialResult, 0, STYPE_COLLIDEABLE, frustum);
	//---------------------------------------------------------------------------

	float maxlen = 1000.0f;
	CInventoryItem* pNearestItem = NULL;
	for (u32 o_it=0; o_it<ISpatialResult.size(); o_it++)
	{
		ISpatial*		spatial	= ISpatialResult[o_it];
		CInventoryItem*	pIItem	= smart_cast<CInventoryItem*> (spatial->dcast_CObject        ());
		if (0 == pIItem) continue;
		if (pIItem->object().H_Parent() != NULL) continue;
		if (!pIItem->CanTake()) continue;
		//. if (pIItem->object().CLS_ID == CLSID_OBJECT_G_RPG7 || pIItem->object().CLS_ID == CLSID_OBJECT_G_FAKE)
		if ( smart_cast<CExplosiveRocket*>( &pIItem->object() ) )
		{
			continue;
		}
		/*if ( smart_cast<CWeaponRPG7*>( &pIItem->object() ) || smart_cast<CExplosiveRocket*>( &pIItem->object() ) )
		{
			continue;
		}*/

		CGrenade*	pGrenade	= smart_cast<CGrenade*> (spatial->dcast_CObject        ());
		if (pGrenade && !pGrenade->Useful()) continue;

		CMissile*	pMissile	= smart_cast<CMissile*> (spatial->dcast_CObject        ());
		if (pMissile && !pMissile->Useful()) continue;
		
		Fvector A, B, tmp; 
		pIItem->object().Center			(A);
		if (A.distance_to_sqr(Position())>4) continue;

		tmp.sub(A, cam_Active()->vPosition);
		B.mad(cam_Active()->vPosition, cam_Active()->vDirection, tmp.dotproduct(cam_Active()->vDirection));
		float len = B.distance_to_sqr(A);
		if (len > 1) continue;

		if (maxlen>len && !pIItem->object().getDestroy())
		{
			maxlen = len;
			pNearestItem = pIItem;
		};
	}

	if(pNearestItem)
	{
		CFrustum					frustum;
		frustum.CreateFromMatrix	(Device.mFullTransform,FRUSTUM_P_LRTB|FRUSTUM_P_FAR);
		if (!CanPickItem(frustum,Device.vCameraPosition,&pNearestItem->object()))
			pNearestItem = NULL;
	}
	if (pNearestItem && pNearestItem->cast_game_object())
	{
		if (Level().m_feel_deny.is_object_denied(pNearestItem->cast_game_object()))
				pNearestItem = NULL;
	}
	if (pNearestItem && pNearestItem->cast_game_object())
	{
		if(!pNearestItem->cast_game_object()->getVisible())
				pNearestItem = NULL;
	}

	HUD().GetUI()->UIMainIngameWnd->SetPickUpItem(pNearestItem);

	if (pNearestItem && m_bPickupMode)
	{
		//подбирание объекта
		Game().SendPickUpEvent(ID(), pNearestItem->object().ID());
		
		PickupModeOff();
	}
};
示例#7
0
void CBaseMonster::debug_fsm()
{
	if (!g_Alive()) return;

	if (!psAI_Flags.test(aiMonsterDebug)) {
		DBG().object_info(this,this).clear ();
		return;
	}
	
	EMonsterState state = StateMan->get_state_type();
	
	string128 st;

	switch (state) {
		case eStateRest_WalkGraphPoint:					sprintf_s(st,"Rest :: Walk Graph");			break;
		case eStateRest_Idle:							sprintf_s(st,"Rest :: Idle");					break;
		case eStateRest_Fun:							sprintf_s(st,"Rest :: Fun");					break;
		case eStateRest_Sleep:							sprintf_s(st,"Rest :: Sleep");				break;
		case eStateRest_MoveToHomePoint:				sprintf_s(st,"Rest :: MoveToHomePoint");		break;
		case eStateRest_WalkToCover:					sprintf_s(st,"Rest :: WalkToCover");			break;
		case eStateRest_LookOpenPlace:					sprintf_s(st,"Rest :: LookOpenPlace");		break;

		case eStateEat_CorpseApproachRun:				sprintf_s(st,"Eat :: Corpse Approach Run");	break;
		case eStateEat_CorpseApproachWalk:				sprintf_s(st,"Eat :: Corpse Approach Walk");	break;
		case eStateEat_CheckCorpse:						sprintf_s(st,"Eat :: Check Corpse");			break;
		case eStateEat_Eat:								sprintf_s(st,"Eat :: Eating");				break;
		case eStateEat_WalkAway:						sprintf_s(st,"Eat :: Walk Away");				break;
		case eStateEat_Rest:							sprintf_s(st,"Eat :: Rest After Meal");		break;
		case eStateEat_Drag:							sprintf_s(st,"Eat :: Drag");					break;
		
		case eStateAttack_Run:							sprintf_s(st,"Attack :: Run");				break;
		case eStateAttack_Melee:						sprintf_s(st,"Attack :: Melee");				break;
		case eStateAttack_RunAttack:					sprintf_s(st,"Attack :: Run Attack");			break;
		case eStateAttack_RunAway:						sprintf_s(st,"Attack :: Run Away");			break;
		case eStateAttack_FindEnemy:					sprintf_s(st,"Attack :: Find Enemy");			break;
		case eStateAttack_Steal:						sprintf_s(st,"Attack :: Steal");				break;
		case eStateAttack_AttackHidden:					sprintf_s(st,"Attack :: Attack Hidden");		break;
		
		case eStateAttackCamp_Hide:						sprintf_s(st,"Attack Camp:: Hide");			break;
		case eStateAttackCamp_Camp:						sprintf_s(st,"Attack Camp:: Camp");			break;
		case eStateAttackCamp_StealOut:					sprintf_s(st,"Attack Camp:: Steal Out");		break;

		case eStateAttack_HideInCover:					sprintf_s(st,"Attack :: Hide In Cover");		break;
		case eStateAttack_MoveOut:						sprintf_s(st,"Attack :: Move Out From Cover");break;
		case eStateAttack_CampInCover:					sprintf_s(st,"Attack :: Camp In Cover");		break;

		case eStateAttack_Psy:							sprintf_s(st,"Attack :: Psy");				break;
		case eStateAttack_MoveToHomePoint:				sprintf_s(st,"Attack :: Move To Home Point");	break;
		case eStateAttack_HomePoint_Hide:				sprintf_s(st,"Attack :: Home Point :: Hide");	break;
		case eStateAttack_HomePoint_Camp:				sprintf_s(st,"Attack :: Home Point :: Camp");	break;
		case eStateAttack_HomePoint_LookOpenPlace:		sprintf_s(st,"Attack :: Home Point :: Look Open Place");	break;
		
		case eStatePanic_Run:							sprintf_s(st,"Panic :: Run Away");				break;
		case eStatePanic_FaceUnprotectedArea:			sprintf_s(st,"Panic :: Face Unprotected Area");	break;
		case eStatePanic_HomePoint_Hide:				sprintf_s(st,"Panic :: Home Point :: Hide");		break;
		case eStatePanic_HomePoint_LookOpenPlace:		sprintf_s(st,"Panic :: Home Point :: Look Open Place");	break;
		case eStatePanic_HomePoint_Camp:				sprintf_s(st,"Panic :: Home Point :: Camp");		break;

		case eStateHitted_Hide:							sprintf_s(st,"Hitted :: Hide");					break;
		case eStateHitted_MoveOut:						sprintf_s(st,"Hitted :: MoveOut");				break;
		case eStateHitted_Home:							sprintf_s(st,"Hitted :: Home");				break;

		case eStateHearDangerousSound_Hide:				sprintf_s(st,"Dangerous Snd :: Hide");			break;
		case eStateHearDangerousSound_FaceOpenPlace:	sprintf_s(st,"Dangerous Snd :: FaceOpenPlace");	break;
		case eStateHearDangerousSound_StandScared:		sprintf_s(st,"Dangerous Snd :: StandScared");		break;
		case eStateHearDangerousSound_Home:				sprintf_s(st,"Dangerous Snd :: Home");			break;

		case eStateHearInterestingSound_MoveToDest:		sprintf_s(st,"Interesting Snd :: MoveToDest");	break;
		case eStateHearInterestingSound_LookAround:		sprintf_s(st,"Interesting Snd :: LookAround");	break;
		
		case eStateHearHelpSound:						sprintf_s(st,"Hear Help Sound");	break;
		case eStateHearHelpSound_MoveToDest:			sprintf_s(st,"Hear Help Sound :: MoveToDest");	break;
		case eStateHearHelpSound_LookAround:			sprintf_s(st,"Hear Help Sound :: LookAround");	break;

		case eStateControlled_Follow_Wait:				sprintf_s(st,"Controlled :: Follow : Wait");			break;
		case eStateControlled_Follow_WalkToObject:		sprintf_s(st,"Controlled :: Follow : WalkToObject");	break;
		case eStateControlled_Attack:					sprintf_s(st,"Controlled :: Attack");					break;
		case eStateThreaten:							sprintf_s(st,"Threaten :: ");							break;
		case eStateFindEnemy_Run:						sprintf_s(st,"Find Enemy :: Run");							break;
		case eStateFindEnemy_LookAround_MoveToPoint:	sprintf_s(st,"Find Enemy :: Look Around : Move To Point");	break;
		case eStateFindEnemy_LookAround_LookAround:		sprintf_s(st,"Find Enemy :: Look Around : Look Around");		break;
		case eStateFindEnemy_LookAround_TurnToPoint:	sprintf_s(st,"Find Enemy :: Look Around : Turn To Point");	break;
		case eStateFindEnemy_Angry:						sprintf_s(st,"Find Enemy :: Angry");							break;
		case eStateFindEnemy_WalkAround:				sprintf_s(st,"Find Enemy :: Walk Around");					break;
		case eStateSquad_Rest_Idle:						sprintf_s(st,"Squad :: Rest : Idle");					break;
		case eStateSquad_Rest_WalkAroundLeader:			sprintf_s(st,"Squad :: Rest : WalkAroundLeader");		break;
		case eStateSquad_RestFollow_Idle:				sprintf_s(st,"Squad :: Follow Leader : Idle");		break;
		case eStateSquad_RestFollow_WalkToPoint:		sprintf_s(st,"Squad :: Follow Leader : WalkToPoint");	break;
		case eStateCustom_Vampire:						sprintf_s(st,"Attack :: Vampire");					break;
		case eStateVampire_ApproachEnemy:				sprintf_s(st,"Vampire :: Approach to enemy");			break;
		case eStateVampire_Execute:						sprintf_s(st,"Vampire :: Hit");						break;
		case eStateVampire_RunAway:						sprintf_s(st,"Vampire :: Run Away");					break;
		case eStateVampire_Hide:						sprintf_s(st,"Vampire :: Hide");						break;
		case eStatePredator:							sprintf_s(st,"Predator");								break;
		case eStatePredator_MoveToCover:				sprintf_s(st,"Predator :: MoveToCover");				break;
		case eStatePredator_LookOpenPlace:				sprintf_s(st,"Predator :: Look Open Place");			break;
		case eStatePredator_Camp:						sprintf_s(st,"Predator :: Camp");						break;
		case eStateBurerAttack_Tele:					sprintf_s(st,"Attack :: Telekinesis");			break;
		case eStateBurerAttack_Gravi:					sprintf_s(st,"Attack :: Gravi Wave");				break;
		case eStateBurerAttack_RunAround:				sprintf_s(st,"Attack :: Run Around");			break;
		case eStateBurerAttack_FaceEnemy:				sprintf_s(st,"Attack :: Face Enemy");			break;
		case eStateBurerAttack_Melee:					sprintf_s(st,"Attack :: Melee");				break;
		case eStateBurerScanning:						sprintf_s(st,"Attack :: Scanning");			break;
		case eStateCustomMoveToRestrictor:				sprintf_s(st,"Moving To Restrictor :: Position not accessible");	break;
		case eStateSmartTerrainTask:					sprintf_s(st,"ALIFE");	break;
		case eStateSmartTerrainTaskGamePathWalk:		sprintf_s(st,"ALIFE :: Game Path Walk");	break;
		case eStateSmartTerrainTaskLevelPathWalk:		sprintf_s(st,"ALIFE :: Level Path Walk");	break;
		case eStateSmartTerrainTaskWaitCapture:			sprintf_s(st,"ALIFE :: Wait till smart terrain will capture me");	break;
		case eStateUnknown:								sprintf_s(st,"Unknown State :: ");			break;
		default:										sprintf_s(st,"Undefined State ::");			break;
	}
	
	DBG().object_info(this,this).remove_item (u32(0));
	DBG().object_info(this,this).remove_item (u32(1));
	DBG().object_info(this,this).remove_item (u32(2));

	DBG().object_info(this,this).add_item	 (*cName(), D3DCOLOR_XRGB(255,0,0), 0);
	DBG().object_info(this,this).add_item	 (st, D3DCOLOR_XRGB(255,0,0), 1);
	
	sprintf_s(st, "Team[%u]Squad[%u]Group[%u]", g_Team(), g_Squad(), g_Group());
	DBG().object_info(this,this).add_item	 (st, D3DCOLOR_XRGB(255,0,0), 2);

	CEntityAlive *entity = smart_cast<CEntityAlive *>(Level().CurrentEntity());
	if (entity && entity->character_physics_support()->movement()) {
		sprintf_s(st,"VELOCITY [%f,%f,%f] Value[%f]",VPUSH(entity->character_physics_support()->movement()->GetVelocity()),entity->character_physics_support()->movement()->GetVelocityActual());
		DBG().text(this).clear();
		DBG().text(this).add_item(st,200,100,COLOR_GREEN,100);
	}
}
示例#8
0
//
// TentacleThink
//
void CTentacle :: Cycle( void )
{
	// ALERT( at_console, "%s %.2f %d %d\n", STRING( pev->targetname ), pev->origin.z, m_MonsterState, m_IdealMonsterState );
	pev->nextthink = gpGlobals-> time + 0.1;

	// ALERT( at_console, "%s %d %d %d %f %f\n", STRING( pev->targetname ), pev->sequence, m_iGoalAnim, m_iDir, pev->framerate, pev->health );

	if (m_MonsterState == MONSTERSTATE_SCRIPT || m_IdealMonsterState == MONSTERSTATE_SCRIPT)
	{
		pev->angles.y = m_flInitialYaw;
		pev->ideal_yaw = m_flInitialYaw;	
		ClearConditions( IgnoreConditions() );
		MonsterThink( );
		m_iGoalAnim = TENTACLE_ANIM_Pit_Idle;
		return;
	}

	DispatchAnimEvents( );
	StudioFrameAdvance( );

	ChangeYaw( pev->yaw_speed );

	CSound *pSound;

	Listen( );

	// Listen will set this if there's something in my sound list
	if ( HasConditions( bits_COND_HEAR_SOUND ) )
		pSound = PBestSound();
	else
		pSound = NULL;

	if ( pSound )
	{
		Vector vecDir;
		if (gpGlobals->time - m_flPrevSoundTime < 0.5)
		{
			float dt = gpGlobals->time - m_flPrevSoundTime;
			vecDir = pSound->m_vecOrigin + (pSound->m_vecOrigin - m_vecPrevSound) / dt - pev->origin;
		}
		else
		{
			vecDir = pSound->m_vecOrigin - pev->origin;
		}
		m_flPrevSoundTime = gpGlobals->time;
		m_vecPrevSound = pSound->m_vecOrigin;

		m_flSoundYaw = UTIL_VecToYaw ( vecDir ) - m_flInitialYaw;
		m_iSoundLevel = Level( vecDir.z );

		if (m_flSoundYaw < -180)
			m_flSoundYaw += 360;
		if (m_flSoundYaw > 180)
			m_flSoundYaw -= 360;

		// ALERT( at_console, "sound %d %.0f\n", m_iSoundLevel, m_flSoundYaw );
		if (m_flSoundTime < gpGlobals->time)
		{
			// play "I hear new something" sound
			char *sound;	

			switch( RANDOM_LONG(0,1) )
			{
			case 0: sound = "tentacle/te_alert1.wav"; break;
			case 1: sound = "tentacle/te_alert2.wav"; break;
			}

			// UTIL_EmitAmbientSound(ENT(pev), pev->origin + Vector( 0, 0, MyHeight()), sound, 1.0, ATTN_NORM, 0, 100);
		}
		m_flSoundTime = gpGlobals->time + RANDOM_FLOAT( 5.0, 10.0 );
	}

	// clip ideal_yaw
	float dy = m_flSoundYaw;
	switch( pev->sequence )
	{
	case TENTACLE_ANIM_Floor_Rear:
	case TENTACLE_ANIM_Floor_Rear_Idle:
	case TENTACLE_ANIM_Lev1_Rear:
	case TENTACLE_ANIM_Lev1_Rear_Idle:
	case TENTACLE_ANIM_Lev2_Rear:
	case TENTACLE_ANIM_Lev2_Rear_Idle:
	case TENTACLE_ANIM_Lev3_Rear:
	case TENTACLE_ANIM_Lev3_Rear_Idle:
		if (dy < 0 && dy > -m_flMaxYaw)
			dy = -m_flMaxYaw;
		if (dy > 0 && dy < m_flMaxYaw)
			dy = m_flMaxYaw;
		break;
	default:
		if (dy < -m_flMaxYaw)
			dy = -m_flMaxYaw;
		if (dy > m_flMaxYaw)
			dy = m_flMaxYaw;
	}
	pev->ideal_yaw = m_flInitialYaw + dy;

	if (m_fSequenceFinished)
	{
		// ALERT( at_console, "%s done %d %d\n", STRING( pev->targetname ), pev->sequence, m_iGoalAnim );
		if (pev->health <= 1)
		{
			m_iGoalAnim = TENTACLE_ANIM_Pit_Idle;
			if (pev->sequence == TENTACLE_ANIM_Pit_Idle)
			{
				pev->health = 75;
			}
		}
		else if ( m_flSoundTime > gpGlobals->time )
		{
			if (m_flSoundYaw >= -(m_flMaxYaw + 30) && m_flSoundYaw <= (m_flMaxYaw + 30))
			{
				// strike
				m_iGoalAnim = LookupActivity( ACT_T_STRIKE + m_iSoundLevel );
			}
			else if (m_flSoundYaw >= -m_flMaxYaw * 2 && m_flSoundYaw <= m_flMaxYaw * 2) 
			{
				// tap
				m_iGoalAnim = LookupActivity( ACT_T_TAP + m_iSoundLevel );
			}
			else
			{
				// go into rear idle
				m_iGoalAnim = LookupActivity( ACT_T_REARIDLE + m_iSoundLevel );
			}
		}
		else if (pev->sequence == TENTACLE_ANIM_Pit_Idle)
		{
			// stay in pit until hear noise
			m_iGoalAnim = TENTACLE_ANIM_Pit_Idle;
		}
		else if (pev->sequence == m_iGoalAnim)
		{
			if (MyLevel() >= 0 && gpGlobals->time < m_flSoundTime)
			{
				if (RANDOM_LONG(0,9) < m_flSoundTime - gpGlobals->time)
				{
					// continue stike
					m_iGoalAnim = LookupActivity( ACT_T_STRIKE + m_iSoundLevel );
				}
				else
				{
					// tap
					m_iGoalAnim = LookupActivity( ACT_T_TAP + m_iSoundLevel );
				}
			}
			else if (MyLevel( ) < 0)
			{
				m_iGoalAnim = LookupActivity( ACT_T_IDLE + 0 );
			}
			else
			{
				if (m_flNextSong < gpGlobals->time)
				{
					// play "I hear new something" sound
					char *sound;	

					switch( RANDOM_LONG(0,1) )
					{
					case 0: sound = "tentacle/te_sing1.wav"; break;
					case 1: sound = "tentacle/te_sing2.wav"; break;
					}

					EMIT_SOUND(ENT(pev), CHAN_VOICE, sound, 1.0, ATTN_NORM);

					m_flNextSong = gpGlobals->time + RANDOM_FLOAT( 10, 20 );
				}

				if (RANDOM_LONG(0,15) == 0)
				{
					// idle on new level
					m_iGoalAnim = LookupActivity( ACT_T_IDLE + RANDOM_LONG(0,3) );
				}
				else if (RANDOM_LONG(0,3)  == 0)
				{
					// tap
					m_iGoalAnim = LookupActivity( ACT_T_TAP + MyLevel( ) );
				}
				else
				{
					// idle
					m_iGoalAnim = LookupActivity( ACT_T_IDLE + MyLevel( ) );
				}
			}
			if (m_flSoundYaw < 0)
				m_flSoundYaw += RANDOM_FLOAT( 2, 8 );
			else
				m_flSoundYaw -= RANDOM_FLOAT( 2, 8 );
		}

		pev->sequence = FindTransition( pev->sequence, m_iGoalAnim, &m_iDir );

		if (m_iDir > 0)
		{
			pev->frame = 0;
		}
		else
		{
			m_iDir = -1; // just to safe
			pev->frame = 255;
		}
		ResetSequenceInfo( );

		m_flFramerateAdj = RANDOM_FLOAT( -0.2, 0.2 );
		pev->framerate = m_iDir * 1.0 + m_flFramerateAdj;

		switch( pev->sequence)
		{
		case TENTACLE_ANIM_Floor_Tap:
		case TENTACLE_ANIM_Lev1_Tap:
		case TENTACLE_ANIM_Lev2_Tap:
		case TENTACLE_ANIM_Lev3_Tap:
			{
				Vector vecSrc;
				UTIL_MakeVectors( pev->angles );

				TraceResult tr1, tr2;

				vecSrc = pev->origin + Vector( 0, 0, MyHeight() - 4);
				UTIL_TraceLine( vecSrc, vecSrc + gpGlobals->v_forward * 512, ignore_monsters, ENT( pev ), &tr1 );

				vecSrc = pev->origin + Vector( 0, 0, MyHeight() + 8);
				UTIL_TraceLine( vecSrc, vecSrc + gpGlobals->v_forward * 512, ignore_monsters, ENT( pev ), &tr2 );

				// ALERT( at_console, "%f %f\n", tr1.flFraction * 512, tr2.flFraction * 512 );

				m_flTapRadius = SetBlending( 0, RANDOM_FLOAT( tr1.flFraction * 512, tr2.flFraction * 512 ) );
			}
			break;
		default:
			m_flTapRadius = 336; // 400 - 64
			break;
		}
		pev->view_ofs.z = MyHeight( );
		// ALERT( at_console, "seq %d\n", pev->sequence );
	}

	if (m_flPrevSoundTime + 2.0 > gpGlobals->time)
	{
		// 1.5 normal speed if hears sounds
		pev->framerate = m_iDir * 1.5 + m_flFramerateAdj;
	}
	else if (m_flPrevSoundTime + 5.0 > gpGlobals->time)
	{
		// slowdown to normal
		pev->framerate = m_iDir + m_iDir * (5 - (gpGlobals->time - m_flPrevSoundTime)) / 2 + m_flFramerateAdj;
	}
}
示例#9
0
void						CLevel_DemoCrash_Handler	()
{
	if (!g_pGameLevel) return;
	Level().WriteStoredDemo();
	Level().CallOldCrashHandler();
}
示例#10
0
u32 dwfChooseAction(u32 dwActionRefreshRate, float fMinProbability0, float fMinProbability1, float fMinProbability2, float fMinProbability3, u32 dwTeam, u32 dwSquad, u32 dwGroup, u32 a0, u32 a1, u32 a2, u32 a3, u32 a4, CEntity *tpEntity, float fGroupDistance)
{
//	return(a0);
	CGroupHierarchyHolder					&Group = Level().seniority_holder().team(dwTeam).squad(dwSquad).group(dwGroup);
	
	if (Device.dwTimeGlobal - Group.m_dwLastActionTime < dwActionRefreshRate) {
		switch (Group.m_dwLastAction) {
			case 0: return(a0);
			case 1: return(a1);
			case 2: return(a2);
			case 3: return(a3);
			case 4: return(a4);
			default: return(a4);
		}
	}

	const CCustomMonster					*monster = smart_cast<const CCustomMonster*>(tpEntity);
	VERIFY									(monster);
	const CAI_Stalker						*stalker = smart_cast<const CAI_Stalker*>(monster);
	const xr_vector<const CEntityAlive*>	&VisibleEnemies = monster->memory().enemy().objects();

	GroupHierarchyHolder::MEMBER_REGISTRY	Members;
	if (!tpEntity)
		for (int k=0; k<(int)Group.members().size(); ++k) {
			if (Group.members()[k]->g_Alive() && ((Group.members()[k]->spatial.type & STYPE_VISIBLEFORAI) == STYPE_VISIBLEFORAI))
				Members.push_back(Group.members()[k]);
		}
	else
		for (int k=0; k<(int)Group.members().size(); ++k) {
			if (Group.members()[k]->g_Alive() && ((Group.members()[k]->spatial.type & STYPE_VISIBLEFORAI) == STYPE_VISIBLEFORAI))
				if (tpEntity->Position().distance_to(Group.members()[k]->Position()) < fGroupDistance) {

					if (!stalker) {
						Members.push_back	(Group.members()[k]);
						continue;
					}

					const CAI_Stalker		*member = smart_cast<CAI_Stalker*>(Group.members()[k]);
					if (!member) {
						Members.push_back	(Group.members()[k]);
						continue;
					}

					if (Group.agent_manager().member().registered_in_combat(member))
						Members.push_back	(Group.members()[k]);
					else
						if (member->ID() == tpEntity->ID())
							Members.push_back	(Group.members()[k]);
				}
		}

	ai().ef_storage().non_alife().member_item() = 0;
	ai().ef_storage().non_alife().enemy_item() = 0;

	WRITE_QUERY_TO_LOG("\nNew query");
	if (bfGetActionSuccessProbability(Members,VisibleEnemies,fMinProbability0,*ai().ef_storage().m_pfVictoryProbability)) {
		Group.m_dwLastActionTime	= Device.dwTimeGlobal;
		Group.m_dwLastAction		= 0;
		WRITE_QUERY_TO_LOG			("Attack");
		return						(a0);
	}
	else
		if (bfGetActionSuccessProbability(Members,VisibleEnemies,fMinProbability1,*ai().ef_storage().m_pfVictoryProbability)) {
			Group.m_dwLastActionTime	= Device.dwTimeGlobal;
			Group.m_dwLastAction		= 1;
			WRITE_QUERY_TO_LOG			("Attack 1");
			return						(a1);
		}
		else
			if (bfGetActionSuccessProbability(Members,VisibleEnemies,fMinProbability2,*ai().ef_storage().m_pfVictoryProbability)) {
				Group.m_dwLastActionTime	= Device.dwTimeGlobal;
				Group.m_dwLastAction		= 2;
				WRITE_QUERY_TO_LOG			("Defend");
				return						(a2);
			}
			else
				if (bfGetActionSuccessProbability(Members,VisibleEnemies,fMinProbability3,*ai().ef_storage().m_pfVictoryProbability)) {
					Group.m_dwLastActionTime	= Device.dwTimeGlobal;
					Group.m_dwLastAction		= 3;
					WRITE_QUERY_TO_LOG			("Defend 1");
					return						(a3);
				}
				else {
					Group.m_dwLastActionTime	= Device.dwTimeGlobal;
					Group.m_dwLastAction		= 4;
					WRITE_QUERY_TO_LOG			("Retreat");
					return						(a4);
				}
}
示例#11
0
void CSE_ALifeDynamicObject::on_unregister()
{
	Level().MapManager().RemoveMapLocationByObjectID(ID);
}