Skip to content

Commit

Permalink
Script: Remove unnecessary extra hitbox detection for player
Browse files Browse the repository at this point in the history
v2: Keep the 10 unit offset for the player, add changelog entry

This change affects the following scripts:

graph/obj3d/interactive/fix_inter/elevator_plateau/elevator_plateau.asl

 The player no longer takes damage if on top of the elevater AND inside
 the damage zone but this condition is impossible as the check
 is executed when the elevator is on top of the damage zone.

 And if the condition were possible, this would be a bug fix.

graph/obj3d/interactive/fix_inter/pressurepad_gob/pressurepad_gob_0010/pressurepad_gob.asl

 The affected code is unreachable.

graph/obj3d/interactive/fix_inter/pressurepad_gob/pressurepad_gob_0021/pressurepad_gob.asl
graph/obj3d/interactive/fix_inter/pressurepad_gob/pressurepad_gob_0022/pressurepad_gob.asl
graph/obj3d/interactive/fix_inter/pressurepad_gob/pressurepad_gob_0023/pressurepad_gob.asl
graph/obj3d/interactive/fix_inter/pressurepad_gob/pressurepad_gob_0024/pressurepad_gob.asl

 An additional IF (§levitate == 1) ACCEPT check is executed but this
 check is redundant so there is no noticeable change.

Signed-off-by: Daniel Scharrer <daniel@constexpr.org>
  • Loading branch information
meszaros-lajos-gyorgy authored and dscharrer committed Jul 8, 2022
1 parent 466f7fa commit 5028ce9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -44,6 +44,7 @@ Modding:
* Added the weapon/summoned/spell ID as parameter 3 to the hit script event (feature request #1599)
* Added the damage type flags as parameter 4 to the hit script event
* Added support for stopping specific spells using the destroy script command
* Fixed the ^$objontop script variable to not have a leading space and don't repeat 'player'

Debugging:

Expand Down
10 changes: 2 additions & 8 deletions src/graphics/data/Mesh.cpp
Expand Up @@ -165,17 +165,11 @@ long MakeTopObjString(Entity * entity, std::string & dest) {

dest = "";

if(player.pos.x > box.min.x && player.pos.x < box.max.x
&& player.pos.z > box.min.z && player.pos.z < box.max.z) {
if(glm::abs(player.pos.y + 160.f - box.min.y) < 50.f) {
dest += " player";
}
}

for(const Entity & other : entities.inScene(IO_NPC | IO_ITEM)) {
if(&other != entity) {
if(other.pos.x > box.min.x && other.pos.x < box.max.x && other.pos.z > box.min.z && other.pos.z < box.max.z) {
if(glm::abs(other.pos.y - box.min.y) < 40.f) {
float offset = (&other == entities.player() ? 10.f : 0.f);
if(glm::abs(other.pos.y - offset - box.min.y) < 40.f + offset) {
if(dest.length() != 0) {
dest += ' ';
}
Expand Down

0 comments on commit 5028ce9

Please sign in to comment.