mirror of
				https://codeberg.org/tenplus1/mobs_redo.git
				synced 2025-11-04 01:05:51 +01:00 
			
		
		
		
	increase go_to time to 20 and add force flag to do_attack
This commit is contained in:
		
							
								
								
									
										11
									
								
								api.lua
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								api.lua
									
									
									
									
									
								
							@@ -14,7 +14,7 @@ local use_vh1 = minetest.get_modpath("visual_harm_1ndicators")
 | 
			
		||||
-- Global
 | 
			
		||||
mobs = {
 | 
			
		||||
	mod = "redo",
 | 
			
		||||
	version = "20240524",
 | 
			
		||||
	version = "20240525",
 | 
			
		||||
	translate = S,
 | 
			
		||||
	invis = minetest.global_exists("invisibility") and invisibility or {},
 | 
			
		||||
	node_snow = minetest.registered_aliases["mapgen_snow"]
 | 
			
		||||
@@ -225,9 +225,9 @@ end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-- attack player/mob
 | 
			
		||||
function mob_class:do_attack(player)
 | 
			
		||||
function mob_class:do_attack(player, force)
 | 
			
		||||
 | 
			
		||||
	if self.state == "attack" then
 | 
			
		||||
	if self.state == "attack" and not force then
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
@@ -1872,11 +1872,12 @@ minetest.register_entity("mobs:_pos", {
 | 
			
		||||
		visual = "sprite", texture = "", hp_max = 1, physical = false,
 | 
			
		||||
		static_save = false, pointable = false, is_visible = false
 | 
			
		||||
	}, health = 1, _cmi_is_mob = true,
 | 
			
		||||
 | 
			
		||||
	on_step = function(self, dtime)
 | 
			
		||||
 | 
			
		||||
		self.counter = (self.counter or 0) + dtime
 | 
			
		||||
 | 
			
		||||
		if self.counter > 10 then
 | 
			
		||||
		if self.counter > 20 then
 | 
			
		||||
			self.object:remove()
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
@@ -1888,7 +1889,7 @@ function mob_class:go_to(pos)
 | 
			
		||||
	local obj = minetest.add_entity(pos, "mobs:_pos")
 | 
			
		||||
 | 
			
		||||
	if obj and obj:get_luaentity() then
 | 
			
		||||
		self:do_attack(obj)
 | 
			
		||||
		self:do_attack(obj, true)
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								api.txt
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								api.txt
									
									
									
									
									
								
							@@ -402,7 +402,8 @@ Each mob contains a set of functions that can be called for use internally or fr
 | 
			
		||||
another mod entirely, replace mob_class with the mob entity variable:
 | 
			
		||||
 | 
			
		||||
mob_class:mob_sound(sound) -- play sound at mob position
 | 
			
		||||
mob_class:do_attack(player) -- if not already attacking, attack object given
 | 
			
		||||
mob_class:do_attack(player [, force]) -- if not already attacking, attack object given,
 | 
			
		||||
forced being true stops attacking current target and focuses on one given
 | 
			
		||||
mob_class:stop_attack() -- stops mob attacking
 | 
			
		||||
mob_class:collision() -- checks for player collision with mob and returns {x, z} vector
 | 
			
		||||
mob_class:set_velocity(velocity) -- move at velocity in the facing direction
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user