mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-25 11:52:40 +01:00
Melee animation handling
This commit is contained in:
parent
ba913e5154
commit
fd11f9c7e3
@ -688,9 +688,31 @@ bool Activities::UseItem::update(CharacterObject *character,
|
||||
character->playCycle(shootcycle);
|
||||
}
|
||||
} else if (weapon->fireType == WeaponData::MELEE) {
|
||||
RW_CHECK(weapon->fireType != WeaponData::MELEE,
|
||||
"Melee attacks not implemented");
|
||||
return true;
|
||||
/// @todo second attack animation for on-ground targets
|
||||
const auto attackAnimation = shootcycle;
|
||||
|
||||
if (character->getCurrentCycle() != attackAnimation) {
|
||||
character->playCycle(attackAnimation);
|
||||
}
|
||||
|
||||
auto fireTime = weapon->animFirePoint / 100.f;
|
||||
auto loopStart = weapon->animLoopStart / 100.f;
|
||||
auto currentTime = animator->getAnimationTime(AnimIndexAction);
|
||||
|
||||
if (currentTime >= fireTime && !fired) {
|
||||
/// @todo weapon hit here
|
||||
fired = true;
|
||||
}
|
||||
|
||||
if (animator->isCompleted(AnimIndexAction)) {
|
||||
if (character->getCurrentState().primaryActive) {
|
||||
animator->setAnimationTime(AnimIndexAction, loopStart);
|
||||
fired = false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
RW_ERROR("Unrecognized fireType: " << weapon->fireType);
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user