Author Topic: "Predator" Vision  (Read 8234 times)

0 Members and 1 Guest are viewing this topic.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
"Predator" Vision
« on: July 10, 2006, 09:06:36 PM »
Hi folks.
 Have any of you more advanced LUA scripters made a vision script before?
I found a nice one with three different levels of intensity at FacePunch for Night Vision,
http://forums.facepunchstudios.com/showthread.php?t=114088&highlight=night+vision , but I'm looking for more along the lines of thermal, red background with characters looking blue/yellowish, like in the movie Predator (the original)
 Is there a way to do this? I figure the Night Vision files could be edited to reddish tint, but, that wouldn't make players look bright blue/yellow.
 Is it possible to attach a sprite/texture to a player that only the client sees using LUA?
(I know, v10 might allow this, but I was hoping for now)

Thanks in advance
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Golden-Death

  • Hero Member
  • *****
  • Posts: 751
  • Karma: 0
  • Honored Lua Scripter
    • BlueFire
Re: "Predator" Vision
« Reply #1 on: July 10, 2006, 10:43:19 PM »
Technically possible, but it'd be pretty laggy I think. There are scripts that detect ent positions, like the radar, so itd be easy to make it find ents and draw a rect around them, but still tough.


Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: "Predator" Vision
« Reply #2 on: July 11, 2006, 08:37:06 AM »
I'll have to look into that Radar. Is it like the CS one?
I've seen the holo-radar post. Didn't seem to have potential for what I'm trying to do.
I didn't think of drawing rectangles on/around players.
(See, I knew I asked in the right place)
Does seem like it would be slow though. And not fully what I'd like, but we work with what we have.
The nuclear pack at FP has a Redeemer, that places some type of text above (I think its above, been a while since I used it) player and NPC heads as you're flying it.
 Though the script can't be used well online due to its lag factor when the nuclear explosion goes off, perhaps I could use the ideas from its 'text' tracking to try drawing rectangles.

Also, now that I've slept on it, I think Predator's main vision was more blue blackground, with yellow/red thermals. I'll have to watch to movie to make sure.

Either way, I'm still open to more ideas.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Golden-Death

  • Hero Member
  • *****
  • Posts: 751
  • Karma: 0
  • Honored Lua Scripter
    • BlueFire
Re: "Predator" Vision
« Reply #3 on: July 11, 2006, 02:31:43 PM »
Forgot what its called, but its a radar that draws a a line accross your screen and ents on it are red squares, growing bigger on your screen radar as you approach them


Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: "Predator" Vision
« Reply #4 on: July 12, 2006, 07:00:30 AM »
I searched. Found several radars. None really did what I wanted.
I dug into the Redeemer nuke swep at FP. (I'm at work, can't grab the link right now, darn Websense!! Geez. Like they don't want me to slack or something inbetween other work coding.  ;D ;D )

Here's my version of the 'targetting' code I will hopefully use. (Oh, feel free to modify/edit/use, just credit original SWEP at FP, and tweaks I made.)

HOWEVER... I'd like help with the following....
As discussed previously, I'd like to use rectangles (or some type of sprite? I'm thinking combine ball in reasonable shape of player would be great)instead of Text.
I have no problem drawing a plain rectangle for use in a menu, its pretty static. However, players/npcs move. Am I going to have to write think code to automatically adjust the size of the rectangle? Or can the size of the rectangle be set on the players position, and then it adjust as I move closer/farther away, like the text automatically does now?

Code: [Select]
--Target code idea is from Apocolypse Mod "redeemer" SWEP from FP forums, heavily modified
targs     = {}
radius    = 9999

function findtargets(predid, centervec, radius)
    targs = _EntitiesFindInSphere( centervec, radius )
for i = 1,table.getn(targs) do
    if (string.find (_EntGetType(targs[i]),"npc_",1,true) ~= nil) or
(_EntGetType(targs[i]) == "player")
then
_GModText_Start("Default")
_GModText_SetText("\[ ]")
_GModText_SetColor(255,20,50,200)
_GModText_SetTime(9999,0.1,0.1)
_GModText_SetEntity( targs[i] )
_GModText_SetEntityOffset(vector3(0,0,32))
_GModText_Send(predid,888 + i + predid)
    end
end
end
--[[
 There were originally 15 or more 'if (_EntGetType(targs[i]) == "npc_BLAHBLAH") or' comparisons above.
Where BLAHBLAH was each npc individually from game.
JamminR had hoped there was an easier way.
There is. Thanks to string handling explanation http://www.lua.org/manual/5.1/manual.html#5.4
    string.find (s, pattern [, init [, plain]])
JamminR hasn't timed the two different ones.
Even if not faster, at least its neater/smaller code.
]]--
function hidetargets( predid, channel )
    if (allowindicators == 1) then
for i = 1,table.getn(targs) do
_GModText_Hide(predid,channel + i + predid)
end
    end
end

function DoShowTargets(predid)
   local targetvector = _PlayerGetShootPos(predid)
   findtargets(predid, targetvector, 9999)
end

CONCOMMAND("target",DoShowTargets)
CONCOMMAND("notarget",hidetargets,888)

Edit: I just realized the rectangle can be made into any VMT material. Nice. I can work with that instead of gmod/white. Still, anyone help me with other concerns? I'm concerned width/heigth won't auto if I use _GmodRect_SetPos and SetPosOffset, anyone know? I've not ever worked with the vectors before, and am trepid about doing so
« Last Edit: July 12, 2006, 07:30:51 AM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Golden-Death

  • Hero Member
  • *****
  • Posts: 751
  • Karma: 0
  • Honored Lua Scripter
    • BlueFire
Re: "Predator" Vision
« Reply #5 on: July 12, 2006, 01:36:44 PM »
I suppose parenting a sprite to a player would work. I can't find the radar myself, but basically, it was a gray bar, lthe size of a ruler, in the center of the screen, and as you got closer to a wall, the gray got darker to resemble the wall and red boxes represented ents and grew bigger as you got toward them, kinda like sonar vision would look, it was pretty cool.


Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: "Predator" Vision
« Reply #6 on: July 12, 2006, 02:00:40 PM »
Golden-Death, I found I can apply a material to the rectangular box instead of gmod/white, as long as the material has a vmt file.

My challenge now is getting help if the height/width need dynamic adjust ment, to adjust size if being attached to a ent doesn't make them grow smaller or larger as they move farther away/closer to.

The above target code will be used to apply a color box to each player as they move if I can get everything to work.
As for the rest of the predator vision, I intend to convert the night vision LUA from FP to a blue-ish tint. I'm thinking blue background, with perhaps combine halo/or ball, material as the rect, would make it 'kind of' look like the Predators thermal vision from original movie.

I'm headed home from work soon. Will hopefully know how difficult converting the text to rects will be in a few hours.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Golden-Death

  • Hero Member
  • *****
  • Posts: 751
  • Karma: 0
  • Honored Lua Scripter
    • BlueFire
Re: "Predator" Vision
« Reply #7 on: July 12, 2006, 06:52:55 PM »
Sounds good.