Comets and Shockwave

Been trying out some new bits to make space a bit more interesting.
Can people think of an easy way to make
Shockwaves? Kinda a blackhole that pushes instead of pulls....

Asteroids, this time that do damage on impact so a mine basically that moves....

Either i can do though LUA but asking in case there is something easy....

Comments

  • I added moving asteroids to my latest LUA scenario scripts. I put this in the init function:
    setMovingAsteroids()
    ...and this in the update function:
    	if plotA ~= nil then	--asteroids in motion
    		plotA(delta)
    	end
    
    ...and added these two functions to send them on random trajectories and replenish them after they all impact various players, stations and other things and get destroyed over time:
    function setMovingAsteroids()
    	movingAsteroidList = {}
    	for aidx=1,30 do
    		xAst = random(-100000,100000)
    		yAst = random(-100000,100000)
    		outRange = true
    		for p2idx=1,8 do
    			p2obj = getPlayerShip(p2idx)
    			if p2obj ~= nil and p2obj:isValid() then
    				if distance(p2obj,xAst,yAst) < 30000 then
    					outRange = false
    				end
    			end
    		end
    		if outRange then
    			mAst = Asteroid():setPosition(xAst,yAst)
    			mAst.angle = random(0,360)
    			mAst.travel = random(40,220)
    			if random(1,100) < 50 then
    				mAst.curve = 0
    			else
    				mAst.curve = math.random()*.16 - .08
    			end
    			table.insert(movingAsteroidList,mAst)
    		end
    	end
    	plotA = moveAsteroids
    end
    
    function moveAsteroids(delta)
    	movingAsteroidCount = 0
    	for aidx, aObj in ipairs(movingAsteroidList) do
    		if aObj:isValid() then
    			movingAsteroidCount = movingAsteroidCount + 1
    			mAstx, mAsty = aObj:getPosition()
    			if mAstx < -150000 or mAstx > 150000 or mAsty < -150000 or mAsty > 150000 then
    				aObj.angle = random(0,360)
    				if random(1,100) < 50 then
    					curve = 0
    				else
    					curve = math.random()*.08
    				end
    				if aObj.angle < 90 then
    					aObj:setPosition(random(-150000,-100000),random(-150000,-100000))
    					if aObj.angle < 45 then
    						aObj.curve = curve
    					else
    						aObj.curve = -curve
    					end
    				elseif aObj.angle < 180 then
    					aObj:setPosition(random(100000,150000),random(-150000,-100000))
    					if aObj.angle < 135 then
    						aObj.curve = curve
    					else
    						aObj.curve = -curve
    					end
    				elseif aObj.angle < 270 then
    					aObj:setPosition(random(100000,150000),random(100000,150000))
    					if aObj.angle < 225 then
    						aObj.curve = curve
    					else
    						aObj.curve = -curve
    					end
    				else
    					aObj:setPosition(random(-150000,-100000),random(100000,150000))
    					if aObj.angle < 315 then
    						aObj.curve = curve
    					else
    						aObj.curve = -curve
    					end
    				end
    			else
    				deltaAstx, deltaAsty = vectorFromAngle(aObj.angle,aObj.travel)
    				aObj:setPosition(mAstx+deltaAstx,mAsty+deltaAsty)
    				aObj.angle = aObj.angle + aObj.curve
    			end
    		end
    	end
    	if movingAsteroidCount < 1 then
    		setMovingAsteroids()
    	end
    end
    Feel free to use and/or abuse this as you see fit. I make no warranty as to its suitability for your purpose. The asteroids do some damage when they hit. If you made mines fly around like these asteroids, they would be far more dangerous than these.
  • Oh you are a star, that should work perfectly well.
Sign In or Register to comment.