Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/tests/test_Damage.js
Engine.LoadHelperScript("DamageBonus.js"); | Engine.LoadHelperScript("DamageBonus.js"); | ||||
Engine.LoadHelperScript("DamageTypes.js"); | Engine.LoadHelperScript("DamageTypes.js"); | ||||
Engine.LoadHelperScript("Player.js"); | Engine.LoadHelperScript("Player.js"); | ||||
Engine.LoadHelperScript("Sound.js"); | Engine.LoadHelperScript("Sound.js"); | ||||
Engine.LoadHelperScript("ValueModification.js"); | Engine.LoadHelperScript("ValueModification.js"); | ||||
Engine.LoadComponentScript("interfaces/Attack.js"); | Engine.LoadComponentScript("interfaces/Attack.js"); | ||||
Engine.LoadComponentScript("interfaces/AttackDetection.js"); | Engine.LoadComponentScript("interfaces/AttackDetection.js"); | ||||
Engine.LoadComponentScript("interfaces/AuraManager.js"); | Engine.LoadComponentScript("interfaces/AuraManager.js"); | ||||
Engine.LoadComponentScript("interfaces/Capturable.js"); | |||||
Engine.LoadComponentScript("interfaces/Damage.js"); | Engine.LoadComponentScript("interfaces/Damage.js"); | ||||
Engine.LoadComponentScript("interfaces/DamageReceiver.js"); | Engine.LoadComponentScript("interfaces/DamageReceiver.js"); | ||||
Engine.LoadComponentScript("interfaces/Formation.js") | |||||
Engine.LoadComponentScript("interfaces/Health.js"); | Engine.LoadComponentScript("interfaces/Health.js"); | ||||
Engine.LoadComponentScript("interfaces/Loot.js"); | Engine.LoadComponentScript("interfaces/Loot.js"); | ||||
Engine.LoadComponentScript("interfaces/Player.js"); | Engine.LoadComponentScript("interfaces/Player.js"); | ||||
Engine.LoadComponentScript("interfaces/Promotion.js"); | Engine.LoadComponentScript("interfaces/Promotion.js"); | ||||
Engine.LoadComponentScript("interfaces/StatusEffectsReceiver.js"); | Engine.LoadComponentScript("interfaces/StatusEffectsReceiver.js"); | ||||
Engine.LoadComponentScript("interfaces/TechnologyManager.js"); | Engine.LoadComponentScript("interfaces/TechnologyManager.js"); | ||||
Engine.LoadComponentScript("interfaces/Timer.js"); | Engine.LoadComponentScript("interfaces/Timer.js"); | ||||
Engine.LoadComponentScript("Attack.js"); | Engine.LoadComponentScript("Attack.js"); | ||||
Engine.LoadComponentScript("Damage.js"); | Engine.LoadComponentScript("Damage.js"); | ||||
Engine.LoadComponentScript("Timer.js"); | Engine.LoadComponentScript("Timer.js"); | ||||
function Test_Generic() | function Test_Generic() | ||||
{ | { | ||||
ResetState(); | ResetState(); | ||||
let cmpDamage = ConstructComponent(SYSTEM_ENTITY, "Damage"); | let cmpDamage = ConstructComponent(SYSTEM_ENTITY, "Damage"); | ||||
let cmpTimer = ConstructComponent(SYSTEM_ENTITY, "Timer"); | let cmpTimer = ConstructComponent(SYSTEM_ENTITY, "Timer"); | ||||
cmpTimer.OnUpdate({ turnLength: 1 }); | cmpTimer.OnUpdate({ turnLength: 1 }); | ||||
let attacker = 11; | let attacker = 11; | ||||
let atkPlayerEntity = 1; | let atkPlayerEntity = 1; | ||||
let attackerOwner = 6; | let attackerOwner = 6; | ||||
let cmpAttack = ConstructComponent(attacker, "Attack", | let cmpAttack = ConstructComponent(attacker, "Attack", | ||||
{ | { | ||||
"Ranged": { | "Ranged": { | ||||
"Damage": { | |||||
"Hack": 1 | |||||
}, | |||||
"MaxRange": 50, | "MaxRange": 50, | ||||
"MinRange": 0, | "MinRange": 0, | ||||
"Delay": 0, | "Delay": 0, | ||||
"Projectile": { | "Projectile": { | ||||
"Speed": 75.0, | "Speed": 75.0, | ||||
"Spread": 0.5, | "Spread": 0.5, | ||||
"Gravity": 9.81, | "Gravity": 9.81, | ||||
"LaunchPoint": { "@y": 3 } | "LaunchPoint": { "@y": 3 } | ||||
} | } | ||||
} | } | ||||
}); | }); | ||||
let damage = 5; | let damage = 5; | ||||
let target = 21; | let target = 21; | ||||
let targetOwner = 7; | let targetOwner = 7; | ||||
let targetPos = new Vector3D(3, 0, 3); | let targetPos = new Vector3D(3, 0, 3); | ||||
let type = "Melee"; | let type = "Melee"; | ||||
let damageTaken = false; | let damageTaken = false; | ||||
cmpAttack.GetAttackStrengths = attackType => ({ "hack": 0, "pierce": 0, "crush": damage }); | cmpAttack.GetAttackStrengths = attackType => ({ "hack": 0, "pierce": 0, "crush": damage, "Capture": 0 }); | ||||
let data = { | let data = { | ||||
"attacker": attacker, | "attacker": attacker, | ||||
"target": target, | "target": target, | ||||
"type": "Melee", | "type": "Melee", | ||||
"strengths": { "hack": 0, "pierce": 0, "crush": damage }, | "strengths": { "hack": 0, "pierce": 0, "crush": damage }, | ||||
"multiplier": 1.0, | "multiplier": 1.0, | ||||
"attackerOwner": attackerOwner, | "attackerOwner": attackerOwner, | ||||
"position": targetPos, | "position": targetPos, | ||||
"isSplash": false, | "isSplash": false, | ||||
"projectileId": 9, | "projectileId": 9, | ||||
"direction": new Vector3D(1,0,0) | "direction": new Vector3D(1,0,0) | ||||
}; | }; | ||||
AddMock(atkPlayerEntity, IID_Player, { | AddMock(atkPlayerEntity, IID_Player, { | ||||
"GetPlayerID": () => atkPlayerEntity, | |||||
"GetEnemies": () => [targetOwner] | "GetEnemies": () => [targetOwner] | ||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | ||||
"GetPlayerByID": id => atkPlayerEntity, | "GetPlayerByID": id => atkPlayerEntity, | ||||
"GetAllPlayers": () => [0, 1, 2, 3, 4] | "GetAllPlayers": () => [0, 1, 2, 3, 4] | ||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_ProjectileManager, { | AddMock(SYSTEM_ENTITY, IID_ProjectileManager, { | ||||
"RemoveProjectile": () => {}, | "RemoveProjectile": () => {}, | ||||
"LaunchProjectileAtPoint": (ent, pos, speed, gravity) => {}, | "LaunchProjectileAtPoint": (ent, pos, speed, gravity) => {}, | ||||
}); | }); | ||||
AddMock(target, IID_Identity, { | |||||
"GetClassesList": () => [] | |||||
}); | |||||
AddMock(target, IID_Position, { | AddMock(target, IID_Position, { | ||||
"GetPosition": () => targetPos, | "GetPosition": () => targetPos, | ||||
"GetPreviousPosition": () => targetPos, | "GetPreviousPosition": () => targetPos, | ||||
"GetPosition2D": () => Vector2D.From(targetPos), | "GetPosition2D": () => Vector2D.From(targetPos), | ||||
"GetHeightOffset": () => 0, | |||||
"IsInWorld": () => true, | "IsInWorld": () => true, | ||||
}); | }); | ||||
AddMock(target, IID_Health, {}); | AddMock(target, IID_Health, { | ||||
"CanAttack": () => true | |||||
}); | |||||
AddMock(target, IID_DamageReceiver, { | AddMock(target, IID_DamageReceiver, { | ||||
"TakeDamage": (strengths, multiplier) => { damageTaken = true; return { "killed": false, "change": -multiplier * strengths.crush }; }, | "TakeDamage": (playerID, strengths, multiplier) => { damageTaken = true; return { "killed": false, "healthChange": -multiplier * strengths.crush }; }, | ||||
}); | }); | ||||
Engine.PostMessage = function(ent, iid, message) | Engine.PostMessage = function(ent, iid, message) | ||||
{ | { | ||||
TS_ASSERT_UNEVAL_EQUALS({ "attacker": attacker, "target": target, "type": type, "damage": damage, "attackerOwner": attackerOwner }, message); | TS_ASSERT_UNEVAL_EQUALS({ "attacker": attacker, "target": target, "type": type, "damage": damage, "attackerOwner": attackerOwner }, message); | ||||
}; | }; | ||||
AddMock(target, IID_Footprint, { | AddMock(target, IID_Footprint, { | ||||
"GetShape": () => ({ "type": "circle", "radius": 20 }), | "GetShape": () => ({ "type": "circle", "radius": 20 }), | ||||
}); | }); | ||||
AddMock(attacker, IID_Ownership, { | AddMock(attacker, IID_Ownership, { | ||||
"GetOwner": () => attackerOwner, | "GetOwner": () => attackerOwner | ||||
}); | }); | ||||
AddMock(attacker, IID_Position, { | AddMock(attacker, IID_Position, { | ||||
"GetPosition": () => new Vector3D(2, 0, 3), | "GetPosition": () => new Vector3D(2, 0, 3), | ||||
"GetRotation": () => new Vector3D(1, 2, 3), | "GetRotation": () => new Vector3D(1, 2, 3), | ||||
"IsInWorld": () => true, | "IsInWorld": () => true, | ||||
"GetHeightOffset": () => 0, | |||||
"GetTurretParent": () => INVALID_ENTITY | |||||
}); | }); | ||||
function TestDamage() | function TestDamage() | ||||
{ | { | ||||
cmpTimer.OnUpdate({ turnLength: 1 }); | cmpTimer.OnUpdate({ turnLength: 1 }); | ||||
TS_ASSERT(damageTaken); | TS_ASSERT(damageTaken); | ||||
damageTaken = false; | damageTaken = false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | AddMock(61, IID_Position, { | ||||
"GetPosition2D": () => new Vector2D(0, 0), | "GetPosition2D": () => new Vector2D(0, 0), | ||||
}); | }); | ||||
AddMock(62, IID_Position, { | AddMock(62, IID_Position, { | ||||
"GetPosition2D": () => new Vector2D(5, 2), | "GetPosition2D": () => new Vector2D(5, 2), | ||||
}); | }); | ||||
AddMock(60, IID_DamageReceiver, { | AddMock(60, IID_DamageReceiver, { | ||||
"TakeDamage": (strengths, multiplier) => { | "TakeDamage": (playerID, strengths, multiplier) => { | ||||
hitEnts.add(60); | hitEnts.add(60); | ||||
TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 100 * fallOff(2.2, -0.4)); | TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 100 * fallOff(2.2, -0.4)); | ||||
return { "killed": false, "change": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | return { "killed": false, "healthChange": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | ||||
} | } | ||||
}); | }); | ||||
AddMock(61, IID_DamageReceiver, { | AddMock(61, IID_DamageReceiver, { | ||||
"TakeDamage": (strengths, multiplier) => { | "TakeDamage": (playerID, strengths, multiplier) => { | ||||
hitEnts.add(61); | hitEnts.add(61); | ||||
TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 100 * fallOff(0, 0)); | TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 100 * fallOff(0, 0)); | ||||
return { "killed": false, "change": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | return { "killed": false, "healthChange": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | ||||
} | } | ||||
}); | }); | ||||
AddMock(62, IID_DamageReceiver, { | AddMock(62, IID_DamageReceiver, { | ||||
"TakeDamage": (strengths, multiplier) => { | "TakeDamage": (playerID, strengths, multiplier) => { | ||||
hitEnts.add(62); | hitEnts.add(62); | ||||
TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 0); | TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 0); | ||||
return { "killed": false, "change": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | return { "killed": false, "healthChange": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | ||||
} | } | ||||
}); | }); | ||||
cmpDamage.CauseSplashDamage(data); | cmpDamage.CauseSplashDamage(data); | ||||
TS_ASSERT(hitEnts.has(60)); | TS_ASSERT(hitEnts.has(60)); | ||||
TS_ASSERT(hitEnts.has(61)); | TS_ASSERT(hitEnts.has(61)); | ||||
TS_ASSERT(hitEnts.has(62)); | TS_ASSERT(hitEnts.has(62)); | ||||
hitEnts.clear(); | hitEnts.clear(); | ||||
data.direction = new Vector3D(0.6, 747, 0.8); | data.direction = new Vector3D(0.6, 747, 0.8); | ||||
AddMock(60, IID_DamageReceiver, { | AddMock(60, IID_DamageReceiver, { | ||||
"TakeDamage": (strengths, multiplier) => { | "TakeDamage": (playerID, strengths, multiplier) => { | ||||
hitEnts.add(60); | hitEnts.add(60); | ||||
TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 100 * fallOff(1, 2)); | TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 100 * fallOff(1, 2)); | ||||
return { "killed": false, "change": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | return { "killed": false, "healthChange": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | ||||
} | } | ||||
}); | }); | ||||
cmpDamage.CauseSplashDamage(data); | cmpDamage.CauseSplashDamage(data); | ||||
TS_ASSERT(hitEnts.has(60)); | TS_ASSERT(hitEnts.has(60)); | ||||
TS_ASSERT(hitEnts.has(61)); | TS_ASSERT(hitEnts.has(61)); | ||||
TS_ASSERT(hitEnts.has(62)); | TS_ASSERT(hitEnts.has(62)); | ||||
hitEnts.clear(); | hitEnts.clear(); | ||||
Show All 36 Lines | function TestCircularSplashDamage() | ||||
}); | }); | ||||
// Target on the frontier of the shape | // Target on the frontier of the shape | ||||
AddMock(64, IID_Position, { | AddMock(64, IID_Position, { | ||||
"GetPosition2D": () => new Vector2D(9, -4), | "GetPosition2D": () => new Vector2D(9, -4), | ||||
}); | }); | ||||
AddMock(60, IID_DamageReceiver, { | AddMock(60, IID_DamageReceiver, { | ||||
"TakeDamage": (strengths, multiplier) => { | "TakeDamage": (playerID, strengths, multiplier) => { | ||||
TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 100 * fallOff(0)); | TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 100 * fallOff(0)); | ||||
return { "killed": false, "change": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | return { "killed": false, "healthChange": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | ||||
} | } | ||||
}); | }); | ||||
AddMock(61, IID_DamageReceiver, { | AddMock(61, IID_DamageReceiver, { | ||||
"TakeDamage": (strengths, multiplier) => { | "TakeDamage": (playerID, strengths, multiplier) => { | ||||
TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 100 * fallOff(5)); | TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 100 * fallOff(5)); | ||||
return { "killed": false, "change": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | return { "killed": false, "healthChange": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | ||||
} | } | ||||
}); | }); | ||||
AddMock(62, IID_DamageReceiver, { | AddMock(62, IID_DamageReceiver, { | ||||
"TakeDamage": (strengths, multiplier) => { | "TakeDamage": (playerID, strengths, multiplier) => { | ||||
TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 100 * fallOff(1)); | TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 100 * fallOff(1)); | ||||
return { "killed": false, "change": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | return { "killed": false, "healthChange": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | ||||
} | } | ||||
}); | }); | ||||
AddMock(63, IID_DamageReceiver, { | AddMock(63, IID_DamageReceiver, { | ||||
"TakeDamage": (strengths, multiplier) => { | "TakeDamage": (playerID, strengths, multiplier) => { | ||||
TS_ASSERT(false); | TS_ASSERT(false); | ||||
} | } | ||||
}); | }); | ||||
AddMock(64, IID_DamageReceiver, { | AddMock(64, IID_DamageReceiver, { | ||||
"TakeDamage": (strengths, multiplier) => { | "TakeDamage": (playerID, strengths, multiplier) => { | ||||
TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 0); | TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 0); | ||||
return { "killed": false, "change": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | return { "killed": false, "healthChange": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | ||||
} | } | ||||
}); | }); | ||||
cmpDamage.CauseSplashDamage({ | cmpDamage.CauseSplashDamage({ | ||||
"attacker": 50, | "attacker": 50, | ||||
"origin": new Vector2D(3, 4), | "origin": new Vector2D(3, 4), | ||||
"radius": radius, | "radius": radius, | ||||
"shape": "Circular", | "shape": "Circular", | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | AddMock(60, IID_Position, { | ||||
"GetPreviousPosition": () => targetPos, | "GetPreviousPosition": () => targetPos, | ||||
"GetPosition2D": () => Vector2D.From(targetPos), | "GetPosition2D": () => Vector2D.From(targetPos), | ||||
"IsInWorld": () => true, | "IsInWorld": () => true, | ||||
}); | }); | ||||
AddMock(60, IID_Health, {}); | AddMock(60, IID_Health, {}); | ||||
AddMock(60, IID_DamageReceiver, { | AddMock(60, IID_DamageReceiver, { | ||||
"TakeDamage": (strengths, multiplier) => { | "TakeDamage": (playerID, strengths, multiplier) => { | ||||
hitEnts.add(60); | hitEnts.add(60); | ||||
TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 100); | TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 100); | ||||
return { "killed": false, "change": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | return { "killed": false, "healthChange": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | ||||
} | } | ||||
}); | }); | ||||
AddMock(60, IID_Footprint, { | AddMock(60, IID_Footprint, { | ||||
"GetShape": () => ({ "type": "circle", "radius": 20 }), | "GetShape": () => ({ "type": "circle", "radius": 20 }), | ||||
}); | }); | ||||
AddMock(70, IID_Ownership, { | AddMock(70, IID_Ownership, { | ||||
Show All 19 Lines | function Test_MissileHit() | ||||
AddMock(60, IID_Position, { | AddMock(60, IID_Position, { | ||||
"GetPosition": () => new Vector3D(900, 10, 0), | "GetPosition": () => new Vector3D(900, 10, 0), | ||||
"GetPreviousPosition": () => new Vector3D(900, 10, 0), | "GetPreviousPosition": () => new Vector3D(900, 10, 0), | ||||
"GetPosition2D": () => new Vector2D(900, 0), | "GetPosition2D": () => new Vector2D(900, 0), | ||||
"IsInWorld": () => true, | "IsInWorld": () => true, | ||||
}); | }); | ||||
AddMock(60, IID_DamageReceiver, { | AddMock(60, IID_DamageReceiver, { | ||||
"TakeDamage": (strengths, multiplier) => { | "TakeDamage": (playerID, strengths, multiplier) => { | ||||
TS_ASSERT_EQUALS(false); | TS_ASSERT_EQUALS(false); | ||||
return { "killed": false, "change": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | return { "killed": false, "healthChange": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | ||||
} | } | ||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_RangeManager, { | AddMock(SYSTEM_ENTITY, IID_RangeManager, { | ||||
"ExecuteQueryAroundPos": () => [61] | "ExecuteQueryAroundPos": () => [61] | ||||
}); | }); | ||||
AddMock(61, IID_Position, { | AddMock(61, IID_Position, { | ||||
"GetPosition": () => targetPos, | "GetPosition": () => targetPos, | ||||
"GetPreviousPosition": () => targetPos, | "GetPreviousPosition": () => targetPos, | ||||
"GetPosition2D": () => Vector2D.from3D(targetPos), | "GetPosition2D": () => Vector2D.from3D(targetPos), | ||||
"IsInWorld": () => true, | "IsInWorld": () => true, | ||||
}); | }); | ||||
AddMock(61, IID_Health, {}); | AddMock(61, IID_Health, {}); | ||||
AddMock(61, IID_DamageReceiver, { | AddMock(61, IID_DamageReceiver, { | ||||
"TakeDamage": (strengths, multiplier) => { | "TakeDamage": (playerID, strengths, multiplier) => { | ||||
TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 100); | TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 100); | ||||
hitEnts.add(61); | hitEnts.add(61); | ||||
return { "killed": false, "change": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | return { "killed": false, "healthChange": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | ||||
} | } | ||||
}); | }); | ||||
AddMock(61, IID_Footprint, { | AddMock(61, IID_Footprint, { | ||||
"GetShape": () => ({ "type": "circle", "radius": 20 }), | "GetShape": () => ({ "type": "circle", "radius": 20 }), | ||||
}); | }); | ||||
cmpDamage.MissileHit(data, 0); | cmpDamage.MissileHit(data, 0); | ||||
Show All 9 Lines | function Test_MissileHit() | ||||
data.splashStrengths = { "hack": 0, "pierce": 0, "crush": 200 }; | data.splashStrengths = { "hack": 0, "pierce": 0, "crush": 200 }; | ||||
AddMock(SYSTEM_ENTITY, IID_RangeManager, { | AddMock(SYSTEM_ENTITY, IID_RangeManager, { | ||||
"ExecuteQueryAroundPos": () => [61, 62] | "ExecuteQueryAroundPos": () => [61, 62] | ||||
}); | }); | ||||
let dealtDamage = 0; | let dealtDamage = 0; | ||||
AddMock(61, IID_DamageReceiver, { | AddMock(61, IID_DamageReceiver, { | ||||
"TakeDamage": (strengths, multiplier) => { | "TakeDamage": (playerID, strengths, multiplier) => { | ||||
dealtDamage += multiplier * (strengths.hack + strengths.pierce + strengths.crush); | dealtDamage += multiplier * (strengths.hack + strengths.pierce + strengths.crush); | ||||
hitEnts.add(61); | hitEnts.add(61); | ||||
return { "killed": false, "change": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | return { "killed": false, "healthChange": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | ||||
} | } | ||||
}); | }); | ||||
AddMock(62, IID_Position, { | AddMock(62, IID_Position, { | ||||
"GetPosition": () => new Vector3D(8, 10, 0), | "GetPosition": () => new Vector3D(8, 10, 0), | ||||
"GetPreviousPosition": () => new Vector3D(8, 10, 0), | "GetPreviousPosition": () => new Vector3D(8, 10, 0), | ||||
"GetPosition2D": () => new Vector2D(8, 0), | "GetPosition2D": () => new Vector2D(8, 0), | ||||
"IsInWorld": () => true, | "IsInWorld": () => true, | ||||
}); | }); | ||||
AddMock(62, IID_Health, {}); | AddMock(62, IID_Health, {}); | ||||
AddMock(62, IID_DamageReceiver, { | AddMock(62, IID_DamageReceiver, { | ||||
"TakeDamage": (strengths, multiplier) => { | "TakeDamage": (playerID, strengths, multiplier) => { | ||||
TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 200 * 0.75); | TS_ASSERT_EQUALS(multiplier * (strengths.hack + strengths.pierce + strengths.crush), 200 * 0.75); | ||||
hitEnts.add(62); | hitEnts.add(62); | ||||
return { "killed": false, "change": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | return { "killed": false, "healthChange": -multiplier * (strengths.hack + strengths.pierce + strengths.crush) }; | ||||
} | } | ||||
}); | }); | ||||
AddMock(62, IID_Footprint, { | AddMock(62, IID_Footprint, { | ||||
"GetShape": () => ({ "type": "circle", "radius": 20 }), | "GetShape": () => ({ "type": "circle", "radius": 20 }), | ||||
}); | }); | ||||
cmpDamage.MissileHit(data, 0); | cmpDamage.MissileHit(data, 0); | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator