mirror of
				https://codeberg.org/tenplus1/mobs_redo.git
				synced 2025-10-25 22:05:25 +02:00 
			
		
		
		
	Compare commits
	
		
			2 Commits
		
	
	
		
			bf32a09e5e
			...
			76ee3d0b51
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 76ee3d0b51 | ||
|  | 00ac9efc8c | 
							
								
								
									
										27
									
								
								api.lua
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								api.lua
									
									
									
									
									
								
							| @@ -8,7 +8,7 @@ local use_cmi = minetest.global_exists("cmi") | ||||
|  | ||||
| mobs = { | ||||
| 	mod = "redo", | ||||
| 	version = "20201206", | ||||
| 	version = "20210104", | ||||
| 	intllib = S, | ||||
| 	invis = minetest.global_exists("invisibility") and invisibility or {} | ||||
| } | ||||
| @@ -65,6 +65,7 @@ local max_per_block = tonumber(settings:get("max_objects_per_block") or 99) | ||||
| local mob_nospawn_range = tonumber(settings:get("mob_nospawn_range") or 12) | ||||
| local active_limit = tonumber(settings:get("mob_active_limit") or 0) | ||||
| local mob_chance_multiplier = tonumber(settings:get("mob_chance_multiplier") or 1) | ||||
| local peaceful_player_enabled = settings:get_bool("enable_peaceful_player") | ||||
| local active_mobs = 0 | ||||
|  | ||||
|  | ||||
| @@ -1848,6 +1849,23 @@ function mob_class:smart_mobs(s, p, dist, dtime) | ||||
| end | ||||
|  | ||||
|  | ||||
| -- peaceful player privilege support | ||||
| local function is_peaceful_player(player) | ||||
|  | ||||
| 	if peaceful_player_enabled then | ||||
|  | ||||
| 		local player_name = player:get_player_name() | ||||
|  | ||||
| 		if player_name | ||||
| 		and minetest.check_player_privs(player_name, "peaceful_player") then | ||||
| 			return true | ||||
| 		end | ||||
| 	end | ||||
|  | ||||
| 	return false | ||||
| end | ||||
|  | ||||
|  | ||||
| -- general attack function for all mobs | ||||
| function mob_class:general_attack() | ||||
|  | ||||
| @@ -1920,7 +1938,8 @@ function mob_class:general_attack() | ||||
| 		-- choose closest player to attack that isnt self | ||||
| 		if dist ~= 0 | ||||
| 		and dist < min_dist | ||||
| 		and self:line_of_sight(sp, p, 2) == true then | ||||
| 		and self:line_of_sight(sp, p, 2) == true | ||||
| 		and not is_peaceful_player(player) then | ||||
| 			min_dist = dist | ||||
| 			min_player = player | ||||
| 		end | ||||
| @@ -4503,10 +4522,10 @@ function mobs:capture_mob(self, clicker, chance_hand, chance_net, | ||||
| 				minetest.add_item(clicker:get_pos(), new_stack) | ||||
| 			end | ||||
|  | ||||
| 			remove_mob(self, true) | ||||
|  | ||||
| 			self:mob_sound("default_place_node_hard") | ||||
|  | ||||
| 			remove_mob(self, true) | ||||
|  | ||||
| 			return new_stack | ||||
|  | ||||
| 		-- when chance above fails or set to 0, miss! | ||||
|   | ||||
							
								
								
									
										6
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								init.lua
									
									
									
									
									
								
							| @@ -1,6 +1,12 @@ | ||||
|  | ||||
| local path = minetest.get_modpath("mobs") | ||||
|  | ||||
| -- Peaceful player privilege | ||||
| minetest.register_privilege("peaceful_player", { | ||||
| 	description = "Prevents Mobs Redo mobs from attacking player", | ||||
| 	give_to_singleplayer = false | ||||
| }) | ||||
|  | ||||
| -- Mob API | ||||
| dofile(path .. "/api.lua") | ||||
|  | ||||
|   | ||||
| @@ -23,6 +23,7 @@ Lucky Blocks: 9 | ||||
|  | ||||
|  | ||||
| Changelog: | ||||
| - 1.55 - Add 'peaceful_player' privelage and setting so mobs don't attack specific players (thanks sfence) | ||||
| - 1.54 - Simplified animal breeding function, added editable settings (thanks Wuzzy), Child mobs now take 20 mins to grow up, reverted to simple mob spawning with setting to use area checks, on_flop added, air_damage added. | ||||
| - 1.53 - Added 'on_map_load' settings to mobs:spawn so that mobs will only spawn when new areas of map are loaded. | ||||
| - 1.52 - Added 'mob_active_limit' in settings to set number of mobs in game, | ||||
|   | ||||
| @@ -36,3 +36,6 @@ mob_active_limit (Mob Active Limit) float 0 | ||||
|  | ||||
| #    Enables area check when spawning mobs | ||||
| mob_area_spawn (Mob Area Spawn) bool false | ||||
|  | ||||
| #    Enable peaceful player attack prevention | ||||
| enable_peaceful_player (Mobs do not attack peaceful player without reason) bool false | ||||
|   | ||||
		Reference in New Issue
	
	Block a user