当前位置: 首页>>代码示例>>C++>>正文


C++ CCharacter类代码示例

本文整理汇总了C++中CCharacter的典型用法代码示例。如果您正苦于以下问题:C++ CCharacter类的具体用法?C++ CCharacter怎么用?C++ CCharacter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CCharacter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sheet

//---------------------------------------------------
void CCharacterVersionAdapter::adaptToVersion2(CCharacter &character) const
{
	/****************************************************************/
	/* reset all bricks and actions, set charcateristics to their 
	/* starting values and recompute scores
	/****************************************************************/

	static const NLMISC::CSheetId sheet("skills.skill_tree");
	static const CStaticSkillsTree * skillsTree = CSheets::getSkillsTreeForm( sheet );

	character._SpType[EGSPD::CSPType::Fight] = 10 * skillsTree->getPlayerSkillPointsUnderSkill(&character._Skills, SKILLS::SF);
	character._SpType[EGSPD::CSPType::Magic] = 10 * skillsTree->getPlayerSkillPointsUnderSkill(&character._Skills, SKILLS::SM);
	character._SpType[EGSPD::CSPType::Craft] = 10 * skillsTree->getPlayerSkillPointsUnderSkill(&character._Skills, SKILLS::SC);
	character._SpType[EGSPD::CSPType::Harvest] = 10 * skillsTree->getPlayerSkillPointsUnderSkill(&character._Skills, SKILLS::SH);

	character._Skills._Sp = 0;
	
	// clear all memories... 
	character._MemorizedPhrases.forgetAll();

	// clear bricks and phrases
	character._KnownPhrases.clear();
	character._BoughtPhrases.clear();
	character._KnownBricks.clear();

	for( uint i = 0; i < CHARACTERISTICS::NUM_CHARACTERISTICS; ++i )
	{
		// at level 1 for formula dependency with regenerate value
		character._PhysCharacs._PhysicalCharacteristics[ i ].Base = 10; 
	
		character._PhysCharacs._PhysicalCharacteristics[ i ].Max = character._PhysCharacs._PhysicalCharacteristics[ i ].Base + character._PhysCharacs._PhysicalCharacteristics[ i ].Modifier;
		character._PhysCharacs._PhysicalCharacteristics[ i ].Current = character._PhysCharacs._PhysicalCharacteristics[ i ].Max;
	}
	// Compute Scores
	// !!! DOT NOT change modifiers as they are changed by equipement !!!
	for(uint i = 0; i < SCORES::NUM_SCORES; ++i )
	{
		switch( i )
		{
		case SCORES::hit_points:
			character._PhysScores._PhysicalScores[ i ].Base = character._PhysCharacs._PhysicalCharacteristics[ CHARACTERISTICS::constitution ].Base * 10;
			break;
		case SCORES::sap:
			character._PhysScores._PhysicalScores[ i ].Base = character._PhysCharacs._PhysicalCharacteristics[ CHARACTERISTICS::intelligence ].Base * 10;
			break;
		case SCORES::stamina:
			character._PhysScores._PhysicalScores[ i ].Base = character._PhysCharacs._PhysicalCharacteristics[ CHARACTERISTICS::strength ].Base * 10;
			break;
		case SCORES::focus:
			character._PhysScores._PhysicalScores[ i ].Base = character._PhysCharacs._PhysicalCharacteristics[ CHARACTERISTICS::dexterity ].Base * 10;
			break;
		default:;
		}
		character.updateRegen();
		character._PhysScores._PhysicalScores[ i ].Max = character._PhysScores._PhysicalScores[ i ].Base + character._PhysScores._PhysicalScores[ i ].Modifier;
		character._PhysScores._PhysicalScores[ i ].Current = character._PhysScores._PhysicalScores[ i ].Max;
		character._PhysScores._PhysicalScores[ i ].CurrentRegenerate = character._PhysScores._PhysicalScores[ i ].BaseRegenerateAction + character._PhysScores._PhysicalScores[ i ].RegenerateModifier;
	}

	character.addCreationBricks();
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:62,代码来源:character_version_adapter.cpp

示例2: Update

LTBOOL CAISenseSeeEnemy::Update(HOBJECT hStimulus, LTFLOAT fTimeDelta)
{
	if ( !IsCharacter(hStimulus) ) return LTFALSE;

	if ( m_pAI->GetCharacterClass() == NEUTRAL )
	{
		// If we're innocent, we only consider someone an enemy if they have a gun

        CCharacter* pCharacter = (CCharacter*)g_pLTServer->HandleToObject(hStimulus);
		if ( !pCharacter->HasDangerousWeapon() )
		{
            return LTFALSE;
		}
	}

	// Instead of looking right at the center of the target, we at a grid of points.
	// The grid is a plane with normal equal to the forward vector of the object,
	// in the center of the object, clipped to the objects dims. We scan the grid
	// at a given resolution and simply advance our scan col/row every frame. Note
	// that the grid is aligned with the objects rotation, not the bounding boxes,
	// since all the bounding boxes are axis aligned.

	int nXRange = m_rngGridX.GetMax() - m_rngGridX.GetMin();
	int nYRange = m_rngGridY.GetMax() - m_rngGridY.GetMin();

    LTVector vDims;
    g_pLTServer->GetObjectDims(hStimulus, &vDims);

    LTFLOAT fX = vDims.x * ((LTFLOAT)m_nGridX/(LTFLOAT)nXRange);
    LTFLOAT fY = vDims.y * ((LTFLOAT)m_nGridY/(LTFLOAT)nYRange);

    LTVector vPosition;
    g_pLTServer->GetObjectPos(hStimulus, &vPosition);

    LTRotation rRot;
    g_pLTServer->GetObjectRotation(hStimulus, &rRot);

    LTVector vUp, vRight, vForward;
    g_pLTServer->GetRotationVectors(&rRot, &vUp, &vRight, &vForward);

	vPosition += vRight*fX;
	vPosition += vUp*fY;

	// Update the point

    LTFLOAT fDistanceSqr;
    LTBOOL bVisible;

	if ( m_pAI->CanSeeThrough() )
	{
        bVisible = m_pAI->IsObjectPositionVisibleFromEye(CAI::SeeThroughFilterFn, CAI::SeeThroughPolyFilterFn, hStimulus, vPosition, (m_fDistanceSqr), LTTRUE, &fDistanceSqr);
	}
	else
	{
        bVisible = m_pAI->IsObjectPositionVisibleFromEye(CAI::DefaultFilterFn, NULL, hStimulus, vPosition, (m_fDistanceSqr), LTTRUE, &fDistanceSqr);
	}

	if ( bVisible )
	{
		if ( fDistanceSqr > g_pAIButeMgr->GetSenses()->fInstantSeeDistanceSqr )
		{
			LTFLOAT fRateModifier = (1.0f - fDistanceSqr/m_fDistanceSqr);
			IncreaseStimulation(fTimeDelta, (fRateModifier));
		}
		else
		{
			IncreaseStimulation(fTimeDelta, 99999999.0f);
		}
	}

	// Update our grid col/row values

	if ( ++m_nGridX > m_rngGridX.GetMax() )
	{
		m_nGridX = m_rngGridX.GetMin();

		if ( ++m_nGridY > m_rngGridY.GetMax() )
		{
			m_nGridY = m_rngGridY.GetMin();
		}
	}

	return bVisible;
}
开发者ID:germanocaldeira,项目名称:no-one-lives-forever,代码行数:84,代码来源:AISense.cpp

示例3: DoTeamScoreWincheck

void CGameControllerCTF::Tick()
{
	IGameController::Tick();

	DoTeamScoreWincheck();
	
	for(int fi = 0; fi < 2; fi++)
	{
		CFlag *F = m_apFlags[fi];
		
		if(!F)
			continue;
		
		// flag hits death-tile, reset it
		if(GameServer()->Collision()->GetCollisionAt(F->m_Pos.x, F->m_Pos.y)&CCollision::COLFLAG_DEATH)
		{
			GameServer()->CreateSoundGlobal(SOUND_CTF_RETURN);
			F->Reset();
			continue;
		}
		
		//
		if(F->m_pCarryingCharacter)
		{
			// update flag position
			F->m_Pos = F->m_pCarryingCharacter->m_Pos;
			
			if(m_apFlags[fi^1] && m_apFlags[fi^1]->m_AtStand)
			{
				if(distance(F->m_Pos, m_apFlags[fi^1]->m_Pos) < CFlag::ms_PhysSize + CCharacter::ms_PhysSize)
				{
					// CAPTURE! \o/
					m_aTeamscore[fi^1] += 100;
					F->m_pCarryingCharacter->GetPlayer()->m_Score += 5;

					char aBuf[512];
					str_format(aBuf, sizeof(aBuf), "flag_capture player='%d:%s'",
						F->m_pCarryingCharacter->GetPlayer()->GetCID(),
						Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID()));
					GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);

					float CaptureTime = (Server()->Tick() - F->m_GrabTick)/(float)Server()->TickSpeed();
					if(CaptureTime <= 60)
					{
						str_format(aBuf, sizeof(aBuf), "The %s flag was captured by '%s' (%d.%s%d seconds)", fi ? "blue" : "red", Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID()), (int)CaptureTime%60, ((int)(CaptureTime*100)%100)<10?"0":"", (int)(CaptureTime*100)%100);
					}
					else
					{
						str_format(aBuf, sizeof(aBuf), "The %s flag was captured by '%s'", fi ? "blue" : "red", Server()->ClientName(F->m_pCarryingCharacter->GetPlayer()->GetCID()));
					}
					GameServer()->SendChat(-1, -2, aBuf);
					for(int i = 0; i < 2; i++)
						m_apFlags[i]->Reset();
					
					GameServer()->CreateSoundGlobal(SOUND_CTF_CAPTURE);
				}
			}
		}
		else
		{
			CCharacter *apCloseCCharacters[MAX_CLIENTS];
			int Num = GameServer()->m_World.FindEntities(F->m_Pos, CFlag::ms_PhysSize, (CEntity**)apCloseCCharacters, MAX_CLIENTS, NETOBJTYPE_CHARACTER);
			for(int i = 0; i < Num; i++)
			{
				if(!apCloseCCharacters[i]->IsAlive() || apCloseCCharacters[i]->GetPlayer()->GetTeam() == -1 || GameServer()->Collision()->IntersectLine(F->m_Pos, apCloseCCharacters[i]->m_Pos, NULL, NULL))
					continue;
				
				if(apCloseCCharacters[i]->GetPlayer()->GetTeam() == F->m_Team)
				{
					// return the flag
					if(!F->m_AtStand)
					{
						CCharacter *pChr = apCloseCCharacters[i];
						pChr->GetPlayer()->m_Score += 1;

						char aBuf[256];
						str_format(aBuf, sizeof(aBuf), "flag_return player='%d:%s'",
							pChr->GetPlayer()->GetCID(),
							Server()->ClientName(pChr->GetPlayer()->GetCID()));
						GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);

						GameServer()->CreateSoundGlobal(SOUND_CTF_RETURN);
						F->Reset();
					}
				}
				else
				{
					// take the flag
					if(F->m_AtStand)
					{
						m_aTeamscore[fi^1]++;
						F->m_GrabTick = Server()->Tick();
					}
					
					F->m_AtStand = 0;
					F->m_pCarryingCharacter = apCloseCCharacters[i];
					F->m_pCarryingCharacter->GetPlayer()->m_Score += 1;

					char aBuf[256];
					str_format(aBuf, sizeof(aBuf), "flag_grab player='%d:%s'",
//.........这里部分代码省略.........
开发者ID:Rush,项目名称:teeworlds,代码行数:101,代码来源:ctf.cpp

示例4: H_AUTO

//-----------------------------------------------
// CFaberPhrase apply
//-----------------------------------------------
void CFaberPhrase::apply()
{
	H_AUTO(CFaberPhrase_apply);
	
	CCharacter * c = dynamic_cast< CCharacter * > ( CEntityBaseManager::getEntityBasePtr( _ActorRowId ) );
	if( c == 0 )
	{
		nlwarning("<CFaberPhrase::apply> Player character not found but his crafting action still running!!!");
		stop();
		return;
	}

	// apply wearing equipment penalty on Recommended skill
	_Recommended -= (uint32)(_Recommended * c->wearMalus() * WearMalusCraftFactor);

	const CStaticBrick * plan = CSheets::getSBrickForm( c->getCraftPlan() );
	if( plan == 0 )
	{
		nlwarning("<CFaberPhrase::apply> Can't found static form of craft plan %s", c->getCraftPlan().toString().c_str() );
		PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "UNKNOWN_CRAFT_PLAN");
		stop();
		return;
	}
	_RootFaberPlan = plan;

	// TODO check compatibility of Rms with plan
	// temporary only check number of Mp match with plan

	sint32 nbMp = (sint32)_Mps.size();

	uint32 nbMpNeedeInPlan = 0;
	uint32 neededMp = (uint32)_RootFaberPlan->Faber->NeededMps.size();
	for( uint mp = 0; mp < neededMp; ++mp )
	{
		//for each type of Mp needed
		nbMpNeedeInPlan += _RootFaberPlan->Faber->NeededMps[ mp ].Quantity;
	}

	if( nbMpNeedeInPlan != _Mps.size() )
	{
		nlwarning("<CFaberPhrase::apply> Craft plan %s need %d Raw Material and client send %d Raw Material", c->getCraftPlan().toString().c_str(), _RootFaberPlan->Faber->NeededMps.size(), _Mps.size() );
		PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "RAW_MATERIAL_MISSING");
		stop();
		return;
	}

	nbMp = (sint32)_MpsFormula.size();
	
	uint32 nbMpForumulaNeedeInPlan = 0;
	neededMp = (uint32)_RootFaberPlan->Faber->NeededMpsFormula.size();
	for( uint mp = 0; mp < neededMp; ++mp )
	{
		//for each type of Mp needed
		nbMpForumulaNeedeInPlan += _RootFaberPlan->Faber->NeededMpsFormula[ mp ].Quantity;
	}
	
	if( nbMpForumulaNeedeInPlan != _MpsFormula.size() )
	{
		nlwarning("<CFaberPhrase::apply> Craft plan %s need %d Raw Material Formula and client send %d Raw Material Formula", c->getCraftPlan().toString().c_str(), _RootFaberPlan->Faber->NeededMpsFormula.size(), _MpsFormula.size() );
		PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "RAW_MATERIAL_MISSING");
		stop();
		return;
	}

	// Check skill on faber plan
	if( _RootFaberPlan->getSkill(0) == SKILLS::unknown )
	{
		nlwarning("<CFaberPhrase::apply> Craft plan %s contains an invalid skill", c->getCraftPlan().toString().c_str() );
		PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "INVALID_CRAFT_PLAN");
		stop();
		return;
	}

	_CraftedItemStaticForm = CSheets::getForm( plan->Faber->CraftedItem );
	if( _CraftedItemStaticForm == 0 )
	{
		nlwarning("<CFaberPhrase::apply> Can't found static form of crafted item %s", plan->Faber->CraftedItem.toString().c_str() );
		PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "UNKNOWN_CRAFTED_ITEM");
		stop();
		return;
	}

	// build the craft action
	_FaberAction = IFaberActionFactory::buildAction( _ActorRowId, this, _CraftedItemStaticForm->Type );
	if ( !_FaberAction )
	{
		nlwarning( "<CFaberPhrase build> could not build action for plan brick %s", _RootFaberPlan->SheetId.toString().c_str() );
		stop();
		return;
	}
	
	neededMp = _RootFaberPlan->Faber->NeededMps.size();
    EGSPD::CPeople::TPeople civRestriction = _RootFaberPlan->CivRestriction;
	uint32 usedMp=0;
	vector< const CStaticItem * > usedMps = _Mps;

	for( uint mp = 0; mp < neededMp; ++mp )
//.........这里部分代码省略.........
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:101,代码来源:faber_phrase.cpp

示例5: DoWeaponSwitch

void CCharacter::FireWeapon()
{
	if(m_ReloadTimer != 0)
		return;

	DoWeaponSwitch();
	vec2 Direction = normalize(vec2(m_LatestInput.m_TargetX, m_LatestInput.m_TargetY));

	bool FullAuto = false;
	if(m_ActiveWeapon == WEAPON_GRENADE || m_ActiveWeapon == WEAPON_SHOTGUN || m_ActiveWeapon == WEAPON_RIFLE)
		FullAuto = true;


	// check if we gonna m_Fire
	bool WillFire = false;
	if(CountInput(m_LatestPrevInput.m_Fire, m_LatestInput.m_Fire).m_Presses)
		WillFire = true;
	if(FullAuto && (m_LatestInput.m_Fire&1) && m_aWeapons[m_ActiveWeapon].m_Ammo)
		WillFire = true;
	if(!WillFire)
		return;
	modFireAction mfa;
	for(std::set<mod *>::iterator i = modLoaderGetter::modloader_main->modList.begin(); i != modLoaderGetter::modloader_main->modList.end(); i++){
		modFireAction mfa2 = (*i)->onFire(m_ActiveWeapon, this);
		if(!mfa2.doAmmoDecrease){
			mfa.doAmmoDecrease = false;
		}
		if(mfa2.AmmoDecreaseValue != 1){
			mfa.AmmoDecreaseValue = mfa2.AmmoDecreaseValue;
		}
		if(mfa2.breakShoot){
			mfa.breakShoot = true;
		}
	}
	if(mfa.breakShoot) return;
	// check for ammo
	if(!m_aWeapons[m_ActiveWeapon].m_Ammo)
	{
		// 125ms is a magical limit of how fast a human can click
		m_ReloadTimer = 125 * Server()->TickSpeed() / 1000;
		if(m_LastNoAmmoSound+Server()->TickSpeed() <= Server()->Tick())
		{
			GameServer()->CreateSound(m_Pos, SOUND_WEAPON_NOAMMO);
			m_LastNoAmmoSound = Server()->Tick();
		}
		return;
	}

	vec2 ProjStartPos = m_Pos+Direction*m_ProximityRadius*0.75f;

	switch(m_ActiveWeapon)
	{
		case WEAPON_HAMMER:
		{
			// reset objects Hit
			m_NumObjectsHit = 0;
			GameServer()->CreateSound(m_Pos, SOUND_HAMMER_FIRE);

			CCharacter *apEnts[MAX_CLIENTS];
			int Hits = 0;
			int Num = GameServer()->m_World.FindEntities(ProjStartPos, m_ProximityRadius*0.5f, (CEntity**)apEnts,
														MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);

			for (int i = 0; i < Num; ++i)
			{
				CCharacter *pTarget = apEnts[i];

				if ((pTarget == this) || GameServer()->Collision()->IntersectLine(ProjStartPos, pTarget->m_Pos, NULL, NULL))
					continue;

				// set his velocity to fast upward (for now)
				if(length(pTarget->m_Pos-ProjStartPos) > 0.0f)
					GameServer()->CreateHammerHit(pTarget->m_Pos-normalize(pTarget->m_Pos-ProjStartPos)*m_ProximityRadius*0.5f);
				else
					GameServer()->CreateHammerHit(ProjStartPos);

				vec2 Dir;
				if (length(pTarget->m_Pos - m_Pos) > 0.0f)
					Dir = normalize(pTarget->m_Pos - m_Pos);
				else
					Dir = vec2(0.f, -1.f);

				pTarget->TakeDamage(vec2(0.f, -1.f) + normalize(Dir + vec2(0.f, -1.1f)) * 10.0f, g_pData->m_Weapons.m_Hammer.m_pBase->m_Damage,
					m_pPlayer->GetCID(), m_ActiveWeapon);
				Hits++;
			}

			// if we Hit anything, we have to wait for the reload
			if(Hits)
				m_ReloadTimer = Server()->TickSpeed()/3;

		} break;

		case WEAPON_GUN:
		{
			CProjectile *pProj = new CProjectile(GameWorld(), WEAPON_GUN,
				m_pPlayer->GetCID(),
				ProjStartPos,
				Direction,
				(int)(Server()->TickSpeed()*GameServer()->Tuning()->m_GunLifetime),
//.........这里部分代码省略.........
开发者ID:moonmagian,项目名称:teeworlds_srv_smod,代码行数:101,代码来源:character.cpp

示例6: Iter


//.........这里部分代码省略.........
							random -= InfectionProb;
						}
					}
				}
			}
		}
		else
		{
			if(m_pHeroFlag)
				m_pHeroFlag->Show();
			
			GameServer()->DisableTargetToKill();
			
			CPlayerIterator<PLAYERITER_SPECTATORS> IterSpec(GameServer()->m_apPlayers);
			while(IterSpec.Next())
			{
				IterSpec.Player()->SetClass(PLAYERCLASS_NONE);
			}
		}
		
		//Win check
		if(m_InfectedStarted && m_HumanCounter == 0 && m_InfectedCounter > 1)
		{			
			int Seconds = (Server()->Tick()-m_RoundStartTick)/((float)Server()->TickSpeed());
			
			GameServer()->SendChatTarget_Localization(-1, CHATCATEGORY_INFECTED, _("Infected won the round in {sec:RoundDuration}"), "RoundDuration", &Seconds, NULL);
			
			EndRound();
		}
		
		//Start the final explosion if the time is over
		if(m_InfectedStarted && !m_ExplosionStarted && g_Config.m_SvTimelimit > 0 && (Server()->Tick()-m_RoundStartTick) >= g_Config.m_SvTimelimit*Server()->TickSpeed()*60)
		{
			for(CCharacter *p = (CCharacter*) GameServer()->m_World.FindFirst(CGameWorld::ENTTYPE_CHARACTER); p; p = (CCharacter *)p->TypeNext())
			{
				if(p->IsInfected())
				{
					GameServer()->SendEmoticon(p->GetPlayer()->GetCID(), EMOTICON_GHOST);
				}
				else
				{
					GameServer()->SendEmoticon(p->GetPlayer()->GetCID(), EMOTICON_EYES);
				}
			}
			m_ExplosionStarted = true;
		}
		
		//Do the final explosion
		if(m_ExplosionStarted)
		{		
			bool NewExplosion = false;
			
			for(int j=0; j<m_MapHeight; j++)
			{
				for(int i=0; i<m_MapWidth; i++)
				{
					if((m_GrowingMap[j*m_MapWidth+i] & 1) && (
						(i > 0 && m_GrowingMap[j*m_MapWidth+i-1] & 2) ||
						(i < m_MapWidth-1 && m_GrowingMap[j*m_MapWidth+i+1] & 2) ||
						(j > 0 && m_GrowingMap[(j-1)*m_MapWidth+i] & 2) ||
						(j < m_MapHeight-1 && m_GrowingMap[(j+1)*m_MapWidth+i] & 2)
					))
					{
						NewExplosion = true;
						m_GrowingMap[j*m_MapWidth+i] |= 8;
						m_GrowingMap[j*m_MapWidth+i] &= ~1;
开发者ID:necropotame,项目名称:teeworlds-infclass,代码行数:67,代码来源:mod.cpp

示例7: if

void CAIActionReactToDanger::ActivateAction( CAI* pAI, CAIWorldState& wsWorldStateGoal )
{
	super::ActivateAction( pAI, wsWorldStateGoal );

	// Bail if we are not aware of danger.

	CAIWMFact factQuery;
	factQuery.SetFactType( kFact_Danger );
	CAIWMFact* pFact = pAI->GetAIWorkingMemory()->FindWMFact( factQuery );
	if( !pFact )
	{
		return;
	}

	// Set animate state.

	pAI->SetState( kState_Animate );

	// Set flinch animation.

	CAnimationProps	animProps;
	animProps.Set( kAPG_Posture, kAP_POS_Crouch );
	animProps.Set( kAPG_Weapon, pAI->GetAIBlackBoard()->GetBBPrimaryWeaponProp() );
	animProps.Set( kAPG_WeaponPosition, kAP_WPOS_Up );
	animProps.Set( kAPG_Activity, kAP_ATVT_Distress );
	animProps.Set( kAPG_Action, kAP_ACT_Idle );

	CAIStateAnimate* pStateAnimate = (CAIStateAnimate*)( pAI->GetState() );
	pStateAnimate->SetAnimation( animProps, !LOOP );

	// Do NOT play a threat sound if threatened by a Turret.
	// Instead, allow turret targeting to play something appropriate.

	if( IsPlayer( pFact->GetSourceObject() ) )
	{
		CPlayerObj* pPlayer = (CPlayerObj*)g_pLTServer->HandleToObject( pFact->GetSourceObject() );
		if( pPlayer && pPlayer->GetTurret() )
		{
			return;
		}
	}

	// Play threat sound.

	// "Fire!"

	if( IsAINode( pFact->GetSourceObject() ) )
	{
		EnumAISoundType eAISound = kAIS_Danger;
		AINode* pNode = (AINode*)g_pLTServer->HandleToObject( pFact->GetSourceObject() );
		if( pNode && pNode->GetType() == kNode_Stimulus )
		{
			AINodeStimulus* pNodeStim = (AINodeStimulus*)pNode;
			if( pNodeStim )
			{
				eAISound = pNodeStim->GetAISoundType();
			}
		}
		g_pAISoundMgr->RequestAISound( pAI->m_hObject, eAISound, kAISndCat_Event, NULL, 0.f );
	}

	// "Watch out grenade!"
	// "Shit!"

	else if( IsKindOf( pFact->GetSourceObject(), "CProjectile" ) )
	{
		// Don't say anything if ally threw grenade.

		CProjectile* pProjectile = (CProjectile*)g_pLTServer->HandleToObject( pFact->GetSourceObject() );
		if( pProjectile && IsCharacter( pProjectile->GetFiredFrom() ) )
		{
			CCharacter *pChar = (CCharacter*)g_pLTServer->HandleToObject( pProjectile->GetFiredFrom() );
			if( pChar && kCharStance_Like != g_pCharacterDB->GetStance( pAI->GetAlignment(), pChar->GetAlignment() ) )
			{
				ENUM_AI_SQUAD_ID eSquad = g_pAICoordinator->GetSquadID( pAI->m_hObject );
				CAISquad* pSquad = g_pAICoordinator->FindSquad( eSquad );
				if( pSquad && pSquad->GetNumSquadMembers() > 1 )
				{
					g_pAISoundMgr->RequestAISound( pAI->m_hObject, kAIS_GrenadeThreat, kAISndCat_Event, NULL, 0.f );
				}
				else {
					g_pAISoundMgr->RequestAISound( pAI->m_hObject, kAIS_GrenadeThreatAlone, kAISndCat_Event, NULL, 0.f );
				}
			}
		}
	}

	// "Shit"

	else 
	{
		g_pAISoundMgr->RequestAISound( pAI->m_hObject, kAIS_GrenadeThreatAlone, kAISndCat_Event, NULL, 0.f );
	}



	// Search for the source of the danger.

	LTVector vDangerPos = pFact->GetPos();
	SearchForDangerOrigin( pAI, vDangerPos );
//.........这里部分代码省略.........
开发者ID:Arc0re,项目名称:lithtech,代码行数:101,代码来源:AIActionReactToDanger.cpp

示例8: LOWER_BY_DIFFICULTY

void CAIBrain::GetDodgeStatus(DodgeStatus* peDodgeStatus, Direction* peDirection, DodgeAction* peDodgeAction, uint32* pdwNode)
{
	if ( !GetAI()->HasTarget() || !GetAI()->HasLastVolume() ) 
	{
		*peDodgeStatus = m_eDodgeStatusLast = eDodgeStatusOk;
		return;
	}

	if ( g_pLTServer->GetTime() >= m_fDodgeStatusCheckTimeVector )
	{
		m_fDodgeStatusCheckTimeVector = g_pLTServer->GetTime() + LOWER_BY_DIFFICULTY(m_pBrain->fDodgeVectorCheckTime);

		if ( GetRandom(0.0f, 1.0f) <= RAISE_BY_DIFFICULTY(m_pBrain->fDodgeVectorCheckChance) )
		{
			if ( GetAI()->GetTarget()->IsVisiblePartially() )
			{
				CCharacter* pCharacter = (CCharacter*)g_pLTServer->HandleToObject(GetAI()->GetTarget()->GetObject());
				if ( pCharacter->HasDangerousWeapon() )
				{
					LTRotation rRot;
					LTVector vNull, vForward;
					g_pLTServer->GetObjectRotation(GetAI()->GetTarget()->GetObject(), &rRot);
					g_pMathLT->GetRotationVectors(rRot, vNull, vNull, vForward);

					LTVector vDir;
					vDir = GetAI()->GetPosition() - GetAI()->GetTarget()->GetPosition();
					vDir.y = 0;
					vDir.Norm();

					// TODO: bute this

					const static LTFLOAT fThreshhold = 0.95f;

					if ( (vDir.Dot(vForward) > fThreshhold) && (GetAI()->GetForwardVector().Dot(vForward) < -fThreshhold) )
					{
						LTFLOAT fCheckDistance;

						LTFLOAT fRandom = GetRandom(0.0f, 1.0f);

						if ( fRandom > m_pBrain->fDodgeVectorCoverChance )
						{
							if ( fRandom > (m_pBrain->fDodgeVectorCoverChance + m_pBrain->fDodgeVectorRollChance) )
							{
								*peDodgeAction = eDodgeActionShuffle;
								fCheckDistance = 109.0f;
							}
							else
							{
								*peDodgeAction = eDodgeActionRoll;
								fCheckDistance = 140.0f;
							}

							// MAKE SURE WE WON'T DODGE OUT OF THE VOLUME 
							if ( GetAI()->GetLastVolume()->Inside2d(GetAI()->GetPosition()+GetAI()->GetRightVector()*fCheckDistance, GetAI()->GetRadius()) )
							{
								*peDirection = eDirectionRight;
								*peDodgeStatus = m_eDodgeStatusLast = eDodgeStatusVector;
								return;
							}
							else if ( GetAI()->GetLastVolume()->Inside2d(GetAI()->GetPosition()-GetAI()->GetRightVector()*fCheckDistance, GetAI()->GetRadius()) )
							{
								*peDirection = eDirectionLeft;
								*peDodgeStatus = m_eDodgeStatusLast = eDodgeStatusVector;
								return;
							}
							else
							{
								*peDodgeStatus = m_eDodgeStatusLast = eDodgeStatusOk;
								return;
							}
						}
						else
						{
							CAINode* pNode = g_pAINodeMgr->FindNearestCoverFromThreat(GetAI()->GetPosition(), GetAI()->GetTarget()->GetObject());

							if ( pNode )
							{
								*peDodgeAction = eDodgeActionCover;
								*peDodgeStatus = m_eDodgeStatusLast = eDodgeStatusVector;
								*pdwNode = pNode->GetID();
							}
							else
							{
								*peDodgeStatus = m_eDodgeStatusLast = eDodgeStatusOk;
							}
							return;
						}
					}
				}
			}
		}
	}

	if ( g_pLTServer->GetTime() >= m_fDodgeStatusCheckTimeProjectile )
	{
		m_fDodgeStatusCheckTimeProjectile = g_pLTServer->GetTime() + RAISE_BY_DIFFICULTY(m_pBrain->fDodgeProjectileCheckTime);

		if ( GetRandom(0.0f, 1.0f) <= RAISE_BY_DIFFICULTY(m_pBrain->fDodgeProjectileCheckChance) )
		{
			CGrenade* pGrenade;
//.........这里部分代码省略.........
开发者ID:Arc0re,项目名称:lithtech,代码行数:101,代码来源:AIBrain.cpp

示例9: outgoingPacket

void CLobbyServerPlayer::ProcessGetCharacters(const PacketData& packetData)
{
	CLog::GetInstance().LogMessage(LOG_NAME, "GetCharacters");

	if(m_dbConnection.IsEmpty())
	{
		CLog::GetInstance().LogMessage(LOG_NAME, "No database connection available. Bailing.");
		m_disconnect = true;
		return;
	}

	PacketData outgoingPacket(std::begin(g_characterListPacket), std::end(g_characterListPacket));

	CCharacter character;

	try
	{
		auto query = string_format("SELECT * FROM ffxiv_characters WHERE userId = %d", m_userId);
		auto result = m_dbConnection.Query(query.c_str());
		if(result.GetRowCount() != 0)
		{
			character = CCharacter(result);
		}
	}
	catch(const std::exception& exception)
	{
		CLog::GetInstance().LogError(LOG_NAME, "Failed to fetch characters for user (id = %d): %s", m_userId, exception.what());
		m_disconnect = true;
		return;
	}

	PacketData characterData(std::begin(g_characterData), std::end(g_characterData));
	
	characterData[0x21] = CCharacter::GetModelFromTribe(character.tribe);
	characterData[0x9F] = character.tribe;
	characterData[0xC7] = character.guardian;
	characterData[0xC8] = character.birthMonth;
	characterData[0xC9] = character.birthDay;
	characterData[0xE8] = character.allegiance;

	*reinterpret_cast<uint32*>(&characterData[0x25]) = character.size;				//size

	*reinterpret_cast<uint32*>(&characterData[0x29]) = character.GetColorInfo();	//hairColor + skinColor
	*reinterpret_cast<uint32*>(&characterData[0x2D]) = character.GetFaceInfo();		//face Stuff?
	*reinterpret_cast<uint32*>(&characterData[0x31]) = character.hairStyle << 10;	//hair model
	*reinterpret_cast<uint32*>(&characterData[0x35]) = character.voice;				//voice
	*reinterpret_cast<uint32*>(&characterData[0x39]) = character.weapon1;			//weapon1
	*reinterpret_cast<uint32*>(&characterData[0x3D]) = character.weapon2;			//weapon2
	*reinterpret_cast<uint32*>(&characterData[0x55]) = character.headGear;			//headGear
	*reinterpret_cast<uint32*>(&characterData[0x59]) = character.bodyGear;			//bodyGear
	*reinterpret_cast<uint32*>(&characterData[0x5D]) = character.legsGear;			//legsGear
	*reinterpret_cast<uint32*>(&characterData[0x61]) = character.handsGear;			//handsGear
	*reinterpret_cast<uint32*>(&characterData[0x65]) = character.feetGear;			//feetGear
	*reinterpret_cast<uint32*>(&characterData[0x69]) = character.waistGear;			//waistGear
//	*reinterpret_cast<uint32*>(&characterData[0x6D]) = 0;							//???
	*reinterpret_cast<uint32*>(&characterData[0x71]) = character.rightEarGear;		//rightEarGear
	*reinterpret_cast<uint32*>(&characterData[0x75]) = character.leftEarGear;		//leftEarGear
//	*reinterpret_cast<uint32*>(&characterData[0x79]) = 0;							//???
//	*reinterpret_cast<uint32*>(&characterData[0x7D]) = 0;							//???
	*reinterpret_cast<uint32*>(&characterData[0x81]) = character.rightFingerGear;	//rightFingerGear
	*reinterpret_cast<uint32*>(&characterData[0x85]) = character.leftFingerGear;	//leftFingerGear

	auto encodedCharacterData = Framework::ToBase64(characterData.data(), characterData.size());
	std::replace(std::begin(encodedCharacterData), std::end(encodedCharacterData), '+', '-');
	std::replace(std::begin(encodedCharacterData), std::end(encodedCharacterData), '/', '_');

	static const uint32 characterInfoBase = 0x860;

	if(character.active)
	{
		for(unsigned int i = 0; i < encodedCharacterData.size(); i++)
		{
			outgoingPacket[characterInfoBase + 0x40 + i] = encodedCharacterData[i];
		}

		*reinterpret_cast<uint32*>(&outgoingPacket[characterInfoBase + 0x00]) = 0x0158E7FC;
		*reinterpret_cast<uint32*>(&outgoingPacket[characterInfoBase + 0x04]) = character.id;
		*reinterpret_cast<uint32*>(&outgoingPacket[characterInfoBase + 0x0C]) = 0x000000F4;

		//Insert character name
		for(unsigned int i = 0; i < character.name.size(); i++)
		{
			outgoingPacket[characterInfoBase + 0x10 + i] = character.name[i];
		}
		outgoingPacket[characterInfoBase + 0x10 + character.name.size()] = 0;
	}

	CPacketUtils::EncryptPacket(outgoingPacket);
	QueuePacket(outgoingPacket);
}
开发者ID:kidaa,项目名称:SeventhUmbral,代码行数:90,代码来源:LobbyServerPlayer.cpp

示例10: GetPos

void CProjectile::Tick()
{
	float Pt = (Server()->Tick()-m_StartTick-1)/(float)Server()->TickSpeed();
	float Ct = (Server()->Tick()-m_StartTick)/(float)Server()->TickSpeed();
	vec2 PrevPos = GetPos(Pt);
	vec2 CurPos = GetPos(Ct);
	vec2 ColPos;
	vec2 NewPos;
	int Collide = GameServer()->Collision()->IntersectLine(PrevPos, CurPos, &ColPos, &NewPos, false);
	CCharacter *pOwnerChar = 0;



	if(m_Owner >= 0)
		pOwnerChar = GameServer()->GetPlayerChar(m_Owner);

	CCharacter *pTargetChr = GameServer()->m_World.IntersectCharacter(PrevPos, ColPos, m_Freeze ? 1.0f : 6.0f, ColPos, pOwnerChar);

	if(m_LifeSpan > -1)
		m_LifeSpan--;

	int TeamMask = -1;
	bool isWeaponCollide = false;
	if
	(
			pOwnerChar &&
			pTargetChr &&
			pOwnerChar->IsAlive() &&
			pTargetChr->IsAlive() &&
			!pTargetChr->CanCollide(m_Owner)
			)
	{
			isWeaponCollide = true;
			//TeamMask = OwnerChar->Teams()->TeamMask( OwnerChar->Team());
	}
	if (pOwnerChar && pOwnerChar->IsAlive())
	{
			TeamMask = pOwnerChar->Teams()->TeamMask(pOwnerChar->Team(), -1, m_Owner);
	}
	if( ((pTargetChr && (pOwnerChar ? !(pOwnerChar->m_Hit&CCharacter::DISABLE_HIT_GRENADE) : g_Config.m_SvHit || m_Owner == -1 || pTargetChr == pOwnerChar)) || Collide || GameLayerClipped(CurPos)) && !isWeaponCollide)
	{
		if(m_Explosive/*??*/ && (!pTargetChr || (pTargetChr && !m_Freeze)))
		{
			GameServer()->CreateExplosion(ColPos, m_Owner, m_Weapon, m_Owner == -1, (!pTargetChr ? -1 : pTargetChr->Team()),
			(m_Owner != -1)? TeamMask : -1);
			GameServer()->CreateSound(ColPos, m_SoundImpact,
			(m_Owner != -1)? TeamMask : -1);
		}
		else if(pTargetChr && m_Freeze && ((m_Layer == LAYER_SWITCH && GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[pTargetChr->Team()]) || m_Layer != LAYER_SWITCH))
			pTargetChr->Freeze();
		if(Collide && m_Bouncing != 0)
		{
			m_StartTick = Server()->Tick();
			m_Pos = NewPos+(-(m_Direction*4));
			if (m_Bouncing == 1)
				m_Direction.x = -m_Direction.x;
			else if(m_Bouncing == 2)
				m_Direction.y =- m_Direction.y;
			if (fabs(m_Direction.x) < 1e-6)
				m_Direction.x = 0;
			if (fabs(m_Direction.y) < 1e-6)
				m_Direction.y = 0;
			m_Pos += m_Direction;
		}
		else if (m_Weapon == WEAPON_GUN)
		{
			GameServer()->CreateDamageInd(CurPos, -atan2(m_Direction.x, m_Direction.y), 10, (m_Owner != -1)? TeamMask : -1);
			GameServer()->m_World.DestroyEntity(this);
		}
		else
			if (!m_Freeze)
				GameServer()->m_World.DestroyEntity(this);
	}
	if(m_LifeSpan == -1)
	{
		GameServer()->m_World.DestroyEntity(this);
	}
}
开发者ID:BigCrazyChris,项目名称:XXLDDRace,代码行数:78,代码来源:projectile.cpp

示例11: Move

void CPickup::Tick()
{
	Move();
	/*// wait for respawn
	if(m_SpawnTick > 0)
	{
		if(Server()->Tick() > m_SpawnTick)
		{
			// respawn
			m_SpawnTick = -1;

			if(m_Type == POWERUP_WEAPON)
				GameServer()->CreateSound(m_Pos, SOUND_WEAPON_SPAWN);
		}
		else
			return;
	}*/
	// Check if a player intersected us
	CCharacter *apEnts[MAX_CLIENTS];
	int Num = GameWorld()->FindEntities(m_Pos, 20.0f, (CEntity**)apEnts, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);
	for(int i = 0; i < Num; ++i) {
		CCharacter * pChr = apEnts[i];
		if(pChr && pChr->IsAlive())
		{
			if(m_Layer == LAYER_SWITCH && !GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[pChr->Team()]) continue;
			bool sound = false;
			// player picked us up, is someone was hooking us, let them go
			switch (m_Type)
			{
				case POWERUP_HEALTH:
					if(pChr->Freeze()) GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH, pChr->Teams()->TeamMask(pChr->Team()));
					break;

				case POWERUP_ARMOR:
					if(pChr->Team() == TEAM_SUPER) continue;
					for(int i = WEAPON_SHOTGUN; i < NUM_WEAPONS; i++)
					{
						if(pChr->GetWeaponGot(i))
						{
							if(!(pChr->m_FreezeTime && i == WEAPON_NINJA))
							{
								pChr->SetWeaponGot(i, false);
								pChr->SetWeaponAmmo(i, 0);
								sound = true;
							}
						}
					}
					pChr->SetNinjaActivationDir(vec2(0,0));
					pChr->SetNinjaActivationTick(-500);
					pChr->SetNinjaCurrentMoveTime(0);
					if (sound)
					{
						pChr->SetLastWeapon(WEAPON_GUN);
						GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR, pChr->Teams()->TeamMask(pChr->Team()));
					}
					if(!pChr->m_FreezeTime && pChr->GetActiveWeapon() >= WEAPON_SHOTGUN)
						pChr->SetActiveWeapon(WEAPON_HAMMER);
					break;

				case POWERUP_WEAPON:

					if (m_Subtype >= 0 && m_Subtype < NUM_WEAPONS && (!pChr->GetWeaponGot(m_Subtype) || (pChr->GetWeaponAmmo(m_Subtype) != -1 && !pChr->m_FreezeTime)))
					{
						pChr->GiveWeapon(m_Subtype);

						//RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;

						if (m_Subtype == WEAPON_GRENADE)
							GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE, pChr->Teams()->TeamMask(pChr->Team()));
						else if (m_Subtype == WEAPON_SHOTGUN)
							GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN, pChr->Teams()->TeamMask(pChr->Team()));
						else if (m_Subtype == WEAPON_RIFLE)
							GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN, pChr->Teams()->TeamMask(pChr->Team()));

						if (pChr->GetPlayer())
							GameServer()->SendWeaponPickup(pChr->GetPlayer()->GetCID(), m_Subtype);

					}
					break;

			case POWERUP_NINJA:
				{
					// activate ninja on target player
					pChr->GiveNinja();
					//RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;

					/*// loop through all players, setting their emotes
					CCharacter *pC = static_cast<CCharacter *>(GameServer()->m_World.FindFirst(CGameWorld::ENTTYPE_CHARACTER));
					for(; pC; pC = (CCharacter *)pC->TypeNext())
					{
						if (pC != pChr)
							pC->SetEmote(EMOTE_SURPRISE, Server()->Tick() + Server()->TickSpeed());
					}*/
					break;
				}
				default:
					break;
			};

			/*if(RespawnTime >= 0)
//.........这里部分代码省略.........
开发者ID:eeeee,项目名称:ddnet,代码行数:101,代码来源:pickup.cpp

示例12: DoWeaponSwitch

void CCharacter::FireWeapon()
{
	if(m_ReloadTimer != 0)
		return;

	DoWeaponSwitch();
	vec2 Direction = normalize(vec2(m_LatestInput.m_TargetX, m_LatestInput.m_TargetY));

	bool FullAuto = false;
	if(m_ActiveWeapon == WEAPON_GRENADE || m_ActiveWeapon == WEAPON_SHOTGUN || m_ActiveWeapon == WEAPON_RIFLE || (m_ActiveWeapon == WEAPON_HAMMER && g_Config.m_SvSuperHammer))
		FullAuto = true;


	// check if we gonna fire
	bool WillFire = false;
	if(CountInput(m_LatestPrevInput.m_Fire, m_LatestInput.m_Fire).m_Presses)
		WillFire = true;

	if(FullAuto && (m_LatestInput.m_Fire&1) && m_aWeapons[m_ActiveWeapon].m_Ammo)
		WillFire = true;

	if (!g_Config.m_SvNinja && m_ActiveWeapon == WEAPON_NINJA)
		WillFire = false;

	if(!WillFire)
		return;

	// check for ammo
	if(!m_aWeapons[m_ActiveWeapon].m_Ammo)
	{
		// 125ms is a magical limit of how fast a human can click
		m_ReloadTimer = 125 * Server()->TickSpeed() / 1000;
		GameServer()->CreateSound(m_Pos, SOUND_WEAPON_NOAMMO);
		return;
	}

	vec2 ProjStartPos = m_Pos+Direction*m_ProximityRadius*0.75f;

	switch(m_ActiveWeapon)
	{
		case WEAPON_HAMMER:
		{
			// reset objects Hit
			m_NumObjectsHit = 0;
			GameServer()->CreateSound(m_Pos, SOUND_HAMMER_FIRE);

			CCharacter *apEnts[MAX_CLIENTS];
			int Hits = 0;
			int Num = GameServer()->m_World.FindEntities(ProjStartPos, m_ProximityRadius*0.5f, (CEntity**)apEnts,
														MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER);

			for (int i = 0; i < Num; ++i)
			{
				CCharacter *pTarget = apEnts[i];

				if ((pTarget == this) || GameServer()->Collision()->IntersectLine(ProjStartPos, pTarget->m_Pos, NULL, NULL))
					continue;

				// set his velocity to fast upward (for now)
				if(length(pTarget->m_Pos-ProjStartPos) > 0.0f)
					GameServer()->CreateHammerHit(pTarget->m_Pos-normalize(pTarget->m_Pos-ProjStartPos)*m_ProximityRadius*0.5f);
				else
					GameServer()->CreateHammerHit(ProjStartPos);

				vec2 Dir;
				if (length(pTarget->m_Pos - m_Pos) > 0.0f)
					Dir = normalize(pTarget->m_Pos - m_Pos);
				else
					Dir = vec2(0.f, -1.f);

				bool MeltHit = GameServer()->m_pController->IsTeamplay() && pTarget->GetPlayer()->GetTeam() == GetPlayer()->GetTeam() && pTarget->GetFreezeTicks() > 0;

				vec2 Force = (vec2(0.f, -1.f) + normalize(Dir + vec2(0.f, -1.1f)) * 10.0f);
				if (!MeltHit)
				{
					Force.x *= g_Config.m_SvHammerScaleX*0.01f;
					Force.y *= g_Config.m_SvHammerScaleY*0.01f;
				}
				else
				{
					Force.x *= g_Config.m_SvMeltHammerScaleX*0.01f;
					Force.y *= g_Config.m_SvMeltHammerScaleY*0.01f;
				}

				pTarget->TakeDamage(Force, g_pData->m_Weapons.m_Hammer.m_pBase->m_Damage, m_pPlayer->GetCID(), m_ActiveWeapon);
				Hits++;

				pTarget->m_HammeredBy = GetPlayer()->GetCID();

				if (MeltHit)
				{
					pTarget->Freeze(pTarget->GetFreezeTicks() - g_Config.m_SvHammerMelt * Server()->TickSpeed());
					if (pTarget->GetFreezeTicks() <= 0)
					{
						pTarget->m_MoltenBy = m_pPlayer->GetCID();
						pTarget->m_MoltenAt = -1; // we don't want the unfreezability to take effect when being molten by hammer
					}
				}
					
			}
//.........这里部分代码省略.........
开发者ID:TsFreddie,项目名称:teeworlds-solofng,代码行数:101,代码来源:character.cpp

示例13:

//---------------------------------------------------
void CCharacterVersionAdapter::adaptToVersion11(CCharacter &character) const
{
	// delete all missions
	std::map<uint32,EGSPD::CMissionPD *>::iterator it;
	while (true)
	{
		it = character._Missions->getMissionsBegin();
		if (it == character._Missions->getMissionsEnd())
			break;
		character._Missions->deleteFromMissions( (*it).first );
	}
	
	// get the region where the user is
	CRegion * region = dynamic_cast<CRegion*> (	CZoneManager::getInstance().getPlaceFromId( character.getCurrentRegion() ) );
	if ( !region )
	{
		nlwarning("<adaptToVersion11> user%s is on invalid region %u",character.getId().toString().c_str(), character.getCurrentRegion()  );
		return;
	}
	
	vector<TAIAlias> bots;
	TAIAlias mission = CAIAliasTranslator::Invalid;
	// if the user is in newbie land, give him the appropriate newbie mission
	if ( region->isNewbieRegion() )
	{
		switch( character.getRace() )
		{
		case EGSPD::CPeople::Fyros :
			mission = CAIAliasTranslator::getInstance()->getMissionUniqueIdFromName( "FYROS_NEWB_WELCOME_KAEMON_1" );
			CAIAliasTranslator::getInstance()->getNPCAliasesFromName("welcomer_kaemon_1", bots);
			break;
		case EGSPD::CPeople::Matis :
			mission = CAIAliasTranslator::getInstance()->getMissionUniqueIdFromName( "MATIS_NEWB_WELCOME_BOREA_1" );
			CAIAliasTranslator::getInstance()->getNPCAliasesFromName("welcomer_borea_1", bots);
			break;
		case EGSPD::CPeople::Tryker :
			mission = CAIAliasTranslator::getInstance()->getMissionUniqueIdFromName( "TRYKER_NEWB_WELCOME_BARKDELL_1" );
			CAIAliasTranslator::getInstance()->getNPCAliasesFromName("welcomer_barkdell_1", bots);
			break;
		case EGSPD::CPeople::Zorai :
			mission = CAIAliasTranslator::getInstance()->getMissionUniqueIdFromName( "ZORAI_NEWB_WELCOME_SHENG_WO_1" );
			CAIAliasTranslator::getInstance()->getNPCAliasesFromName("welcomer_sheng_wo_1", bots);
			break;	
		}
	}
	// other give him a rite intro mission
	else
	{
		switch( character.getRace() )
		{
		case EGSPD::CPeople::Fyros :
			mission = CAIAliasTranslator::getInstance()->getMissionUniqueIdFromName( "FYROS_ENCYCLO_TUTORIAL" );
			CAIAliasTranslator::getInstance()->getNPCAliasesFromName("pyr_barman", bots);
			break;
		case EGSPD::CPeople::Matis :
			mission = CAIAliasTranslator::getInstance()->getMissionUniqueIdFromName( "MATIS_ENCYCLO_TUTORIAL" );
			CAIAliasTranslator::getInstance()->getNPCAliasesFromName("yrkanis_barman", bots);
			break;
		case EGSPD::CPeople::Tryker :
			mission = CAIAliasTranslator::getInstance()->getMissionUniqueIdFromName( "TRYKER_ENCYCLO_TUTORIAL" );
			CAIAliasTranslator::getInstance()->getNPCAliasesFromName("fairhaven_barman_1", bots);
			break;
		case EGSPD::CPeople::Zorai :
			mission = CAIAliasTranslator::getInstance()->getMissionUniqueIdFromName( "ZORAI_ENCYCLO_TUTORIAL" );
			CAIAliasTranslator::getInstance()->getNPCAliasesFromName("zora_barman", bots);
			break;	
		}
	}
	if ( mission == CAIAliasTranslator::Invalid || bots.empty() )
	{
		nlwarning("<adaptToVersion11> %s cant have newbie/rite mission set. race is '%s' bot vector size is %u mission is %u newbie mission is %u",
			character.getId().toString().c_str(),
			EGSPD::CPeople::toString( character.getRace() ).c_str(),
			bots.size(),
			mission,
			region->isNewbieRegion());
		return;
	}

	nlassert(!bots.empty());
	character.setWelcomeMissionDesc(mission, bots[0]);
}
开发者ID:Kiddinglife,项目名称:ryzom,代码行数:83,代码来源:character_version_adapter.cpp

示例14: defined


//.........这里部分代码省略.........
		for( int i = 0;i < MOUSE_MAX;++i )
		{
			char Temp[20] = "";
			
			sprintf( Temp, "mouse%d.csv", i+1 );
			
			pResFile = m_pApp->GetFileMgr()->FileOpen(Temp);
			
			sprintf(Temp, "Mouse%d", i+1 );
			
			m_p3DObj->AppendObject( new CEnemyMouse("mouse.smf", Math::Vector3D(0.0f, 0.0f, -40.0f), pResFile->GetNamePointer() ), Temp, true );
			
			SAFE_RELEASE( pResFile );
		}
		
		pResFile = m_pApp->GetFileMgr()->FileOpen("manta.csv");
		
		#if defined( TEST_RELEASE )	
			m_p3DObj->AppendObject( new CEnemyManta("manta.smf", Math::Vector3D(0.0f, 0.0f, -40.0f), pResFile->GetNamePointer() ), "Manta", true );
		#else
			m_p3DObj->AppendObject( new CEnemyManta("manta.smf", Math::Vector3D(0.0f, 80.0f, -40.0f), pResFile->GetNamePointer() ), "Manta", true );
		#endif
		
		SAFE_RELEASE( pResFile );
		
		pResFile = m_pApp->GetFileMgr()->FileOpen("rabbit.csv");
		
		m_p3DObj->AppendObject( new CEnemyRabbit("rabbit.smf", Math::Vector3D(0.0f, 0.0f, -40.0f), pResFile->GetNamePointer() ), "Rabbit", true );
		
		SAFE_RELEASE( pResFile );
		
		m_p3DObj->AppendObject( new CCamObject("camera.smf"), "CamObj", false );
		
		m_p3DObj->AppendObject( new CCharacter("statue_dove.smf", Math::Vector3D( -188, 3.6f, -361) ), "FountObj", true );
		m_p3DObj->AppendObject( new CCharacter("flag.smf", Math::Vector3D( -188, 3.6f, -361) ), "Flag", true );
		
		//m_p3DObj->AppendObject( new CFlagObject("flag.smf"), "Flag", false );
		
		//m_p3DObj->AppendObject( new CCharacter("statue_dove.smf", Math::Vector3D( -188, 4.4f, -361) ), "FountObj2", true );
		//m_p3DObj->AppendObject( new CCharacter("statue_dove.smf", Math::Vector3D( -188, 4.4f, -361) ), "FountObj3", true );
		
		
		m_p3DObj->AppendObject( new CCharacter("arrow.smf", Math::Vector3D( 0, 0, 0 ) ), "Arrow", true );
		//m_p3DObj->AppendObject( new CSprite3D("title.png", Math::Vector3D( 0, 0, -100 ) ), "BillBoard", true );
		m_p3DObj->AppendObject( new CCharacter("target.smf", Math::Vector3D( 0, 0, -100 ) ), "Target", true );
		m_p3DObj->AppendObject( new CCharacter("star.smf", Math::Vector3D( 0, 0, -100 ) ), "Star", false ) ;
		m_p3DObj->AppendObject( new CCharacter("flying_island.smf", Math::Vector3D( 162, 180, -212 ) ), "IsLand", true ) ;
		
		
		m_p3DObj->AppendObject( new CSprite3D("flgemo.dds", Math::Vector3D( 0, 0, -10 ) ), "FlagBalloon", true );
		m_p3DObj->AppendObject( new CParticle("smoke.dds", Math::Vector3D(0, 0, 10) ), "RunEffect0", false );
		m_p3DObj->AppendObject( new CParticle("smoke.dds", Math::Vector3D(0, 0, 10) ), "RunEffect1", false );
		m_p3DObj->AppendObject( new CParticle("smoke.dds", Math::Vector3D(0, 0, 10) ), "RunEffect2", false );
		m_p3DObj->AppendObject( new CParticle("smoke.dds", Math::Vector3D(0, 0, 10) ), "RunEffect3", false );
		m_p3DObj->AppendObject( new CFlash("flash2.png", Math::Vector3D( 0, 0, 0 ) ), "Emission0", false );
		m_p3DObj->AppendObject( new CFlash("flash2.png", Math::Vector3D( 0, 0, 0 ) ), "Emission1", false );
		m_p3DObj->AppendObject( new CFlash("flash2.png", Math::Vector3D( 0, 0, 0 ) ), "Emission2", false );
		m_p3DObj->AppendObject( new CFlash("flash2.png", Math::Vector3D( 0, 0, 0 ) ), "Emission3", false );
		m_p3DObj->AppendObject( new CFlash("flash2.png", Math::Vector3D( 0, 0, 0 ) ), "Emission4", false );
		m_p3DObj->AppendObject( new CFlash("flash2.png", Math::Vector3D( 0, 0, 0 ) ), "Emission5", false );
		
		
		m_p3DObj->AppendObject( new CSprite3D("emo.dds", Math::Vector3D( 0, 0, 0 ) ), "Emotion", false );
	
		
		m_pSoundObj->AppendObject( new CSoundEffect("shutter.WAV"), "Shutter", true );
开发者ID:Taka03,项目名称:Camerun,代码行数:67,代码来源:Scene.cpp

示例15: GameServer

bool CPlasma::HitCharacter(vec2 From, vec2 To)
{
	vec2 At;
	vec2 TempPos;

	float ClosestLen = -1;

	CCharacter *pOwnerChar = GameServer()->GetPlayerChar(m_Owner);
	CCharacter *pHit = GameServer()->m_World.IntersectCharacter(From, To, 0.0f, TempPos, pOwnerChar);
	if (pHit)
	{
		ClosestLen = distance(From, TempPos);
		At = TempPos;
	}

	CTurret *pHitTurret = (CTurret*) GameServer()->m_World.IntersectEntity(From, To, 0.0f, TempPos, CGameWorld::ENTTYPE_TURRET);
	if (pHitTurret && pHitTurret->GetOwner() != m_Owner && (ClosestLen > distance(From, TempPos) || ClosestLen == -1))
	{
		ClosestLen = distance(From, TempPos);
		At = TempPos;
		pHit = 0;
	}
	else if (pHitTurret)
		pHitTurret = 0;

	CExplodeWall *pHitExplodeWall = 0;

	{
		CExplodeWall *p = (CExplodeWall *)GameWorld()->FindFirst(CGameWorld::ENTTYPE_EXPLODEWALL);
		for(; p; p = (CExplodeWall *)p->TypeNext())
		{
			// Store the values for fast access and easy
			// equations-to-code conversion
			float x1 = From.x, x2 = To.x, x3 = p->m_From.x, x4 = p->m_Pos.x;
			float y1 = From.y, y2 = To.y, y3 = p->m_From.y, y4 = p->m_Pos.y;

			float d = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
			// If d is zero, there is no intersection
			if (d == 0)
				continue;

			// Get the x and y
			float pre = (x1*y2 - y1*x2), post = (x3*y4 - y3*x4);
			float x = ( pre * (x3 - x4) - (x1 - x2) * post ) / d;
			float y = ( pre * (y3 - y4) - (y1 - y2) * post ) / d;

			// Check if the x and y coordinates are within both lines
			if ( x < min(x1, x2) || x > max(x1, x2) || x < min(x3, x4) || x > max(x3, x4) )
				continue;
			if ( y < min(y1, y2) || y > max(y1, y2) || y < min(y3, y4) || y > max(y3, y4) )
				continue;

			if ( ClosestLen > distance(From, vec2(x, y)) || ClosestLen == -1 )
			{
				ClosestLen = distance(From, vec2(x, y));
				At.x = x;
				At.y = y;
				pHit = 0;
				pHitTurret = 0;
				pHitExplodeWall = p;
			}
		}
	}

	if(!pHit && !pHitTurret && !pHitExplodeWall)
		return false;

	m_Pos = At;
	m_Energy = -1;

	if ( pHit && (!GameServer()->m_pEventsGame->IsActualEvent(WALLSHOT) || m_Bounces > 0 || GameServer()->m_pEventsGame->IsActualEvent(BULLET_PIERCING)) )
		pHit->TakeDamage(vec2(0.f, 0.f), GameServer()->Tuning()->m_LaserDamage, m_Owner, WEAPON_RIFLE, false);
	else if ( pHitTurret && (!GameServer()->m_pEventsGame->IsActualEvent(WALLSHOT) || m_Bounces > 0 || GameServer()->m_pEventsGame->IsActualEvent(BULLET_PIERCING)) )
		pHitTurret->TakeDamage(GameServer()->Tuning()->m_LaserDamage, m_Owner, WEAPON_RIFLE, false);
	else if ( pHitExplodeWall && (!GameServer()->m_pEventsGame->IsActualEvent(WALLSHOT) || m_Bounces > 0 || GameServer()->m_pEventsGame->IsActualEvent(BULLET_PIERCING)) )
		pHitExplodeWall->TakeDamage(GameServer()->Tuning()->m_LaserDamage, m_Owner, WEAPON_RIFLE, false);

	return true;
}
开发者ID:PJK136,项目名称:teeworlds-wDM,代码行数:79,代码来源:plasma.cpp


注:本文中的CCharacter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。