Data Realms Fan Forums
http://45.55.195.193/

Crude scripting through attachables
http://45.55.195.193/viewtopic.php?f=73&t=17068
Page 1 of 1

Author:  Darlos9D [ Sat Nov 07, 2009 4:13 pm ]
Post subject:  Crude scripting through attachables

So while fiddling around with the idea of making a proper laser sight for a gun, I came upon the following solutions:

1 - Make an emitter that's attached to the gun, and make sure its inside the gun
2 - Have the emitter emit short-lived particles with a low velocity or even no velocity
3 - These particles each run a script that casts an MO ray. They should typically return the gun's MOID, since the emitter is buried in the gun and it's always the first thing the MO ray will encounter
4 - Use the gun's MOID to find its root MOID. If an actor is holding it, it'll be the ID of the actor. If nobody is holding it, it'll be the ID of the gun
5 - You still can't run scripts on the gun if an actor is holding it, but you can at least then do a variety of interesting things based off of the actor itself. And you can ALWAYS be pretty damn sure that you're getting the actor and not anything else

Like I said, I used this to make a laser sight. After getting the actor's ID, I just got the actor's AimAngle and used that to cast an obstacle ray from the same particle at the angle that the actor is facing and spawn a small glow wherever it strikes something. It always works.

Something else I could use this for is to make my "only Shoguns can use certain weapons" deal work a whole lot better. I can just set it up so when somebody is holding it, once it finds an actor ID it just forces them to drop their current weapon, or maybe disables their WEAPON_FIRE state.

I'm sure there's more clever things you could do with this method. Plus, it would probably work on things besides guns. Basically, it should work on any attachable.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/