Skip to content

Commit

Permalink
Restore "must be able to see NPC" for chat trigs
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Sep 2, 2013
1 parent 5dddb39 commit b4eb103
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
9 changes: 4 additions & 5 deletions src/main/java/net/aufdemrand/denizen/Settings.java
Expand Up @@ -219,12 +219,11 @@ public static double ChatToNpcOverhearingRange() {
*/

// Currently broken because of Bukkit changes

//public static boolean ChatMustSeeNPC() {
// return DenizenAPI.getCurrentInstance().getConfig()
// .getBoolean("Triggers.Chat.Prerequisites.Must be able to see NPC", true);
//}
public static boolean ChatMustSeeNPC() {
return DenizenAPI.getCurrentInstance().getConfig()
.getBoolean("Triggers.Chat.Prerequisites.Must be able to see NPC", true);
}

public static boolean ChatMustLookAtNPC() {
return DenizenAPI.getCurrentInstance().getConfig()
Expand Down
Expand Up @@ -61,18 +61,17 @@ public Boolean process(Player player, String message) {
+ aH.debugObj("Radius(Max)", npc.getLocation().distance(player.getLocation())
+ "(" + npc.getTriggerTrait().getRadius(name) + ")")
+ aH.debugObj("Trigger text", message)
+ aH.debugObj("LOS", String.valueOf(npc.getEntity().hasLineOfSight(player)))
+ aH.debugObj("LOS", String.valueOf(player.hasLineOfSight(npc.getEntity())))
+ aH.debugObj("Facing", String.valueOf(Rotation.isFacingEntity(player, npc.getEntity(), 45))));

// The Denizen config can require some other criteria for a successful chat-with-npc.
// Should we check 'line of sight'? Players cannot talk to NPCs through walls
// if enabled. Should the Player chat only when looking at the NPC? This may
// reduce accidental chats with NPCs.


// TODO: CraftBukkit 1.6 broke the two lines below. Think of a workaround.

//if (Settings.ChatMustSeeNPC())
// if (!npc.getEntity().hasLineOfSight(player)) return false;
if (Settings.ChatMustSeeNPC())
if (!player.hasLineOfSight(npc.getEntity())) return false;

if (Settings.ChatMustLookAtNPC())
if (!Rotation.isFacingEntity(player, npc.getEntity(), 45)) return false;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Expand Up @@ -35,6 +35,7 @@ Triggers:
Overhearing range: 4
Prerequisites:
Must be looking in direction of NPC: true
Must be able to see NPC: true
Formats:
Player to NPC: "You -> <npc.name.nickname>: <text>"
Player to NPC overheard: "<player.name> -> <npc.name.nickname>: <text>"
Expand Down

0 comments on commit b4eb103

Please sign in to comment.