MCPcopy Create free account
hub / github.com/StrongPC123/Far-Cry-1-Source-Full / StartAnimation

Method StartAnimation

CrySystem/ScriptObjectEntity.cpp:1352–1424  ·  view source on GitHub ↗

! Starts an animation of a character @param pos Number of the character slot @param animname Name of the aniamtion from the .cal file @see CScriptObjectEntity::LoadCharacter @see CEntity::StartAnimation */

Source from the content-addressed store, hash-verified

1350 @see CEntity::StartAnimation
1351*/
1352int CScriptObjectEntity::StartAnimation(IFunctionHandler *pH)
1353{
1354
1355 //CHECK_PARAMETERS(2);
1356 const char *animname;
1357 int pos, layer=0;
1358 bool bLooping = false;
1359 bool bLoopSpecified = false;
1360 float fBlendTime = 0.15f;
1361 float fAniSpeed = 1.0f;
1362 pH->GetParam(1,pos);
1363 if (!pH->GetParam(2,animname))
1364 {
1365 m_pISystem->Warning( VALIDATOR_MODULE_SYSTEM,VALIDATOR_WARNING,0,
1366 0,"CScriptObjectEntity::StartAnimation, animation name not specified, in Entity %s",m_pEntity->GetName() );
1367 return pH->EndFunction(false);
1368 }
1369
1370 if (pH->GetParamCount() > 2)
1371 {
1372 pH->GetParam(3,layer);
1373 if (pH->GetParamCount() > 3)
1374 {
1375 pH->GetParam(4,fBlendTime);
1376 if (pH->GetParamCount() > 4)
1377 {
1378 pH->GetParam(5,fAniSpeed);
1379 m_pEntity->SetAnimationSpeed( fAniSpeed );
1380 if (pH->GetParamCount() > 5)
1381 {
1382 bLoopSpecified = true;
1383 pH->GetParam(6,bLooping);
1384 }
1385 }
1386 }
1387 }
1388
1389 // no character no animation
1390 if (!m_pEntity->GetCharInterface() || !m_pEntity->GetCharInterface()->GetCharacter(pos))
1391 return pH->EndFunction(false);
1392
1393
1394 if (bLoopSpecified)
1395 {
1396 ICryCharInstance *pCharacter = m_pEntity->GetCharInterface()->GetCharacter(pos);
1397 if (pCharacter)
1398 {
1399 ICryAnimationSet *animSet = pCharacter->GetModel()->GetAnimationSet();
1400 if (animSet)
1401 {
1402 int animId = animSet->Find(animname);
1403 if (animId >= 0)
1404 animSet->SetLoop( animId,bLooping );
1405 }
1406 }
1407 }
1408
1409 if (string(animname) == string("NULL"))

Callers

nothing calls this directly

Calls 14

EndFunctionMethod · 0.80
GetCharInterfaceMethod · 0.80
stringClass · 0.50
GetParamMethod · 0.45
WarningMethod · 0.45
GetNameMethod · 0.45
GetParamCountMethod · 0.45
SetAnimationSpeedMethod · 0.45
GetCharacterMethod · 0.45
GetAnimationSetMethod · 0.45
GetModelMethod · 0.45
FindMethod · 0.45

Tested by

no test coverage detected