From e185ddc19f7fe2212323e0e05e3fa21657f7a616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Meelis=20M=C3=A4gi?= Date: Wed, 29 Dec 2021 11:49:38 +0000 Subject: [PATCH] Fix flying text for area magic/combat actions --- ryzom/client/src/character_cl.cpp | 38 ++++++++++---------- ryzom/client/src/user_entity.cpp | 4 +-- ryzom/common/src/game_share/multi_target.cpp | 37 +++++++++---------- ryzom/common/src/game_share/multi_target.h | 22 ++++++------ 4 files changed, 49 insertions(+), 52 deletions(-) diff --git a/ryzom/client/src/character_cl.cpp b/ryzom/client/src/character_cl.cpp index 68f8acfcb..c157c0f85 100644 --- a/ryzom/client/src/character_cl.cpp +++ b/ryzom/client/src/character_cl.cpp @@ -4553,13 +4553,20 @@ void CCharacterCL::applyBehaviourFlyingHPs(const CBehaviourContext &bc, const MB { nlassert(targetHitDates.size()==bc.Targets.Targets.size()); - if(!bc.Targets.Targets.empty()) + if (behaviour.DeltaHP == 0 || bc.Targets.Targets.empty()) + return; + + CRGBA deltaHPColor(0, 0, 0); + for (size_t i=0; iaddHPOutput(behaviour.DeltaHP, deltaHPColor, float(targetHitDates[i]-TimeInSec)); - } + target2->addHPOutput(bc.Targets.Targets[i].DeltaHP, deltaHPColor, float(targetHitDates[i]-TimeInSec)); } } } @@ -9705,7 +9706,7 @@ NLMISC_COMMAND(projectile, "Cast a projectile on another entity", " pos() - ch->pos()).norm(); bool resist = false; if (args.size() > 4) fromString(args[4], resist); - bc.Targets.Targets.push_back(CMultiTarget::CTarget(targetSlot, resist, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)))); + bc.Targets.Targets.push_back(CMultiTarget::CTarget(targetSlot, resist, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)), -11)); } bc.BehavTime = TimeInSec; ch->applyBehaviour(bc); @@ -9743,7 +9744,7 @@ NLMISC_COMMAND(mtProjectile, "Cast a projectile on one or several entities", "pos() - ch->pos()).norm(); - bc.Targets.Targets.push_back(CMultiTarget::CTarget(mainTargetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)))); + bc.Targets.Targets.push_back(CMultiTarget::CTarget(mainTargetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)), 1)); for(sint k = 1; k < (sint) (args.size() - 4); ++k) { uint secondaryTargetSlot; @@ -9753,7 +9754,7 @@ NLMISC_COMMAND(mtProjectile, "Cast a projectile on one or several entities", "pos() - mainTarget->pos()).norm(); - bc.Targets.Targets.push_back(CMultiTarget::CTarget(secondaryTargetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)))); + bc.Targets.Targets.push_back(CMultiTarget::CTarget(secondaryTargetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)), k+1)); } } } @@ -9770,7 +9771,7 @@ NLMISC_COMMAND(mtProjectile, "Cast a projectile on one or several entities", "pos() - ch->pos()).norm(); - bc.Targets.Targets.push_back(CMultiTarget::CTarget(targetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)))); + bc.Targets.Targets.push_back(CMultiTarget::CTarget(targetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)), k+1)); } } } @@ -9787,7 +9788,7 @@ NLMISC_COMMAND(mtProjectile, "Cast a projectile on one or several entities", "pos() - startSlot->pos()).norm(); - bc.Targets.Targets.push_back(CMultiTarget::CTarget(targetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)))); + bc.Targets.Targets.push_back(CMultiTarget::CTarget(targetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)), k+1)); startSlot = target; } } @@ -10100,6 +10101,7 @@ NLMISC_COMMAND(attack, "simulate an attack", " selection(); target.Info = dsPower | (dsType << 3); + target.DeltaHP = -20; bc.Targets.Targets.push_back(target); bc.BehavTime = TimeInSec; bc.Behav.DeltaHP = -20; @@ -10154,7 +10156,7 @@ NLMISC_COMMAND(rangeAttack, "simulate a range attack", " [intensity] [loca CEntityCL *target = EntitiesMngr.entity(targetSlot); if (!target) return false; double dist = (target->pos() - entity->pos()).norm(); - bc.Targets.Targets.push_back(CMultiTarget::CTarget(targetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)))); + bc.Targets.Targets.push_back(CMultiTarget::CTarget(targetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)), -10)); bc.Behav.DeltaHP = -10; entity->applyBehaviour(bc); return true; @@ -10188,7 +10190,7 @@ NLMISC_COMMAND(creatureAttack, "simulate a creature attack (2 attaques per creat { fromString(args[8], resist); } - bc.Targets.Targets.push_back(CMultiTarget::CTarget(targetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)))); + bc.Targets.Targets.push_back(CMultiTarget::CTarget(targetSlot, false, (uint8) ceilf((float) (dist / MULTI_TARGET_DISTANCE_UNIT)), -15)); bc.Behav.CreatureAttack.ActionDuration = 0; uint magicImpactIntensity = 1; if (args.size() > 3) diff --git a/ryzom/client/src/user_entity.cpp b/ryzom/client/src/user_entity.cpp index ca205c6de..265265344 100644 --- a/ryzom/client/src/user_entity.cpp +++ b/ryzom/client/src/user_entity.cpp @@ -491,8 +491,8 @@ void CUserEntity::updateVisualPropertyBehaviour(const NLMISC::TGameCycle &/* gam } CCDBNodeLeaf *targetList0 = dynamic_cast(_DBEntry->getNode(CLFECOMMON::PROPERTY_TARGET_LIST_0)); CCDBNodeLeaf *targetList1 = dynamic_cast(_DBEntry->getNode(CLFECOMMON::PROPERTY_TARGET_LIST_1)); - CCDBNodeLeaf *targetList2 = dynamic_cast(_DBEntry->getNode(CLFECOMMON::PROPERTY_TARGET_LIST_1)); - CCDBNodeLeaf *targetList3 = dynamic_cast(_DBEntry->getNode(CLFECOMMON::PROPERTY_TARGET_LIST_1)); + CCDBNodeLeaf *targetList2 = dynamic_cast(_DBEntry->getNode(CLFECOMMON::PROPERTY_TARGET_LIST_2)); + CCDBNodeLeaf *targetList3 = dynamic_cast(_DBEntry->getNode(CLFECOMMON::PROPERTY_TARGET_LIST_3)); if (targetList0 && targetList1 && targetList2 && targetList3) { uint64 vp[4] = diff --git a/ryzom/common/src/game_share/multi_target.cpp b/ryzom/common/src/game_share/multi_target.cpp index 066d842c9..cef120b60 100644 --- a/ryzom/common/src/game_share/multi_target.cpp +++ b/ryzom/common/src/game_share/multi_target.cpp @@ -22,18 +22,16 @@ // *********************************************************************** void CMultiTarget::pack(uint64 *destVP, uint numVP) { - nlassert(numVP * 4 >= Targets.size()); // not enough room to stores visual properties! + nlassert(numVP * 2 >= Targets.size()); // not enough room to stores visual properties! CTarget invalidTarget; uint index = 0; for(uint k = 0; k < numVP; ++k) { - uint16 parts[4]; - for(uint l = 0; l < 4; ++l) - { - parts[l] = index < Targets.size() ? Targets[index].getPacked() : invalidTarget.getPacked(); - ++ index; - } - destVP[k] = (uint64) parts[0] | ((uint64) parts[1] << 16) | ((uint64) parts[2] << 32) | ((uint64) parts[3] << 48); + destVP[k] = index < Targets.size() ? Targets[index].getPacked() : invalidTarget.getPacked(); + ++index; + + destVP[k] |= uint64(index < Targets.size() ? Targets[index].getPacked() : invalidTarget.getPacked()) << 32; + ++index; } } @@ -43,18 +41,15 @@ void CMultiTarget::unpack(const uint64 *srcVP, uint numVP) Targets.clear(); for(uint k = 0; k < numVP; ++k) { - for(uint l = 0; l < 4; ++l) - { - CTarget t; - t.setPacked((uint16) ((srcVP[k] >> (16 * l)) & 0xffff)); - if (t.TargetSlot != CLFECOMMON::INVALID_SLOT) - { - Targets.push_back(t); - } - else - { - return; - } - } + CTarget t; + t.setPacked(uint32(srcVP[k])); + if(t.TargetSlot == CLFECOMMON::INVALID_SLOT) + return; + Targets.push_back(t); + + t.setPacked(uint32(srcVP[k] >> 32)); + if(t.TargetSlot == CLFECOMMON::INVALID_SLOT) + return; + Targets.push_back(t); } } diff --git a/ryzom/common/src/game_share/multi_target.h b/ryzom/common/src/game_share/multi_target.h index 5b3fd8101..dcc6c9d6c 100644 --- a/ryzom/common/src/game_share/multi_target.h +++ b/ryzom/common/src/game_share/multi_target.h @@ -39,20 +39,21 @@ public: uint8 TargetSlot; // the slot that is targetted uint8 Info; // Damage shield for melee 5:3 format (damage shield io : power ) // Distance for range attacks (that do not have damage shield) format is 7:1 + sint16 DeltaHP; // public: - CTarget(uint8 slot = CLFECOMMON::INVALID_SLOT, bool resist = false, uint8 dist = 0) : TargetSlot(slot) + CTarget(uint8 slot = CLFECOMMON::INVALID_SLOT, bool resist = false, uint8 dist = 0, sint16 deltaHp = 0) : TargetSlot(slot), DeltaHP(deltaHp) { Info = (resist == 0 ? 0 : 0x80) | (dist & 0x7f); } - uint16 getPacked() const; - void setPacked(uint16 value); + uint32 getPacked() const; + void setPacked(uint32 value); }; typedef std::vector TTargetVect; // the list of targets TTargetVect Targets; public: /** create packed version of targets (to store in visual properties) - * each VP encodes 4 targets + * each VP encodes 2 targets * caller must provide enough room to store the result (assertion is raised otherwise) */ void pack(uint64 *destVP, uint numVP); @@ -65,19 +66,18 @@ public: //////////// // ******************************************************************************************* -inline uint16 CMultiTarget::CTarget::getPacked() const +inline uint32 CMultiTarget::CTarget::getPacked() const { //return (uint16) TargetSlot | ((uint16) (Resist ? 1 : 0) << 15) | ((uint16) Distance << 8); - return (uint16) TargetSlot | (uint16(Info) << 8); + return ((uint32) TargetSlot) | ((uint32) Info << 8) | ((uint32) DeltaHP << 16); } // ******************************************************************************************* -inline void CMultiTarget::CTarget::setPacked(uint16 value) +inline void CMultiTarget::CTarget::setPacked(uint32 value) { - TargetSlot = uint8(value & 0xff); - /*Distance = (uint8) ((value >> 8) & 0x7f); - Resist = (value & 0x8000) != 0;*/ - Info = value >> 8; + TargetSlot = uint8(value); + Info = uint8(value >> 8); + DeltaHP = sint16(value >> 16); } #endif