Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/tests/test_UnitAI.js
Show First 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | AddMock(unit, IID_Attack, { | ||||
GetPreference: function(t) { return 0; }, | GetPreference: function(t) { return 0; }, | ||||
GetTimers: function() { return { "prepare": 500, "repeat": 1000 }; }, | GetTimers: function() { return { "prepare": 500, "repeat": 1000 }; }, | ||||
CanAttack: function(v) { return true; }, | CanAttack: function(v) { return true; }, | ||||
CompareEntitiesByPreference: function(a, b) { return 0; }, | CompareEntitiesByPreference: function(a, b) { return 0; }, | ||||
}); | }); | ||||
unitAI.OnCreate(); | unitAI.OnCreate(); | ||||
unitAI.SetupRangeQuery(1); | unitAI.SetupAttackRangeQuery(1); | ||||
if (mode == 1) | if (mode == 1) | ||||
{ | { | ||||
AddMock(enemy, IID_Health, { | AddMock(enemy, IID_Health, { | ||||
GetHitpoints: function() { return 10; }, | GetHitpoints: function() { return 10; }, | ||||
}); | }); | ||||
AddMock(enemy, IID_UnitAI, { | AddMock(enemy, IID_UnitAI, { | ||||
▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | AddMock(unit + i, IID_Attack, { | ||||
GetBestAttackAgainst: function(t) { return "melee"; }, | GetBestAttackAgainst: function(t) { return "melee"; }, | ||||
GetTimers: function() { return { "prepare": 500, "repeat": 1000 }; }, | GetTimers: function() { return { "prepare": 500, "repeat": 1000 }; }, | ||||
CanAttack: function(v) { return true; }, | CanAttack: function(v) { return true; }, | ||||
CompareEntitiesByPreference: function(a, b) { return 0; }, | CompareEntitiesByPreference: function(a, b) { return 0; }, | ||||
}); | }); | ||||
unitAI.OnCreate(); | unitAI.OnCreate(); | ||||
unitAI.SetupRangeQuery(1); | unitAI.SetupAttackRangeQuery(1); | ||||
unitAIs.push(unitAI); | unitAIs.push(unitAI); | ||||
} | } | ||||
// create enemy | // create enemy | ||||
AddMock(enemy, IID_Health, { | AddMock(enemy, IID_Health, { | ||||
GetHitpoints: function() { return 40; }, | GetHitpoints: function() { return 40; }, | ||||
}); | }); | ||||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator