-
Active Member
teleport where character is facing ?
Last edited by uzzy13u; 03-24-2022 at 07:29 AM.
-
Active Member
Use cos and sin on your player facing angle to calculate a vector for the change in x/y
-
Post Thanks / Like - 1 Thanks
uzzy13u (1 members gave Thanks to pinny for this useful post)
-
Banned
Originally Posted by
uzzy13u
hi all
i manage to make simple teleports in c # using x,y,z
now i am trying to learn how to teleport 10 yards for example in front of my char and yes i have (x,y,z and character orientation) i need some formula i think
anyone can tell me please how this works ?
I already made that long time ago when i used to create my hacks for wow.
Let me copy pasta my code
yards = 10
local player_x, player_y, player_z, player_o = get_position(playerguid)
local UNIT_X = math.cos(player_o)*yards
local UNIT_Y = math.sin(player_o)*yards
newx, newy, newz, newo = player_x + UNIT_X , player_y + UNIT_Y , player_z, player_o
Teleport(newx, newy, newz, newo);
Last edited by r4zyel2; 01-21-2017 at 06:51 AM.
-
Post Thanks / Like - 3 Thanks
-
I did something similar for some server-side scripting:
Code:
local function BoulderTicker(_, _, _, pUnit)
pUnit:CastSpell(pUnit, 55766) -- Visual
pUnit:PlayDistanceSound(14342) -- rumbling
local plrs = pUnit:GetPlayersInRange(1.35)
if plrs then
for _,v in pairs(plrs) do
local distance = v:GetDistance2d(pUnit)
pUnit:DealDamage(v, 50 - distance, false)
pUnit:CastSpell(v, 43556) -- curse
pUnit:PlayDistanceSound(14341, v) -- hit noise to just player
local x2 = pUnit:GetX()
local y2 = pUnit:GetY()
local x1 = v:GetX()
local y1 = v:GetY()
local x = x2 - x1
local y = y2 - y1
local angle = math.pi + math.atan2(-y, -x)
local x = x1 - ((math.random(1,2) - distance) * math.cos(angle))
local y = y1 - ((math.random(1,2) - distance) * math.sin(angle))
--local z = pUnit:GetMap():GetHeight(x, y) -- It does not detect WMO height, stormwind is a WMO
--if not z then
z = v:GetZ()
--end
if v:IsWithinLoS(x, y, z) then
v:MoveJump(x, y, z, 9, 2.1)
end
end
end
end
-
Post Thanks / Like - 1 Thanks
uzzy13u (1 members gave Thanks to stoneharry for this useful post)
-
-
Banned
Originally Posted by
uzzy13u
thank you very much everyone for help
i will test it
Glad it served to you, are you making hacks for Elysium?
-
Active Member
Originally Posted by
r4zyel2
Glad it served to you, are you making hacks for Elysium?
yes, i found small way to bypass the x,y,z check and i want to improve it more