-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
154 lines (114 loc) · 6.78 KB
/
init.lua
File metadata and controls
154 lines (114 loc) · 6.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
---@type mod_calllbacks
-- api_version should be the current version of the modloader, if your mod requires a more recent version than is installed we will error
-- version is the version number of your mod
-- AdExtra:
-- * Parameters in mod list:
-- ** Hardness : 0-1 (float) Recommended 0.6
-- ** spawn_rates : 0-2 - spwaning rate
-- * Credits : ADG232 (discord)
--:::More Coming soon:::
-- Brains:
dofile("data/scripts/lua_mods/mods/AdExtra/Brains/Adag_brain.lua")
dofile("data/scripts/lua_mods/mods/AdExtra/Brains/AdagChild_brain.lua")
dofile("data/scripts/lua_mods/mods/AdExtra/Brains/Levithan_brain.lua")
dofile("data/scripts/lua_mods/mods/AdExtra/Brains/Blackhole_brain.lua")
dofile("data/scripts/lua_mods/mods/AdExtra/Brains/Lightning_Levithan_Brain.lua")
dofile("data/scripts/lua_mods/mods/AdExtra/Brains/flame_Brain.lua")
dofile("data/scripts/lua_mods/mods/AdExtra/Brains/Assasin_brain.lua")
dofile("data/scripts/lua_mods/mods/AdExtra/Brains/Creacker_brain.lua")
dofile("data/scripts/lua_mods/mods/AdExtra/Brains/stalkchewer_Brain.lua")
dofile("data/scripts/lua_mods/mods/AdExtra/Brains/Heilakorbius_brain.lua")
local M = {
api_version = 0,
version = "1.09",
Creator = "ADG"
}
---@type spawn_function
_G["AdExtra.explosion_resist"] = function(body_id, x, y)
give_mutation(body_id, MUT_EXPLOSIVE_RESISTANCE)
return {nil, nil, x, y} -- this determines spawn extra info
end
_G["AdExtra.cancer"] = function(body_id, x, y)
give_mutation(body_id, MUT_CANCER )
return {nil, nil, x, y} -- this determines spawn extra info
end
_G["AdExtra.speed"] = function(body_id, x, y)
give_mutation(body_id, MUT_DRIFTING )
return {nil, nil, x, y} -- this determines spawn extra info
end
_G["AdExtra.Lightning_Levithan"] = function(body_id, x, y)
give_mutation(body_id, MUT_CHAIN_LIGHTNING )
give_mutation(body_id, MUT_DRIFTING )
give_mutation(body_id, MUT_EXPLOSIVE_RESISTANCE )
return {nil, nil, x, y} -- this determines spawn extra info
end
_G["AdExtra.Lightning_ExplosiveRes"] = function(body_id, x, y)
give_mutation(body_id, MUT_CHAIN_LIGHTNING )
give_mutation(body_id, MUT_EXPLOSIVE_RESISTANCE )
return {nil, nil, x, y} -- this determines spawn extra info
end
-- pre hook is for changing how functions that everyone uses behaves
function M.pre(api, config)
-- shadow the add_creature_spawn_chance function so we can modify it
local old_add_creature_spawn_chance = add_creature_spawn_chance
function add_creature_spawn_chance(...)
local args = {...} -- collect the arguments into a table for easy modification
args[4] = args[4] -- this arg is the xp drop amount, so make everything drop 20x xp
return old_add_creature_spawn_chance(unpack(args)) -- call the original with the modified args
end
end
-- post hook is for defining creatures
function M.post(api, config)
api.log("--------AdExtra-------- \n" .." * Creator: ".. M.Creator .. "\n * Version: "..M.version)
local spawn_rate = config.spawn_rates or 0.05
_G["Hardness"] = config.Hardness
-- we shadow the creature_list function to call our additional code after it
local old_creature_list = creature_list
creature_list = function(...)
-- call the original
local r = {old_creature_list(...)}
-- register our creatures
register_creature(api.acquire_id("AdExtra.Adag"), "data/scripts/lua_mods/mods/AdExtra/creatures/Adag.bod",
"AdExtra.Adag_brain","AdExtra.explosion_resist")
register_creature(api.acquire_id("AdExtra.Child"), "data/scripts/lua_mods/mods/AdExtra/creatures/AdagChild.bod",
"AdExtra.AdagChild_brain")
register_creature(api.acquire_id("AdExtra.Levithan"), "data/scripts/lua_mods/mods/AdExtra/creatures/cancer_Levithan.bod",
"AdExtra.Levithan_brain","AdExtra.cancer")
register_creature(api.acquire_id("AdExtra.Black_Hole"), "data/scripts/lua_mods/mods/AdExtra/creatures/blockhole.bod",
"AdExtra.Black_Hole_Brain","AdExtra.explosion_resist")
register_creature(api.acquire_id("AdExtra.Lightning_Levithan"), "data/scripts/lua_mods/mods/AdExtra/creatures/Lightning_Levithan.bod",
"AdExtra.Lightning_Levithan_brain","AdExtra.Lightning_Levithan")
register_creature(api.acquire_id("AdExtra.Flamer"), "data/scripts/lua_mods/mods/AdExtra/creatures/flamer.bod",
"AdExtra.flame_brain","AdExtra.explosion_resist")
register_creature(api.acquire_id("AdExtra.assasin"), "data/scripts/lua_mods/mods/AdExtra/creatures/assasin.bod",
"AdExtra.Assasin_brain","AdExtra.Lightning_ExplosiveRes")
register_creature(api.acquire_id("AdExtra.Cracker"), "data/scripts/lua_mods/mods/AdExtra/creatures/Cracker.bod",
"AdExtra.Cracker")
register_creature(api.acquire_id("AdExtra.stalkchewer"), "data/scripts/lua_mods/mods/AdExtra/creatures/stalkchewer.bod",
"AdExtra.stalkchewer")
register_creature(api.acquire_id("AdExtra.Heilakorbius"), "data/scripts/lua_mods/mods/AdExtra/creatures/Heilakorbius.bod",
"AdExtra.Heilakorbius")
-- return the result of the original, not strictly neccesary here but useful in some situations
return unpack(r)
end
-- shadow init_biomes function to call our stuff afterwards
local old_init_biomes = init_biomes
init_biomes = function(...)
local r = {old_init_biomes(...)}
-- add our creatures to the starting biome, if spawn_rates are too high you will start to see issues where only some creatures can spawn
-- to fix this make sure the sum isn't too high, i will perhaps add a prehook for compat with this in future
add_creature_spawn_chance("FIRE", api.acquire_id("AdExtra.Adag"), spawn_rate, 40)
add_creature_spawn_chance("FIRE", api.acquire_id("AdExtra.Child"), spawn_rate * 1.5, 10)
add_creature_spawn_chance("STRT", api.acquire_id("AdExtra.Levithan"), spawn_rate / 11, 14)
add_creature_spawn_chance("FIRE", api.acquire_id("AdExtra.Black_Hole"), spawn_rate / 20, 100)
add_creature_spawn_chance("ICEE", api.acquire_id("AdExtra.Lightning_Levithan"), spawn_rate / 8, 300)
add_creature_spawn_chance("FIRE", api.acquire_id("AdExtra.Flamer"), spawn_rate * 0.5, 40)
add_creature_spawn_chance("ICEE", api.acquire_id("AdExtra.assasin"), spawn_rate, 40)
add_plant_spawn_chance("DARK", api.acquire_id("AdExtra.stalkchewer"), spawn_rate / 2, 200)
add_plant_spawn_chance("STRT", api.acquire_id("AdExtra.stalkchewer"), spawn_rate / 7, 200)
add_plant_spawn_chance("ICEE", api.acquire_id("AdExtra.stalkchewer"), spawn_rate / 2.2, 200)
add_plant_spawn_chance("STRT", api.acquire_id("AdExtra.Heilakorbius"), spawn_rate, 1)
return unpack(r)
end
end
return M