X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=mods%2Fmob%2Fapi%2Fapi_hook.lua;h=6d1c2870f99666d45d7c29735df29bf6535a1f9b;hb=242a3d1665399c43fc68e3ae36cb5bf01334d98a;hp=453ad1e646f69474392f335201266ad0ba02a775;hpb=37b4eded9b2434e84a0770b4e07fb62e7831fd7b;p=Crafter.git diff --git a/mods/mob/api/api_hook.lua b/mods/mob/api/api_hook.lua index 453ad1e..6d1c287 100644 --- a/mods/mob/api/api_hook.lua +++ b/mods/mob/api/api_hook.lua @@ -1,3 +1,4 @@ +local minetest = minetest --class mobs = {} @@ -15,6 +16,8 @@ mobs.register_mob = function(def) local mob_register = {} +register_mob_spawner(def.mobname,def.textures,def.mesh) + ------------------------------------------------ mob_register.initial_properties = { physical = def.physical, @@ -29,6 +32,7 @@ mob_register.initial_properties = { automatic_face_movement_dir = def.automatic_face_movement_dir, automatic_face_movement_max_rotation_per_sec = def.automatic_face_movement_max_rotation_per_sec, makes_footstep_sound = def.makes_footstep_sound, + static_save = false, } @@ -46,8 +50,9 @@ if def.head_bone then mob_register.head_rotation_offset = def.head_rotation_offset mob_register.head_position_correction = def.head_position_correction mob_register.head_coord = def.head_coord + mob_register.flip_pitch = def.flip_pitch else - print("create some other functions to turn mob " .. def.mobname) + --print("create some other functions to turn mob " .. def.mobname) end mob_register.hurt_inside_timer = 0 @@ -55,7 +60,14 @@ mob_register.death_animation_timer = 0 mob_register.dead = false mob_register.mob = true +mob_register.mobname = def.mobname + mob_register.hostile = def.hostile +if def.friendly_in_daylight == true then + mob_register.friendly_in_daylight = def.friendly_in_daylight + mob_register.friendly_in_daylight_timer = 0 +end + mob_register.hostile_cooldown = def.hostile_cooldown mob_register.hostile_timer = 0 @@ -74,6 +86,7 @@ mob_register.group_attack = def.group_attack mob_register.death_rotation = def.death_rotation mob_register.head_mount = def.head_mount +mob_register.rotational_correction = def.rotational_correction or 0 mob_register.hurt_sound = def.hurt_sound mob_register.die_sound = def.die_sound @@ -81,6 +94,7 @@ mob_register.die_sound = def.die_sound mob_register.attack_type = def.attack_type if def.attack_type == "explode" then mob_register.tnt_tick_timer = 0 + mob_register.explosion_type = def.explosion_type end mob_register.explosion_radius = def.explosion_radius mob_register.explosion_power = def.explosion_power @@ -90,10 +104,16 @@ mob_register.explosion_blink_color = def.explosion_blink_color or "white" mob_register.explosion_blink_timer = def.explosion_blink_timer or 0.2 mob_register.custom_function_begin = def.custom_function_begin +mob_register.custom_function = def.custom_function mob_register.custom_function_end = def.custom_function_end + mob_register.projectile_timer_cooldown = def.projectile_timer_cooldown mob_register.attacked_hostile = def.attacked_hostile - +if not def.hostile and not def.attacked_hostile then + mob_register.scared = false + mob_register.scared_timer = 0 +end +mob_register.attack_damage = def.attack_damage mob_register.projectile_timer = 0 mob_register.projectile_type = def.projectile_type @@ -115,12 +135,34 @@ mob_register.hurt_color_timer = 0 mob_register.damage_color = def.damage_color or "red" mob_register.custom_on_death = def.custom_on_death -mob_register.mob = true +mob_register.custom_on_activate = def.custom_on_activate + +mob_register.custom_on_punch = def.custom_on_punch + +mob_register.c_mob_data = def.c_mob_data + +mob_register.deactivating = false + +mob_register.on_fire = false + +mob_register.fire_table = def.fire_table + +mob_register.sound_pitch_mod_min = def.sound_pitch_mod_min +mob_register.sound_pitch_mod_max = def.sound_pitch_mod_max + +mob_register.sound_pitch_mod_min_die = def.sound_pitch_mod_min_die +mob_register.sound_pitch_mod_max_die = def.sound_pitch_mod_max_die -mob_register.collision_boundary = def.collision_boundary or 1 if def.pathfinds then - mob_register.path = {} + --mob_register.path = {} + mob_register.pathfinding_timer = 0 +end + +if def.custom_timer then + mob_register.c_timer = 0 + mob_register.custom_timer = def.custom_timer + mob_register.custom_timer_function = def.custom_timer_function end mobs.create_movement_functions(def,mob_register) @@ -141,9 +183,24 @@ mob_register.on_step = function(self, dtime,moveresult) end if self.dead == false and self.death_animation_timer == 0 then + if self.do_custom_timer then + self.do_custom_timer(self,dtime) + end + + if self.custom_function then + self.custom_function(self,dtime,moveresult) + end + self.move(self,dtime,moveresult) + --self.debug_nametag(self,dtime) + self.manage_hurt_color_timer(self,dtime) + + if self.manage_scared_timer then + self.manage_scared_timer(self,dtime) + end + if self.set_animation then self.set_animation(self) end @@ -152,6 +209,14 @@ mob_register.on_step = function(self, dtime,moveresult) self.look_around(self,dtime) end + if self.pathfinding then + self.pathfinding(self,dtime) + end + + if self.handle_friendly_in_daylight_timer then + self.handle_friendly_in_daylight_timer(self,dtime) + end + self.manage_punch_timer(self,dtime) else self.manage_death_animation(self,dtime)