The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Where is the jerky code?
keen Offline
Junior Member

Posts: 6
Threads: 3
Joined: Aug 2010
Reputation: 0
#1
Where is the jerky code?

Okay, so i thought I'd look to see if i could improve the jerky code for fun. But, I'm having trouble finding it. Is this some it in GameObject.cpp??

Quote:////////////////////////////////////////////
//Attracts Enemies
pObject->mAttractProps.mbActive = cString::ToBool(pGameElem->Attribute("AttractEnemies"),false);
if(pObject->mAttractProps.mbActive)
{
pObject->mAttractProps.mfDistance = cString::ToFloat(pGameElem->Attribute("AttractDistance"),0);
tString sSubTypes = cString::ToString(pGameElem->Attribute("AttractSubtypes"),"");
cString::GetStringVec(sSubTypes,pObject->mAttractProps.mvSubtypes,NULL);

pObject->mAttractProps.mbIsEaten = cString::ToBool(pGameElem->Attribute("AttractIsEaten"),false);
pObject->mAttractProps.mfEatLength = cString::ToFloat(pGameElem->Attribute("AttractEatLength"),0);
}


////////////////////////////////////////////
//-----------------------------------------------------------------------

void cGameObject::UpdateAttraction(float afTimeStep)
{
if(mAttractProps.mbActive==false) return;


///////////////////////////////////////////////
//Check if the current attraction is near enough
if(mpCurrentAttraction)
{
////////////////////////////////////////
//Check for the attracted enemy
iCharacterBody *pBody = mpCurrentAttraction->GetMover()->GetCharBody();
float fDist = cMath::Vector3Dist( pBody->GetFeetPosition(),
mvBodies[0]->GetWorldPosition());

//Check if the enemy have become busy.
if( (mpCurrentAttraction->GetCurrentStateId() != STATE_MOVETO && fDist <pBody->GetSize().x*0.75f)
||
(mAttractProps.mbIsEaten && fDist <pBody->GetSize().x*0.75f))
{
//Use half the width here.
if(mAttractProps.mbIsEaten)
{
mpCurrentAttraction->SetTempFloat(mAttractProps.mfEatLength);
mpCurrentAttraction->ChangeState(STATE_EAT);
}

mpCurrentAttraction->SetAttracted(false);
mpCurrentAttraction = NULL;

mbDestroyMe = true;
return;
}
else if(mpCurrentAttraction->GetCurrentStateId() != STATE_MOVETO)
{
mpCurrentAttraction->SetAttracted(false);
mpCurrentAttraction = NULL;
return;
}
}
///////////////////////////////////////////////
//Check if any enemy is near enough to be attracted
else
{
if(mfAttractCount <=0)
{
float fClosestDist = 10000.0f;
iGameEnemy *pChosenEnemy = NULL;


tGameEnemyIterator enemyIt = mpInit->mpMapHandler->GetGameEnemyIterator();
while(enemyIt.HasNext())
{
iGameEnemy *pEnemy = enemyIt.Next();

if( pEnemy->GetHealth() <= 0 || pEnemy->IsActive()==false ||
pEnemy->IsAttracted())
{
continue;
}

bool bCorrectSub = false;
for(size_t i=0; i< mAttractProps.mvSubtypes.size(); ++i)
{
if(mAttractProps.mvSubtypes[i] == pEnemy->GetSubType()) bCorrectSub = true;
}

if(bCorrectSub==false) continue;

//Check if the enemy has already been attracted by this object
if(m_setAttractedEnemies.find(pEnemy) != m_setAttractedEnemies.end()) continue;

float fDist = cMath::Vector3Dist( pEnemy->GetMover()->GetCharBody()->GetFeetPosition(),
mvBodies[0]->GetWorldPosition());

if(fDist < mAttractProps.mfDistance && fDist < fClosestDist)
{
fClosestDist = fDist;
pChosenEnemy = pEnemy;
}
}

if(pChosenEnemy)
{
if(pChosenEnemy->MoveToPos(mvBodies[0]->GetWorldPosition() +cVector3f(0,0.2f,0)))
{
mpCurrentAttraction = pChosenEnemy;
pChosenEnemy->SetAttracted(true);
m_setAttractedEnemies.insert(pChosenEnemy);
}
}

mfAttractCount = 0.2f;
}
else
{
mfAttractCount -= afTimeStep;
}
}
}

//--------------------------------------------------------------------

If it is the code that controls the "attraction" to the meat/jerky, could you please explain in more detail how it works? If it's not, could you please explain what it does, and where to find the jerky/meat/food code? Thanks. Smile
08-14-2010, 05:54 PM
Find


Messages In This Thread
Where is the jerky code? - by keen - 08-14-2010, 05:54 PM
RE: Where is the jerky code? - by wally - 08-14-2010, 07:17 PM



Users browsing this thread: 1 Guest(s)