Opened 7 years ago

Last modified 6 years ago

#4338 closed defect

Large and small stone colliding — at Version 2

Reported by: elexis Owned by:
Priority: Should Have Milestone: Alpha 23
Component: Maps Keywords:
Cc: Patch:

Description (last modified by temple)

In the mainland map of the attached replay, a small and large stone were placed in the exact same spot. Thus units got stuck trying to gather the inner one. The bug is known from multiple maps (copy n paste hell).

http://trac.wildfiregames.com/raw-attachment/ticket/4338/stone.jpg

Change History (4)

by elexis, 7 years ago

Attachment: replay.txt added

by elexis, 7 years ago

Attachment: stone.jpg added

comment:1 by elexis, 7 years ago

Description: modified (diff)

comment:2 by temple, 7 years ago

Description: modified (diff)

There's a big bug in placer.js. It stores the previous coordinates like this:

resultObjs.push(new Entity(this.type, player, x, z, angle));

In entity.js these are converted to meters rather than tiles:

this.position = {
	x: x * CELL_SIZE,
	y: 0,
	z: z * CELL_SIZE
};

But then in player.js when testing for avoidSelf it mixes the two instead of dividing the position by CELL_SIZE:

var dx = x - resultObjs[i].position.x;
var dy = z - resultObjs[i].position.z;

So, for example:

x = 60.534041579297785, z = 104.47036333882323
resultObjs pos x = 243.887196250026, z = 425.05100603813344
dx = -183.3531546707282, dy = -320.5806426993102

The avoidSelf check literally never fails.

if (dx*dx + dy*dy < 1)
	fail = true;

So we see berry bushes overlapping even though they have an avoidSelf check. (There probably should be a max radius involved here instead of always checking < 1 tile.)

For big and small stones, each SimpleObject in the SimpleGroup is checked against itself rather than also against previous things, so even if the avoidSelf check had been working we would still have this problem. And again, even if that too had been working it only checks within one tile, and large stones have a 20m = 5 tile diameter and small stones a 10m = 2.5 tile diameter, so they could still overlap. (Their obstructions are squares with sides 13m and 7m.)

[new SimpleObject(oStoneSmall, 0,2, 0,4), new SimpleObject(oStoneLarge, 1,1, 0,4)],

This stuff needs a little help. :)

Note: See TracTickets for help on using tickets.