diff --git a/mods/adventuretest/functions.lua b/mods/adventuretest/functions.lua index dd28e04..c111bf0 100644 --- a/mods/adventuretest/functions.lua +++ b/mods/adventuretest/functions.lua @@ -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) diff --git a/mods/adventuretest/init.lua b/mods/adventuretest/init.lua index 30f7f8d..75146c9 100644 --- a/mods/adventuretest/init.lua +++ b/mods/adventuretest/init.lua @@ -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")) diff --git a/mods/adventuretest/register_functions.lua b/mods/adventuretest/register_functions.lua index 525e5aa..144a91d 100644 --- a/mods/adventuretest/register_functions.lua +++ b/mods/adventuretest/register_functions.lua @@ -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) diff --git a/mods/default/functions.lua b/mods/default/functions.lua index 5286dad..86731e3 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -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 diff --git a/mods/default/nodes.lua b/mods/default/nodes.lua index fcfd450..95ed401 100644 --- a/mods/default/nodes.lua +++ b/mods/default/nodes.lua @@ -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 diff --git a/mods/farming_plus/weed.lua b/mods/farming_plus/weed.lua index fdd9e97..5615857 100644 --- a/mods/farming_plus/weed.lua +++ b/mods/farming_plus/weed.lua @@ -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}) diff --git a/mods/mg/dungeons.lua b/mods/mg/dungeons.lua index fe5ffab..325d679 100644 --- a/mods/mg/dungeons.lua +++ b/mods/mg/dungeons.lua @@ -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 ) diff --git a/mods/mobs/api.lua b/mods/mobs/api.lua index e08568b..d6f6b46 100644 --- a/mods/mobs/api.lua +++ b/mods/mobs/api.lua @@ -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] diff --git a/mods/mobs/icons.lua b/mods/mobs/icons.lua new file mode 100644 index 0000000..8fa1977 --- /dev/null +++ b/mods/mobs/icons.lua @@ -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") \ No newline at end of file diff --git a/mods/mobs/init.lua b/mods/mobs/init.lua index 966ae2e..87cfe9e 100644 --- a/mods/mobs/init.lua +++ b/mods/mobs/init.lua @@ -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 \ No newline at end of file diff --git a/mods/mobs/npcs/blacksmith.lua b/mods/mobs/npcs/blacksmith.lua index 46876b5..10b2517 100644 --- a/mods/mobs/npcs/blacksmith.lua +++ b/mods/mobs/npcs/blacksmith.lua @@ -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 diff --git a/mods/mobs/npcs/explorer.lua b/mods/mobs/npcs/explorer.lua index ccb2b62..0833b42 100644 --- a/mods/mobs/npcs/explorer.lua +++ b/mods/mobs/npcs/explorer.lua @@ -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", }) diff --git a/mods/mobs/npcs/kids.lua b/mods/mobs/npcs/kids.lua index e9f1234..d063c94 100644 --- a/mods/mobs/npcs/kids.lua +++ b/mods/mobs/npcs/kids.lua @@ -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 diff --git a/mods/mobs/npcs/men.lua b/mods/mobs/npcs/men.lua index 4e2925d..082cdde 100644 --- a/mods/mobs/npcs/men.lua +++ b/mods/mobs/npcs/men.lua @@ -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, diff --git a/mods/mobs/npcs/women.lua b/mods/mobs/npcs/women.lua index b8be4b0..342bd59 100644 --- a/mods/mobs/npcs/women.lua +++ b/mods/mobs/npcs/women.lua @@ -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 diff --git a/mods/mobs/spawner.lua b/mods/mobs/spawner.lua index 6264dc6..a439cf4 100644 --- a/mods/mobs/spawner.lua +++ b/mods/mobs/spawner.lua @@ -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) diff --git a/mods/mobs/step.lua b/mods/mobs/step.lua index 6826042..9dcf7be 100644 --- a/mods/mobs/step.lua +++ b/mods/mobs/step.lua @@ -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 diff --git a/mods/mobs/textures/mobs_icon_notice.png b/mods/mobs/textures/mobs_icon_notice.png new file mode 100644 index 0000000..7296e18 Binary files /dev/null and b/mods/mobs/textures/mobs_icon_notice.png differ diff --git a/mods/mobs/textures/mobs_icon_quest.png b/mods/mobs/textures/mobs_icon_quest.png new file mode 100644 index 0000000..fe3caf5 Binary files /dev/null and b/mods/mobs/textures/mobs_icon_quest.png differ diff --git a/mods/mobs/textures/mobs_icon_sell.png b/mods/mobs/textures/mobs_icon_sell.png new file mode 100644 index 0000000..bee3787 Binary files /dev/null and b/mods/mobs/textures/mobs_icon_sell.png differ