I'm trying to make a damage calculator, where the user can input any situation: mob, difficulty, weapon held, potion effect, enchantment, all of it really. Something that might be best useful in adventure maps. Here's my very unfinished program layout:
I cannot - for the life of me - find a way to figure out the exact damage that mobs make when holding weapons. For example, a Skeleton spawned with a diamond sword does 5 damage when a diamond sword should do 8. A zombie pigmen does 5 damage with both a gold shovel and a stronger iron one... What? Where are these numbers coming from? Sometimes the damages change between hits.
I can't make an accurate program when the game poops out senseless numbers. I'd also like to know the exact protection values of armor enchantments. How can I get all this info? Or is my program a lost cause?
Rollback Post to RevisionRollBack
Yeah, that guy in the avatar is me. I'm *that* strange. It happens. Sometimes people act like that. Just go with it. I can offer help with suggestions even before you post them - NOT make your suggestions - but help you with them.
I'm trying to make a damage calculator, where the user can input any situation: mob, difficulty, weapon held, potion effect, enchantment, all of it really. Something that might be best useful in adventure maps. Here's my very unfinished program layout:
I cannot - for the life of me - find a way to figure out the exact damage that mobs make when holding weapons. For example, a Skeleton spawned with a diamond sword does 5 damage when a diamond sword should do 8. A zombie pigmen does 5 damage with both a gold shovel and a stronger iron one... What? Where are these numbers coming from? Sometimes the damages change between hits.
I can't make an accurate program when the game poops out senseless numbers. I'd also like to know the exact protection values of armor enchantments. How can I get all this info? Or is my program a lost cause?
If you set up Forge, you'll be able to look at the mob code and see how the game calculates the values. It's probably somewhere in EntityLivingBase.
If you set up Forge, you'll be able to look at the mob code and see how the game calculates the values. It's probably somewhere in EntityLivingBase.
I have Forge installed, but where exactly am I looking for this stuff?
Rollback Post to RevisionRollBack
Yeah, that guy in the avatar is me. I'm *that* strange. It happens. Sometimes people act like that. Just go with it. I can offer help with suggestions even before you post them - NOT make your suggestions - but help you with them.
In either of them, though I got the source because I assumed it'd be there.
I should have asked this from the start, is there already mods/programs that exist to calculate damage in almost any given situation?
Rollback Post to RevisionRollBack
Yeah, that guy in the avatar is me. I'm *that* strange. It happens. Sometimes people act like that. Just go with it. I can offer help with suggestions even before you post them - NOT make your suggestions - but help you with them.
In either of them, though I got the source because I assumed it'd be there.
I should have asked this from the start, is there already mods/programs that exist to calculate damage in almost any given situation?
A quick google doesn't turn up any living programs that function like yours. As to the exact location of the code, once you have it set up in an IDE, the patched Minecraft source is available as forgesrc-<version> under Referenced Libraries(For Eclipse, other IDEs will have different locations). You're looking for the package net.minecraft.entity.
the damage calculations are in net.minecraft.entity.monster.EntityMob#attackEntityAsMob. It does not check what item is used, only the enchantments on the item that is currently being held by the entity. A block of dirt does the same amount of damage as a diamond sword when held by an entity which inherits the EntityMob class.
Does that only apply to some mobs, I did some tests with Zombie Pigmen:
Zombie Pigmen, Unarmed - 2½ hearts damage on Normal
Zombie Pigmen, Iron Axe - 5 hearts damage on Normal
Zombie Pigmen, Diamond Axe - 5½ hearts damage on Normal
Zombie Pigmen, Wooden Pickaxe - 3½ hearts on Normal
These damage values don't really have a persistent calculation to go on. They do correspond to the power of what they're holding, but I don't see a formula.
Rollback Post to RevisionRollBack
Yeah, that guy in the avatar is me. I'm *that* strange. It happens. Sometimes people act like that. Just go with it. I can offer help with suggestions even before you post them - NOT make your suggestions - but help you with them.
I forgot to note that what I provided was for Minecraft 1.8. Zombie pigmen are inheriting the EntityZombie class which inherits EntityMob. So they use the same calculations. From the looks of it, it does not check for the item's damage value, only the enchantment, the enchantment level and the base damage of the entity itself. I might be missing something though.
None of this is making sense.
I did another test with the normal Zombie on normal difficulty. He does the expected 3½ damage when unarmed, but then does 4 hearts with a stone sword? I've yet to install the IDE, and I don't mean to have others do my work for me, but could you point out the exact part in that code that would make sense of my zombie/stone sword dilemma?
Rollback Post to RevisionRollBack
Yeah, that guy in the avatar is me. I'm *that* strange. It happens. Sometimes people act like that. Just go with it. I can offer help with suggestions even before you post them - NOT make your suggestions - but help you with them.
Come to find out, the new snapshot has sort of what I've been asking for. Either the game is replacing my program or my prayers have been answered.
Nevermind, I misread the snapshot's changelog by a mile.
Rollback Post to RevisionRollBack
Yeah, that guy in the avatar is me. I'm *that* strange. It happens. Sometimes people act like that. Just go with it. I can offer help with suggestions even before you post them - NOT make your suggestions - but help you with them.
Mobs' damage IS affected by their held item: their damage uses the SharedMonsterAttribute.attackDamage Attribute, and any held item will apply its AttributeModifiers to the base value (see EntityLivingBase#onUpdate), so when you retrieve the mob's attack damage, it includes all such bonuses.
Thus, you can usually get fairly close to their actual damage output by using entity.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue()
However, there are a LOT of other factors that can change the amount of damage done, from vanilla hard-coding of some damage (i.e. no modifiers applied) to inconsistently applied enchantment modifiers to potion effects to mods doing who-knows-what.
If you want a fairly accurate representation of the mob's damage output, your only recourse is to actually study the attack implementations of each individual mob and see what bonuses, if any, they include, keeping in mind that if they do not use Attributes when actually causing damage that many modifiers will be ignored (Skeletons, for example, don't care what potion effects they are under when shooting arrows).
If you want a fairly accurate representation of the mob's damage output, your only recourse is to actually study the attack implementations of each individual mob and see what bonuses, if any, they include, keeping in mind that if they do not use Attributes when actually causing damage that many modifiers will be ignored (Skeletons, for example, don't care what potion effects they are under when shooting arrows).
In other words, my best bet is to try every combination of a mob hitting me with every tool and weapon and record each and every damage value?
Rollback Post to RevisionRollBack
Yeah, that guy in the avatar is me. I'm *that* strange. It happens. Sometimes people act like that. Just go with it. I can offer help with suggestions even before you post them - NOT make your suggestions - but help you with them.
In other words, my best bet is to try every combination of a mob hitting me with every tool and weapon and record each and every damage value?
Sometimes "brute force" can actually be faster and less effort than doing thing algorithmically. Sure it might take you 10 hours to collect all that data, but it might take you 40 hours to figure out all the code for all the possible situations, and your calculator would still run the risk of a mistake.
However, in this case I think you'd want to combine some actual recording with checking out the code. I think you'll find that many mobs have common algorithm, as outlined by CoolAlias above, but requiring some unique adjustment which you can determine also by checking the code.
One other option is to actually code a mod to record all the combinations -- make the computer do the work for you. You can create an entity, loop through the set of possible items/weapons, loop through possible enchantments and potion effects, then directly call the attack as mob method against your player and print out a logger/console statement indicating the damage dealt.
Actually, along those lines, another idea that might work is to simulate the damage in real time. Like when using your calculator GUI it would actually create an entity in some safe place (you could create a room/cave way underground somewhere) and equip the entity with the item and effects and have it deal damage to another target entity. That might actually be the most accurate and also the least work.
Sometimes "brute force" can actually be faster and less effort than doing thing algorithmically. Sure it might take you 10 hours to collect all that data, but it might take you 40 hours to figure out all the code for all the possible situations, and your calculator would still run the risk of a mistake.
Luckily, not every single mob can hold a weapon, so it wouldn't be suicidally long, but still very time consuming.
However, in this case I think you'd want to combine some actual recording with checking out the code. I think you'll find that many mobs have common algorithm, as outlined by CoolAlias above, but requiring some unique adjustment which you can determine also by checking the code.
I don't know... It seems like the brute-force thing alone is the key. I don't know if I have the time to check out all the code and correctly set up every single variable and calculation in my program.
One other option is to actually code a mod to record all the combinations -- make the computer do the work for you. You can create an entity, loop through the set of possible items/weapons, loop through possible enchantments and potion effects, then directly call the attack as mob method against your player and print out a logger/console statement indicating the damage dealt.
This is what the program will already do. The only thing holding me back is the inconsistencies of mob damage holding weapons.
Actually, along those lines, another idea that might work is to simulate the damage in real time. Like when using your calculator GUI it would actually create an entity in some safe place (you could create a room/cave way underground somewhere) and equip the entity with the item and effects and have it deal damage to another target entity. That might actually be the most accurate and also the least work.
That sounds like a plan, but how do I know much damage the damage-taking entity is receiving?
Rollback Post to RevisionRollBack
Yeah, that guy in the avatar is me. I'm *that* strange. It happens. Sometimes people act like that. Just go with it. I can offer help with suggestions even before you post them - NOT make your suggestions - but help you with them.
Luckily, not every single mob can hold a weapon, so it wouldn't be suicidally long, but still very time consuming.
I don't know... It seems like the brute-force thing alone is the key. I don't know if I have the time to check out all the code and correctly set up every single variable and calculation in my program.
This is what the program will already do. The only thing holding me back is the inconsistencies of mob damage holding weapons.
That sounds like a plan, but how do I know much damage the damage-taking entity is receiving?
I agree brute force might be the easiest.
However, I also saw your duplicate thread on minecraftforge.net and responded there. There is actually a lot of wiki information from people who have already reviewed the code. It might be enough to get it mostly right. I've given links in that other forum.
In terms of knowing how much damage the damage-taking entity is receiving, you can just make a simple custom living entity for purpose of being the target. It could just print out the damage, or otherwise store it.
Judging by the look of your interface, this is not a program to be used in-game, so really you don't care what the actual damage is on an entity (which may have armor or other damage-mitigating effects), you just want a basic approximation of what the mob will inflict. I don't think you'll need to go to the extreme of writing a mock program to output all the various damage
Instead, you can easily find that information by looking at each mob's implementation details in Java, or the Minecraft wiki as Jabelar suggested, though that won't give you quite as much nitty-gritty detail. Looking at the code will let you know exactly how each mob accounts for weapons / potions / enchantments / etc., if they do at all, and you can use that information in your GUI.
Basically, if the mob uses its SharedMonsterAttribute.attackDamage value when it attacks, then its damage will increase with weapons, enchantments, and potions. This even goes for mobs which might otherwise seem like they can't use weapons; spiders, for example, will have better attack power if you forcefully equip them with a weapon, whereas slimes will not because they simply use their size as their attack value.
Since there are are only around 20 mobs (many of which share the same calculations), a brute force approach will definitely be the quickest.
In terms of knowing how much damage the damage-taking entity is receiving, you can just make a simple custom living entity for purpose of being the target. It could just print out the damage, or otherwise store it.
How am I storing the damage info, where will I see it?
Looks like I'm doing some long brute-force... However, a zombie holding a stone pickaxe might do 3 damage on hit, then like 2 the next. I keep getting these random number curveballs.
Rollback Post to RevisionRollBack
Yeah, that guy in the avatar is me. I'm *that* strange. It happens. Sometimes people act like that. Just go with it. I can offer help with suggestions even before you post them - NOT make your suggestions - but help you with them.
How do you know it is doing 3 and then 2, rather than 2.5 each time and only looking like 3 and 2? Are you actually printing out the damage values to the console?
Also, why does it matter if a mob's damage is somewhat randomized? I don't know of any vanilla mobs that do random damage, but some of mine do. Does your program really have to give the exact damage that will happen, or just the average for a given setup? What is the actual purpose of your program?
How do you know it is doing 3 and then 2, rather than 2.5 each time and only looking like 3 and 2? Are you actually printing out the damage values to the console?
...This is something I've asked like 2 times already. How do I print out the damage something takes, and where do I view it?
Also, why does it matter if a mob's damage is somewhat randomized? I don't know of any vanilla mobs that do random damage, but some of mine do. Does your program really have to give the exact damage that will happen, or just the average for a given setup? What is the actual purpose of your program?
If you give some mobs weapons, they have randomized damage, otherwise they don't. I want my program to give an exact number, but if I can't get one in every case, I'll print out the range of number. The purpose of my program is pretty self-explanatory... to tell the user how damage something will do given any potion effect/enchantment/whatever...
Rollback Post to RevisionRollBack
Yeah, that guy in the avatar is me. I'm *that* strange. It happens. Sometimes people act like that. Just go with it. I can offer help with suggestions even before you post them - NOT make your suggestions - but help you with them.
...This is something I've asked like 2 times already. How do I print out the damage something takes, and where do I view it?
If you give some mobs weapons, they have randomized damage, otherwise they don't. I want my program to give an exact number, but if I can't get one in every case, I'll print out the range of number. The purpose of my program is pretty self-explanatory... to tell the user how damage something will do given any potion effect/enchantment/whatever...
To print something, either use your logger class or the regular System.out.println("Text you want here").
As to the purpose of your program, obviously, but you make it sound like an external program, i.e. not a mod, in which case players probably cannot view it while in game, so is this just a novelty / fun project (nothing wrong with that), or are you actually expecting people to use it rather than just checking the wiki or using a Damage Indicators type of mod?
I'm trying to make a damage calculator, where the user can input any situation: mob, difficulty, weapon held, potion effect, enchantment, all of it really. Something that might be best useful in adventure maps. Here's my very unfinished program layout:
I cannot - for the life of me - find a way to figure out the exact damage that mobs make when holding weapons. For example, a Skeleton spawned with a diamond sword does 5 damage when a diamond sword should do 8. A zombie pigmen does 5 damage with both a gold shovel and a stronger iron one... What? Where are these numbers coming from? Sometimes the damages change between hits.
I can't make an accurate program when the game poops out senseless numbers. I'd also like to know the exact protection values of armor enchantments. How can I get all this info? Or is my program a lost cause?
Yeah, that guy in the avatar is me. I'm *that* strange. It happens. Sometimes people act like that. Just go with it. I can offer help with suggestions even before you post them - NOT make your suggestions - but help you with them.
Unofficial Suggestions Guide (2.0) - by Theriasis
Unofficial Critics Guide - by yoshi9048
If you set up Forge, you'll be able to look at the mob code and see how the game calculates the values. It's probably somewhere in EntityLivingBase.
Please don't PM me asking for help, I will just redirect you to the appropriate forum, where there are others who are far more skilled than me.
This is not the signature you are looking for.
Banners and such things
I have Forge installed, but where exactly am I looking for this stuff?
Yeah, that guy in the avatar is me. I'm *that* strange. It happens. Sometimes people act like that. Just go with it. I can offer help with suggestions even before you post them - NOT make your suggestions - but help you with them.
Unofficial Suggestions Guide (2.0) - by Theriasis
Unofficial Critics Guide - by yoshi9048
The forge client or the forge source?
Please don't PM me asking for help, I will just redirect you to the appropriate forum, where there are others who are far more skilled than me.
This is not the signature you are looking for.
Banners and such things
In either of them, though I got the source because I assumed it'd be there.
I should have asked this from the start, is there already mods/programs that exist to calculate damage in almost any given situation?
Yeah, that guy in the avatar is me. I'm *that* strange. It happens. Sometimes people act like that. Just go with it. I can offer help with suggestions even before you post them - NOT make your suggestions - but help you with them.
Unofficial Suggestions Guide (2.0) - by Theriasis
Unofficial Critics Guide - by yoshi9048
A quick google doesn't turn up any living programs that function like yours. As to the exact location of the code, once you have it set up in an IDE, the patched Minecraft source is available as forgesrc-<version> under Referenced Libraries(For Eclipse, other IDEs will have different locations). You're looking for the package net.minecraft.entity.
Please don't PM me asking for help, I will just redirect you to the appropriate forum, where there are others who are far more skilled than me.
This is not the signature you are looking for.
Banners and such things
Does that only apply to some mobs, I did some tests with Zombie Pigmen:
These damage values don't really have a persistent calculation to go on. They do correspond to the power of what they're holding, but I don't see a formula.
Yeah, that guy in the avatar is me. I'm *that* strange. It happens. Sometimes people act like that. Just go with it. I can offer help with suggestions even before you post them - NOT make your suggestions - but help you with them.
Unofficial Suggestions Guide (2.0) - by Theriasis
Unofficial Critics Guide - by yoshi9048
None of this is making sense.
I did another test with the normal Zombie on normal difficulty. He does the expected 3½ damage when unarmed, but then does 4 hearts with a stone sword? I've yet to install the IDE, and I don't mean to have others do my work for me, but could you point out the exact part in that code that would make sense of my zombie/stone sword dilemma?
Yeah, that guy in the avatar is me. I'm *that* strange. It happens. Sometimes people act like that. Just go with it. I can offer help with suggestions even before you post them - NOT make your suggestions - but help you with them.
Unofficial Suggestions Guide (2.0) - by Theriasis
Unofficial Critics Guide - by yoshi9048
Entity.maxHurtTime is the max hurt. As I know it is the health of mob.
Come to find out, the new snapshot has sort of what I've been asking for. Either the game is replacing my program or my prayers have been answered.Nevermind, I misread the snapshot's changelog by a mile.
Yeah, that guy in the avatar is me. I'm *that* strange. It happens. Sometimes people act like that. Just go with it. I can offer help with suggestions even before you post them - NOT make your suggestions - but help you with them.
Unofficial Suggestions Guide (2.0) - by Theriasis
Unofficial Critics Guide - by yoshi9048
Mobs' damage IS affected by their held item: their damage uses the SharedMonsterAttribute.attackDamage Attribute, and any held item will apply its AttributeModifiers to the base value (see EntityLivingBase#onUpdate), so when you retrieve the mob's attack damage, it includes all such bonuses.
Thus, you can usually get fairly close to their actual damage output by using entity.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue()
However, there are a LOT of other factors that can change the amount of damage done, from vanilla hard-coding of some damage (i.e. no modifiers applied) to inconsistently applied enchantment modifiers to potion effects to mods doing who-knows-what.
If you want a fairly accurate representation of the mob's damage output, your only recourse is to actually study the attack implementations of each individual mob and see what bonuses, if any, they include, keeping in mind that if they do not use Attributes when actually causing damage that many modifiers will be ignored (Skeletons, for example, don't care what potion effects they are under when shooting arrows).
In other words, my best bet is to try every combination of a mob hitting me with every tool and weapon and record each and every damage value?
Yeah, that guy in the avatar is me. I'm *that* strange. It happens. Sometimes people act like that. Just go with it. I can offer help with suggestions even before you post them - NOT make your suggestions - but help you with them.
Unofficial Suggestions Guide (2.0) - by Theriasis
Unofficial Critics Guide - by yoshi9048
Sometimes "brute force" can actually be faster and less effort than doing thing algorithmically. Sure it might take you 10 hours to collect all that data, but it might take you 40 hours to figure out all the code for all the possible situations, and your calculator would still run the risk of a mistake.
However, in this case I think you'd want to combine some actual recording with checking out the code. I think you'll find that many mobs have common algorithm, as outlined by CoolAlias above, but requiring some unique adjustment which you can determine also by checking the code.
One other option is to actually code a mod to record all the combinations -- make the computer do the work for you. You can create an entity, loop through the set of possible items/weapons, loop through possible enchantments and potion effects, then directly call the attack as mob method against your player and print out a logger/console statement indicating the damage dealt.
Actually, along those lines, another idea that might work is to simulate the damage in real time. Like when using your calculator GUI it would actually create an entity in some safe place (you could create a room/cave way underground somewhere) and equip the entity with the item and effects and have it deal damage to another target entity. That might actually be the most accurate and also the least work.
Luckily, not every single mob can hold a weapon, so it wouldn't be suicidally long, but still very time consuming.
I don't know... It seems like the brute-force thing alone is the key. I don't know if I have the time to check out all the code and correctly set up every single variable and calculation in my program.
This is what the program will already do. The only thing holding me back is the inconsistencies of mob damage holding weapons.
That sounds like a plan, but how do I know much damage the damage-taking entity is receiving?
Yeah, that guy in the avatar is me. I'm *that* strange. It happens. Sometimes people act like that. Just go with it. I can offer help with suggestions even before you post them - NOT make your suggestions - but help you with them.
Unofficial Suggestions Guide (2.0) - by Theriasis
Unofficial Critics Guide - by yoshi9048
I agree brute force might be the easiest.
However, I also saw your duplicate thread on minecraftforge.net and responded there. There is actually a lot of wiki information from people who have already reviewed the code. It might be enough to get it mostly right. I've given links in that other forum.
In terms of knowing how much damage the damage-taking entity is receiving, you can just make a simple custom living entity for purpose of being the target. It could just print out the damage, or otherwise store it.
Judging by the look of your interface, this is not a program to be used in-game, so really you don't care what the actual damage is on an entity (which may have armor or other damage-mitigating effects), you just want a basic approximation of what the mob will inflict. I don't think you'll need to go to the extreme of writing a mock program to output all the various damage
Instead, you can easily find that information by looking at each mob's implementation details in Java, or the Minecraft wiki as Jabelar suggested, though that won't give you quite as much nitty-gritty detail. Looking at the code will let you know exactly how each mob accounts for weapons / potions / enchantments / etc., if they do at all, and you can use that information in your GUI.
Basically, if the mob uses its SharedMonsterAttribute.attackDamage value when it attacks, then its damage will increase with weapons, enchantments, and potions. This even goes for mobs which might otherwise seem like they can't use weapons; spiders, for example, will have better attack power if you forcefully equip them with a weapon, whereas slimes will not because they simply use their size as their attack value.
Since there are are only around 20 mobs (many of which share the same calculations), a brute force approach will definitely be the quickest.
How am I storing the damage info, where will I see it?
Looks like I'm doing some long brute-force... However, a zombie holding a stone pickaxe might do 3 damage on hit, then like 2 the next. I keep getting these random number curveballs.
Yeah, that guy in the avatar is me. I'm *that* strange. It happens. Sometimes people act like that. Just go with it. I can offer help with suggestions even before you post them - NOT make your suggestions - but help you with them.
Unofficial Suggestions Guide (2.0) - by Theriasis
Unofficial Critics Guide - by yoshi9048
How do you know it is doing 3 and then 2, rather than 2.5 each time and only looking like 3 and 2? Are you actually printing out the damage values to the console?
Also, why does it matter if a mob's damage is somewhat randomized? I don't know of any vanilla mobs that do random damage, but some of mine do. Does your program really have to give the exact damage that will happen, or just the average for a given setup? What is the actual purpose of your program?
...This is something I've asked like 2 times already. How do I print out the damage something takes, and where do I view it?
If you give some mobs weapons, they have randomized damage, otherwise they don't. I want my program to give an exact number, but if I can't get one in every case, I'll print out the range of number. The purpose of my program is pretty self-explanatory... to tell the user how damage something will do given any potion effect/enchantment/whatever...
Yeah, that guy in the avatar is me. I'm *that* strange. It happens. Sometimes people act like that. Just go with it. I can offer help with suggestions even before you post them - NOT make your suggestions - but help you with them.
Unofficial Suggestions Guide (2.0) - by Theriasis
Unofficial Critics Guide - by yoshi9048
To print something, either use your logger class or the regular System.out.println("Text you want here").
As to the purpose of your program, obviously, but you make it sound like an external program, i.e. not a mod, in which case players probably cannot view it while in game, so is this just a novelty / fun project (nothing wrong with that), or are you actually expecting people to use it rather than just checking the wiki or using a Damage Indicators type of mod?