Forum

> > CS2D > Scripts > Throw at mouse position
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Throw at mouse position

5 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Throw at mouse position

Jenko63
User Off Offline

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

alt Re: Throw at mouse position

Rainoth
Moderator Off Offline

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

alt Re: Throw at mouse position

Bowlinghead
User Off Offline

Zitieren
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²..

alt Re: Throw at mouse position

Rainoth
Moderator Off Offline

Zitieren
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"))
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht