View unanswered posts | View active topics It is currently Fri Dec 27, 2024 10:08 am



Reply to topic  [ 5 posts ] 
 Recursive Rockets 
Author Message
User avatar

Joined: Sun Oct 29, 2006 4:26 am
Posts: 298
Reply with quote
Post Recursive Rockets
Hey all, been a while, trying to get a hang of this Lua stuff gradually by reverse engineering neat stuff, but I figured I's start with something simple enough.

Essentially, what I'm trying to do is have a Rocket fire out TDExplosives that gib (or explodes after timer, if the engine supports that now) into more of those rockets. That's the core of what I want to do, but I have additional ideas that I'm unsure how to implement: Ideally, each of these TDExplosives should have a semi-random chance of gibbing into the base rocket. Also, if possible, I want to make sure the rockets spawn facing up regardless of the manner their spawning TDE landed, though if there's a strategy for this that works without Lua that would also be nice.

As always, thanks for your help, and I'm very impressed with everything the community has managed to create.


Thu Feb 11, 2010 11:58 pm
Profile YIM
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Recursive Rockets
function Create(self)
self.lifetimer = Timer();
end

function Update(self)
if self.lifetimer:IsPastSimMS(5000) == true then
local chance = math.random(1,4)
if chance == 1 then
local acrocket = CreateACRocket("Presetname","RTE")
acrocket.Pos = self.Pos;
acrocket.Vel = Vector(0,0);
acrocket.RotAngle = 0;
MovableMan:AddActor(acrocket)
end
end
end

Script for TDE's that'd cover what you need.


Fri Feb 12, 2010 12:18 am
Profile
User avatar

Joined: Sun Oct 29, 2006 4:26 am
Posts: 298
Reply with quote
Post Re: Recursive Rockets
Thank you once again good sir.

For the reference of others, I inserted a 'self:GibThis();' after 'local chance = math.random(1,1)', because otherwise it made unlimited copies and did crazy ♥♥♥♥. As it stands, the code just makes the one copy after 5000ms. Next I'll try to modify it using altitude so that they won't pop before touching the ground.


Fri Feb 12, 2010 1:42 am
Profile YIM
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post Re: Recursive Rockets
Add self.lifetimer:Reset(); after the if chance == 1 line. Pretty sure Grif just accidentally forgot it, cuz with it, it has a 1 in 4 chance of gibbing into "another rocket" like u said. So yea.

Edit: so what else do you want it to do?


Fri Feb 12, 2010 1:53 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Recursive Rockets
there's no need to reset it if it gibs regardless of hitting the chance or not

he wanted 1/4 tde's to explode into an acrocket, and with the modification I told him to make, that's what happens


Fri Feb 12, 2010 4:33 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.073s | 13 Queries | GZIP : Off ]