Page 1 of 1
Damage weapons on hitting person or mob?

Posted:
Tue Apr 01, 2014 12:40
by mcfan
Since for some reason I can't post on Mod releases I'm posting this here.
Is there a mod or some code that I can add to the default to make it so when one hits a person or mob it damages the weapon? I saw in the castle mod the battleaxe and it gets damaged when you hit a mob but I don't know about hitting a person.

Posted:
Tue Apr 01, 2014 12:49
by PilzAdam
.esu uoy dom eht no sdneped sbom gnittiH .reyalp htiw ti od ot )sloot eht gnidirrevo ebyam tpecxe( yaw on si erehT

Posted:
Tue Apr 01, 2014 13:24
by Amaz
PilzAdam wrote:.esu uoy dom eht no sdneped sbom gnittiH .reyalp htiw ti od ot )sloot eht gnidirrevo ebyam tpecxe( yaw on si erehT
Is there any way to do it with your simple mobs mod?

Posted:
Tue Apr 01, 2014 14:46
by mcfan
Why are you speaking in german piltzadam. I can't understand you.

Posted:
Tue Apr 01, 2014 14:56
by BrandonReese
In simple mobs I added the following code to the on_punch function to add wear to tools/weapons
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
local weapon = hitter:get_wielded_item()
if weapon:get_definition().tool_capabilities ~= nil then
local wear = ( weapon:get_definition().tool_capabilities.full_punch_interval / 75 ) * 65535
weapon:add_wear(wear)
hitter:set_wielded_item(weapon)
end
My logic was the better weapons have a lower full punch interval so with this formula the better weapons wear slower. I didn't want to dig into groupcaps to get the number of uses.

Posted:
Tue Apr 01, 2014 16:00
by Linxx
mcfan wrote:Why are you speaking in german piltzadam. I can't understand you.
read from right to left

Posted:
Tue Apr 01, 2014 16:39
by mcfan
Lol - that is HARD!

Posted:
Wed Apr 02, 2014 12:07
by mcfan
brandonreese where do I add this code?

Posted:
Wed Apr 02, 2014 17:53
by BrandonReese
If you are using simple mobs, in api.lua, just below
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Somewhere around line 480, I've modded my simple mobs so I don't know the exact line number.

Posted:
Wed Apr 02, 2014 18:44
by mcfan
Can I add this to the player.lua to?

Posted:
Wed Apr 02, 2014 19:38
by minermoder27
player.lua is all about a player's skin and model. No punching code involved.

Posted:
Wed Apr 02, 2014 21:28
by mcfan
Too bad. So is there no way to make it so when I hit someone it will damage the weapon?

Posted:
Thu Apr 03, 2014 02:12
by BrandonReese
You could add an on_use function to each weapon but I wouldn't advise that.

Posted:
Thu Apr 03, 2014 11:32
by mcfan
Why wouldn't you?