Throw at mouse position
5 replies



06.06.18 03:30:27 pm
Code:
1
parse("spawnprojectile "..id.." 72 "..player(id,"x").." "..player(id,"y").." 500 "..player(id,"rot").."")
How to make the gas grenade throw at mouse position instead of the "500 number"

JENKO
math.sqrt((player(id,"mousex")-player(id,"x"))^2 + (player(id,"mousey")-player(id,"y"))^2)
Might have messed up brackets. Basically the difference between coordinates in x in power of 2 and added to the difference between coordinates in y in power of 2 and then the result is in power of 1/2 (root).
Code:
1
2
2
local WhatIsBrain= math.sqrt((player(id,"mousex")-player(id,"x"))^2 + (player(id,"mousey")-player(id,"y"))^2)
parse("spawnprojectile "..id.." 72 "..player(id,"x").." "..player(id,"y").." "..WhatIsBrain.." "..player(id,"rot").."")
parse("spawnprojectile "..id.." 72 "..player(id,"x").." "..player(id,"y").." "..WhatIsBrain.." "..player(id,"rot").."")
a² + b² = c²..
Share time limited free games here

Apologies, forgot that "mousex" and "mousey" are for screen positions. Change them into "mousemapx" and "mousemapy".
Looking at 'player' lua command description, I actually found that blazzingxx implemented that as a player variable. Just use this instead:
Looking at 'player' lua command description, I actually found that blazzingxx implemented that as a player variable. Just use this instead:
parse("spawnprojectile "..id.." 72 "..player(id,"x").." "..player(id,"y").." "..player(id,"mousedist").." "..player(id,"rot"))



