how would you make an attachable that when it comes in contact with an actor is sticks to them for a few seconds and explodes?
I want it to explode....
Sun Feb 24, 2013 6:16 am
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
Re: Attachable that explodes on attaching?
Are you asking for an attachable that explodes when spawned? (since as soon as it's spawned its attached to its parent actor)
Or an attachable that is attached to the actor that, when it comes in contact with another actor, detaches from its original actor, attaches to the new actor, and then explodes?
Or something else? You're a bit vague here.
Sun Feb 24, 2013 6:27 am
Arcalane
Joined: Sun Jan 28, 2007 10:32 pm Posts: 1609 Location: UK
Re: Attachable that explodes on attaching?
I'm guessing a timed stickybomb of some description, either thrown or fired from some kind of launcher. I used a two-stage projectile for the one I made, though I imagine it could be done with a single-stage projectile as well with a decent script.
Sun Feb 24, 2013 6:32 am
Izak12
Joined: Fri Dec 14, 2012 5:44 am Posts: 201
Re: Attachable that explodes on attaching?
CaveCricket48 wrote:
Are you asking for an attachable that explodes when spawned? (since as soon as it's spawned its attached to its parent actor)
Or an attachable that is attached to the actor that, when it comes in contact with another actor, detaches from its original actor, attaches to the new actor, and then explodes?
Or something else? You're a bit vague here.
ah sorry, I meant an attachable that is spawned as a stand alone object and sits there until it comes into contact with any actor within range and sticks to them and explodes.
Mon Feb 25, 2013 4:59 am
Izak12
Joined: Fri Dec 14, 2012 5:44 am Posts: 201
Re: Attachable that explodes on attaching?
Arcalane wrote:
I'm guessing a timed stickybomb of some description, either thrown or fired from some kind of launcher. I used a two-stage projectile for the one I made, though I imagine it could be done with a single-stage projectile as well with a decent script.
yeah or this.
Basically I'm creating the T-virus. After I figure out this I'll replace "Explode" with "Kill original actor and spawn zombie in place".
Mon Feb 25, 2013 5:00 am
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
Re: Attachable that explodes on attaching?
In that case you don't want to use an Attachable.
You could either use a wound emitter with a few tricks to make a sticky bomb, or a modification of the Coalition Remote-GL's sticky grenade script.
Mon Feb 25, 2013 9:18 pm
Arcalane
Joined: Sun Jan 28, 2007 10:32 pm Posts: 1609 Location: UK
Re: Attachable that explodes on attaching?
What I did was a double-stage AEmitter/MOSRotating. The first stage is thrown or launched and has a GibImpulseLimit of 1 so it breaks on the first thing it hits to gib into the second stage; the second stage has a script that makes it stick to whatever it just spawned next to, then explode a few seconds later.
Take in mind this is quite old, may be buggy, and will stick to anything it hits.
Code:
function Create(self) self.lifeTimer = Timer(); local part = nil; local dist = 0; local curdist = 25; local chosenpart = nil;
--Cycle through all MOs and see which is the closest, and attach to it. for i=1,MovableMan:GetMOIDCount()-1 do part = ToMovableObject(MovableMan:GetMOFromID(i)); dist = math.sqrt((self.Pos.X - part.Pos.X) ^ 2 + (self.Pos.Y - part.Pos.Y) ^ 2); if dist < curdist and part.ID ~= self.ID then curdist = dist; chosenpart = part; end end
--If a part was found, attach to it. Otherwise, we assume it is a wall, and stay pinned to it. if chosenpart ~= nil then self.attached = MovableMan:GetMOFromID(chosenpart.RootID); self.offset = Vector(chosenpart.Pos.X-self.Pos.X,chosenpart.Pos.Y-self.Pos.Y); self.offangle = self.offset.AbsRadAngle - chosenpart.RotAngle; self.PinStrength = 0; --Make the grenade not collide with the attached object or any of its children so that it doesn't go off on its own. for i=1,MovableMan:GetMOIDCount()-1 do part = MovableMan:GetMOFromID(i); if part.RootID == self.attached then self:SetWhichMOToNotHit(part,-1); end end end end
function Update(self) --Using trigonometry, move to the right position and update speed and rotation. Check first if it still exists. if self.attached then if MovableMan:ValidMO(self.attached) then self.Pos.X = self.attached.Pos.X + self.offset.Magnitude * math.cos(self.offangle + self.attached.RotAngle); self.Pos.Y = self.attached.Pos.Y + self.offset.Magnitude * math.sin(self.offangle + self.attached.RotAngle); self.Vel = self.attached.Vel; self.RotAngle = self.attached.RotAngle; self.AngularVel = self.attached.AngularVel; end end
if self.lifeTimer:IsPastSimMS(2500) then self:GibThis(); end
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