Skip to content

Implement lineOfSight on features #4282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
aco4 opened this issue May 5, 2025 · 0 comments · May be fixed by #4283
Open

Implement lineOfSight on features #4282

aco4 opened this issue May 5, 2025 · 0 comments · May be fixed by #4283
Labels

Comments

@aco4
Copy link
Contributor

aco4 commented May 5, 2025

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);
}
}
}

@aco4 aco4 added the Feature label May 5, 2025
@aco4 aco4 linked a pull request May 5, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant