PDA

View Full Version : [LScript] Basic 2D-Radar



tamimego
2nd April 2006, 17:28
Yeh ive converted to LScript, its amazingly fast and an extremely new syntax to learn on.
This release exists because h4t3d asked me to.

Credits:
Pickelicious ( dunno how to spell )
HelioS

Preview:
http://img306.imageshack.us/img306/1451/shot000125mb.jpg

What you get?:
Basic LUA Scripted 2D-Radar
Range Adjustment and Clamping
Team Recognition

In PostRender:

Above: DrawPlayerESP call in PostRender

DrawPlayerRadar(Canvas, PRI)

Above: --Restore Visuals

fRadarX = 15
fRadarY = ( Canvas.SizeY / 2 ) - 170
fRange = 50

Canvas.SetDrawColor(0, 0, 0, 255)
Canvas.SetPos(fRadarX + fRange - 2, fRadarY + fRange - 2)
Canvas.DrawTile(TWhite, 4, 4, 0, 0, 4, 4, Canvas.DrawColor)

Canvas.SetDrawColor(255, 255, 255, 255)
Canvas.SetPos(fRadarX + fRange - 1, fRadarY + fRange - 1)
Canvas.DrawTile(TWhite, 2, 2, 0, 0, 2, 2, Canvas.DrawColor)

In Functions:

Above: DrawPlayerESP


-------------------------------------------------------------------------------
function DrawPlayerRadar(Canvas, PRI)

if (PRI.PlayerName == nil) or PRI.bDead or PRI.bIsSpectator or
PRI.bOnlySpectator or PRI.bWaitingPlayer then
return
end
local LocVec = Engine.New(FVector)
local Vec = Engine.New(FVector)
local AdjRot = Engine.New(FRotator)
AdjRot.Pitch = 0
AdjRot.Yaw = 16384
AdjRot.Roll = 0
if Pawn then
LocVec.X = Pawn.Location.X
LocVec.Y = Pawn.Location.Y
LocVec.Z = Pawn.Location.Z
else
LocVec.X = PRI.LocationX
LocVec.Y = PRI.LocationY
LocVec.Z = PRI.LocationZ
end
local D = Canvas.Subtract_VectorVector(LocVec, ViewVec)
D.Z = 0
local R = Canvas.Add_RotatorRotator(ViewRot, AdjRot)
R.Roll = 0
R.Pitch = 0
X, Y, Z = Canvas.GetAxes ( R, Vec, Vec, Vec )
local fPosX = ( ( D.X * X.X + D.Y * X.Y + D.Z * X.Z ) / 60 )
local fPosY = ( ( D.X * Y.X + D.Y * Y.Y + D.Z * Y.Z ) / 60 )
fPosX = Canvas.FClamp ( fPosX, -fRange + 3, fRange - 3 ) + ( fRadarX + fRange );
fPosY = Canvas.FClamp ( fPosY, -fRange + 3, fRange - 3 ) + ( fRadarY + fRange );
Canvas.SetDrawColor(0, 0, 0, 255)
Canvas.SetPos(fPosX - 2, fPosY - 2)
Canvas.DrawTile(TWhite, 4, 4, 0, 0, 4, 4, Canvas.DrawColor)
if PRI.Team and LocalPRI.Team and (#PRI.Team == #LocalPRI.Team) then
Canvas.SetDrawColor(0, 255, 0, 255)
else
Canvas.SetDrawColor(255, 0, 0, 255)
end
Canvas.SetPos(fPosX - 1, fPosY - 1)
Canvas.DrawTile(TWhite, 2, 2, 0, 0, 2, 2, Canvas.DrawColor)

end

SmokeZ
2nd April 2006, 17:36
RadarPosX = 6
RadarPosY = 470

function Draw2DRadar(Canvas, PRI)

--make sure its a valid player
if (PRI == nill) or (PRI.PlayerName == nill) or PRI.bDead or PRI.bIsSpectator or PRI.bOnlySpectator or PRI.bWaitingPlayer then
return
end

local PosX, PosY, RadarRange
local X = Engine.New(FVector)
local Y = Engine.New(FVector)
local Z = Engine.New(FVector)
local D = Engine.New(FVector)

X = ViewAxesX
Y = ViewAxesY
Z = ViewAxesZ

D.X = PRI.LocationX - PC.ViewTarget.Location.X
D.Y = PRI.LocationY - PC.ViewTarget.Location.Y
D.Z = PRI.LocationZ - PC.ViewTarget.Location.Z

D.Z = 0.0
RadarRange = 67.0

PosX = ((D.X * X.X) + (D.Y * X.Y) + (D.Z * X.Z)) / 21
PosY = ((D.X * Y.X) + (D.Y * Y.Y) + (D.Z * Y.Z)) / 21
PosX = FClamp(PosX, -RadarRange, RadarRange)
PosY = FClamp(PosY, -RadarRange, RadarRange)
PosX = PosX + RadarPosX + 78
PosY = PosY + RadarPosY + 80

if (PRI.Team == nill) then
Canvas.SetDrawColor(0,0,255)
else
if (PRI.Team) and (PRI.Team.TeamIndex == PC.PlayerReplicationInfo.Team.TeamIndex) then
Canvas.SetDrawColor(0,255,0)
else
Canvas.SetDrawColor(255,0,0)
end
if(PRI.bVIPPS) then
Canvas.SetDrawColor(32,178,170)
end
if (PRI.bAdmin) then
Canvas.SetDrawColor(30,30,30)
end
end

Canvas.SetPos(PosX,PosY)

if (PRI == PC.PlayerReplicationInfo) then
Canvas.DrawText("X")
else
Canvas.DrawText("o")
end
end

here is my version.. took me about 2min to convert it from uscript °_°

http://img407.imageshack.us/img407/2127/00009rg.jpg

unreal-pwner
2nd April 2006, 17:38
nice job, i needa get this crap to compile, then ill start releasing codes and such..gj man hooah

KizZamP-
2nd April 2006, 17:38
nice job tamimego,ss looks nice too :)
but like i told picklelicious, "(PRI.PlayerName == nil)", am i just reading this wrong? or does it just have to be "none" or "null" cause i don't know a word called "nil".

tamimego
2nd April 2006, 17:38
Your missing an important thing in the rotation, but anyways.

Homer
2nd April 2006, 17:39
wow nice job tami looks fantastic, nice job smoke also hoah

@kizz.. lol read the code and u will understand

KizZamP-
2nd April 2006, 17:43
yes i know but i just didn't know the world "nill"...

Homer
2nd April 2006, 17:44
i dont know the word "nill" too but who cared as long u understand what it do.
enough offtopic now ^^
later

Picklelicious
2nd April 2006, 17:53
I screwed that up. It is 'nil' with one L and not 'nill'.

Lua has a value 'nil' which is similar to C's 'null'. It means is has nothing in it. It is not the same as 0 (zero). In Lua, null pointers are nil pointers.

tamimego
2nd April 2006, 17:56
picklelicious, you wouldn't happen to have msn by any chance? Theres some stuff I wanted to talk to you about that I would prefer not discuss publicly. my msn is in my profile, if you have it please add.

unreal-pwner
2nd April 2006, 20:31
good job man, looks nice...cant wait to figure out how to load the damn console..lol

Homer
2nd April 2006, 21:48
didnt u read picklelicious txt file?
after its injected u can open the lua console with ALT + L ;)

Tibike
12th November 2006, 15:40
function KeyEvent(Key, Action, Value)
--Check if the game console is open
if PC.Player.Console.bTyping then
return false
end

--Check if the game menu is open
if PC.Player.GUIController.bVisible then
return false
end

function Draw2DRadar(Canvas, PRI)

--make sure its a valid player
if (PRI == null) or (PRI.PlayerName == null) or PRI.bDead or PRI.bIsSpectator or PRI.bOnlySpectator or PRI.bWaitingPlayer then
return
end

local PosX, PosY, RadarRange
local X = Engine.New(FVector)
local Y = Engine.New(FVector)
local Z = Engine.New(FVector)
local D = Engine.New(FVector)

X = ViewAxesX
Y = ViewAxesY
Z = ViewAxesZ

D.X = PRI.LocationX - PC.ViewTarget.Location.X
D.Y = PRI.LocationY - PC.ViewTarget.Location.Y
D.Z = PRI.LocationZ - PC.ViewTarget.Location.Z

D.Z = 0.0
RadarRange = 67.0

PosX = ((D.X * X.X) + (D.Y * X.Y) + (D.Z * X.Z)) / 21
PosY = ((D.X * Y.X) + (D.Y * Y.Y) + (D.Z * Y.Z)) / 21
PosX = FClamp(PosX, -RadarRange, RadarRange)
PosY = FClamp(PosY, -RadarRange, RadarRange)
PosX = PosX + RadarPosX + 78
PosY = PosY + RadarPosY + 80

if (PRI.Team == null) then
Canvas.SetDrawColor(0,0,255)
else
if (PRI.Team) and (PRI.Team.TeamIndex == PC.PlayerReplicationInfo.Team.TeamIndex) then
Canvas.SetDrawColor(0,255,0)
else
Canvas.SetDrawColor(255,0,0)
end
if(PRI.bVIPPS) then
Canvas.SetDrawColor(32,178,170)
end
if (PRI.bAdmin) then
Canvas.SetDrawColor(30,30,30)
end
end

Canvas.SetPos(PosX,PosY)

if (PRI == PC.PlayerReplicationInfo) then
Canvas.DrawText("X")
else
Canvas.DrawText("o")
end
end

function PostRender(Canvas)
if (PC.Pawn) then
if (PC.Pawn.Weapon) then
PC.bPerfectAccuracy = true
PC.Pawn.Weapon.bWpnRecoil = false
PC.Pawn.Weapon.bWpnAccuracy = false
end
end
end


pls help me error message::\default.lua:76: 'end' expected (to close 'function' at line 1) near '<eof>'

utopiah
12th November 2006, 16:51
well, you opened your function keyEvent but never closed it

so don't forget to close that function first before opening a new function

Utopiah