View unanswered posts | View active topics It is currently Thu Dec 26, 2024 5:40 pm



Reply to topic  [ 5 posts ] 
 Gib weapon after firing 
Author Message

Joined: Sat Apr 09, 2011 11:20 pm
Posts: 4
Location: B.C. Canada
Reply with quote
Post Gib weapon after firing
I want to make a one-shot weapon that gibs itself after you fire it. After doing some searching and reading on lua scripting I've found that you can't attach lua scripts to weapons(while they're being held by an actor at least) so the workaround seems to be to make an emitter that emits invisible particles that have the script attached to them instead. So this is what I have so far:
The gibself script:
Code:
function Update(self)
   self:GibThis();
end

The emitter:
Code:
AddEffect = AEmitter
   PresetName = GibEmitter
   Mass = 0.001
   PinStrength = 99999
   LifeTime = 100
   HitsMOs = 0
   GetsHitByMOs = 0
   RestThreshold = -500
   OrientToVel = 1
   SpriteFile = ContentFile
      FilePath = myMod.rte/Devices/Weapons/Sprites/Flashes/Null.bmp
   ScriptPath = myMod.rte/Scripts/GibSelf.lua
   FrameCount = 1
   SpriteOffset = Vector
      X = 0
      Y = 0
   AngularVel = 0
   AtomGroup = AtomGroup
      AutoGenerate = 1
      Material = Material
         CopyOf = Air
      Resolution = 2
      Depth = 0
   DeepGroup = AtomGroup
      AutoGenerate = 1
      Material = Material
         CopyOf = Air
      Resolution = 4
      Depth = 10
   DeepCheck = 0


I've attached that emitter to the weapon like so:
Code:
   AddEmitter = AEmitter
      CopyOf = GibEmitter
      ParentOffset = Vector
         X = 0
         Y = 0

But it doesn't work, the weapon doesn't gib at all let alone after use. I have a feeling it's because the lua script is just gibing the invisible particles instead. So how can I have the script gib the MO that its emitter is attached to?
Thanks.


Sat Apr 16, 2011 7:23 am
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: Gib weapon after firing
You're right - the invisible particles are gibbing themselves.
Unfortunately, getting things like this to work is a little awkward at the moment. There's a script in Ronin.rte/Devices/Tools called "IgnoreParent" which has some code you can use. The script is attached to particles that exit the Ronin shovel, and they basically find the nearest actor holding a shovel and ignore it. You can use that same piece of code, but instead of ignoring the actor, just call shovel:GibThis(). It's kind of a sketchy way of doing it, but currently, it's the best we can do (at least that I can think of, feel free to correct me).


Sat Apr 16, 2011 8:39 am
Profile WWW

Joined: Sat Apr 09, 2011 11:20 pm
Posts: 4
Location: B.C. Canada
Reply with quote
Post Re: Gib weapon after firing
After some experimenting, GibThis() doesn't seem to work at all. I tried making my own copy of the shovel script for my weapon and it didn't work so I changed the Ronin shovel script itself and it didn't gib the shovel. Is there a limit of some sort on what I can gib and when?


Sun Apr 17, 2011 2:34 am
Profile
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: Gib weapon after firing
Post up your code - no offence, but it's possible that you did something wrong.
Also, make sure to check the in-game console for errors.


Sun Apr 17, 2011 3:59 am
Profile WWW

Joined: Sat Apr 09, 2011 11:20 pm
Posts: 4
Location: B.C. Canada
Reply with quote
Post Re: Gib weapon after firing
I fixed it, you're right I did something wrong but I figured that anyways. I put weapon.GibThis(); instead of weapon:GibThis(); I'm to used to java syntax it seems. :)
Thank you for your help!


Sun Apr 17, 2011 4:51 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.114s | 13 Queries | GZIP : Off ]