Add icons to mobs, randomseed experiment
parent
dfab21fbc3
commit
1e6ced3782
|
@ -52,7 +52,7 @@ function adventuretest.check_spawn(player)
|
|||
if adventuretest.obj_stuck(player) == true then
|
||||
print("moving player "..tostring(count))
|
||||
local pos = player:getpos()
|
||||
math.randomseed(os.time())
|
||||
--math.randomseed(os.time())
|
||||
newpos.x = pos.x + math.random(-50,50)
|
||||
newpos.z = pos.z + math.random(-50,50)
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
-- VARIOUS MISC ADVENTURETEST RELATED STUFF
|
||||
adventuretest = {}
|
||||
|
||||
adventuretest.seed = os.time()
|
||||
|
||||
game_origin = nil
|
||||
if minetest.setting_get("game_origin") ~= nil then
|
||||
game_origin = minetest.string_to_pos(minetest.setting_get("game_origin"))
|
||||
|
|
|
@ -20,6 +20,8 @@ local function adventuretest_globalstep(dtime)
|
|||
|
||||
abm_globalstep(dtime)
|
||||
--ambience_globalstep(dtime)
|
||||
adventuretest.seed = adventuretest.seed + dtime
|
||||
math.randomseed(adventuretest.seed)
|
||||
end
|
||||
minetest.register_globalstep(adventuretest_globalstep)
|
||||
|
||||
|
|
|
@ -460,7 +460,7 @@ function default.get_file_contents(filename)
|
|||
end
|
||||
|
||||
function randomChance (percent)
|
||||
math.randomseed( os.clock() )
|
||||
--math.randomseed( os.clock() )
|
||||
return percent >= ( math.random(1000, 100000) / 1000 )
|
||||
end
|
||||
|
||||
|
|
|
@ -1281,7 +1281,7 @@ minetest.register_abm({
|
|||
skilled_item = true
|
||||
end
|
||||
|
||||
math.randomseed(os.time() + probability)
|
||||
--math.randomseed(os.time() + probability)
|
||||
local r = math.random(1,99)
|
||||
|
||||
if r < probability then
|
||||
|
|
|
@ -52,7 +52,7 @@ minetest.register_abm({
|
|||
chance = 3,
|
||||
action = function (pos, node)
|
||||
-- default:grass_# # = 1-5
|
||||
math.randomseed(os.time())
|
||||
--math.randomseed(os.time())
|
||||
local grass = math.random(1,5)
|
||||
local node = "default:grass_" .. grass
|
||||
minetest.set_node(pos,{name=node})
|
||||
|
|
|
@ -116,7 +116,7 @@ minetest.register_on_generated( function (minp, maxp, blockseed)
|
|||
|
||||
local size = xsize * zsize
|
||||
|
||||
math.randomseed(os.clock())
|
||||
--math.randomseed(os.clock())
|
||||
local fillratio = ( math.random(8,14) / 100 )
|
||||
local numgoblins = 2 + ( ((xsize * 2) * (zsize * 2)) * fillratio )
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ function mobs:register_mob(name, def)
|
|||
avoid_nodes = def.avoid_nodes or nil,
|
||||
avoid_range = def.avoid_range or nil,
|
||||
random_freq = def.random_freq or 1,
|
||||
icon = def.icon or nil,
|
||||
|
||||
stimer = 0,
|
||||
timer = 0,
|
||||
|
@ -137,6 +138,7 @@ function mobs:register_mob(name, def)
|
|||
if self.sounds.war_cry then
|
||||
if math.random(0,100) < 90 then
|
||||
minetest.sound_play(self.sounds.war_cry,{ object = self.object })
|
||||
mobs.put_icon(self,"mobs:icon_notice",3)
|
||||
end
|
||||
end
|
||||
self.state = "attack"
|
||||
|
@ -323,6 +325,9 @@ function mobs:register_mob(name, def)
|
|||
if self.lifetimer <= 0 and not self.tamed and self.type ~= "npc" then
|
||||
self.object:remove()
|
||||
end
|
||||
if self.icon ~= nil then
|
||||
mobs.put_icon(self,self.icon,false)
|
||||
end
|
||||
end,
|
||||
|
||||
get_staticdata = function(self)
|
||||
|
@ -554,7 +559,7 @@ function mobs:spawn_mob(pos,name)
|
|||
mob.object:set_hp( newHP )
|
||||
mob.state = "walk" -- make them walk when they spawn so they walk away from their original spawn position
|
||||
-- vary the walk and run velocity when a mob is spawned so groups of mobs don't clump up so bad
|
||||
math.randomseed(os.clock())
|
||||
--math.randomseed(os.clock())
|
||||
|
||||
mob.walk_velocity = mob.walk_velocity - ( mob.walk_velocity * ( math.random(0,12) / 100 ) )
|
||||
if mob.walk_velocity < 0 then
|
||||
|
@ -565,6 +570,9 @@ function mobs:spawn_mob(pos,name)
|
|||
if mob.run_velocity < 0 then
|
||||
mob.run_velocity = 0
|
||||
end
|
||||
if mob.icon ~= nil then
|
||||
mobs.put_icon(mob,mob.icon,false)
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
@ -572,8 +580,8 @@ end
|
|||
|
||||
function mobs:get_random(type)
|
||||
if mobs.mob_list[type] ~= nil then
|
||||
local seed = os.clock() + os.time()
|
||||
math.randomseed(seed)
|
||||
--local seed = os.clock() + os.time()
|
||||
--math.randomseed(seed)
|
||||
local idx = math.random(1,#mobs.mob_list[type])
|
||||
if mobs.mob_list[type][idx] ~= nil then
|
||||
return mobs.mob_list[type][idx]
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
function mobs.register_icon(name,texture)
|
||||
minetest.register_entity(name, {
|
||||
physical = false,
|
||||
visual = "sprite",
|
||||
visual_size = { x=0.4,y=0.4 },
|
||||
textures = {texture},
|
||||
timeout = 0,
|
||||
timer = 0,
|
||||
on_step = function (self, dtime)
|
||||
self.timer = self.timer + dtime
|
||||
if self.timeout ~= false and self.timer > self.timeout then
|
||||
-- remove the entity when it times out
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
function mobs.put_icon(obj,icon,timeout)
|
||||
local pos = obj.object:getpos()
|
||||
local iobj = minetest.add_entity({x=pos.x,y=(pos.y+3),z=pos.z},icon)
|
||||
if iobj ~= nil then
|
||||
print("putting icon ")
|
||||
iobj = iobj:get_luaentity()
|
||||
iobj.timeout = timeout
|
||||
iobj.object:set_attach(obj.object,"",{x = 0, y = 10, z = 0}, {x = 0, y = 0, z = 0})
|
||||
else
|
||||
print("failed to add entity")
|
||||
end
|
||||
end
|
||||
|
||||
mobs.register_icon("mobs:icon_notice","mobs_icon_notice.png")
|
||||
mobs.register_icon("mobs:icon_quest","mobs_icon_quest.png")
|
||||
mobs.register_icon("mobs:icon_sell","mobs_icon_sell.png")
|
|
@ -22,6 +22,8 @@ dofile(minetest.get_modpath("mobs").."/animals/rat.lua")
|
|||
dofile(minetest.get_modpath("mobs").."/animals/sheep.lua")
|
||||
dofile(minetest.get_modpath("mobs").."/animals/rabbits.lua")
|
||||
|
||||
dofile(minetest.get_modpath("mobs").."/icons.lua")
|
||||
|
||||
if minetest.setting_get("log_mods") then
|
||||
minetest.log("action", "mobs loaded")
|
||||
end
|
|
@ -29,6 +29,7 @@ mobs:register_mob("mobs:blacksmith",{
|
|||
blacksmith_formspec(self,clicker)
|
||||
else
|
||||
minetest.sound_play("mobs_blacksmith_sorry",{pos=self.object:getpos(),max_hear_distance=12,gain=0.6})
|
||||
mobs.put_icon(self,"mobs:icon_notice",5)
|
||||
end
|
||||
end,
|
||||
walk_chance = 1,
|
||||
|
@ -71,6 +72,7 @@ function blacksmith_formspec(self,player)
|
|||
if active_blacksmiths[name] == nil then
|
||||
mobs:face_pos(self,player:getpos())
|
||||
minetest.sound_play("mobs_blacksmith_what",{pos=self.object:getpos(),max_hear_distance=12,gain=0.6})
|
||||
mobs.put_icon(self,"mobs:icon_notice",5)
|
||||
active_blacksmiths[name] = {entity=self,inventory=nil,player=player,furnace=nil,active=false}
|
||||
local formspec = "size[8,6.25]"..
|
||||
"list[current_player;main;0,2.5;8,4;]"..
|
||||
|
@ -81,6 +83,7 @@ function blacksmith_formspec(self,player)
|
|||
minetest.show_formspec(name,"blacksmith",formspec)
|
||||
else
|
||||
minetest.sound_play("mobs_blacksmith_sorry",{pos=self.object:getpos(),max_hear_distance=12,gain=0.6})
|
||||
mobs.put_icon(self,"mobs:icon_notice",5)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -111,6 +114,7 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
|
|||
local stack = inv:get_stack("src",1)
|
||||
if stack:get_count() == 0 then
|
||||
chat.local_chat(player:getpos(),"Blacksmith: Please give me something to smelt",3)
|
||||
mobs.put_icon(blacksmith,"mobs:icon_notice",5)
|
||||
active_blacksmiths[name] = nil
|
||||
return
|
||||
else
|
||||
|
@ -135,6 +139,7 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
|
|||
if money.get(name) < crNeeded then
|
||||
chat.local_chat(player:getpos(),"Blacksmith: Sorry, you don't have enough money. I charge 2cr per lump.")
|
||||
minetest.sound_play("mobs_blacksmith_sorry",{pos=blacksmith.object:getpos(),max_hear_distance=12,gain=0.6})
|
||||
mobs.put_icon(blacksmith,"mobs:icon_notice",5)
|
||||
active_blacksmiths[name] = nil
|
||||
return
|
||||
end
|
||||
|
@ -150,12 +155,14 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
|
|||
else
|
||||
chat.local_chat(player:getpos(),"Blacksmith: Sorry, I can't get to the furance.",3)
|
||||
minetest.sound_play("mobs_blacksmith_sorry",{pos=blacksmith.object:getpos(),max_hear_distance=12,gain=0.6})
|
||||
mobs.put_icon(blacksmith,"mobs:icon_notice",5)
|
||||
active_blacksmiths[name] = nil
|
||||
return
|
||||
end
|
||||
else
|
||||
chat.local_chat(player:getpos(),"Blacksmith: Sorry, I don't see a furance in this area.",3)
|
||||
minetest.sound_play("mobs_blacksmith_sorry",{pos=blacksmith.object:getpos(),max_hear_distance=12,gain=0.6})
|
||||
mobs.put_icon(blacksmith,"mobs:icon_notice",5)
|
||||
active_blacksmiths[name] = nil
|
||||
-- TODO Get invnetory and throw item toward player
|
||||
end
|
||||
|
@ -200,6 +207,7 @@ function blacksmith_globalstep(dtime)
|
|||
bs.entity.state = "standing"
|
||||
bs.entity.set_animation(bs.entity,"stand")
|
||||
chat.local_chat(bs.entity.object:getpos(),"Blacksmith: "..name.." your ingots are ready!",25)
|
||||
mobs.put_icon(bs.entity,"mobs:icon_notice",5)
|
||||
active_blacksmiths[name] = nil -- I think it's all byref so bs = nil should also work
|
||||
meta:set_int("in_use",0)
|
||||
end
|
||||
|
|
|
@ -62,4 +62,5 @@ mobs:register_mob("mobs:explorer",{
|
|||
activity_level = 2,
|
||||
avoid_nodes = {"fire:basic_flame","default:water_source","default:water_flowing","default:lava_source","default:lava_flowing"},
|
||||
avoid_range = 4,
|
||||
icon = "mobs:icon_quest",
|
||||
})
|
||||
|
|
|
@ -87,7 +87,7 @@ mobs:register_mob("mobs:kid_lost", {
|
|||
end
|
||||
end
|
||||
|
||||
math.randomseed(os.clock())
|
||||
--math.randomseed(os.clock())
|
||||
if math.random(1, 100) < self.activity_level then
|
||||
if mobs.api_throttling(self) then return end
|
||||
-- if there is a player nearby look at them
|
||||
|
|
|
@ -45,7 +45,7 @@ mobs:register_mob("mobs:male1_npc",{
|
|||
attack = "default_punch2",
|
||||
random = "mobs_male1_random",
|
||||
},
|
||||
random_freq = 1,
|
||||
random_freq = 8,
|
||||
attacks_monsters=true,
|
||||
peaceful = true,
|
||||
group_attack = true,
|
||||
|
@ -110,7 +110,7 @@ mobs:register_mob("mobs:male2_npc",{
|
|||
attack = "default_punch2",
|
||||
random = "mobs_male2_random",
|
||||
},
|
||||
random_freq = 1,
|
||||
random_freq = 5,
|
||||
attacks_monsters=true,
|
||||
peaceful = true,
|
||||
group_attack = true,
|
||||
|
@ -175,7 +175,7 @@ mobs:register_mob("mobs:male3_npc",{
|
|||
attack = "default_punch2",
|
||||
random = "mobs_male3_random",
|
||||
},
|
||||
random_freq = 1,
|
||||
random_freq = 3,
|
||||
attacks_monsters=true,
|
||||
peaceful = true,
|
||||
group_attack = true,
|
||||
|
|
|
@ -43,7 +43,7 @@ type = "npc",
|
|||
attack = "default_punch",
|
||||
random = "mobs_female1_random",
|
||||
},
|
||||
random_freq = 1,
|
||||
random_freq = 7,
|
||||
attacks_monsters=false,
|
||||
peaceful = true,
|
||||
step=2,
|
||||
|
@ -104,7 +104,7 @@ type = "npc",
|
|||
attack = "default_punch",
|
||||
random = "mobs_female2_random",
|
||||
},
|
||||
random_freq = 1,
|
||||
random_freq = 12,
|
||||
attacks_monsters=false,
|
||||
peaceful = true,
|
||||
step=2,
|
||||
|
@ -183,7 +183,7 @@ type = "npc",
|
|||
})
|
||||
|
||||
mobs:register_mob("mobs:mother", {
|
||||
type = "npc_special",
|
||||
type = "npc_special",
|
||||
hp_min = 30,
|
||||
hp_max = 75,
|
||||
exp_min = 0,
|
||||
|
@ -257,7 +257,7 @@ type = "npc_special",
|
|||
end
|
||||
end
|
||||
|
||||
math.randomseed(os.clock())
|
||||
--math.randomseed(os.clock())
|
||||
if math.random(1, 100) < self.activity_level then
|
||||
if mobs.api_throttling(self) then return end
|
||||
-- if there is a player nearby look at them
|
||||
|
|
|
@ -123,7 +123,7 @@ if randomChance(30) then
|
|||
return
|
||||
end
|
||||
|
||||
math.randomseed(os.clock())
|
||||
--math.randomseed(os.clock())
|
||||
local numNPCs = math.random(0,1)
|
||||
--print("Spawning "..tostring(numNPCs).." NPCs")
|
||||
if numNPCs > 0 then
|
||||
|
@ -162,7 +162,7 @@ local numNPCs = math.random(0,1)
|
|||
if mob then
|
||||
mob = mob:get_luaentity()
|
||||
local p = mob.object:getpos()
|
||||
math.randomseed( ( p.x * p.y * p.z ) )
|
||||
--math.randomseed( ( p.x * p.y * p.z ) )
|
||||
|
||||
minetest.set_node(spawnerpos,{name="mobs:spawner"})
|
||||
local meta = minetest.get_meta(spawnerpos)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
function mobs.on_step(self,dtime)
|
||||
--math.randomseed(os.time() + dtime)
|
||||
if self.lifetimer ~= false then
|
||||
self.lifetimer = self.lifetimer - dtime
|
||||
if self.lifetimer <= 0 and not self.tamed and self.type ~= "npc" then
|
||||
|
@ -70,6 +71,7 @@ function mobs.on_step(self,dtime)
|
|||
g = 0.7
|
||||
end
|
||||
minetest.sound_play(self.sounds.random, {object = self.object, max_hear_distance=maxhear, gain=g})
|
||||
mobs.put_icon(self,"mobs:icon_notice",4)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -376,7 +378,7 @@ function mobs.on_step(self,dtime)
|
|||
|
||||
if self.state == "stand" then
|
||||
-- randomly turn
|
||||
math.randomseed(os.clock())
|
||||
--math.randomseed(os.clock())
|
||||
if math.random(1, 100) < self.activity_level then
|
||||
if mobs.api_throttling(self) then return end
|
||||
-- if there is a player nearby look at them
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
Loading…
Reference in New Issue