Skip to content
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

fix(engine): fix spam click obj bug #1066

Merged
merged 4 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 5 additions & 18 deletions src/engine/entity/PathingEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ export default abstract class PathingEntity extends Entity {
target: Entity | null = null;
targetOp: TargetOp = -1;
targetSubject: TargetSubject = {type: -1, com: -1};
targetX: number = -1;
targetZ: number = -1;
apRange: number = 10;
apRangeCalled: boolean = false;

Expand Down Expand Up @@ -402,10 +400,6 @@ export default abstract class PathingEntity extends Entity {

pathToMoveClick(input: number[], needsfinding: boolean): void {
if (this.moveStrategy === MoveStrategy.SMART) {
if (this.target && this.target instanceof PathingEntity && Environment.NODE_CLIENT_ROUTEFINDER && CoordGrid.intersects(this.x, this.z, this.width, this.length, this.target.x, this.target.z, this.target.width, this.target.length)) {
this.queueWaypoints(findNaivePath(this.level, this.x, this.z, this.target.x, this.target.z, this.width, this.length, this.target.width, this.target.length, 0, CollisionType.NORMAL));
return;
}
if (needsfinding) {
const { x, z } = CoordGrid.unpackCoord(input[0]);
this.queueWaypoints(findPath(this.level, this.x, this.z, x, z));
Expand All @@ -428,6 +422,11 @@ export default abstract class PathingEntity extends Entity {
return;
}

if (Environment.NODE_CLIENT_ROUTEFINDER && CoordGrid.intersects(this.x, this.z, this.width, this.length, this.target.x, this.target.z, this.target.width, this.target.length)) {
this.queueWaypoints(findNaivePath(this.level, this.x, this.z, this.target.x, this.target.z, this.width, this.length, this.target.width, this.target.length, 0, CollisionType.NORMAL));
return;
}

if (!this.isLastOrNoWaypoint()) {
return;
}
Expand All @@ -449,14 +448,6 @@ export default abstract class PathingEntity extends Entity {
return;
}

this.targetX = this.target.x;
this.targetZ = this.target.z;

const faceX: number = this.target.x * 2 + this.target.width;
const faceZ: number = this.target.z * 2 + this.target.length;
this.orientationX = faceX;
this.orientationZ = faceZ;

if (this.moveStrategy === MoveStrategy.SMART) {
if (this.target instanceof PathingEntity) {
if (Environment.NODE_CLIENT_ROUTEFINDER && CoordGrid.intersects(this.x, this.z, this.width, this.length, this.target.x, this.target.z, this.target.width, this.target.length)) {
Expand Down Expand Up @@ -524,8 +515,6 @@ export default abstract class PathingEntity extends Entity {
this.target = target;
this.targetOp = op;
this.targetSubject = subject ?? {type: -1, com: -1};
this.targetX = target.x;
this.targetZ = target.z;
this.apRange = 10;
this.apRangeCalled = false;

Expand Down Expand Up @@ -568,8 +557,6 @@ export default abstract class PathingEntity extends Entity {
this.target = null;
this.targetOp = -1;
this.targetSubject = {type: -1, com: -1};
this.targetX = -1;
this.targetZ = -1;
this.apRange = 10;
this.apRangeCalled = false;
}
Expand Down
3 changes: 1 addition & 2 deletions src/network/rs225/client/handler/MoveClickHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ export default class MoveClickHandler extends MessageHandler<MoveClick> {
const dest = message.path[message.path.length - 1];
player.userPath = [CoordGrid.packCoord(player.level, dest.x, dest.z)];
}
player.clearInteraction();
player.closeModal();
if (Environment.NODE_WALKTRIGGER_SETTING === WalkTriggerSetting.PLAYERPACKET) {
player.pathToMoveClick(player.userPath, !Environment.NODE_CLIENT_ROUTEFINDER);
}
player.interactWalkTrigger = false;
if (!message.opClick) {
player.clearPendingAction();
if (player.runenergy < 100 && message.ctrlHeld === 1) {
player.setVar(VarPlayerType.TEMP_RUN, 0);
} else {
Expand Down
3 changes: 1 addition & 2 deletions src/network/rs225/client/handler/OpHeldHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ export default class OpHeldHandler extends MessageHandler<OpHeld> {
player.lastItem = item;
player.lastSlot = slot;

player.clearInteraction();
player.closeModal();
player.clearPendingAction();
player.moveClickRequest = false; // uses the dueling ring op to move whilst busy & queue pending: https://youtu.be/GPfN3Isl2rM
player.faceEntity = -1;
player.masks |= player.entitymask;
Expand Down
3 changes: 1 addition & 2 deletions src/network/rs225/client/handler/OpHeldTHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ export default class OpHeldTHandler extends MessageHandler<OpHeldT> {
player.lastItem = item;
player.lastSlot = slot;

player.clearInteraction();
player.closeModal();
player.clearPendingAction();
player.faceEntity = -1;
player.masks |= player.entitymask;

Expand Down
3 changes: 1 addition & 2 deletions src/network/rs225/client/handler/OpHeldUHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ export default class OpHeldUHandler extends MessageHandler<OpHeldU> {
const objType = ObjType.get(player.lastItem);
const useObjType = ObjType.get(player.lastUseItem);

player.clearInteraction();
player.closeModal();
player.clearPendingAction();
player.faceEntity = -1;
player.masks |= player.entitymask;

Expand Down
Loading