Remove animation checks
Remove animation checks from hunter plugin because animations are unreliable and do not work during 3ticking. Reasoning is it is better to have shown extra traps sometimes than not registering own traps sometimes Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -36,7 +36,6 @@ import java.util.Set;
|
||||
import javax.inject.Inject;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.AnimationID;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameObject;
|
||||
import net.runelite.api.ObjectID;
|
||||
@@ -117,9 +116,9 @@ public class HunterPlugin extends Plugin
|
||||
@Subscribe
|
||||
public void onGameObjectSpawned(GameObjectSpawned event)
|
||||
{
|
||||
GameObject gameObject = event.getGameObject();
|
||||
HunterTrap myTrap = getTrapFromCollection(gameObject);
|
||||
Player localPlayer = client.getLocalPlayer();
|
||||
final GameObject gameObject = event.getGameObject();
|
||||
final HunterTrap myTrap = getTrapFromCollection(gameObject);
|
||||
final Player localPlayer = client.getLocalPlayer();
|
||||
|
||||
switch (gameObject.getId())
|
||||
{
|
||||
@@ -129,22 +128,15 @@ public class HunterPlugin extends Plugin
|
||||
* ------------------------------------------------------------------------------
|
||||
*/
|
||||
case ObjectID.DEADFALL: // Deadfall trap placed
|
||||
if (localPlayer.getWorldLocation().distanceTo(gameObject.getWorldLocation()) <= 2
|
||||
&& localPlayer.getAnimation() == AnimationID.HUNTER_LAY_DEADFALLTRAP)
|
||||
{
|
||||
log.debug("Deadfall trap placed by \"{}\" on {}", localPlayer.getName(), gameObject.getWorldLocation());
|
||||
traps.add(new HunterTrap(gameObject));
|
||||
lastActionTime = Instant.now();
|
||||
}
|
||||
break;
|
||||
case ObjectID.MONKEY_TRAP: // Maniacal monkey trap placed
|
||||
if (localPlayer.getWorldLocation().distanceTo(gameObject.getWorldLocation()) < 2)
|
||||
// If player is right next to "object" trap assume that player placed the trap
|
||||
if (localPlayer.getWorldLocation().distanceTo(gameObject.getWorldLocation()) <= 1)
|
||||
{
|
||||
log.debug("Maniacal monkey trap placed by \"{}\" on {} of {}", localPlayer.getName(),
|
||||
gameObject.getWorldLocation(), gameObject);
|
||||
log.debug("Trap placed by \"{}\" on {}", localPlayer.getName(), gameObject.getWorldLocation());
|
||||
traps.add(new HunterTrap(gameObject));
|
||||
lastActionTime = Instant.now();
|
||||
}
|
||||
|
||||
break;
|
||||
case ObjectID.MAGIC_BOX: // Imp box placed
|
||||
case ObjectID.BOX_TRAP_9380: // Box trap placed
|
||||
@@ -154,28 +146,17 @@ public class HunterPlugin extends Plugin
|
||||
case ObjectID.NET_TRAP_8992: // Net trap placed at red sallys
|
||||
case ObjectID.NET_TRAP_9002: // Net trap placed at black sallys
|
||||
// Look for players that are on the same tile
|
||||
PlayerQuery playerQuery = new PlayerQuery().atLocalLocation(gameObject.getLocalLocation());
|
||||
List<Player> possiblePlayers = Arrays.asList(queryRunner.runQuery(playerQuery));
|
||||
final PlayerQuery playerQuery = new PlayerQuery().atLocalLocation(gameObject.getLocalLocation());
|
||||
final List<Player> possiblePlayers = Arrays.asList(queryRunner.runQuery(playerQuery));
|
||||
|
||||
/* If the player is on that tile, and it has the correct animation, assume he is the one that placed the trap
|
||||
* Special case: if you herb+tar, then move and place the trap, it does not detect laying the trap. It does work
|
||||
* if you herb+tar en then place the trap.
|
||||
*/
|
||||
// If the player is on that tile, assume he is the one that placed the trap
|
||||
if (possiblePlayers.contains(localPlayer))
|
||||
{
|
||||
switch (localPlayer.getAnimation())
|
||||
{
|
||||
case AnimationID.HUNTER_LAY_BOXTRAP_BIRDSNARE:
|
||||
case AnimationID.HUNTER_LAY_NETTRAP:
|
||||
case AnimationID.HERBLORE_MAKE_TAR: // When 3 ticking
|
||||
log.debug("Trap placed by \"{}\" on {}", localPlayer.getName(), localPlayer.getWorldLocation());
|
||||
traps.add(new HunterTrap(gameObject));
|
||||
|
||||
lastActionTime = Instant.now();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
/*
|
||||
* ------------------------------------------------------------------------------
|
||||
@@ -203,7 +184,6 @@ public class HunterPlugin extends Plugin
|
||||
case ObjectID.LARGE_BOULDER_28831: // Maniacal monkey tail obtained
|
||||
if (myTrap != null)
|
||||
{
|
||||
log.debug("Yay, you caught something");
|
||||
myTrap.setState(HunterTrap.State.FULL);
|
||||
catchAtempts++;
|
||||
catchSuccess++;
|
||||
@@ -214,6 +194,7 @@ public class HunterPlugin extends Plugin
|
||||
notifier.notify("You've caught part of a monkey's tail.");
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
/*
|
||||
* ------------------------------------------------------------------------------
|
||||
@@ -225,13 +206,13 @@ public class HunterPlugin extends Plugin
|
||||
case ObjectID.BIRD_SNARE: //Empty box trap
|
||||
if (myTrap != null)
|
||||
{
|
||||
log.debug("Your trap didn't catch anything");
|
||||
myTrap.setState(HunterTrap.State.EMPTY);
|
||||
myTrap.resetTimer();
|
||||
catchAtempts++;
|
||||
|
||||
lastActionTime = Instant.now();
|
||||
}
|
||||
|
||||
break;
|
||||
/*
|
||||
* ------------------------------------------------------------------------------
|
||||
@@ -353,13 +334,14 @@ public class HunterPlugin extends Plugin
|
||||
* Looks for a trap in the local players trap collection, on the same
|
||||
* place as the given GameObject.
|
||||
*
|
||||
* @param gameObject
|
||||
* @param gameObject game object
|
||||
* @return A HunterTrap object if the player has a trap on the same
|
||||
* location as the GameObject. Otherwise it returns null.
|
||||
*/
|
||||
private HunterTrap getTrapFromCollection(GameObject gameObject)
|
||||
{
|
||||
Point gameObjectLocation = gameObject.getWorldLocation();
|
||||
final Point gameObjectLocation = gameObject.getWorldLocation();
|
||||
|
||||
for (HunterTrap trap : traps)
|
||||
{
|
||||
if (gameObjectLocation.equals(trap.getGameObject().getWorldLocation()))
|
||||
@@ -367,6 +349,7 @@ public class HunterPlugin extends Plugin
|
||||
return trap;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user