mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-23 02:42:39 +01:00
parent
327ac49e64
commit
b23a81063d
@ -58,6 +58,7 @@ public:
|
|||||||
|
|
||||||
bool isCollected() const { return m_collected; }
|
bool isCollected() const { return m_collected; }
|
||||||
|
|
||||||
|
PickupType getPickupType() const { return m_type; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
btPairCachingGhostObject* m_ghost;
|
btPairCachingGhostObject* m_ghost;
|
||||||
|
@ -370,8 +370,16 @@ bool Activities::ShootWeapon::update(CharacterObject *character, CharacterContro
|
|||||||
// Update player direction
|
// Update player direction
|
||||||
character->setRotation(glm::angleAxis(character->getLook().x, glm::vec3{0.f, 0.f, 1.f}));
|
character->setRotation(glm::angleAxis(character->getLook().x, glm::vec3{0.f, 0.f, 1.f}));
|
||||||
|
|
||||||
|
RW_CHECK(wepdata->inventorySlot < maxInventorySlots, "Inventory slot out of bounds");
|
||||||
|
auto& itemState = character->getCurrentState().weapons[wepdata->inventorySlot];
|
||||||
|
if (itemState.bulletsClip == 0 && itemState.bulletsTotal > 0) {
|
||||||
|
itemState.bulletsClip += std::min(int(itemState.bulletsTotal), wepdata->clipSize);
|
||||||
|
itemState.bulletsTotal -= itemState.bulletsClip;
|
||||||
|
}
|
||||||
|
bool hasammo = itemState.bulletsClip > 0;
|
||||||
|
|
||||||
if( wepdata->fireType == WeaponData::INSTANT_HIT ) {
|
if( wepdata->fireType == WeaponData::INSTANT_HIT ) {
|
||||||
if( _item->isFiring(character) ) {
|
if( _item->isFiring(character) && hasammo ) {
|
||||||
|
|
||||||
auto shootanim = character->engine->data->animations[wepdata->animation1];
|
auto shootanim = character->engine->data->animations[wepdata->animation1];
|
||||||
if( shootanim ) {
|
if( shootanim ) {
|
||||||
@ -386,6 +394,7 @@ bool Activities::ShootWeapon::update(CharacterObject *character, CharacterContro
|
|||||||
auto currID = character->animator->getAnimationTime(AnimIndexAction);
|
auto currID = character->animator->getAnimationTime(AnimIndexAction);
|
||||||
|
|
||||||
if( currID >= firetime && ! _fired ) {
|
if( currID >= firetime && ! _fired ) {
|
||||||
|
itemState.bulletsClip --;
|
||||||
_item->fire(character);
|
_item->fire(character);
|
||||||
_fired = true;
|
_fired = true;
|
||||||
}
|
}
|
||||||
@ -402,7 +411,7 @@ bool Activities::ShootWeapon::update(CharacterObject *character, CharacterContro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// @todo Use Thrown flag instead of project (RPG isn't thrown eg.)
|
/// @todo Use Thrown flag instead of project (RPG isn't thrown eg.)
|
||||||
else if( wepdata->fireType == WeaponData::PROJECTILE ) {
|
else if( wepdata->fireType == WeaponData::PROJECTILE && hasammo ) {
|
||||||
auto shootanim = character->engine->data->animations[wepdata->animation1];
|
auto shootanim = character->engine->data->animations[wepdata->animation1];
|
||||||
auto throwanim = character->engine->data->animations[wepdata->animation2];
|
auto throwanim = character->engine->data->animations[wepdata->animation2];
|
||||||
|
|
||||||
@ -416,6 +425,7 @@ bool Activities::ShootWeapon::update(CharacterObject *character, CharacterContro
|
|||||||
auto currID = character->animator->getAnimationTime(AnimIndexAction);
|
auto currID = character->animator->getAnimationTime(AnimIndexAction);
|
||||||
|
|
||||||
if( currID >= firetime && !_fired ) {
|
if( currID >= firetime && !_fired ) {
|
||||||
|
itemState.bulletsClip --;
|
||||||
_item->fire(character);
|
_item->fire(character);
|
||||||
_fired = true;
|
_fired = true;
|
||||||
}
|
}
|
||||||
@ -431,6 +441,11 @@ bool Activities::ShootWeapon::update(CharacterObject *character, CharacterContro
|
|||||||
RW_CHECK(wepdata->fireType != WeaponData::MELEE, "Melee attacks not implemented");
|
RW_CHECK(wepdata->fireType != WeaponData::MELEE, "Melee attacks not implemented");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RW_ERROR("Unrecognized fireType: " << wepdata->fireType);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -14,5 +14,46 @@ ItemPickup::ItemPickup(GameWorld *world, const glm::vec3 &position, PickupType t
|
|||||||
bool ItemPickup::onCharacterTouch(CharacterObject *character)
|
bool ItemPickup::onCharacterTouch(CharacterObject *character)
|
||||||
{
|
{
|
||||||
character->addToInventory(item);
|
character->addToInventory(item);
|
||||||
|
auto& wep = character->getCurrentState().weapons[item->getInventorySlot()];
|
||||||
|
auto totalRounds = 0, clipRounds = 0;
|
||||||
|
|
||||||
|
switch (item->getModelID()) {
|
||||||
|
case 173: /* Pistol */
|
||||||
|
totalRounds = 45;
|
||||||
|
break;
|
||||||
|
case 178: /* Uzi */
|
||||||
|
totalRounds = 125;
|
||||||
|
break;
|
||||||
|
case 176: /* Shotgun */
|
||||||
|
totalRounds = 25;
|
||||||
|
break;
|
||||||
|
case 170: /* Grenade */
|
||||||
|
totalRounds = 5;
|
||||||
|
break;
|
||||||
|
case 174: /* Molotov */
|
||||||
|
totalRounds = 5;
|
||||||
|
break;
|
||||||
|
case 181: /* Flame thrower */
|
||||||
|
totalRounds = 25;
|
||||||
|
break;
|
||||||
|
case 171: /* AK */
|
||||||
|
totalRounds = 150;
|
||||||
|
break;
|
||||||
|
case 180: /* M16 */
|
||||||
|
totalRounds = 300;
|
||||||
|
break;
|
||||||
|
case 177: /* Sniper Rifle */
|
||||||
|
totalRounds = 25;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getPickupType() == OnStreet || getPickupType() == OnStreetSlow)
|
||||||
|
{
|
||||||
|
totalRounds /= 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
wep.bulletsTotal = totalRounds;
|
||||||
|
wep.bulletsClip = clipRounds;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user