PDA

View Full Version : Drawing enemy positions on the Hud


Dragonfly_of_Forgery
26th Aug 2001, 12:11 AM
In the guidedwarshell it has this beautiful piece of code:


simulated function PostRender( canvas Canvas )
{
local float Dist;
local Pawn P;
local int XPos, YPos;
local Vector X,Y,Z, Dir;

GetAxes(Rotation, X,Y,Z);
Canvas.Font = Font'TinyRedFont';
if ( Level.bHighDetailMode )
Canvas.Style = ERenderStyle.STY_Translucent;
else
Canvas.Style = ERenderStyle.STY_Normal;
foreach visiblecollidingactors(class'Pawn', P, 2000,, true)
{
Dir = P.Location - Location;
Dist = VSize(Dir);
Dir = Dir/Dist;
if ( (Dir Dot X) > 0.7 )
{
XPos = 0.5 * Canvas.ClipX * (1 + 1.4 * (Dir Dot Y));
YPos = 0.5 * Canvas.ClipY * (1 - 1.4 * (Dir Dot Z));
Canvas.SetPos(XPos - 8, YPos - 8);
Canvas.DrawIcon(texture'CrossHair6', 1.0);
Canvas.SetPos(Xpos - 12, YPos + 8);
Canvas.DrawText(Dist, true);
}
}
}


Could someone explain it all? In particuar:


What does "dot" do?
What are all the numbers in the XPos = 0.5 * etc line?
How do I make this work correctly when the players FOV is higher or lower than 90?

2COOL4-U
26th Aug 2001, 01:43 AM
What does "dot" do?
I think this does the same as placing a .(Dunno for sure never saw it before)

EvilDrWong
26th Aug 2001, 02:41 AM
Isnt DOT something to return the Dot product or something tacky like that? i dont know how on earth it works... but apparently its a good thing to use in situations like that. And from what i have gathered the Canvas.ClipY and Canvas.ClipX are the screensize... like 320x240 or 640x480... maybe?
and theres no way that it can work correctly with a FOV other than 90. Its just the law, it even says so in the Big Book Of Laws What I Just Made Up Because I Am Tired And I Drank A Bit Too Much For My Weenie 127 Lb Frame Can Handle Says The Pirate: Yar! Har Har Har
"If any persons playing the computer game 'Unreal Tournament' wishes to have the thing with the DOT and the Canvas work at any Field of view other than 90 they will die. Its the law"

Dragonfly_of_Forgery
26th Aug 2001, 06:00 AM
There must be a way...

Postal
26th Aug 2001, 07:59 AM
Look at the rifle hud, theres code to adjust the scale of the crosshairs depending on the zoom, you could try that

Bytekeeper
26th Aug 2001, 08:17 AM
You might as well load Pfoenix's aimtrainer and expand the .uc files ( on your own risk lol ). Since the enemy stuff is drawn into the HUD imho you may find something useful in there...

Postal
26th Aug 2001, 08:45 AM
I dont suggest using other peoples ideas or code with out permission.

Dragonfly_of_Forgery
26th Aug 2001, 11:26 PM
Originally posted by Postal
I dont suggest using other peoples ideas or code with out permission.

Uh... no.... of course not...

Dragonfly goes away to recode 70% of the Seekers Pack

Actually, most of the code that I steal is from UT itself so that's ok.

Last time I stole some code I ended up making a monster that attacked itself. It waved its stick and then took damage.


I haven't checked with the rifle thing but I think the "scale" variable is only used for the little number that shows your zoom.

Bytekeeper
27th Aug 2001, 02:45 PM
I didn't mean copy&paste ;) And any coder once extracted .uc files from another mod to see "how he has done it".
For sure, the best would be to as Pfoenix, but if you don't just copy&paste it out, but understand how it works, it's imho no problem.

Bytekeeper
27th Aug 2001, 04:54 PM
Oh just looked at the WAR site a bit, now I understand you a bit more postal. Copying other peoples code without permission is for sure not the way it should go. That is something I would never do. ( Only if it is not allowed to use UT code lol )
About the ideas... As soon as you implement something new and special, be sure that it'll be in many other mods too. Most of the time one thinks that he or she developed something new it was already there.
The trick is to use the best ideas I mean, if something's working, why try to avoid using it. Take most of the counter terroristc mods of today, they all say they`re "special" but everything start from a basic idea.
Even most commercial games use to copy ideas from other people without even crediting them.

I'm one of those who thinks that a great ideas have the right to be used in more than one game/mod. Not doing that would kill the mod community.
( If everybody would just copy code of others, mods would die too )

2COOL4-U
28th Aug 2001, 09:55 AM
ByteKeeper I agree with you!