! 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 */
| 1350 | @see CEntity::StartAnimation |
| 1351 | */ |
| 1352 | int 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")) |
nothing calls this directly
no test coverage detected