--print("mushroom_exploder init") require "lua/entity.lua" require "lua/utilities.lua" iamdead = 0 --metaobject.ValueInfo metaobject.IntMeasurement --create variable setAlpha(0.01) scale(0.01,0.01,0.01) --play SoundInfoResolver.ShroomSpawn timer = 0 shakeTimer = 0 bright = 0 myTime = 0 colorTimer = 0 x,y,z = position() rx,ry,rz = rotation() myExplosion = spawn("mushrooms_exp", x , y , z ) myExplosion.rotation( rx , ry , rz ) function waitToExplode() if iamdead == 1 or (demo and myTime > demoOffset) then currentBehavior=explode timer = myTime+0.1 shakeTimer = myTime + math.random(0,25) * 0.001 moveRelative(math.random(0,0.5),math.random(0,360),0) --displace --bright = 1 --play SoundInfoResolver.Mushroom_Warning end --OpFlowBehavior end function explode() if myTime >= colorTimer then if bright == 0 then setColorSmooth(convert255to1(85) , 0 , 0 , 1.0, convert255to1(85) , 1.0 , 0.25) bright = 1 elseif bright == 1 then setColorSmooth(1.0, convert255to1(85) , 1.0 , convert255to1(85) , 0 , 0 , 0.25 ) bright = 0 end --flow continue colorTimer = myTime + 0.25 end if myTime >= shakeTimer then --print("shake") shakeTimer = myTime + math.random(0,25) * 0.001 --moveRelative(math.random(0, (ft2m(0.5)*100) * 0.01 ),math.random(0,360),0) --displace moveRelative(math.random(0, 15) * 0.01 ,math.random(0,360),0) end --flow continue if myTime >= timer then myExplosion.trigger.send(1) collision.mask{ index=1 , recSet=0x2 , sendSet=0x2} trigger.send(1,"SoundExplode") trigger.send(1,"SoundHit") currentBehavior = postExplosion demo = false end --flow continue end --OpFlowBehavior function postExplosion() delete() end currentBehavior = waitToExplode while tick() do myTime = myTime + dt if myTime > 0.1 and not didFadeIn then --print("mushroom fade in") setAlphaSmooth(0.01,1.0,1.0) scaleRandom = math.random (0,20) * 0.01 --print(scaleRandom) scaleSmooth(0.6+scaleRandom,0.6+scaleRandom,0.6+scaleRandom,1.0) trigger.send(1,"SoundGrow") didFadeIn = true end if trigger.received(1,"demo") then print("mushroom got demo") demo = true demoOffset = myTime + 2 end if trigger.received(1,"gotHurt") then --print("gotHurt trigger") iamdead = 1 end currentBehavior() end --[[ function SHUTDOWN() --stop SoundInfoResolver.Mushroom_Warning find subset of ActorInfoResolver.Mushroom_Exploder_InvulGuards.placement.clones.position.distance<= 25 for k,v in pairs(subset ActorInfoResolver.Mushroom_Exploder_InvulGuards.placement.clones.position.distance<= 25) do --working forward offset by 0 members do --cause damage end end find subset of ActorInfoResolver.Mushroom_Exploder.placement.clones.position.distance<= 25 for k,v in pairs(subset ActorInfoResolver.Mushroom_Exploder.placement.clones.position.distance<= 25) do --working forward offset by 0 members do --cause damage end --flow loop end if ValueInfoResolver.Match_Underway= 1 then find subset of ActorInfoResolver.[Minions].position.distance<= 20 for k,v in pairs(subset ActorInfoResolver.[Minions].position.distance<= 20) do --working forward offset by 0 members do --if element type is not 7 set shroomed to true --cause damage end end --play SoundInfoResolver.Cannon_Explode --trigger mushroom explosion particle end ]]