Exemple #1
0
// Function for callbacks added by Cribbledirge.
void CWeaponMagazined::StateSwitchCallback(GameObject::ECallbackType actor_type, GameObject::ECallbackType npc_type)
{
	xr_string ammo_type;
	if (GetAmmoElapsed() == 0 || m_magazine.empty())
	{
		ammo_type = *m_ammoTypes[m_ammoType];
	}
	else
	{
		ammo_type = *m_ammoTypes[m_magazine.back().m_LocalAmmoType];
	}

	if (g_actor)
	{
		if (smart_cast<CActor*>(H_Parent()))  // This is an actor.
		{
			Actor()->callback(actor_type)(
				lua_game_object(),  // The weapon as a game object.
				ammo_type.c_str()   // The caliber of the weapon.
			);
		}
		else if (smart_cast<CEntityAlive*>(H_Parent()))  // This is an NPC.
		{
			Actor()->callback(npc_type)(
				smart_cast<CEntityAlive*>(H_Parent())->lua_game_object(),       // The owner of the weapon.
				lua_game_object(),                                              // The weapon itself.
                                ammo_type.c_str()                                               // The caliber of the weapon.
			);
		}
	}
}
Exemple #2
0
void	CActor::SwitchOutBorder(bool new_border_state)
{
	if(new_border_state)
	{
//.		Msg("exit level border");
		callback(GameObject::eExitLevelBorder)(lua_game_object());
	}
	else 
	{
//.		Msg("enter level border");
		callback(GameObject::eEnterLevelBorder)(lua_game_object());
	}
	m_bOutBorder=new_border_state;
}
void CDestroyablePhysicsObject::Destroy()
{
	VERIFY(!physics_world()->Processing());
	const CGameObject *who_object = smart_cast<const CGameObject*>(FatalHit().initiator());
	callback(GameObject::eDeath)(lua_game_object(),who_object  ? who_object : 0);
	CPHDestroyable::Destroy(ID(),"physic_destroyable_object");
	if(m_destroy_sound._handle())
	{
		m_destroy_sound.play_at_pos(this,Position());
	}
	if(*m_destroy_particles)
	{		
			//Fvector dir;dir.set(0,1,0);
		Fmatrix m;m.identity();
		/////////////////////////////////////////////////
		m.j.set(0,1.f,0);
		///////////////////////////////////////////////

		Fvector hdir;hdir.set(CPHDestroyable::FatalHit().direction());

		if(fsimilar(_abs(m.j.dotproduct(hdir)),1.f,EPS_L))
		{
			do {
				hdir.random_dir();
			} while(fsimilar(_abs(m.j.dotproduct(hdir)),1.f,EPS_L));
		}
		m.i.crossproduct(m.j,hdir);m.i.normalize();
		m.k.crossproduct(m.i,m.j);
			StartParticles(m_destroy_particles,m,ID());
	}
	SheduleRegister();
}
Exemple #4
0
//void CHangingLamp::Hit(float P,Fvector &dir, CObject* who,s16 element,
//					   Fvector p_in_object_space, float impulse, ALife::EHitType hit_type)
void	CHangingLamp::Hit					(SHit* pHDS)
{
	SHit	HDS = *pHDS;
	callback(GameObject::eHit)(
		lua_game_object(), 
		HDS.power,
		HDS.dir,
		smart_cast<const CGameObject*>(HDS.who)->lua_game_object(),
		HDS.bone()
		);

#ifdef HLAMP_AFFECT_IMMUNITIES
	HDS.power = CHitImmunity::AffectHit(HDS.power,HDS.hit_type);	
	inherited::Hit(pHDS);
#endif
	BOOL	bWasAlive		= Alive		() || light_render->get_active();

	if(m_pPhysicsShell) 
	   m_pPhysicsShell->applyHit(pHDS->p_in_bone_space,pHDS->dir,pHDS->impulse,pHDS->boneID,pHDS->hit_type);
	
	if (!bWasAlive) return;

	if (pHDS->boneID==light_bone)
	    SetHealth ( 0.f );
	else
	{
		float damage = pHDS->damage() * 100.f;
		Msg("DEBUG: %s health = %.3f, damage = %.3f", Name_script(), GetHealth(), damage);
		SetHealth(GetHealth() - damage);
	}
	if (bWasAlive && (!Alive()))		TurnOff	();
}
Exemple #5
0
void CGrenade::Throw() 
{
	if (!m_fake_missile || m_thrown)
		return;

	CGrenade					*pGrenade = smart_cast<CGrenade*>(m_fake_missile);
	VERIFY						(pGrenade);
	
	if (pGrenade) {
		pGrenade->set_destroy_time(m_dwDestroyTimeMax);
		//установить ID того кто кинул гранату
		pGrenade->SetInitiator( H_Parent()->ID() );
	}
	inherited::Throw			();
	m_fake_missile->processing_activate();//@sliph
	m_thrown = true;
	
	// Real Wolf.Start.18.12.14
	auto parent = smart_cast<CGameObject*>(H_Parent());
	auto obj	= smart_cast<CGameObject*>(m_fake_missile);
	if (parent && obj)
	{
		parent->callback(GameObject::eOnThrowGrenade)(obj->lua_game_object());
	}
	// Real Wolf.End.18.12.14
}
bool CActor::OnReceiveInfo(shared_str info_id) const
{
	if(!CInventoryOwner::OnReceiveInfo(info_id))
		return false;

	CInfoPortion info_portion;
	info_portion.Load(info_id);

	AddEncyclopediaArticle	(&info_portion);
	AddGameTask				(&info_portion);

	callback(GameObject::eInventoryInfo)(lua_game_object(), *info_id);

	if(!HUD().GetUI())
		return false;
	//только если находимся в режиме single
	CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame());
	if(!pGameSP) return false;

	if(pGameSP->TalkMenu->IsShown())
	{
		pGameSP->TalkMenu->NeedUpdateQuestions();
	}


	return true;
}
Exemple #7
0
void CScriptZone::feel_touch_new	(CObject *tpObject)
{
    CGameObject					*l_tpGameObject = smart_cast<CGameObject*>(tpObject);
    if (!l_tpGameObject)
        return;

    callback(GameObject::eZoneEnter)(lua_game_object(),l_tpGameObject->lua_game_object());
}
Exemple #8
0
void CScriptZone::feel_touch_delete	(CObject *tpObject)
{
    CGameObject					*l_tpGameObject = smart_cast<CGameObject*>(tpObject);

    if (!l_tpGameObject || l_tpGameObject->getDestroy())
        return;

    callback(GameObject::eZoneExit)(lua_game_object(),l_tpGameObject->lua_game_object());
}
Exemple #9
0
void CScriptZone::net_Relcase			(CObject *O)
{
    CGameObject					*l_tpGameObject = smart_cast<CGameObject*>(O);
    if (!l_tpGameObject)
        return;

    xr_vector<CObject*>::iterator	I = std::find(feel_touch.begin(),feel_touch.end(),O);
    if (I != feel_touch.end()) {
        callback(GameObject::eZoneExit)(lua_game_object(),l_tpGameObject->lua_game_object());
    }
}
void CActor::AddEncyclopediaArticle	 (const CInfoPortion* info_portion) const
{
	VERIFY(info_portion);
	ARTICLE_VECTOR& article_vector = encyclopedia_registry->registry().objects();

	ARTICLE_VECTOR::iterator last_end = article_vector.end();
	ARTICLE_VECTOR::iterator B = article_vector.begin();
	ARTICLE_VECTOR::iterator E = last_end;

	for(ARTICLE_ID_VECTOR::const_iterator it = info_portion->ArticlesDisable().begin();
									it != info_portion->ArticlesDisable().end(); it++)
	{
		FindArticleByIDPred pred(*it);
		last_end = std::remove_if(B, last_end, pred);
	}
	article_vector.erase(last_end, E);


	for(ARTICLE_ID_VECTOR::const_iterator it = info_portion->Articles().begin();
									it != info_portion->Articles().end(); it++)
	{
		FindArticleByIDPred pred(*it);
		if( std::find_if(article_vector.begin(), article_vector.end(), pred) != article_vector.end() ) continue;

		CEncyclopediaArticle article;

		article.Load(*it);

		article_vector.push_back(ARTICLE_DATA(*it, Level().GetGameTime(), article.data()->articleType));
		LPCSTR g,n;
		int _atype = article.data()->articleType;
		g = *(article.data()->group);
		n = *(article.data()->name);
		callback(GameObject::eArticleInfo)(lua_game_object(), g, n, _atype);

		if( HUD().GetUI() ){
			CUIGameSP* pGameSP = smart_cast<CUIGameSP*>(HUD().GetUI()->UIGame());
			pda_section::part p = pda_section::encyclopedia;
			switch (article.data()->articleType){
				case ARTICLE_DATA::eEncyclopediaArticle:	p = pda_section::encyclopedia;	break;
				case ARTICLE_DATA::eJournalArticle:			p = pda_section::journal;		break;
				case ARTICLE_DATA::eInfoArticle:			p = pda_section::info;			break;
				case ARTICLE_DATA::eTaskArticle:			p = pda_section::quests;		break;
				default: NODEFAULT;
			};
			pGameSP->PdaMenu->PdaContentsChanged			(p);
		}

	}

}
void CBaseMonster::HitSignal(float amount, Fvector& vLocalDir, CObject* who, s16 element)
{
	if (!g_Alive()) return;
	
	feel_sound_new(who,SOUND_TYPE_WEAPON_SHOOTING,0,who->Position(),1.f);
	if (g_Alive()) sound().play(MonsterSound::eMonsterSoundTakeDamage);

	if (element < 0) return;

	// Определить направление хита (перед || зад || лево || право)
	float yaw,pitch;
	vLocalDir.getHP(yaw,pitch);
	
	yaw = angle_normalize(yaw);
	
	EHitSide hit_side = eSideFront;
	if ((yaw >= PI_DIV_4) && (yaw <= 3*PI_DIV_4)) hit_side = eSideLeft;
	else if ((yaw >= 3 * PI_DIV_4) && (yaw <= 5*PI_DIV_4)) hit_side = eSideBack;
	else if ((yaw >= 5 * PI_DIV_4) && (yaw <= 7*PI_DIV_4)) hit_side = eSideRight;

	anim().FX_Play	(hit_side, 1.0f);

	HitMemory.add_hit	(who,hit_side);

	Morale.on_hit		();

	callback(GameObject::eHit)(
		lua_game_object(), 
		amount,
		vLocalDir,
		smart_cast<const CGameObject*>(who)->lua_game_object(),
		element
	);

	// если нейтрал - добавить как врага
	CEntityAlive	*obj = smart_cast<CEntityAlive*>(who);
	if (obj && (tfGetRelationType(obj) == ALife::eRelationTypeNeutral)) EnemyMan.add_enemy(obj);
}
//void CDestroyablePhysicsObject::Hit							(float P,Fvector &dir,CObject *who,s16 element,Fvector p_in_object_space, float impulse,  ALife::EHitType hit_type)
void	CDestroyablePhysicsObject::Hit					(SHit* pHDS)
{
	SHit	HDS = *pHDS;
	callback(GameObject::eHit)(
		lua_game_object(), 
		HDS.power,
		HDS.dir,
		smart_cast<const CGameObject*>(HDS.who)->lua_game_object(),
		HDS.bone()
		);
	HDS.power=CHitImmunity::AffectHit(HDS.power,HDS.hit_type);
	float hit_scale=1.f,wound_scale=1.f;
	CDamageManager::HitScale(HDS.bone(),hit_scale,wound_scale);
	HDS.power*=hit_scale;
//	inherited::Hit(P,dir,who,element,p_in_object_space,impulse,hit_type);
	inherited::Hit(&HDS);
	m_fHealth-=HDS.power;
	if(m_fHealth<=0.f)
	{
//		CPHDestroyable::SetFatalHit(SHit(P,dir,who,element,p_in_object_space,impulse,hit_type));
		CPHDestroyable::SetFatalHit(HDS);
		if(CPHDestroyable::CanDestroy())Destroy();
	}
}
Exemple #13
0
void		CHangingLamp::SetPosition(const Fvector &v) 
{
	lua_game_object()->SetPosition(v);	
}
Exemple #14
0
void		CHangingLamp::SetDirection(const Fvector &v, float bank)
{
	lua_game_object()->SetDirection(v, bank);		
}