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

Sentry damage value and <context.damage> different in "damage trigger". #398

Closed
mythan opened this issue Sep 1, 2013 · 4 comments
Closed

Comments

@mythan
Copy link

mythan commented Sep 1, 2013

I can confirm "context.damage" is now returning a value in the "damage trigger", which is great - thanks for adding that.

The problem (same as with "npc.last_damage.amount") is that Sentry returns one value and "context.damage" returns another. "context.damage" seems to show the amount of damage that would've been dealt by the weapon type and if the NPC had no armour/effects applied it. What it needs to do is grab the value reported by Sentry after the armour modifiers have been applied.

Alternatively, let me know if I'm using the wrong tag maybe?

@mythan
Copy link
Author

mythan commented Sep 1, 2013

I would've used the "npc.health" tag and then calculated the difference to figure out how much damage has been dealt, but the problem is that that it shows the <npc.health> value first (as full health) and then apply the Sentry damage. So Denizen is always a step ahead of the Sentry value so I'm unable to calculate an accurate damage.

@ghost ghost assigned mcmonkey4eva Sep 1, 2013
@mcmonkey4eva
Copy link
Member

As was said in the IRC, Sentry stores its damage modifications entirely internally, an external plugin can't see it. It requires jrbudda helps a little, and probably Depenizen use as well.
Of course, you could also just delay a single tick, and then compare health values. Sentry NPCs can't be hit twice that rapidly. (It's programmatically restricted)

damage trigger:
  script:
  - define phealth <npc.health>
  # It's assumed the default delay of a timed queue applies here. If not, add - wait 1t
  - define finaldamage <m:<npc.health>-phealth>
  - announce "%finaldamage%"

... Done!

@mythan
Copy link
Author

mythan commented Sep 1, 2013

Great, I've used your suggestion with near perfect success. The only problem at this point is the last hit is not properly calculated because "npc.health" isn't valid anymore since the NPC died.

Can you please suggest a way to deal with that?

The console throws the following error:

18:58:18 [INFO] +- Executing dCommand: define/mythanical ------+
18:58:18 [INFO]  ERROR! Unfilled attributes '[health]'for tag
                   <npc.health>!
18:58:18 [SEVERE] Could not pass event ReplaceableTagEvent to Denizen v0.9.2-SNA
PSHOT (build 1220)
org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
va:427)
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
a:62)
        at org.bukkit.plugin.TimedRegisteredListener.callEvent(TimedRegisteredLi
stener.java:30)
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
ava:478)
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
ava:463)
        at net.aufdemrand.denizen.tags.TagManager.tag(TagManager.java:131)
        at net.aufdemrand.denizen.tags.TagManager.fillArguments(TagManager.java:
174)
        at net.aufdemrand.denizen.scripts.commands.CommandExecuter.execute(Comma
ndExecuter.java:162)
        at net.aufdemrand.denizen.scripts.queues.ScriptEngine.revolve(ScriptEngi
ne.java:41)
        at net.aufdemrand.denizen.scripts.queues.ScriptQueue.revolve(ScriptQueue
.java:474)
        at net.aufdemrand.denizen.scripts.queues.core.TimedQueue.access$000(Time
dQueue.java:9)
        at net.aufdemrand.denizen.scripts.queues.core.TimedQueue$1.run(TimedQueu
e.java:152)
        at org.bukkit.craftbukkit.v1_6_R2.scheduler.CraftTask.run(CraftTask.java
:58)
        at org.bukkit.craftbukkit.v1_6_R2.scheduler.CraftScheduler.mainThreadHea
rtbeat(CraftScheduler.java:345)
        at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:5
18)
        at net.minecraft.server.v1_6_R2.DedicatedServer.t(DedicatedServer.java:2
39)
        at net.minecraft.server.v1_6_R2.MinecraftServer.s(MinecraftServer.java:4
81)
        at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java
:413)
        at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:5
82)
Caused by: java.lang.IllegalArgumentException: null is not a number
        at net.aufdemrand.denizen.utilities.javaluator.DoubleEvaluator.toValue(D
oubleEvaluator.java:196)
        at net.aufdemrand.denizen.utilities.javaluator.DoubleEvaluator.toValue(D
oubleEvaluator.java:48)
        at net.aufdemrand.denizen.utilities.javaluator.AbstractEvaluator.output(
AbstractEvaluator.java:122)
        at net.aufdemrand.denizen.utilities.javaluator.AbstractEvaluator.evaluat
e(AbstractEvaluator.java:321)
        at net.aufdemrand.denizen.utilities.javaluator.AbstractEvaluator.evaluat
e(AbstractEvaluator.java:201)
        at net.aufdemrand.denizen.tags.core.UtilTags.mathTags(UtilTags.java:36)
        at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
va:425)
        ... 18 more
18:58:18 [INFO]  +> Executing 'DEFINE':
                   queue='E871F7A0-0036-4C3A-A46A-DA2AADAEB255'
                   definition='finaldamage'  value='3.0-null'
18:58:18 [INFO] +- Executing dCommand: flag/mythanical ------+
18:58:18 [INFO]  +> Executing 'FLAG': flag_name='BOSSPLAYERTOTALDAMAGE'
                   Action/Value='INCREASE(3.0-null)'
                   flag_target='p@mythanical'
18:58:18 [INFO]  ERROR! Woah!! An exception has been called with this
                   command!
18:58:18 [SEVERE] java.lang.NumberFormatException: For input string: "3.0-null"
18:58:18 [SEVERE]       at sun.misc.FloatingDecimal.readJavaFormatString(Floatin
gDecimal.java:1241)
18:58:18 [SEVERE]       at java.lang.Double.valueOf(Double.java:504)
18:58:18 [SEVERE]       at net.aufdemrand.denizen.flags.FlagManager$Flag.doActio
n(FlagManager.java:528)
18:58:18 [SEVERE]       at net.aufdemrand.denizen.scripts.commands.core.FlagComm
and.execute(FlagCommand.java:196)
18:58:18 [SEVERE]       at net.aufdemrand.denizen.scripts.commands.CommandExecut
er.execute(CommandExecuter.java:197)
18:58:18 [SEVERE]       at net.aufdemrand.denizen.scripts.queues.ScriptEngine.re
volve(ScriptEngine.java:41)
18:58:18 [SEVERE]       at net.aufdemrand.denizen.scripts.queues.ScriptQueue.rev
olve(ScriptQueue.java:474)
18:58:18 [SEVERE]       at net.aufdemrand.denizen.scripts.queues.core.TimedQueue
.access$000(TimedQueue.java:9)
18:58:18 [SEVERE]       at net.aufdemrand.denizen.scripts.queues.core.TimedQueue
$1.run(TimedQueue.java:152)
18:58:18 [SEVERE]       at org.bukkit.craftbukkit.v1_6_R2.scheduler.CraftTask.ru
n(CraftTask.java:58)
18:58:18 [SEVERE]       at org.bukkit.craftbukkit.v1_6_R2.scheduler.CraftSchedul
er.mainThreadHeartbeat(CraftScheduler.java:345)
18:58:18 [SEVERE]       at net.minecraft.server.v1_6_R2.MinecraftServer.t(Minecr
aftServer.java:518)
18:58:18 [SEVERE]       at net.minecraft.server.v1_6_R2.DedicatedServer.t(Dedica
tedServer.java:239)
18:58:18 [SEVERE]       at net.minecraft.server.v1_6_R2.MinecraftServer.s(Minecr
aftServer.java:481)
18:58:18 [SEVERE]       at net.minecraft.server.v1_6_R2.MinecraftServer.run(Mine
craftServer.java:413)
18:58:18 [SEVERE]       at net.minecraft.server.v1_6_R2.ThreadServerApplication.
run(SourceFile:582)
18:58:18 [INFO]  Completing queue E871F7A0-0036-4C3A-A46A-DA2AADAEB255...

@mcmonkey4eva
Copy link
Member

Okay, actually maybe like this:

damage trigger:
  script:
  - define phealth <npc.health>
  # It's assumed the default delay of a timed queue applies here. If not, add - wait 1t
  - if <npc.is_spawned> == "true"
    define finaldamage <m:<npc.health>-%phealth%>
    else define finaldamage %phealth%
  - announce "%finaldamage%"

Basically: If the NPC is still spawned, define the damage as current health - previous health - otherwise, assume the NPC died, and define the damage as exactly as much health as the NPC had.
Might misalign with sentry's damage report if you overkill the target, but... good enough, in my opinion.

EDIT: Actually, Ima see if I can make <npc.health> return 0 when the NPC dies...
EDIT2: Sadly, that can't be done in a reasonable manner. health is an entity tag, and when an NPC dies it loses its entity.

EDIT3: I'm closing this because there's nothing more that can be done (at least as far as Denizen coding). Feel free to continue asking for help here or in the IRC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants