Skip to content

Implement lineOfSight on features #4282

@aco4

Description

@aco4

Features include a lineOfSight property:

"Tree1": {
"armour": 10,
"breadth": 1,
"hitpoints": 50,
"id": "Tree1",
"lineOfSight": 0,
"model": "mitrees.pie",
"name": "*Tree1*",
"tileDraw": 1,
"type": "TREE",
"width": 1
},

It seems that this propety controls whether units and structures can see through the feature and shoot at objects behind it:

; damageable <1|0> Whether or not the feature is damageable, if set to 0, the 'x' cursor will appear instead of the 'attack' cursor
; lineOfSight <1|0> Line Of Sight. Whether of not units and structures can see through them and shoot at objects behind them
; startVisible <1|0> Whether or not the feature is visible even if you haven't explored that area of terrain yet

However, this property doesn't seem to do anything in the source code currently. It seems that visibility.cpp is the right place to implement it?

warzone2100/src/visibility.cpp

Lines 1131 to 1154 in f45d614

{
const MAPTILE *psTile;
halfway = current + (next - current) / 2;
psTile = mapTile(map_coord(halfway.x), map_coord(halfway.y));
if (TileHasStructure(psTile) && psTile->psObject != psTarget)
{
// check whether target was reached before tile's "half way" line
part = halfway - start;
partSq = dot(part, part);
if (partSq >= distSq)
{
break;
}
// allowed to shoot over enemy structures if they are NOT the target
if (partSq > 0)
{
angle_check(&angletan, oldPartSq,
psTile->psObject->pos.z + establishTargetHeight(psTile->psObject) - pos.z,
distSq, dest.z - pos.z, direct);
}
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions