Forum

> > CS2D > Scripts > Throw at mouse position
Forums overviewCS2D overview Scripts overviewLog in to reply

English Throw at mouse position

5 replies
To the start Previous 1 Next To the start

old Throw at mouse position

Jenko63
User Off Offline

Quote
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"

old Re: Throw at mouse position

Rainoth
Moderator Off Offline

Quote
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).

old Re: Throw at mouse position

Bowlinghead
User Off Offline

Quote
1
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").."")
a² + b² = c²..

old Re: Throw at mouse position

Rainoth
Moderator Off Offline

Quote
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:
parse("spawnprojectile "..id.." 72 "..player(id,"x").." "..player(id,"y").." "..player(id,"mousedist").." "..player(id,"rot"))
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview