View unanswered posts | View active topics It is currently Wed Dec 25, 2024 4:53 pm



Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
 [SOLVED] Easily Customized Laser Sight Range? 
Author Message
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1609
Location: UK
Reply with quote
Post [SOLVED] Easily Customized Laser Sight Range?
This has got me stumped -- I'm trying to polish up the 40K comp's laser sights to cut down on redundancy, and make it so only one AEmitter/MOSRot/Script is needed per dot colour.

How it works at the moment is relatively simple;

The AEmitter is attached to the gun, and emits the MOSRotating. The extremely short-lived MOSRotating has a script that casts a MORay to determine which team/actor to ignore and an ObstacleRay to find out whether or not the beam is actually touching anything. The range is defined in the script's Create event - so if you want multiple ranges, you need a script, emitter and particle for each range.

What I want to do is have the script get a value (let's say Sharpness) from the MOSRotating, which in turn is set by getting that same value from the AEmitter. Then, when attaching the AEmitter, you just specify the desired range as the Sharpness in the CopyOf behaviour there, and no need for sights in 500/1000/etc. increments!

In case the explanation made no sense at all, a script and the current setup of ini code is attached for examination;
Attachment:
SightsBasic.zip [1.49 KiB]
Downloaded 430 times


Anyone got any ideas on how to pull this off? Getting the sharpness from the parent MOSRotating is easy, but figuring out how to get the MOSRotating's sharpness from the AEmitter is what's troubling me.


Last edited by Arcalane on Fri Jun 22, 2012 7:59 am, edited 1 time in total.



Fri Jun 15, 2012 6:22 am
Profile YIM
DRL Developer
DRL Developer

Joined: Tue Aug 11, 2009 5:09 am
Posts: 395
Reply with quote
Post Re: Easily Customized Laser Sight Range?
What you have is most likely a clever hack from B23, but now that we have scriptable weapons you can just replace it with a single script. Just add the script below to the weapon (or merge it with any existing script), and modify it to take its range or particle from the weapon's sharpness.

Code:
function Create(self)
   self.PointPos = Vector()
   self.DotName = "Coalition RPG Laser Particle"   -- This should be a MOPixel with an infinite LifeTime
end

function Update(self)
   if self.ID ~= self.RootID then   -- ID == RootID if the weapon is on the ground
      local Trace = self:RotateOffset(Vector(700,0))   -- Trace 700 pixels along the gun's barrel.
      local Act = MovableMan:GetMOFromID(self.RootID)
      if SceneMan:CastObstacleRay(self.MuzzlePos, Trace, Vector(), self.PointPos, self.RootID, Act.Team, 0, 3) > 0 then
      -- If no pixel of the right material was found, < 0 is returned. If an obstacle on the starting position was encountered, 0 is returned.
         if self.Dot and MovableMan:IsParticle(self.Dot) and self.Dot.PresetName == self.DotName then
            self.Dot.Pos = self.PointPos
         else
            self.Dot = CreateMOPixel(self.DotName, "Coalition.rte")
            if self.Dot then
               self.Dot.Pos = self.PointPos
               MovableMan:AddParticle(self.Dot)
            end
         end
      elseif self.Dot and MovableMan:IsParticle(self.Dot) then
         self.Dot.ToDelete = true
         self.Dot = nil
      end
   elseif self.Dot and MovableMan:IsParticle(self.Dot) then
      self.Dot.ToDelete = true
      self.Dot = nil
   end
end


Fri Jun 15, 2012 12:18 pm
Profile
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1609
Location: UK
Reply with quote
Post Re: Easily Customized Laser Sight Range?
Hrm. This is slightly less easy to attach to existing weapons, and doesn't have the balancing benefit of being slightly offset so that the sights are a -guide-, but not an exact indication of what your weapon barrel is aimed at.

It seems a bit one step forward for one step back. One dot-particle and one main script, but more script-merging, which is making for larger and more specialized scripts.

Also, the dots are having a bad habit of 'sticking' to terrain for a few seconds after weapon change, which wasn't a problem with the old version.


Fri Jun 15, 2012 5:39 pm
Profile YIM
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1609
Location: UK
Reply with quote
Post Re: Easily Customized Laser Sight Range?
Nonsequitorian wrote:
It's simpler, and will create less particles and less lag. Because Abdul just wrote it now, it's probably not as perfect as a method that had all of B23 to perfect. When you tweak the script, add an offset, and the like, it will be a lot better.


The original one was pretty damn smooth, but trimming out unnecessary particlespam and possible causes of slowdown is good, so I don't mind that at all.

--
Nonsequitorian wrote:
What you can also do is attach the script too just an attachable, which you can copy onto any gun. Less specialized scripts, offset already there, and blahdyblahdyblah. Just change self.MuzzlePos to self.Pos, and it will start from the center of the laser pointer.


Right! Good point. That's a good start. Now the problem is in IDs and rotation... I've got it working decently again, but now it's only projecting the dot to the right, even when the actor is facing left.


Fri Jun 15, 2012 7:02 pm
Profile YIM
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1609
Location: UK
Reply with quote
Post Re: Easily Customized Laser Sight Range?
For the moment I'm just using Abdul's script up there as-is, except with a quick check in Create to get the range from the AEmitter's Sharpness, and a very quick ID hack (changing the ~= to ==) for the sake of quick testing.


Fri Jun 15, 2012 9:17 pm
Profile YIM
User avatar

Joined: Fri Feb 16, 2007 8:43 pm
Posts: 1695
Location: AH SHIT FUCK AUGH
Reply with quote
Post Re: Easily Customized Laser Sight Range?
Not to discredit Abdul or anything, but i happen to have a laser sight template stashed, lemme go find it.

/me rummage rummage

Here we go. You'll probably want to use the LaserNoToggle one, since the other one uses Sharpness to determine whether the laser is active or not. If you want, you can just set self.range in the Lua file to self.Sharpness, since that'd make the script use the guns sharpness as range in pixels. There might be a bit of fiddling involved, but i've gone out of my way to simplify customization (and added comments). It's also possible and quite easy to set an offset to the lasers origin. And yes, i did update it to B27 compatibility.


Attachments:
File comment: huargh
LaserPointer.rar [5.01 KiB]
Downloaded 428 times
Fri Jun 15, 2012 11:07 pm
Profile WWW
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1609
Location: UK
Reply with quote
Post Re: Easily Customized Laser Sight Range?
I hate to sound ungrateful, but that's no good. I just want the single dot projected directly onto the target, no intervening beam. The dots are a guide for shooting past the sharpaim dots, but I think a straight line to target would be a little too good. I guess setting it to have an interval the same as the beam range might work?

Hint: I have no idea what I'm doing. If that wasn't obvious.


Sat Jun 16, 2012 1:40 am
Profile YIM
User avatar

Joined: Fri Feb 16, 2007 8:43 pm
Posts: 1695
Location: AH SHIT FUCK AUGH
Reply with quote
Post Re: Easily Customized Laser Sight Range?
Oh, pardon me, i might have overlooked something there. But, it's a fairly simple modification. You just need to provide a glowing MOPixel called Tracer Particle (unless you fiddle with the Lua file) with a one-frame lifetime, then the script SHOULD put a dot at whatever you're aiming, with a range in pixels equal to the Sharpness of the gun.


Attachments:
LaserDot.lua [1.47 KiB]
Downloaded 369 times
Sat Jun 16, 2012 2:03 pm
Profile WWW
User avatar

Joined: Sun Dec 16, 2007 12:09 am
Posts: 1115
Location: Being The Great Juju
Reply with quote
Post Re: Easily Customized Laser Sight Range?
If that script doesn't work out for you, I seem to recall Darkstorm having a few weapons with laser dots. Might want to check it out.


Sat Jun 16, 2012 2:48 pm
Profile
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1609
Location: UK
Reply with quote
Post Re: Easily Customized Laser Sight Range?
Shook wrote:
Oh, pardon me, i might have overlooked something there. But, it's a fairly simple modification. You just need to provide a glowing MOPixel called Tracer Particle (unless you fiddle with the Lua file) with a one-frame lifetime, then the script SHOULD put a dot at whatever you're aiming, with a range in pixels equal to the Sharpness of the gun.


Mm, the thing is, a lot of the guns with sights have scripts - merging isn't really a problem, mind you, but I'm trying to be efficient(ish) - and a couple of those scripts already make use of the weapon's Sharpness value for certain things. That's why I want to stick with the attachable sight method. One script, one dot, and one emitter/attachable, per colour, range defined by the emitter/attachable's sharpness in the copyof.

--

Ragdollmaster wrote:
If that script doesn't work out for you, I seem to recall Darkstorm having a few weapons with laser dots. Might want to check it out.


Those were the basis of the original scripts, actually. The problem is the lack of flexibility when it comes to ranges - you need an emitter, mopixel dot, mosrotating, and script, for every range of sight you want. That's great if you only want three standardized ranges (like I do now - 600, 1200, and 1800) but it gets messy if you want more variance between weapons. Which I do.


Sat Jun 16, 2012 10:58 pm
Profile YIM
User avatar

Joined: Fri Feb 16, 2007 8:43 pm
Posts: 1695
Location: AH SHIT FUCK AUGH
Reply with quote
Post Re: Easily Customized Laser Sight Range?
Hrm, only now do i realize that i've given you a non-functional script, terribly sorry about that. Here's a revised and actually working one that you can slap on just about anything, including attachables. There are a few problems, however; it doesn't seem to inherit the team of the gun, so the dot doesn't ignore team mates, and all attempts at making the laser deactivate when on the ground have been futile, since it refuses to acknowledge that it's actually connected to something. It does, however, take its Sharpness for a range value, and the dot is fully visible most of the time. It's a start, anyways.
Also, remember to either make a Tracer Particle, or change the name of the used particle in the script, else nothing will spawn.

EDIT: NOW WORKS


Attachments:
File comment: balls
LaserDot.lua [1.44 KiB]
Downloaded 431 times


Last edited by Shook on Sun Jun 17, 2012 8:26 pm, edited 1 time in total.

Sun Jun 17, 2012 7:09 pm
Profile WWW
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1609
Location: UK
Reply with quote
Post Re: Easily Customized Laser Sight Range?
I had the original one ignoring teammates fine, so it should be possible to inherit from the gun... :???:

But, more to the point, my console is getting spammed with;

Code:
ERROR: no overload of  'SceneManager:ShortestDistance' matched the arguments (SceneManager, nil, const Vector, boolean)
candidates are:
SceneManager:ShortestDistance(Vector, Vector, boolean)


This is only after I remove the self.RootID/self.ID check - if I leave it as ~= then the script is simply not doing anything.


Sun Jun 17, 2012 7:58 pm
Profile YIM
User avatar

Joined: Fri Feb 16, 2007 8:43 pm
Posts: 1695
Location: AH SHIT FUCK AUGH
Reply with quote
Post Re: Easily Customized Laser Sight Range?
Oh heavenly ♥♥♥♥ of granite, I UPLOADED THE WRONG VERSION. Fixed it now, many apologies for the inconvenience. Use it or not, it's there now. I can't figure out how to make it inherit the holders team for the life of me, since it refuses to acknowledge self.RootID as anything, and self.Team doesn't produce any results. I'll keep dicking around with it, but it's possible that i'll just call it quits before i complicate things even further (and look like an incompetent ♥♥♥♥ in the process).


Sun Jun 17, 2012 8:31 pm
Profile WWW
User avatar

Joined: Sun Jan 28, 2007 10:32 pm
Posts: 1609
Location: UK
Reply with quote
Post Re: Easily Customized Laser Sight Range?
:lol:

It flat out ain't doin' a thing for me now. No dot, no errors, nothin'. :???:


Sun Jun 17, 2012 8:42 pm
Profile YIM
User avatar

Joined: Fri Feb 16, 2007 8:43 pm
Posts: 1695
Location: AH SHIT FUCK AUGH
Reply with quote
Post Re: Easily Customized Laser Sight Range?
That's likely because you're missing the Tracer Particle in your INI's. It doesn't produce any errors if it's missing, it just does diddly squat. I tested it myself this time, and i'm decently sure that's the problem, since it did produce that tiny red dot when i tried. Otherwise, lend me a shovel so i can go bury myself.


Sun Jun 17, 2012 8:52 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 17 posts ]  Go to page 1, 2  Next

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.210s | 14 Queries | GZIP : Off ]