Version 0.42.1
[MineClone/MineClone2.git] / mods / ENTITIES / mobs_mc / wither.lua
blob4c85390ecaacbcb96d9bf44e8c5564ab6431c821
1 --MCmobs v0.4
2 --maikerumine
3 --made for MC like Survival game
4 --License for code WTFPL and otherwise stated in readmes
6 -- intllib
7 local MP = minetest.get_modpath(minetest.get_current_modname())
8 local S, NS = dofile(MP.."/intllib.lua")
10 --dofile(minetest.get_modpath("mobs").."/api.lua")
13 --###################
14 --################### WITHER
15 --###################
18 mobs:register_mob("mobs_mc:wither", {
19 type = "monster",
20 hp_max = 300,
21 hp_min = 300,
22 armor = 80,
23 -- This deviates from MC Wiki's size, which makes no sense
24 collisionbox = {-0.9, 0.4, -0.9, 0.9, 2.45, 0.9},
25 visual = "mesh",
26 mesh = "mobs_mc_wither.b3d",
27 textures = {
28 {"mobs_mc_wither.png"},
30 visual_size = {x=4, y=4},
31 makes_footstep_sound = true,
32 view_range = 16,
33 fear_height = 4,
34 walk_velocity = 2,
35 run_velocity = 4,
36 stepheight = 1.2,
37 sounds = {
38 shoot_attack = "mobs_mc_ender_dragon_shoot",
39 attack = "mobs_mc_ender_dragon_attack",
40 -- TODO: sounds
41 distance = 60,
43 jump = true,
44 jump_height = 10,
45 jump_chance = 98,
46 fly = true,
47 dogshoot_switch = 1,
48 dogshoot_count_max =1,
49 attack_animals = true,
50 floats=1,
51 drops = {
52 {name = mobs_mc.items.nether_star,
53 chance = 1,
54 min = 1,
55 max = 1},
57 water_damage = 0,
58 lava_damage = 0,
59 light_damage = 0,
60 attack_type = "dogshoot",
61 explosion_radius = 3,
62 explosion_fire = false,
63 dogshoot_stop = true,
64 arrow = "mobs_mc:fireball",
65 reach = 5,
66 shoot_interval = 0.5,
67 shoot_offset = -1,
68 animation = {
69 walk_speed = 12, run_speed = 12, stand_speed = 12,
70 stand_start = 0, stand_end = 20,
71 walk_start = 0, walk_end = 20,
72 run_start = 0, run_end = 20,
74 blood_amount = 0,
77 local mobs_griefing = minetest.settings:get_bool("mobs_griefing") ~= false
79 mobs:register_arrow("mobs_mc:roar_of_the_dragon", {
80 visual = "sprite",
81 visual_size = {x = 1, y = 1},
82 textures = {"blank.png"},
83 velocity = 10,
85 on_step = function(self, dtime)
87 local pos = self.object:getpos()
89 local n = minetest.get_node(pos).name
91 if self.timer == 0 then
92 self.timer = os.time()
93 end
95 if os.time() - self.timer > 8 or minetest.is_protected(pos, "") then
96 self.object:remove()
97 end
99 local objects = minetest.get_objects_inside_radius(pos, 1)
100 for _,obj in ipairs(objects) do
101 local name = self.name
102 if name~="mobs_mc:roar_of_the_dragon" and name ~= "mobs_mc:wither" then
103 obj:set_hp(obj:get_hp()-0.05)
104 if (obj:get_hp() <= 0) then
105 if (not obj:is_player()) and name ~= self.object:get_luaentity().name then
106 obj:remove()
112 if mobs_griefing then
113 minetest.set_node(pos, {name="air"})
114 if math.random(1,2)==1 then
115 local dx = math.random(-1,1)
116 local dy = math.random(-1,1)
117 local dz = math.random(-1,1)
118 local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
119 minetest.set_node(p, {name="air"})
124 --GOOD LUCK LOL!
125 -- fireball (weapon)
126 mobs:register_arrow(":mobs_mc:fireball", {
127 visual = "sprite",
128 visual_size = {x = 0.75, y = 0.75},
129 -- TODO: 3D projectile, replace tetxture
130 textures = {"mobs_mc_TEMP_wither_projectile.png"},
131 velocity = 6,
133 -- direct hit, no fire... just plenty of pain
134 hit_player = function(self, player)
135 minetest.sound_play("tnt_explode", {pos = pos, gain = 1.5, max_hear_distance = 16})
136 player:punch(self.object, 1.0, {
137 full_punch_interval = 0.5,
138 damage_groups = {fleshy = 8},
139 }, nil)
141 end,
143 hit_mob = function(self, player)
144 minetest.sound_play("tnt_explode", {pos = pos, gain = 1.5,max_hear_distance = 16})
145 player:punch(self.object, 1.0, {
146 full_punch_interval = 0.5,
147 damage_groups = {fleshy = 8},
148 }, nil)
150 end,
152 -- node hit, bursts into flame
153 hit_node = function(self, pos, node)
154 -- FIXME: Deprecated, switch to mobs:boom instead
155 mobs:explosion(pos, 3, 0, 1)
158 --Spawn egg
159 mobs:register_egg("mobs_mc:wither", S("Wither"), "mobs_mc_spawn_icon_wither.png", 0)
161 --Compatibility
162 mobs:alias_mob("nssm:mese_dragon", "mobs_mc:wither")