Code edit (8 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: unit is not defined' in or related to this line: 'switch (unit.type) {' Line Number: 2176
Code edit (1 edits merged)
Please save this source code
Code edit (14 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: rockIlot2Center is not defined' in or related to this line: 'baseBuilding = {' Line Number: 1740
Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: LK.getTime is not a function' in or related to this line: 'self.lastHitTime = LK.getTime();' Line Number: 1099
Code edit (2 edits merged)
Please save this source code
User prompt
could you implement findFactoryForUnit
Code edit (1 edits merged)
Please save this source code
User prompt
add a new function findEmplacementForBuilding(building, cellX, cellY) that scans the map around the given cellX,cellY to find a free area of rocks that fits the given building size
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: buildable.placeBuilding is not a function' in or related to this line: 'buildable.placeBuilding(placeX, placeY);' Line Number: 2117
Code edit (1 edits merged)
Please save this source code
Code edit (6 edits merged)
Please save this source code
User prompt
in handleDragEnd, don't select buildings if they are under fog
User prompt
don't select ennemy units and building if they are under fog
User prompt
in updateFogOfWar remove the fog in a radius shape instead of a square
Code edit (2 edits merged)
Please save this source code
User prompt
in building growExplosion, remove building from player list of buildings
User prompt
in checkGameEnd, check if player1 of player2 have no more buildings game over if so
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
call updateFogOfWar(); after every building placement
===================================================================
--- original.js
+++ change.js
@@ -569,9 +569,11 @@
// Create and return the navigation mesh for pathfinding
};
self.findPath = function (start, end, range, ignoreSpecificBuilding) {
range = range || 0;
- console.log("findPath ", start, end, range);
+ if (range == 13) {
+ console.log("findPath ", start, end, range);
+ }
// A* pathfinding algorithm implementation
// Avoid buildings by checking if the cell is occupied
var openSet = [];
var closedSet = [];
@@ -603,8 +605,11 @@
var currentNode = openSet[lowestIndex];
var dx = currentNode.x - endNode.x;
var dy = currentNode.y - endNode.y;
if (Math.sqrt(dx * dx + dy * dy) <= range) {
+ if (range == 13) {
+ console.log("findPath Ok Within range :", currentNode.x, currentNode.y + " / dist=" + Math.sqrt(dx * dx + dy * dy));
+ }
var curr = currentNode;
while (curr.parent) {
var prev = curr.parent;
if (prev) {
@@ -619,9 +624,11 @@
}
curr = curr.parent;
}
path.reverse();
- //console.log("Return path 1", path);
+ if (range == 13) {
+ console.log("Return path 1", path);
+ }
return path;
}
openSet.splice(lowestIndex, 1);
closedSet.push(currentNode);
@@ -1052,16 +1059,16 @@
self.lastAttackTime = Date.now();
// Check if target is in range
var distanceToTarget = calculateDistance(self, self.attackTarget);
if (distanceToTarget <= self.attackRange) {
- console.log("Target at range => fire");
+ console.log(self.playerId + " - " + self.type + " : Target at range => fire");
// Rotate towards the target
var angleToTarget = calculateAngle(self, self.attackTarget);
self.asset.rotation = angleToTarget;
// Fire at the target
self.fire();
} else {
- console.log("Target too far => move to target");
+ console.log(self.playerId + " - " + self.type + " : Target too far => move to target");
self.attackMode = 2;
// Move towards the target if it's out of range
var path = gameMap.findPath({
x: self.cellX,
@@ -1375,10 +1382,9 @@
'className': 'UnitHeavyTank',
'actions': ['move', 'attack', 'return'],
'health': 60,
'sightRange': 8,
- 'attackRange': 2,
- //6, TEMP DEBUG !!!TEMP DEBUG !!!TEMP DEBUG !!!
+ 'attackRange': 6,
'attackSpeed': 5,
'attackDamage': 6
}
// Add more units as needed
@@ -1658,9 +1664,9 @@
console.log("AttackActionLogic...", targetCellX, ',', targetCellY);
var target = gameMap.cells[targetCellX][targetCellY].unit || gameMap.cells[targetCellX][targetCellY].building;
if (theUnit && theUnit.isUnit && target) {
theUnit.stopOtherActions();
- var attackPosition = findAvailableCellAtRange(targetCellX, targetCellY, theUnit.range);
+ var attackPosition = findAvailableCellAtRange(targetCellX, targetCellY, theUnit.attackRange);
var path = gameMap.findPath({
x: theUnit.cellX,
y: theUnit.cellY
}, {
@@ -2469,9 +2475,11 @@
//unit.visible = false;
});
gameMap.handleDrag(inputPosition);
dragDelta = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
- selectionMarker.setOnElement(currentSelection);
+ if (currentSelection && currentSelection.health > 0) {
+ selectionMarker.setOnElement(currentSelection);
+ }
}
}
function handleDragEnd(obj) {
var currentPos = obj.event.getLocalPosition(game);
a tileable sand terrain tile.
A square tileable rock terrain tile WITHOUT BBORDER. Single Game Texture. In-Game asset. 2d. No shadows. No Border
Zenith view of Dune's Wind Trap power facility square fence. Ressembles a bit to Sydney's Opera. Zenith view Directly from above.
grey cancel icon. UI
thin white circle empty.
0x5e86ff
Zenith view of a white rectangular Harvester shape of a garbage truck with a triangular head. Harvesting on sand, with flowing spice in the back. inside a square fence. Zenith view. Directly overhead. Plumb view.
Minimal Ui icon of an right sign aside with an icon of a target. sand background
Minimal icon of a home with direction icon pointing to the home. sand background
3 white flat isometric concentric circles like a target.
Remove background
Gray background
Minimal Ui icon of target sign on a fire icon.. sand background
top view of an explosion effect.
Simple heavy army tank factory buiding a tank with a crane. Square fence... Zenith view Directly overhead. Plumb view.
an empty black popup UI. UI