mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-17 13:53:57 -07:00
Fix bonus multiplier issue in 16b452cf91 (multiple attack effects) and consider more entities in EntitiesNearPoint
- the bonus multiplier would self-multiply with every effect, so an attack with multiple effect would have a broken multiplier. - EntitiesNearPoint used IID_Resistance, which is now facultative. To not miss entities, it now returns all entities owned by enemy players. For GAIA it checks for Health to avoid returning trees. This means enemy units have higher priority over missed projectiles, but that should generally be OK. This also adds simple tests. Reported By: Freagarach Differential Revision: https://code.wildfiregames.com/D2322 This was SVN commit r23012.
This commit is contained in:
parent
81e084d616
commit
38b2e37a61
1 changed files with 12 additions and 3 deletions
|
|
@ -234,14 +234,14 @@ Attacking.prototype.CauseDamageOverArea = function(data)
|
|||
|
||||
Attacking.prototype.HandleAttackEffects = function(attackType, attackData, target, attacker, attackerOwner, bonusMultiplier = 1)
|
||||
{
|
||||
bonusMultiplier *= !attackData.Bonuses ? 1 : GetAttackBonus(attacker, target, attackType, attackData.Bonuses);
|
||||
|
||||
let targetState = {};
|
||||
for (let effectType of g_EffectTypes)
|
||||
{
|
||||
if (!attackData[effectType])
|
||||
continue;
|
||||
|
||||
bonusMultiplier *= !attackData.Bonuses ? 1 : GetAttackBonus(attacker, target, attackType, attackData.Bonuses);
|
||||
|
||||
let receiver = g_EffectReceiver[effectType];
|
||||
let cmpReceiver = Engine.QueryInterface(target, global[receiver.IID]);
|
||||
if (!cmpReceiver)
|
||||
|
|
@ -281,7 +281,16 @@ Attacking.prototype.EntitiesNearPoint = function(origin, radius, players)
|
|||
if (!origin || !radius || !players)
|
||||
return [];
|
||||
|
||||
return Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager).ExecuteQueryAroundPos(origin, 0, radius, players, IID_Resistance);
|
||||
let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
|
||||
|
||||
// Return all entities, except for Gaia: IID_Health is required to avoid returning trees and such.
|
||||
let gaiaEntities = [];
|
||||
let gaiaIndex = players.indexOf(0);
|
||||
if (gaiaIndex !== -1)
|
||||
// splice() modifies players in-place and returns [0]
|
||||
gaiaEntities = gaiaEntities.concat(cmpRangeManager.ExecuteQueryAroundPos(origin, 0, radius, players.splice(gaiaIndex, 1), IID_Health));
|
||||
|
||||
return cmpRangeManager.ExecuteQueryAroundPos(origin, 0, radius, players, 0).concat(gaiaEntities);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue