indeed gtox these bugs are awesome
just had to tidy the script a little, get a new video up and tweak the settings some - i felt this one would be safer without giving too much modification via settings but i'm sure many of you can work it out if you need to change it - but i'm always happy to help if not.
now the scripts
you need to apply this 1 to all the bees (note the bees aren't scaled so you will need to scale those yourself (scaling in the script didn't make them small enough for my liking so i left it out otherwise it would overwrite any scale changes you made)
bee.lua (edit: fixed a possible bug)
--script by smallg
local state = {}
local speed = {}
local nearest_flower = {}
local nearest_flower_dist = {}
local height = {}
local w_animating = {}
local maxvolume = {}
local minvolume = {}
local noise = {}
local nvolume = {}
local delay = {}
local new_delay = {}
local timer_started = {}
local angle_y = {}
local dist = {}
function bee_init(e)
state[e] = "init"
speed[e] = 50
CollisionOff(e)
Scale(e,50)
--GravityOn(e)
nearest_flower[e] = e
nearest_flower_dist[e] = 999999
w_animating[e] = 0
SetSoundVolume(100)
maxvolume[e] = 100
minvolume[e] = 1
noise[e] = 0
nvolume[e] = 0
delay[e] = 5000
new_delay[e] = delay[e]
timer_started[e] = 0
end
function bee_main(e)
CollisionOff(e)
Scale(e,50)
nvolume[e] = maxvolume[e] - ( GetPlayerDistance(e) / 100.0 )
if nvolume[e] < minvolume[e] then
StopSound(e,0)
noise[e]=0
else
if noise[e] == 0 then
LoopSound(e,0)
noise[e] = 1
end
SetSoundVolume(nvolume[e])
end
if w_animating[e] == 0 then
StopAnimation(e)
w_animating[e] = 1
end
if w_animating[e] == 1 then
if g_Entity[e]['animating'] == 0 then
SetAnimationFrames(1,2)
LoopAnimation(e)
g_Entity[e]['animating'] = 1
end
end
if state[e] == "init" then
for a = e-50, e+50 do
if g_Entity[a] ~= nil then
if a ~= nearest_flower[e] then
if flower[a] == 1 then
dist[e] = math.random(100,500)
if GetDistance(e,a) < nearest_flower_dist[e] and GetDistance(e,a) > dist[e] then
RotateToEntity(e,a)
nearest_flower_dist[e] = GetDistance(e,a)
nearest_flower[e] = a
state[e] = "moving"
end
end
end
end
end
elseif state[e] == "moving" then
if g_Entity[e]['y'] < 720 then
height[e] = math.random(-50,-10)
if g_Entity[e]['y'] > 630 then
MoveUp(e,height[e])
else
height[e] = math.random(10,30)
end
MoveUp(e,height[e])
else
MoveUp(e,-height[e])
end
if GetDistance(e,nearest_flower[e]) > 35 then
RotateToEntity(e,nearest_flower[e])
MoveForward(e,speed[e])
angle_y[e] = math.random(-90,90)
else
if timer_started[e] == 0 then
timer_started[e] = 1
delay[e] = GetTimer(e) + new_delay[e]
else
if GetTimer(e) > delay[e] then
nearest_flower_dist[e] = 999999
state[e] = "init"
timer_started[e] = 0
end
end
RotateY(e,angle_y[e])
MoveForward(e,speed[e] / 4 )
end
end
end --main
function GetDistance(e,v)
if g_Entity[e] ~= nil and g_Entity[e] ~= 0 and g_Entity[v] ~= nil and g_Entity[v] ~= 0 then
local disx = g_Entity[e]['x'] - g_Entity[v]['x']
local disz = g_Entity[e]['z'] - g_Entity[v]['z']
local disy = g_Entity[e]['y'] - g_Entity[v]['y']
return math.sqrt(disx^2 + disz^2 + disy^2)
end
end
function RotateToEntity(e,v)
if g_Entity[e] ~= nil and g_Entity[e] ~= 0 and g_Entity[v] ~= nil and g_Entity[v] ~= 0 then
local x = g_Entity[v]['x'] - g_Entity[e]['x']
local z = g_Entity[v]['z'] - g_Entity[e]['z']
local angle = math.atan2(x,z)
angle = angle * (180.0 / math.pi)
if angle < 0 then
angle = 360 + angle
elseif angle > 360 then
angle = angle - 360
end
SetRotation(e,0,angle,0)
return angle
end
end
and a basic script to give to the flowers, this is simply to tell the bees that it is a flower but it does scale the flowers a bit bigger
flower.lua
flower = {}
function flower_init(e)
CollisionOff(e)
Scale(e,160)
end
function flower_main(e)
flower[e] = 1
end
edit: new video to add to the showcase of all the bugs
life\'s one big game
windows vista ultimate
i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11