New widget: Enemy Spotter - Page 8

New widget: Enemy Spotter

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: New widget: Enemy Spotter

Post by Argh »

Hrmm.

Image
Attachments
screen00074.jpg
screen00074.jpg (27.1 KiB) Viewed 1099 times
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

Re: New widget: Enemy Spotter

Post by TradeMark »

thats too strong color, use opacity of 0.23 for the strongest color there just like in my widget, and change to blue color

then it should look perfect
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: New widget: Enemy Spotter

Post by Argh »

It doesn't work like that. It's a quad. I can turn down total opacity, just by changing a line of code, tho.

As for blue... no way, you can change that line in your personal version:

Code: Select all

glColor(0,0,1,0.9)
But most people, including myself, strongly associate Red with Enemy, because that's the color code in most games. People can make it pink (1,0.9,0.9,0.9) if they want to, but my official version is red.
User avatar
very_bad_soldier
Posts: 1397
Joined: 20 Feb 2007, 01:10

Re: New widget: Enemy Spotter

Post by very_bad_soldier »

Niobium wrote: I copied & renamed my modified teamplatters widget. And replaced the 1 display list call for polygons with 1 display list call for texture quad. Which I believe is more of a valid test of texture vs polygon than comparing two DIFFERENT widgets, as VBS did. But feel free to use his result to declare yourself the winner if you want to look stupid.
Sorry, but I just cant see how using your own secret code nobody has ever seen while using a test environment you dont talk about is a valid test.
Just add some facts and post your code already. We will all be happy if it is really three times as fast.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: New widget: Enemy Spotter

Post by Argh »

Uh, I posted my version of TradeMark's, so test that, it's pretty much apples-->apples.

I admit, in the other one I posted, I thought I'd sped it up enough for it to show true TC without adding to cost... wrong-o.

Curious to see how much moving that stupid glTexture helped, though. That was a stupid error, especially after me talking about how much those cost, in other contexts :roll:

That about what you wanted, TradeMark? That's that code I posted (the rewrite of yours), 2.6 for the radius, and glColor(0,0,1,0.5). Oh, and here's the modified TGA, it's in the zip.
Image

Oh, and before anybody complains, yes, it clips. Don't want it to? Change glDepthTest(false), just be aware it might cause issues with other graphics.
Attachments
StaticCircle.zip
(34.92 KiB) Downloaded 17 times
screen00075.jpg
(63.5 KiB) Downloaded 2 times
Last edited by Argh on 17 Dec 2009, 16:01, edited 2 times in total.
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

Re: New widget: Enemy Spotter

Post by TradeMark »

yeah something like that, now benchmark again by using those settings?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: New widget: Enemy Spotter

Post by Argh »

Yeah, should be a good test. I am really doubting there's going to be a 300% difference, though. I am kinda curious whether it'd get faster if I use a shader... surely not, for something this basic. But I may get bored and try it out, I think the one in P.U.R.E. needs some shader magic anyhow.
User avatar
very_bad_soldier
Posts: 1397
Joined: 20 Feb 2007, 01:10

Re: New widget: Enemy Spotter

Post by very_bad_soldier »

Okay gentlemen, here are the results. Same setup as yesterday.
(I will post the profiler screenshots if someone wants to see, but you can just believe it without :mrgreen:)
I tested all three version again to be sure the results are comparable.

Again time in DrawWorldPreUnit:
Argh v2: 2.44 ms
Trademark: 2.79 ms
Argh: 4.24 ms

So, Argh has taken the lead (slightly). He is about 15% faster today.

PS. Argh your units look awesome!
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: New widget: Enemy Spotter

Post by Argh »

15% faster, and a texture. That's acceptable.

I assume that third figure's the fixed one with true TC? If so, then I should look at it again, removing that glTexture should've sped things up more than that, I'd have thought.

And that's not really "my" unit, it's a CA one I did a little repaint and minor fixes on, then applied a basic shader to. It's in WB because I wanted a generic "guardbot" for some maps where I wanted Gaia enemies. Credit where credit's due, that's certainly not my design.
Last edited by Argh on 17 Dec 2009, 16:13, edited 1 time in total.
User avatar
very_bad_soldier
Posts: 1397
Joined: 20 Feb 2007, 01:10

Re: New widget: Enemy Spotter

Post by very_bad_soldier »

The third one is the same as I tested yesterday. I made the same test again but added your v2 version this time.

Dont ask me why the absolute results for those two differ from yesterday, maybe I had VMWare running in background yesterday or something.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: New widget: Enemy Spotter

Post by Argh »

Please test the fixed one. Really curious how close that got me to the original's speed. Probably not enough, but I'm hoping it's within 25%.

And meh, absolute results are going to vary with whatever's happening in the gamecode in general anyhow, I don't really take it all that seriously, so long as it's fast enough.
User avatar
very_bad_soldier
Posts: 1397
Joined: 20 Feb 2007, 01:10

Re: New widget: Enemy Spotter

Post by very_bad_soldier »

Okay, did a complete set again. Results:
Argh v2: 2.40ms
Argh v1 fixed: 2.70ms
Trademark: 2.78 ms
Argh v1: 4.35 ms
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: New widget: Enemy Spotter

Post by Argh »

Well, I'll be darned. That was one really expensive one-line mistake. Guess I need to review all of my code now, that's just plain wasteful, and I'm probably guilty of similar screwups elsewhere. Thanks.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: New widget: Enemy Spotter

Post by lurker »

Argh wrote:My understanding about this was that if we localized like this:

local GetUnitPosition = Spring.GetUnitPosition

...then we're saving an upvalue call on a regular basis, because that memory address was localized within the application at runtime. What you're saying implies that it's being re-localized every pass, and therefore the cost savings are zero.
You are saving a lookup in the global table, followed by a lookup in the Spring table, and replacing it WITH an upvalue, which is faster. How did you manage to get the wrong labels for everything? Did you have the wrong definition of upvalue before this thread or did you make a weird assumption from my post?
Argh wrote:And, at least in the case of anywhere where we need to call a value in multiple places, it seems counterintuitive that we'd actually improve speed by doing this:

Code: Select all

subfunction(value)
  ... do stuff to value
  return value
end

function blah()
  local value
  ... do stuff to value
  subfunction(value)
  value = value
end
Doing that as opposed to what? You have to show me the change you mean or I can't tell how performance is altered. But you have some clear nonsense in there. value=value?

Argh wrote:I mean, if that's actually better, fine, it just seems counterintuitive, I thought variable initialization wasn't something we should waste cycles on, though.
WHAT initialization?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: New widget: Enemy Spotter

Post by jK »

Argh wrote:

Code: Select all

function widget:DrawWorldPreUnit()
	glDepthTest(true)
	glTexture(texture)
	glColor(1.0,0,0,1.0)
	local teamID, ud
	local visible = GetVisibleUnits(ALL_UNITS, myTeamID, false)

	for i = 1,#visible do
		unitID = visible[i]
		teamID = spGetUnitTeam(unitID)
		if teamID ~= LocalTeam then
			ud = spGetUnitDefID(unitID)
			radius = radiusDefs[ud]
			glDrawListAtUnit(unitID, SimpleCircle, false, radius, 1.0, radius, 0, 0, 0, 0)
		end
	end
end
I might be a bit harsh, but:
grrr I told you already MULTIPLE times you have to disable the texture after you used it! else the next widget will render everything with your damn texture!
Also the wiki says:

Code: Select all

Spring.GetVisibleUnits 
 ( [number teamID = -1 [, number radius = 30 [, boolean Icons ]]] )
   -> nil | unitTable = { [1] = number unitID, ... }
how does that fit with your GetVisibleUnits(ALL_UNITS, myTeamID, false) ?

fixed code is:

Code: Select all

function widget:DrawWorldPreUnit()
	glDepthTest(true)
	glTexture(texture)
	glColor(1.0,0,0,1.0)

	local visEnemies = GetVisibleUnits(Spring.ENEMY_UNITS, nil, false)
	for i=1, #visEnemies do
		unitID = visEnemies[i]
		ud = spGetUnitDefID(unitID)
		radius = radiusDefs[ud]
		glDrawListAtUnit(unitID, SimpleCircle, false, radius, 1.0, radius, 0, 0, 0, 0)
	end

	glColor(1,1,1,1)
	glTexture(false)
end
User avatar
Jazcash
Posts: 5309
Joined: 08 Dec 2007, 17:39

Re: New widget: Enemy Spotter

Post by Jazcash »

Awesome. So now there's a widget to spot enemies for you. It's not long now before widgets play the game for you.
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

Re: New widget: Enemy Spotter

Post by TradeMark »

says a guy who has over 9000 widgets in use ^^

i made this widget because i got annoyed of dgunning allies Raiders (also my own raiders xD), since they have almost no teamcolor in their texture, and even if they had, its still fucking hard to distinguish enemies from allies in a big mess of both sides units...

also this is fucking awesome widget for air attacks... you can easily see which one is enemy air unit, many times ive been like "OMFG YOU GET COMNAPPED" but it was ally atlas... -_-

also this helps in finding those units you didnt kill in your base... for example some radar planes or scout planes lying around your base... happens a lot of times, at least for my enemies when i scout, sometimes it takes half a hour until they notice them :D
User avatar
Jazcash
Posts: 5309
Joined: 08 Dec 2007, 17:39

Re: New widget: Enemy Spotter

Post by Jazcash »

TradeMark wrote: i made this widget because i got annoyed of dgunning allies Raiders (also my own raiders xD)
Fair enough, make a widget for yourself because you can't aim. I'll forgive you.
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

Re: New widget: Enemy Spotter

Post by TradeMark »

lol, its not about aiming, its about knowing which one of them is enemy or ally... not easy with raiders
User avatar
Jazcash
Posts: 5309
Joined: 08 Dec 2007, 17:39

Re: New widget: Enemy Spotter

Post by Jazcash »

TradeMark wrote:lol, its not about aiming, its about knowing which one of them is enemy or ally... not easy with raiders
Well, maybe I have a little advantage using the Team Platter widget and having the distance units become dots at around 150.
Post Reply

Return to “Lua Scripts”