Merge branch 'fix-area-effect-flying-text' into 'main/gingo-test'

Fix flying text for area magic/combat actions

See merge request ryzom/ryzom-core!19
feature/compatibility-old-gcc
Nuno Gonçalves (Ulukyn) 3 years ago
commit e891dddd1e

@ -4553,13 +4553,20 @@ void CCharacterCL::applyBehaviourFlyingHPs(const CBehaviourContext &bc, const MB
{ {
nlassert(targetHitDates.size()==bc.Targets.Targets.size()); 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; i<bc.Targets.Targets.size(); ++i)
{ {
if(behaviour.DeltaHP != 0) if(bc.Targets.Targets[i].DeltaHP == 0)
continue;
CEntityCL *target2 = EntitiesMngr.entity(bc.Targets.Targets[i].TargetSlot);
if(target2)
{ {
CRGBA deltaHPColor(0, 0, 0);
// if it's a hit // if it's a hit
if( behaviour.DeltaHP < 0 ) if(bc.Targets.Targets[i].DeltaHP < 0)
{ {
// if the behaviour is casted by the user // if the behaviour is casted by the user
if( slot() == 0 ) if( slot() == 0 )
@ -4590,13 +4597,7 @@ void CCharacterCL::applyBehaviourFlyingHPs(const CBehaviourContext &bc, const MB
deltaHPColor = CRGBA(0,220,0); deltaHPColor = CRGBA(0,220,0);
} }
// Set the delta HP target2->addHPOutput(bc.Targets.Targets[i].DeltaHP, deltaHPColor, float(targetHitDates[i]-TimeInSec));
for (size_t i=0; i<bc.Targets.Targets.size(); ++i)
{
CEntityCL *target2 = EntitiesMngr.entity(bc.Targets.Targets[i].TargetSlot);
if(target2)
target2->addHPOutput(behaviour.DeltaHP, deltaHPColor, float(targetHitDates[i]-TimeInSec));
}
} }
} }
} }
@ -9705,7 +9706,7 @@ NLMISC_COMMAND(projectile, "Cast a projectile on another entity", "<spellID> <st
double dist = (target->pos() - ch->pos()).norm(); double dist = (target->pos() - ch->pos()).norm();
bool resist = false; bool resist = false;
if (args.size() > 4) fromString(args[4], resist); 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; bc.BehavTime = TimeInSec;
ch->applyBehaviour(bc); ch->applyBehaviour(bc);
@ -9743,7 +9744,7 @@ NLMISC_COMMAND(mtProjectile, "Cast a projectile on one or several entities", "<c
if (mainTarget) if (mainTarget)
{ {
double dist = (mainTarget->pos() - ch->pos()).norm(); double dist = (mainTarget->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) for(sint k = 1; k < (sint) (args.size() - 4); ++k)
{ {
uint secondaryTargetSlot; uint secondaryTargetSlot;
@ -9753,7 +9754,7 @@ NLMISC_COMMAND(mtProjectile, "Cast a projectile on one or several entities", "<c
if (secondaryTarget) if (secondaryTarget)
{ {
dist = (secondaryTarget->pos() - mainTarget->pos()).norm(); dist = (secondaryTarget->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", "<c
if (target) if (target)
{ {
double dist = (target->pos() - ch->pos()).norm(); double dist = (target->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", "<c
if (target) if (target)
{ {
double dist = (target->pos() - startSlot->pos()).norm(); double dist = (target->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; startSlot = target;
} }
} }
@ -10100,6 +10101,7 @@ NLMISC_COMMAND(attack, "simulate an attack", "<slot> <intensity> <hit_type> <loc
CMultiTarget::CTarget target; CMultiTarget::CTarget target;
target.TargetSlot = UserEntity->selection(); target.TargetSlot = UserEntity->selection();
target.Info = dsPower | (dsType << 3); target.Info = dsPower | (dsType << 3);
target.DeltaHP = -20;
bc.Targets.Targets.push_back(target); bc.Targets.Targets.push_back(target);
bc.BehavTime = TimeInSec; bc.BehavTime = TimeInSec;
bc.Behav.DeltaHP = -20; bc.Behav.DeltaHP = -20;
@ -10154,7 +10156,7 @@ NLMISC_COMMAND(rangeAttack, "simulate a range attack", "<slot> [intensity] [loca
CEntityCL *target = EntitiesMngr.entity(targetSlot); CEntityCL *target = EntitiesMngr.entity(targetSlot);
if (!target) return false; if (!target) return false;
double dist = (target->pos() - entity->pos()).norm(); 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; bc.Behav.DeltaHP = -10;
entity->applyBehaviour(bc); entity->applyBehaviour(bc);
return true; return true;
@ -10188,7 +10190,7 @@ NLMISC_COMMAND(creatureAttack, "simulate a creature attack (2 attaques per creat
{ {
fromString(args[8], resist); 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; bc.Behav.CreatureAttack.ActionDuration = 0;
uint magicImpactIntensity = 1; uint magicImpactIntensity = 1;
if (args.size() > 3) if (args.size() > 3)

@ -491,8 +491,8 @@ void CUserEntity::updateVisualPropertyBehaviour(const NLMISC::TGameCycle &/* gam
} }
CCDBNodeLeaf *targetList0 = dynamic_cast<CCDBNodeLeaf *>(_DBEntry->getNode(CLFECOMMON::PROPERTY_TARGET_LIST_0)); CCDBNodeLeaf *targetList0 = dynamic_cast<CCDBNodeLeaf *>(_DBEntry->getNode(CLFECOMMON::PROPERTY_TARGET_LIST_0));
CCDBNodeLeaf *targetList1 = dynamic_cast<CCDBNodeLeaf *>(_DBEntry->getNode(CLFECOMMON::PROPERTY_TARGET_LIST_1)); CCDBNodeLeaf *targetList1 = dynamic_cast<CCDBNodeLeaf *>(_DBEntry->getNode(CLFECOMMON::PROPERTY_TARGET_LIST_1));
CCDBNodeLeaf *targetList2 = dynamic_cast<CCDBNodeLeaf *>(_DBEntry->getNode(CLFECOMMON::PROPERTY_TARGET_LIST_1)); CCDBNodeLeaf *targetList2 = dynamic_cast<CCDBNodeLeaf *>(_DBEntry->getNode(CLFECOMMON::PROPERTY_TARGET_LIST_2));
CCDBNodeLeaf *targetList3 = dynamic_cast<CCDBNodeLeaf *>(_DBEntry->getNode(CLFECOMMON::PROPERTY_TARGET_LIST_1)); CCDBNodeLeaf *targetList3 = dynamic_cast<CCDBNodeLeaf *>(_DBEntry->getNode(CLFECOMMON::PROPERTY_TARGET_LIST_3));
if (targetList0 && targetList1 && targetList2 && targetList3) if (targetList0 && targetList1 && targetList2 && targetList3)
{ {
uint64 vp[4] = uint64 vp[4] =

@ -22,18 +22,16 @@
// *********************************************************************** // ***********************************************************************
void CMultiTarget::pack(uint64 *destVP, uint numVP) 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; CTarget invalidTarget;
uint index = 0; uint index = 0;
for(uint k = 0; k < numVP; ++k) for(uint k = 0; k < numVP; ++k)
{ {
uint16 parts[4]; destVP[k] = index < Targets.size() ? Targets[index].getPacked() : invalidTarget.getPacked();
for(uint l = 0; l < 4; ++l) ++index;
{
parts[l] = index < Targets.size() ? Targets[index].getPacked() : invalidTarget.getPacked(); destVP[k] |= uint64(index < Targets.size() ? Targets[index].getPacked() : invalidTarget.getPacked()) << 32;
++ index; ++index;
}
destVP[k] = (uint64) parts[0] | ((uint64) parts[1] << 16) | ((uint64) parts[2] << 32) | ((uint64) parts[3] << 48);
} }
} }
@ -43,18 +41,15 @@ void CMultiTarget::unpack(const uint64 *srcVP, uint numVP)
Targets.clear(); Targets.clear();
for(uint k = 0; k < numVP; ++k) for(uint k = 0; k < numVP; ++k)
{ {
for(uint l = 0; l < 4; ++l) CTarget t;
{ t.setPacked(uint32(srcVP[k]));
CTarget t; if(t.TargetSlot == CLFECOMMON::INVALID_SLOT)
t.setPacked((uint16) ((srcVP[k] >> (16 * l)) & 0xffff)); return;
if (t.TargetSlot != CLFECOMMON::INVALID_SLOT) Targets.push_back(t);
{
Targets.push_back(t); t.setPacked(uint32(srcVP[k] >> 32));
} if(t.TargetSlot == CLFECOMMON::INVALID_SLOT)
else return;
{ Targets.push_back(t);
return;
}
}
} }
} }

@ -39,20 +39,21 @@ public:
uint8 TargetSlot; // the slot that is targetted uint8 TargetSlot; // the slot that is targetted
uint8 Info; // Damage shield for melee 5:3 format (damage shield io : power ) 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 // Distance for range attacks (that do not have damage shield) format is 7:1
sint16 DeltaHP; //
public: 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); Info = (resist == 0 ? 0 : 0x80) | (dist & 0x7f);
} }
uint16 getPacked() const; uint32 getPacked() const;
void setPacked(uint16 value); void setPacked(uint32 value);
}; };
typedef std::vector<CTarget> TTargetVect; typedef std::vector<CTarget> TTargetVect;
// the list of targets // the list of targets
TTargetVect Targets; TTargetVect Targets;
public: public:
/** create packed version of targets (to store in visual properties) /** 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) * caller must provide enough room to store the result (assertion is raised otherwise)
*/ */
void pack(uint64 *destVP, uint numVP); 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) (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); TargetSlot = uint8(value);
/*Distance = (uint8) ((value >> 8) & 0x7f); Info = uint8(value >> 8);
Resist = (value & 0x8000) != 0;*/ DeltaHP = sint16(value >> 16);
Info = value >> 8;
} }
#endif #endif

Loading…
Cancel
Save