Compare commits
	
		
			8 Commits
		
	
	
		
			nalc-1.2.0
			...
			armorswap
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | b2ae7f9c8b | ||
|  | 33738dcff8 | ||
|  | f3ad7ec6f1 | ||
|  | fccd4d8b15 | ||
|  | e5b2cf3a34 | ||
|  | d2608351f6 | ||
|  | a05eae3782 | ||
|  | 2ac90f8d19 | 
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						| @@ -4,6 +4,7 @@ | ||||
| *bak* | ||||
| tags | ||||
| *.vim | ||||
| armor.conf | ||||
|  | ||||
| ## Eclipse project files & directories | ||||
| .project | ||||
|   | ||||
| @@ -279,6 +279,11 @@ armor.set_player_armor = function(self, player) | ||||
| 	if use_armor_monoid then | ||||
| 		armor_monoid.monoid:add_change(player, change, "3d_armor:armor") | ||||
| 	else | ||||
| 		-- Preserve immortal group (damage disabled for player) | ||||
| 		local immortal = player:get_armor_groups().immortal | ||||
| 		if immortal and immortal ~= 0 then | ||||
| 			groups.immortal = 1 | ||||
| 		end | ||||
| 		player:set_armor_groups(groups) | ||||
| 	end | ||||
| 	if use_player_monoids then | ||||
|   | ||||
| @@ -1,37 +0,0 @@ | ||||
| -- Armor Configuration (defaults) | ||||
|  | ||||
| -- Increase this if you get initialization glitches when a player first joins. | ||||
| ARMOR_INIT_DELAY = 3 | ||||
|  | ||||
| -- Number of initialization attempts. | ||||
| -- Use in conjunction with ARMOR_INIT_DELAY if initialization problems persist. | ||||
| ARMOR_INIT_TIMES = 3 | ||||
|  | ||||
| -- Increase this if armor is not getting into bones due to server lag. | ||||
| ARMOR_BONES_DELAY = 3 | ||||
|  | ||||
| -- How often player armor/wield items are updated. | ||||
| ARMOR_UPDATE_TIME = 1 | ||||
|  | ||||
| -- Drop armor when a player dies. | ||||
| -- Uses bones mod if present, otherwise items are dropped around the player. | ||||
| ARMOR_DROP = true | ||||
|  | ||||
| -- Pulverise armor when a player dies, overrides ARMOR_DROP. | ||||
| ARMOR_DESTROY = false | ||||
|  | ||||
| -- You can use this to increase or decrease overall armor effectiveness, | ||||
| -- eg: ARMOR_LEVEL_MULTIPLIER = 0.5 will reduce armor level by half. | ||||
| ARMOR_LEVEL_MULTIPLIER = 1 | ||||
|  | ||||
| -- You can use this to increase or decrease overall armor healing, | ||||
| -- eg: ARMOR_HEAL_MULTIPLIER = 0 will disable healing altogether. | ||||
| ARMOR_HEAL_MULTIPLIER = 1 | ||||
|  | ||||
| -- You can also use this file to execute arbitary lua code | ||||
| -- eg: Dumb the armor down if using Simple Mobs | ||||
| --if minetest.get_modpath("mobs") then | ||||
| --	ARMOR_LEVEL_MULTIPLIER = 1 | ||||
| --	ARMOR_HEAL_MULTIPLIER = 0 | ||||
| --end | ||||
|  | ||||
| @@ -99,17 +99,27 @@ armor.formspec = armor.formspec.. | ||||
| if armor.config.fire_protect then | ||||
| 	armor.formspec = armor.formspec.."label[5,2;"..F(S("Fire"))..":  armor_attr_fire]" | ||||
| end | ||||
| armor:register_on_damage(function(player, index, stack) | ||||
| 	local name = player:get_player_name() | ||||
| 	local def = stack:get_definition() | ||||
| 	if name and def and def.description and stack:get_wear() > 60100 then | ||||
| 		minetest.chat_send_player(name, S("Your @1 is almost broken!", def.description)) | ||||
| 		minetest.sound_play("default_tool_breaks", {to_player = name, gain = 2.0}) | ||||
| 	end | ||||
| end) | ||||
| armor:register_on_destroy(function(player, index, stack) | ||||
| 	local name = player:get_player_name() | ||||
| 	local def = stack:get_definition() | ||||
| 	if name and def and def.description then | ||||
| 		minetest.chat_send_player(name, S("Your @1 got destroyed!", def.description)) | ||||
| 		minetest.sound_play("default_tool_breaks", {to_player = name, gain = 2.0}) | ||||
| 	end | ||||
| end) | ||||
|  | ||||
| local function validate_armor_inventory(player) | ||||
| 	-- Workaround for detached inventory swap exploit | ||||
| 	local _, inv = armor:get_valid_player(player, "[validate_armor_inventory]") | ||||
| 	local pos = player:get_pos() | ||||
| 	if not inv then | ||||
| 		return | ||||
| 	end | ||||
| @@ -140,6 +150,7 @@ local function validate_armor_inventory(player) | ||||
| 				elements[element] = true; | ||||
| 			else | ||||
| 				inv:remove_item("armor", stack) | ||||
| 				minetest.item_drop(stack, player, pos) | ||||
| 				-- The following code returns invalid items to the player's main | ||||
| 				-- inventory but could open up the possibity for a hacked client | ||||
| 				-- to receive items back they never really had. I am not certain | ||||
| @@ -330,8 +341,8 @@ if armor.config.drop == true or armor.config.destroy == true then | ||||
| 		if pos and armor.config.destroy == false then | ||||
| 			minetest.after(armor.config.bones_delay, function() | ||||
| 				local meta = nil | ||||
| 				local maxp = vector.add(pos, 8) | ||||
| 				local minp = vector.subtract(pos, 8) | ||||
| 				local maxp = vector.add(pos, 16) | ||||
| 				local minp = vector.subtract(pos, 16) | ||||
| 				local bones = minetest.find_nodes_in_area(minp, maxp, {"bones:bones"}) | ||||
| 				for _, p in pairs(bones) do | ||||
| 					local m = minetest.get_meta(p) | ||||
| @@ -467,5 +478,3 @@ if armor.config.water_protect == true or armor.config.fire_protect == true then | ||||
| 		armor.timer = 0 | ||||
| 	end) | ||||
| end | ||||
|  | ||||
| minetest.log("action", "[3d_armor] loaded.") | ||||
|   | ||||
| Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 548 B After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 937 B After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 602 B After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 903 B After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 821 B After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 872 B After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 779 B After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 854 B After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 530 B After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 783 B After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 501 B After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.2 KiB | 
| Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 3.3 KiB | 
| Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.2 KiB | 
| Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 613 B After Width: | Height: | Size: 3.2 KiB | 
| Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 3.3 KiB | 
| Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 3.2 KiB | 
| Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 3.3 KiB | 
| Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 3.2 KiB | 
| Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 3.1 KiB | 
| Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB | 
| Before Width: | Height: | Size: 869 B After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 3.2 KiB | 
| Before Width: | Height: | Size: 796 B After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.1 KiB | 
| Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 494 B After Width: | Height: | Size: 3.2 KiB | 
| Before Width: | Height: | Size: 834 B After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 3.2 KiB | 
| Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 3.1 KiB | 
| Before Width: | Height: | Size: 586 B After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 3.1 KiB | 
| Before Width: | Height: | Size: 732 B After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 3.2 KiB | 
| Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 932 B After Width: | Height: | Size: 3.1 KiB | 
| Before Width: | Height: | Size: 471 B After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 129 B After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 142 B After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 3.1 KiB | 
| Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 138 B After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 2.8 KiB | 
| Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 154 B After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 2.9 KiB | 
| Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 2.9 KiB |