Clean up grass block group stuff
[MineClone/MineClone2.git] / mods / ENTITIES / mobs_mc / iron_golem.lua
blob0c30e6d6746300c44435e93d45e9cb8842520dbc
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")
11 --###################
12 --################### IRON GOLEM
13 --###################
17 mobs:register_mob("mobs_mc:iron_golem", {
18 type = "npc",
19 passive = true,
20 hp_min = 100,
21 hp_max = 100,
22 collisionbox = {-0.7, -0.01, -0.7, 0.7, 2.69, 0.7},
23 visual = "mesh",
24 mesh = "mobs_mc_iron_golem.b3d",
25 textures = {
26 {"mobs_mc_iron_golem.png"},
28 visual_size = {x=3, y=3},
29 makes_footstep_sound = true,
30 sounds = {
31 -- TODO
32 distance = 16,
34 view_range = 16,
35 stepheight = 1.1,
36 owner = "",
37 order = "follow",
38 floats = 0,
39 walk_velocity = 0.6,
40 run_velocity = 1.2,
41 -- Approximation
42 damage = 14,
43 reach = 3,
44 group_attack = true,
45 attacks_monsters = true,
46 attack_type = "dogfight",
47 drops = {
48 {name = mobs_mc.items.iron_ingot,
49 chance = 1,
50 min = 3,
51 max = 5,},
52 {name = mobs_mc.items.poppy,
53 chance = 1,
54 min = 0,
55 max = 2,},
57 water_damage = 0,
58 lava_damage = 4,
59 light_damage = 0,
60 fall_damage = 0,
61 animation = {
62 stand_speed = 15, walk_speed = 15, run_speed = 25, punch_speed = 15,
63 stand_start = 0, stand_end = 0,
64 walk_start = 0, walk_end = 40,
65 run_start = 0, run_end = 40,
66 punch_start = 40, punch_end = 50,
68 jump = true,
69 blood_amount = 0,
73 -- spawn eggs
74 mobs:register_egg("mobs_mc:iron_golem", S("Iron Golem"), "mobs_mc_spawn_icon_iron_golem.png", 0)
77 --[[ This is to be called when a pumpkin or jack'o lantern has been placed. Recommended: In the on_construct function of the node.
78 This summons an iron golen if placing the pumpkin created an iron golem summon pattern:
80 .P.
81 III
82 .I.
84 P = Pumpkin or jack'o lantern
85 I = Iron block
86 . = Air
89 mobs_mc.tools.check_iron_golem_summon = function(pos)
90 local checks = {
91 -- These are the possible placement patterns, with offset from the pumpkin block.
92 -- These tables include the positions of the iron blocks (1-4) and air blocks (5-8)
93 -- 4th element is used to determine spawn position.
94 -- If a 9th element is present, that one is used for the spawn position instead.
95 -- Standing (x axis)
97 {x=-1, y=-1, z=0}, {x=1, y=-1, z=0}, {x=0, y=-1, z=0}, {x=0, y=-2, z=0}, -- iron blocks
98 {x=-1, y=0, z=0}, {x=1, y=0, z=0}, {x=-1, y=-2, z=0}, {x=1, y=-2, z=0}, -- air
100 -- Upside down standing (x axis)
102 {x=-1, y=1, z=0}, {x=1, y=1, z=0}, {x=0, y=1, z=0}, {x=0, y=2, z=0},
103 {x=-1, y=0, z=0}, {x=1, y=0, z=0}, {x=-1, y=2, z=0}, {x=1, y=2, z=0},
104 {x=0, y=0, z=0}, -- Different offset for upside down pattern
107 -- Standing (z axis)
109 {x=0, y=-1, z=-1}, {x=0, y=-1, z=1}, {x=0, y=-1, z=0}, {x=0, y=-2, z=0},
110 {x=0, y=0, z=-1}, {x=0, y=0, z=1}, {x=0, y=-2, z=-1}, {x=0, y=-2, z=1},
112 -- Upside down standing (z axis)
114 {x=0, y=1, z=-1}, {x=0, y=1, z=1}, {x=0, y=1, z=0}, {x=0, y=2, z=0},
115 {x=0, y=0, z=-1}, {x=0, y=0, z=1}, {x=0, y=2, z=-1}, {x=0, y=2, z=1},
116 {x=0, y=0, z=0},
119 -- Lying
121 {x=-1, y=0, z=-1}, {x=0, y=0, z=-1}, {x=1, y=0, z=-1}, {x=0, y=0, z=-2},
122 {x=-1, y=0, z=0}, {x=1, y=0, z=0}, {x=-1, y=0, z=-2}, {x=1, y=0, z=-2},
125 {x=-1, y=0, z=1}, {x=0, y=0, z=1}, {x=1, y=0, z=1}, {x=0, y=0, z=2},
126 {x=-1, y=0, z=0}, {x=1, y=0, z=0}, {x=-1, y=0, z=2}, {x=1, y=0, z=2},
129 {x=-1, y=0, z=-1}, {x=-1, y=0, z=0}, {x=-1, y=0, z=1}, {x=-2, y=0, z=0},
130 {x=0, y=0, z=-1}, {x=0, y=0, z=1}, {x=-2, y=0, z=-1}, {x=-2, y=0, z=1},
133 {x=1, y=0, z=-1}, {x=1, y=0, z=0}, {x=1, y=0, z=1}, {x=2, y=0, z=0},
134 {x=0, y=0, z=-1}, {x=0, y=0, z=1}, {x=2, y=0, z=-1}, {x=2, y=0, z=1},
140 for c=1, #checks do
141 -- Check all possible patterns
142 local ok = true
143 -- Check iron block nodes
144 for i=1, 4 do
145 local cpos = vector.add(pos, checks[c][i])
146 local node = minetest.get_node(cpos)
147 if node.name ~= mobs_mc.items.iron_block then
148 ok = false
149 break
152 -- Check air nodes
153 for a=5, 8 do
154 local cpos = vector.add(pos, checks[c][a])
155 local node = minetest.get_node(cpos)
156 if node.name ~= "air" then
157 ok = false
158 break
161 -- Pattern found!
162 if ok then
163 -- Remove the nodes
164 minetest.remove_node(pos)
165 core.check_for_falling(pos)
166 for i=1, 4 do
167 local cpos = vector.add(pos, checks[c][i])
168 minetest.remove_node(cpos)
169 core.check_for_falling(cpos)
171 -- Summon iron golem
172 local place
173 if checks[c][9] then
174 place = vector.add(pos, checks[c][9])
175 else
176 place = vector.add(pos, checks[c][4])
178 place.y = place.y - 0.5
179 minetest.add_entity(place, "mobs_mc:iron_golem")
180 break
185 if minetest.settings:get_bool("log_mods") then
186 minetest.log("action", "MC Iron Golem loaded")