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

Divide armor wear amongst number of pieces worn #34

Closed
sirrobzeroone opened this issue Dec 19, 2020 · 3 comments
Closed

Divide armor wear amongst number of pieces worn #34

sirrobzeroone opened this issue Dec 19, 2020 · 3 comments

Comments

@sirrobzeroone
Copy link

sirrobzeroone commented Dec 19, 2020

The partial fix for issue #24 exposed that when armor recieves wear, whether you wear 1 piece or 5 pieces the armor pieces all take the same amount of wear/damage.

My suggestion; Is that as you wear more pieces of armor the damage/use is spread as a fraction across all armor pieces. Given that damage/use is already set by the armor piece type this would simply involve dividing the use/damage for that armor piece by the number of armor pieces worn.

I have developed a small change to api.lua>>armor.damage which makes the above change, I have tested this and can't detect any issues - basically replace the current armor.damage starting at ~= line 417 with the below :

armor.damage = function(self, player, index, stack, use)
	local old_stack = ItemStack(stack)	
	local worn_armor = armor:get_weared_armor_elements(player)               -- Addition Start
	local armor_p_cnt = 0
	for k,v in pairs(worn_armor) do
		armor_p_cnt = armor_p_cnt + 1
	end
	use = math.ceil(use/armor_p_cnt)                                         --Addition End	
	minetest.chat_send_all(stack:get_name().." pre_wear: "..stack:get_wear()) -- Added for testing
	stack:add_wear(use)
	minetest.chat_send_all(stack:get_name().." post_wear: "..stack:get_wear()) -- Added for testing
	self:run_callbacks("on_damage", player, index, stack)
	self:set_inventory_stack(player, index, stack)
	if stack:get_count() == 0 then
		self:run_callbacks("on_unequip", player, index, old_stack)
		self:run_callbacks("on_destroy", player, index, old_stack)
		self:set_player_armor(player)
	end
end

Testing and outcomes all as expected - short-hand test cases:

One
Wearing just Wooden Chestplate - Recieved full 2000 use/damage

Two
Wearing Wooden Chestplate and Wooden Boots - Each Recieved 1000 use/damage

Three
Wearing Diamond Chestplate and Wooden Boots - Chestplate 100 use/damage, Boots 1000 use/damage

Four
Full Wooden armor Chest, Boots, Leggings, Helmet - Each recieved 500 use/damage

Five
Wood Helmet, Diamond Chest, Bronze Leggings, Steel Boots:
Helmet 500 use/damage, Chestplate 50 use/damage, Leggings 100 use/damage, boots 200 use/damage.

I did contemplate making Chestplate take a larger proportion (say 2/6 when wearing 5 pieces ie have chestplate count as "2" not 1) but that makes the fix significantly more complex and I thought for an initial enhancement simple might be best? I'm very happy to take suggestions and ideas and code imporvements etc and even roll in that chestplate fix although I was worried ppl might then not wear chestplates.....

@sirrobzeroone
Copy link
Author

I did push this issue onto the 3d_armor thread on the minetest forums (https://forum.minetest.net/viewtopic.php?f=11&t=4654&start=850) Fairly sure the regulars would have seen it and flagged any major concerns.

I'll move onto the next step for this for me which is a more intense testing step involving mobs and PVP. I've also been running the shield fix #30 and haven't noticed any issues, crashes, odd errors etc. So I think I'll just do a single pull request for this and #30

I hope I'm not setting a direction here for 3d_armor that was never intended, I'd hate to be standing on anyone's toes. I'm very much just trying to add functionality/fix issues I'm currently stumbling over that i need in a mod Im working on. I could add this functionality to just my mod but in most cases to me it would appear to be better placed in 3d_armor than in my mod alone.

@sirrobzeroone
Copy link
Author

sirrobzeroone commented Dec 21, 2020

Tested so far, with this and #30 in place

The below in Singleplayer and Server, for the attacks full diamond armor with shield and gloves to push lvl over 100

  • Register armor - P
  • Put on and take off armor - P
  • Mob damage player - P
    • No armor - P
    • under 50 armor - P
    • over 50 armor - P
    • over 110 armor - P
  • Mob damage armor - P
    • No armor - P
    • under 50 armor - P
    • over 50 armor - P
    • over 110 armor - P
  • Player damage player - P
    • No armor - P
    • under 50 armor - P
    • over 50 armor - P
    • over 110 armor - P
  • Player damage armor - P
    • No armor - P
    • under 50 armor - P
    • over 50 armor - P
    • over 110 armor - P
  • Player can't damage armor with incorrect weapon level - P
    • Diamond sword on Diamond armor- P
    • Wood sword on Diamond armor - P
  • Weapon takes use damage and at correct rate- P
    • Wood sword 10 uses - P
  • Craft armor pieces - P
    • Diamond Leggings - P
    • Wood Chestplate - P

Inside Protection area PVP off

  • M vs Pl - Damage - P
  • M vs Pl armor - Damage - F (investigating) -P
  • Pl vs Pl owner - nil damage - P - P
  • Pl vs Pl owner armor - nil damage - P - P
  • Pl owner vs Pl - damage - P - P
  • Pl owner vs Pl armor - P - P
    all above match when protector active alone

Inside Protection area PVP on

  • M vs Pl - Damage - P
  • M vs Pl armor - Damage - P
  • Pl vs Pl owner - Damage - P
  • Pl vs Pl owner armor - Damage - P
  • Pl owner vs Pl - Damage - P
  • Pl owner vs Pl armor - Damage - P

Outside Protection area

  • M vs Pl - expect damage - P
  • M vs Pl armor - expect damage - P
  • Pl vs Pl - expect damage - P
  • Pl vs Pl armor - expect damage - p

Mixed armor use testing

  • Full Set all the same
    • Steel sword vs full diamond nil damage - P
    • Mese sword vs full dimaond damage - P (Very tough I couldnt actually score a hit but armor took damage)
  • 1 Diamond piece and 1 Wood piece
    • Steel sword on Diamond helmet and Wood chest plate - Player damage, Chestplate damage, Helmet nil damage - P
    • Mese sword on the above - Player damage, Chestplate damage, Helmet damage - P

Other than one bug I should have picked up when testing #13 with mobs which I've fixed and will note and bundle with this pull request when I do it (sorry about that). I haven't picked up any other issues. Armor does damage slower when wearing multiple pieces vs single piece but thats to be expected. I would not want to watch PVP of two people in diamond armor, using shields and gloves.....I'm not sure who would win or if they would just quit from sheer bordem...not sure if thats an issue given the multiplier can be adjusted up and down as you like in settings for PVP servers, I also view that as more of a limitation of the currrent armor/damage mechanic.

  • Armor does last longer than weapons/swords noticably so. I think this is a tad more what the player would expect ie weapons wear out faster than your trusty armor.
  • More armor pieces the damage is distributed rather than every piece taking the same damage probably more aligned with player expectations.

I'll see if I can think of any other tests to run and add them to the above as I think of them over the enxt few days

sirrobzeroone added a commit to sirrobzeroone/3d_armor that referenced this issue Dec 22, 2020
Picked up while testing  minetest-mods#34 and minetest-mods#30 that this needed to be adjusted from hitter name to hitter is player.

Hitter name was resolving to true even when mob was attacking...nil being counted as a value.

I should have picked this up before and not sure how I missed this.
BuckarooBanzay pushed a commit that referenced this issue Dec 23, 2020
Picked up while testing  #34 and #30 that this needed to be adjusted from hitter name to hitter is player.

Hitter name was resolving to true even when mob was attacking...nil being counted as a value.

I should have picked this up before and not sure how I missed this.
sirrobzeroone added a commit to sirrobzeroone/3d_armor that referenced this issue Dec 24, 2020
See Details contained in minetest-mods#34

Note1: I split out the fix for Issue 13 and it had been applied
Note2: I will also do a seperate pull request for Issue 30

From what I udnerstand smaller specific pull requests allow for reversion of specific additions and features much more easily. Please do correct me if I have the wrong end of the stick on this.
sirrobzeroone added a commit to sirrobzeroone/3d_armor that referenced this issue Dec 24, 2020
2 line update so that shields when used no longer affects the base armor.config.level_multiplier and hard sets this to 0.9 and overriding whatever value maybe set under the UI for this seeting.

Tested in combination with minetest-mods#34 but no issues detected
BuckarooBanzay pushed a commit that referenced this issue Dec 26, 2020
2 line update so that shields when used no longer affects the base armor.config.level_multiplier and hard sets this to 0.9 and overriding whatever value maybe set under the UI for this seeting.

Tested in combination with #34 but no issues detected
BuckarooBanzay pushed a commit that referenced this issue Dec 26, 2020
See Details contained in #34

Note1: I split out the fix for Issue 13 and it had been applied
Note2: I will also do a seperate pull request for Issue 30

From what I udnerstand smaller specific pull requests allow for reversion of specific additions and features much more easily. Please do correct me if I have the wrong end of the stick on this.
@BuckarooBanzay
Copy link
Member

fixed by 3ddcbae

thanks again @sirrobzeroone 👍

mckaygerhard added a commit to minenux/minetest-mod-3d_armor that referenced this issue Oct 28, 2021
mckaygerhard added a commit to minenux/minetest-mod-3d_armor that referenced this issue Oct 28, 2021
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