Spectator mode v1.7 (AKA "actionfinder")

Spectator mode v1.7 (AKA "actionfinder")

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

Moderator: Moderators

xyz
Posts: 152
Joined: 29 Nov 2008, 16:06

Spectator mode v1.7 (AKA "actionfinder")

Post by xyz »

Hello, this is my first attempt of learning Lua.

The script was inspired from the MinimapEvents widget written by trepan. It adds a "/luaui specmode" command during gameplay to activate it. You can also use CTRL+ALT+S to enable/disable it and CTRL+ALT+C to switch between normal mode and attract mode.

The script will move the camera around "hot" places on the map. If there is no fighting then the widget will show different buildings, units that are created.

For the moment there is no algorithm to prioritize the importance of an event just that an battle event is more important than a building completion one.
Attachments
cmd_actionfinder.lua
1.7
(17.52 KiB) Downloaded 42 times
Last edited by xyz on 11 May 2013, 19:55, edited 16 times in total.
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Spectator mode

Post by hoijui »

i have tried it, it works very well! :-)
its perfect to spec spring games on the second computer, and use it like a TV (doing nothing) or for publicly streaming tournament games or so..
good idea for a first try, well done!
thanks! :-)
xyz
Posts: 152
Joined: 29 Nov 2008, 16:06

Re: Spectator mode

Post by xyz »

hoijui wrote:i have tried it, it works very well! :-)
its perfect to spec spring games on the second computer, and use it like a TV (doing nothing) or for publicly streaming tournament games or so..
good idea for a first try, well done!
thanks! :-)
Thanks for trying it out!

I've updated the first post with version 1.1 of the script.

change-log 1.0 - > 1.1:
- Fixed bug: the script was not paused if the user was moving the mouse, or scrolling using the keyboard.
- Did some cleanup.

P.S. Is it just me, or the smilies here look a bit, EVIL?
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Spectator mode v1.1

Post by hoijui »

yeah... if you want to look at it like this.. you can see them as evil :D

will try the new version too.
User avatar
MidKnight
Posts: 2652
Joined: 10 Sep 2008, 03:11

Re: Spectator mode v1.1

Post by MidKnight »

The smileys here look evil because our community is EVIL! :twisted:
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: Spectator mode v1.1

Post by zwzsg »

Thanks. I renamed it because "Spec Mod" isn't very descriptive. I made it also change the height, and made it choose between three camera mode, TA, Total War, and the elusive tracking FPS. Plus some other changes.

Now that I can have an attract mode, all I need is some huge monitor in view of passerbys to advertise.
Attachments
cmd_actionfinder.lua
(14.36 KiB) Downloaded 35 times
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: Spectator mode v1.1

Post by imbaczek »

works really nice, gj. you could try to not fps-track 3do models, they look fugly when not looked at from above ;p
MelTraX
Posts: 470
Joined: 02 Jan 2007, 16:18

Re: Spectator mode v1.1

Post by MelTraX »

Why not just deselect the tracked unit instead of disabling user widgets?
Attachments
cmd_actionfinder.lua
(14.24 KiB) Downloaded 38 times
xyz
Posts: 152
Joined: 29 Nov 2008, 16:06

Re: Spectator mode v1.2 (AKA "actionfinder")

Post by xyz »

Thanks to everyone for helping.
zwzsg wrote:Thanks. I renamed it because "Spec Mod" isn't very descriptive. I made it also change the height, and made it choose between three camera mode, TA, Total War, and the elusive tracking FPS. Plus some other changes.

Now that I can have an attract mode, all I need is some huge monitor in view of passerbys to advertise.
I've updated the first post to use the latest script.

I did some modifications:
- removed math.sqrt by comparing with the square of 150 = 22500 for performance reasons (sqrt is CPU intensive).
- also included MelTraX changes.

There is a bug in DrawWorldPreUnit and IsTerrainViewable, in some rear circumstances the camera will continually be adjusted jumping around the unit, and ignoring all the other events. It is because lastMove is reseted every time the camera is changed, but I don't have any idea how to fix it.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: Spectator mode v1.2 (AKA "actionfinder")

Post by zwzsg »

My IsTerrainViewable isn't perfect, I had to give it a huge tolerance and I'm pretty sure it sometimes find un-viewable terrain that is, but I have no idea what's wrong, and it seemed to works right most of the times anyway.

I hadn't noticed the bug about how it can keep adjusting view while forgetting to change view, but to fix it, I guess just add another variable counting how many time the same view has been adjusted.
MelTraX wrote:Why not just deselect the tracked unit instead of disabling user widgets?
Because I thought a SendCommands wasn't immediate but took a cycle or two to take effect. Appears I was wrong.
imbaczek wrote:works really nice, gj. you could try to not fps-track 3do models, they look fugly when not looked at from above ;p
Stop playing 98's mods.

Also, my logic was that most of camera change are done with UpdateCamera, which does travelling but doesn't change the view angle, and that PickCameraMode was only used like every 3 or so Update, or when we have to (view blocked, FPS unit dead, etc...). Because a simple travelling is easier on the eye than a sudden turning all over. With your change, lastMove = gameSecs is not done when UpdateCamera goes into the "else" "SetCameraTarget" part. Oh, and you forgot to comment out the Spring.Echo of the distance calculated by IsTerrainViewable.
xyz
Posts: 152
Joined: 29 Nov 2008, 16:06

Re: Spectator mode v1.2 (AKA "actionfinder")

Post by xyz »

zwzsg wrote:With your change, lastMove = gameSecs is not done when UpdateCamera goes into the "else" "SetCameraTarget" part. Oh, and you forgot to comment out the Spring.Echo of the distance calculated by IsTerrainViewable.
I've uploaded the wrong file, changed it back to the good one, thanks.

I was wandering, isn't it better to keep the normal BA camera type for fighting events and only do the fancy camera mode switch when the script is showing buildings? As if you change the camera while showing a battle is hard to keep track who is attacking who.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: Spectator mode v1.2 (AKA "actionfinder")

Post by zwzsg »

I don't use it to follow what's going on, I use it to have some fanciful videos on my screen (F5 to disable the GUI). In fact, I find that the heavily tilted and tracking FPS viewed are not used often.
xyz wrote:the normal BA camera type
Bawwww!
xyz
Posts: 152
Joined: 29 Nov 2008, 16:06

Re: Spectator mode v1.3 (AKA "actionfinder")

Post by xyz »

Updated the first post to version 1.3

I've separated specmode option from zwzsg's attracctmode option.

Specmode option:
-Enable it by typing /luaui specmode
-This option will not change the camera type during gameplay

Attractmode option:
-Enable it by typing /luaui attractmode
-This option will also change the camera mode while switching from one event to another.

To switch between the two modes you can also use CTRL+ALT+C (you need to be in specmode or attractmode before using this).

Bugfixing:
-tried to fix the camera jumping around bug in attractmode.
-optimisation: in attractmode do not check every frame if the the unit is in view.
xyz
Posts: 152
Joined: 29 Nov 2008, 16:06

Re: Spectator mode v1.3 (AKA "actionfinder")

Post by xyz »

xyz wrote: Bugfixing:
-tried to fix the camera jumping around bug in attractmode.
The fix has failed,but i found a way to reproduce the bug:

Start a AIvsAI game as a spectator,
Turn the script off
Select a unit (Commander) and press T to track it
While tracking enable the attractmode and wait.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: Spectator mode v1.3 (AKA "actionfinder")

Post by zwzsg »

Sorry, I though deselecting was enough to disable tracking, but it's not, you need some "trackoff" commands. I fixed that and the bug about the camera that keeps picking new angles and forget to change point, but then I started to turn it into a gadget and things went awry.
xyz
Posts: 152
Joined: 29 Nov 2008, 16:06

Re: Spectator mode v1.3 (AKA "actionfinder")

Post by xyz »

What things went away? :-)

Converting it into a gadget means that it will need to be installed on all the clients.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: Spectator mode v1.3 (AKA "actionfinder")

Post by zwzsg »

xyz wrote:What things went away?
Call-ins such as UnitDamaged, UnitDestroyed, etc... in the unsynced part of a gadget.
xyz wrote:Converting it into a gadget means that it will need to be installed on all the clients.
Uh. How to explain. See, we have different goals. You're still thinking "So I log into the lobby, find a nice DSD BA 16v16 battleroom, enter it, tick spec, then actively watch how other people are playing.", while I'm thinking "Use the spring engine in a way it was not intented, as a mean of having my monitor shows a never ending stream of pretty moving images of battles, disregarding notions such as "playing", "game", "user input"".
xyz
Posts: 152
Joined: 29 Nov 2008, 16:06

Re: Spectator mode v1.3 (AKA "actionfinder")

Post by xyz »

I've updated the firs post with version 1.4

changes since 1.3:

- ESC no longer exits the script, to turn specmode on or off use CTRL+ALT+S
- After 10 fighting events the script will force an economy event to be displayed next so that in games with a lot of fighting the user will also get a glance of how the players economy is doing.
Satirik
Lobby Developer
Posts: 1688
Joined: 16 Mar 2007, 18:27

Re: Spectator mode v1.3 (AKA "actionfinder")

Post by Satirik »

maybe you could split the map in areas, and every time something interesting happens in an area you increase its score (a map could be splitted in like 20x20 areas), then you show the part of the map with the best areas, to choose what part of the map to show you fix a maximum zoom, then you iterate through all possible pos of the cam on the map, and get the best one, then reduce the maximum zoom, itarate through all possible pos of the cam on the map again take the best one by average score of its areas etc (ofc the zoom step should be big to make it fast) until you reach a min zoom

you would get a list of cam pos + score for each zoom level, then you could pick the best score and show its cam pos + zoom level

every .... N seconds, you would decrease the areas visible on the screen, and search for a new cam pos, so displayed areas would loose interest over time unless things keep happening there, you could limit the score to add in displayed areas so it won't show the same thing for too long

the hard part would be to assign the right score to events

edit: comparing cam pos by average score is really good but i can't think of something better right now
xyz
Posts: 152
Joined: 29 Nov 2008, 16:06

Re: Spectator mode v1.4 (AKA "actionfinder")

Post by xyz »

hey, Satirik
Thanks for the suggestions.

The thing is that when I first set off in writing this script I planned to divide the map in sectors, but then I realized that if an area of the map has a lot of activity it is more likely that the script will select an event in that part of the map, that's why I had to put that 10 fighting events limit, so that the script will show some economy every once in a while.

As for scoring I was thinking of something like the more HP a unit that generates the event has (unit finished, unit destroyed, unit attacked) the higher the score, and then put this into an event priority queue, and select the first most important event.

Your idea to adjust the zoom so that more action is included sounds really good, I'll have to look into that.

Thanks again.
Post Reply

Return to “Lua Scripts”