{"action":"created","issue":{"url":"https://api.github.com/repos/OpenRA/OpenRA/issues/9357","labels_url":"https://api.github.com/repos/OpenRA/OpenRA/issues/9357/labels{/name}","comments_url":"https://api.github.com/repos/OpenRA/OpenRA/issues/9357/comments","events_url":"https://api.github.com/repos/OpenRA/OpenRA/issues/9357/events","html_url":"https://github.com/OpenRA/OpenRA/pull/9357","id":106706209,"number":9357,"title":"Added a LineImpactProjectile (Attempt 2)","user":{"login":"UberWaffe","id":2726355,"avatar_url":"https://avatars.githubusercontent.com/u/2726355?v=3","gravatar_id":"","url":"https://api.github.com/users/UberWaffe","html_url":"https://github.com/UberWaffe","followers_url":"https://api.github.com/users/UberWaffe/followers","following_url":"https://api.github.com/users/UberWaffe/following{/other_user}","gists_url":"https://api.github.com/users/UberWaffe/gists{/gist_id}","starred_url":"https://api.github.com/users/UberWaffe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UberWaffe/subscriptions","organizations_url":"https://api.github.com/users/UberWaffe/orgs","repos_url":"https://api.github.com/users/UberWaffe/repos","events_url":"https://api.github.com/users/UberWaffe/events{/privacy}","received_events_url":"https://api.github.com/users/UberWaffe/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/OpenRA/OpenRA/labels/PR:%20Changes%20requested","name":"PR: Changes requested","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-09-16T06:10:12Z","updated_at":"2015-09-25T06:28:02Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/OpenRA/OpenRA/pulls/9357","html_url":"https://github.com/OpenRA/OpenRA/pull/9357","diff_url":"https://github.com/OpenRA/OpenRA/pull/9357.diff","patch_url":"https://github.com/OpenRA/OpenRA/pull/9357.patch"},"body":"Attempt number 2 at  #6252\r\n\r\nNew projectile can create multiple weapon impacts along its travel vector.\r\n(i.e. apply all warheads effects at multiple positions as it travels).\r\n\r\nIt has a leading head position, and a following tail position, and renders a beam (LaserZap) between these two positions. Weapon impacts are created (iteratively over the distance) between the head and tail, at definable intervals.\r\n\r\nThe tail position (origin of beam) tracks the firing actor until it detaches and travels on its own. This means that if you move the firing actor while the beam is firing, it does track correctly.\r\n\r\nYou can currently tell it to:\r\n* Define how many ticks the tail must lag the head (i.e. the length of the travelling beam).\r\n* Create an impact every WRange, every X ticks, between head and tail.\r\n* Only create an impact if at least WRange away from its source.\r\n* Only create an impact if at least within WRange of its target.\r\n* Keep traveling for up to WRange beyond its target.\r\n* Have damage falloff (essentially passed as a firepowermodifier to the weapon during impact) that\r\n  * Has a WRange before it starts\r\n  * Has a WRange at which it reaches maximum falloff\r\n  * Has a maximum falloff.\r\n\r\nWas based off mixture of Bullet and LaserZap.\r\n\r\nDoes NOT support\r\n* A proper rendering engine to make it look like something other than a basic beam. (Currently looks fine for instant-hit beams. But slow-moving beams are ugly.)\r\n\r\nI still have to do:\r\n* The target is a static position, so if you fire at a moving actor, even while the firing actor is still busy emitting the beam, the head does not 'track' the target. Not sure how to do this. (Would like to make this an Info setting.)\r\n* ~~Add Ray-casting, finding all actors within the bounds of the beam's length and width. #8186~~\r\n* ~~Make warheads apply to actors directly, ignoring warhead spreads.~~ (Causes crashes and unexpected behavior. Will require some warhead refactoring, or at least a new warhead type.)\r\n* ~~When the actor is ordered to stop, the beam should stop emitting if still busy.~~\r\n* ~~When the actor dies, the beam should stop emitting if still busy.~~\r\n\r\nStill to be tested:\r\n* ~~That walls properly block the beam if the beam is blockable.~~\r\n* ~~That the projectile properly works for 'short' beams, such as D2K sonic ball.~~ Works, though very short beams render as practically invisible.\r\n* ~~That the projectile properly works for brief instant-hit beams, such as TS railguns.~~ Works\r\n\r\nPossibly Closes  #4458.\r\n\r\nI've attempted to apply it to the D2K sonic tank, and the TS disruptor tank, but balancing needs work.\r\n\r\n@pchote: I've re-read and attempted to apply all the requests in #6252. But given that this is over an year overdue, I suspect much has changed and the requirements need revisiting.\r\n\r\nSidenote: I apologize for dropping the ball on this last year."},"comment":{"url":"https://api.github.com/repos/OpenRA/OpenRA/issues/comments/143140771","html_url":"https://github.com/OpenRA/OpenRA/pull/9357#issuecomment-143140771","issue_url":"https://api.github.com/repos/OpenRA/OpenRA/issues/9357","id":143140771,"user":{"login":"UberWaffe","id":2726355,"avatar_url":"https://avatars.githubusercontent.com/u/2726355?v=3","gravatar_id":"","url":"https://api.github.com/users/UberWaffe","html_url":"https://github.com/UberWaffe","followers_url":"https://api.github.com/users/UberWaffe/followers","following_url":"https://api.github.com/users/UberWaffe/following{/other_user}","gists_url":"https://api.github.com/users/UberWaffe/gists{/gist_id}","starred_url":"https://api.github.com/users/UberWaffe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UberWaffe/subscriptions","organizations_url":"https://api.github.com/users/UberWaffe/orgs","repos_url":"https://api.github.com/users/UberWaffe/repos","events_url":"https://api.github.com/users/UberWaffe/events{/privacy}","received_events_url":"https://api.github.com/users/UberWaffe/received_events","type":"User","site_admin":false},"created_at":"2015-09-25T06:28:02Z","updated_at":"2015-09-25T06:28:02Z","body":"> There is a .HorizontalLengthSquared property for calculating only the x and y components.\r\nExcellent, that will help a lot.\r\n\r\n> [number] / [larger number] will always return 0.\r\nYes, I had that issue in the first round of trying integer only. (The effect is rather obvious in game, as only actors close to the 'head' and 'tail' of the ray are intersected. None along the ray length are intersected.) I've managed to avoid that this round.\r\n\r\nI've currently done the following:\r\n```// Should be dist = (target - source).LengthSquared;```\r\n```// But in order to avoid floating points, we do not divide here, but rather work with the large numbers as far as possible.```\r\n```var dist = 1;```\r\n```var ans = (xDiff + yDiff) / dist;```\r\n\r\nAnd then only divide here, after first multiplying:\r\n```// Using floating points, this would be: var newX = (int)((double)target.X + t * (double)(source.X - target.X));```\r\n```// where t would already be divided by squaredLength.```\r\n```var newX = (int)(target.X + (t * (source.X - target.X) / squaredLength));```\r\n```var newY = (int)(target.Y + (t * (source.Y - target.Y) / squaredLength));```\r\n\r\nI used ```Log.Write``` to log the steps of the calculation along the way, and it was returning values close to what the floating point math had returned.\r\n\r\nI'll implement the * 1024 factor and do the same, and see if the accuracy improves."}}