Forged Alliance Forever Forged Alliance Forever Forums 2015-05-11T17:52:27+02:00 /feed.php?f=41&t=9928 2015-05-11T17:52:27+02:00 2015-05-11T17:52:27+02:00 /viewtopic.php?t=9928&p=99916#p99916 <![CDATA[Re: Need help calculating a location]]> Statistics: Posted by Legion Darrath — 11 May 2015, 17:52


]]>
2015-05-11T16:17:40+02:00 2015-05-11T16:17:40+02:00 /viewtopic.php?t=9928&p=99913#p99913 <![CDATA[Re: Need help calculating a location]]>
Legion Darrath wrote:
Moved to mods.


Gee thanx for the assist... No idea what the world would of done with you at that moment in time. (sarc)

Statistics: Posted by Resin_Smoker — 11 May 2015, 16:17


]]>
2015-05-11T16:06:58+02:00 2015-05-11T16:06:58+02:00 /viewtopic.php?t=9928&p=99912#p99912 <![CDATA[Re: Need help calculating a location]]> Statistics: Posted by Legion Darrath — 11 May 2015, 16:06


]]>
2015-05-11T15:15:32+02:00 2015-05-11T15:15:32+02:00 /viewtopic.php?t=9928&p=99910#p99910 <![CDATA[Re: Need help calculating a location]]>
This not only gets the entities at the location but also validates and sorts entities by range.

Any suggestions?

Note: This will be used for the chain-lightning revamp.

Resin

---Code---
Spoiler: show
Code:
   GetValidTargetsAlongScaledVector = function(self, entity1, entity2, scale)
      if self.BeamDebug then WARN('GetValidTargets') end
      local posV1 = entity1:GetPosition()
      local posV2 = entity2:GetPosition()
      local modPos = utilities.GetScaledDirectionVector( posV1, posV2, scale )
      if self.BeamDebug then
         WARN('modPos x: ', modPos[1],'modPos y: ', modPos[2],'modPos z: ', modPos[3])
      end
      local targets, targByDist = {}
      local targets = GetEntitiesInRect( Rect(modPos[1] - scale, modPos[3] - scale, modPos[1] + scale, modPos[3] + scale) )
      if targets == nil or table.getsize(targets) < 0 then return nil end
      for a, b in targets do
         if not b:BeenDestroyed() and b:GetHealth() > 0 then
            table.insert(targByDist, {dist = utilities.XZDistanceTwoVectors(posV1, b:GetPosition()), unit = b})
         end
      end
      table.sort(targByDist, sort_by('dist'))
      if self.BeamDebug then
         for c, d in targByDist do
            WARN('    Unit: ', d:GetEntityId(), ' Distance: ', utilities.XZDistanceTwoVectors(posV1, d:GetPosition()) )
         end
      end
      return targByDist
   end,

Statistics: Posted by Resin_Smoker — 11 May 2015, 15:15


]]>
2015-05-11T13:35:35+02:00 2015-05-11T13:35:35+02:00 /viewtopic.php?t=9928&p=99907#p99907 <![CDATA[Re: Need help calculating a location]]>
something like this might work
Code:
A + NormalizeVector( GetDirectionVector( v1, v2 ) )*length

Statistics: Posted by Myxir — 11 May 2015, 13:35


]]>
2015-05-11T13:21:14+02:00 2015-05-11T13:21:14+02:00 /viewtopic.php?t=9928&p=99906#p99906 <![CDATA[Re: Need help calculating a location]]>
Resin

Statistics: Posted by Resin_Smoker — 11 May 2015, 13:21


]]>
2015-05-11T10:28:37+02:00 2015-05-11T10:28:37+02:00 /viewtopic.php?t=9928&p=99904#p99904 <![CDATA[Re: Need help calculating a location]]> Statistics: Posted by Vee — 11 May 2015, 10:28


]]>
2015-05-11T05:20:47+02:00 2015-05-11T05:20:47+02:00 /viewtopic.php?t=9928&p=99897#p99897 <![CDATA[Re: Need help calculating a location]]>
Find the difference between the X and Z values for the positions of the units. Use that to calculate the distance. Then calculate two ratios, one for the X value over the distance and one for the Z value over the distance. (These would be called "Sine" and "Cosine" in trigonometry). Then pull whatever your set distance between unit B and position D is (I assume it's a fixed value?) and multiple these ratios times the set distance, and you have your X and Z position deviations from unit B.

Statistics: Posted by FunkOff — 11 May 2015, 05:20


]]>
2015-05-11T05:17:05+02:00 2015-05-11T05:17:05+02:00 /viewtopic.php?t=9928&p=99896#p99896 <![CDATA[Re: Need help calculating a location]]>
Given a vector from A to B, you can obtain a vector from A to a point beyond B by multiplying it by a scalar.

It's also not quite true that a vector is "a direction": a vector represents both direction and magnitude.

Statistics: Posted by ckitching — 11 May 2015, 05:17


]]>
2015-05-11T04:22:41+02:00 2015-05-11T04:22:41+02:00 /viewtopic.php?t=9928&p=99895#p99895 <![CDATA[Re: Need help calculating a location]]> Statistics: Posted by IceDreamer — 11 May 2015, 04:22


]]>
2015-05-11T03:41:07+02:00 2015-05-11T03:41:07+02:00 /viewtopic.php?t=9928&p=99894#p99894 <![CDATA[Need help calculating a location]]>
What i want to do is use both units locations to create a vector (direction) and then set a new location a specific distance along said vector.

Example:

Unit A Position.
Unit B Position.
New Destination along the same vector a given distance away.

A ------ B -----> D

While i can easily calculate a vector from two points, creating a new destination from said vector and a specified distance has eluded me thus far.

Thanks in advance!

Resin

Statistics: Posted by Resin_Smoker — 11 May 2015, 03:41


]]>