Jump to content
Sign in to follow this  
A. Benz

Item spawn reminder

Recommended Posts

Here,
 
https://dl.dropboxusercontent.com/u/885543/ItemReminder.lua

https://dl.dropboxusercontent.com/u/885543/ItemTimers.lua
 
Screenshot: https://dl.dropboxusercontent.com/u/885543/timers.png
 
Features:
 
- repositioned timers
- greyed-out non-active timers
- get colored "spawning"-message below xhair, if an item is 5 sec away from spawning
 

Regards

Share this post


Link to post
Share on other sites

Would you put the code in a "code block" in your first post as well... I kind of like being able to see the code in the nice forum formatting, makes it more convenient to read up on what you did.

 

As an idea... it might be nice to have an icon of the item about to spawn next to the spawning text as well. Visual gimmick... but it may help to immediately identify the item in question and be less "hardcore" ;)

Share this post


Link to post
Share on other sites

Would you put the code in a "code block" in your first post as well... I kind of like being able to see the code in the nice forum formatting, makes it more convenient to read up on what you did.

 

As an idea... it might be nice to have an icon of the item about to spawn next to the spawning text as well. Visual gimmick... but it may help to immediately identify the item in question and be less "hardcore" ;)

 

Done. Yeah, i thought about icons.... but i thought it'd be too much. Simple color coding feels pretty sufficient for me for now. But hey...feel free to modify wtf you want!

 

Regards

Share this post


Link to post
Share on other sites

Just tested your widget... seems to work fine... though will 5 seconds actually be enough to get to the item in question? Or is it more like "drat, forgot about the Quad, it will respawn soon and I am nowhere close enough to grab it"? ;)

 

I could imagine combining your code with that of the default timer bar... e.g. enlarging the item there, blinking colours or something. Well... just a thought for the tinkers out there.

 

It's pretty nifty that with some effort one can actually "simply" do it now.

Share this post


Link to post
Share on other sites

Only just noticed this short of code snippet for the first time:

function SetSettings()
consolePerformCommand("ui_set_widget_anchor ItemReminder 0 1");
consolePerformCommand("ui_set_widget_offset ItemReminder 0 -475");
end

SetSettings();

I wonder if the user can actually still override your settings from the game.cfg. As a few quick tests show: "yes".

 

Placing your widget anchor from the centre of the screen, e.g.

ui_show_widget ItemReminder
ui_set_widget_scale ItemReminder 1.0000
ui_set_widget_anchor ItemReminder 0 0
ui_set_widget_offset ItemReminder 0.0000 50.0000

might also be more convenient, than all the way from the bottom of the screen.

 

Well... for those interested... the above code indeed lets the programmer define the "default" anchor and offset should these not yet be defined in the game.cfg. Once they exist in the .cfg they can be overridden to whatever the user prefers by editing the game.cfg. Practical.

Share this post


Link to post
Share on other sites

Yeah, tested on CPM22..and 5 sec..where pretty much perfect. I felt very cheap tbh. I mean...it was way easier to play and keep track of items, estimate where my enemy might be/go.

 

I had it with offset 0 50 ...but my anchor was 0 1, hence it didn't really work :D. my bad. fixed.

Share this post


Link to post
Share on other sites

Ah... so it is possible to get to things in 5 seconds... you guys are fast :)

 

One small additional tweak:

            nvgRect(-55,-16,110,36);

I enlarged the frame around the text slightly to be less cramped in and evenly spaced. Also I also upper cased the text to:

            nvgText(x, y, "Spawning");

Trivial... but you might like to use it... possibly.

 

Also noted that you actually did already have the icon paths from two cases, e.g.

            iconSvg = "internal/ui/icons/health";

in your code, just not use the icons. Will need to look up how icons are presented on-screen.

Share this post


Link to post
Share on other sites

For those interested, I enhanced Benz' code slightly to show a properly coloured icon to the left of the "Spawning" text as well:

require "base/internal/ui/reflexcore"

ItemReminder =
{
};
registerWidget("ItemReminder");

--
function SetSettings()
    consolePerformCommand("ui_set_widget_anchor ItemReminder 0 0");
    consolePerformCommand("ui_set_widget_offset ItemReminder 0 50");
end

SetSettings();

function ItemReminder:draw()

    -- Offsets
    local iconRadius = 36/2;
    local iconX = -(50 + iconRadius*2);
    local iconY = 2;

    -- Count pickups
    local pickupCount = 0;
    for k, v in pairs(pickupTimers) do
        pickupCount = pickupCount + 1;
    end

    -- Iterate pickups
    for i = 1, pickupCount do
        local pickup = pickupTimers[i];

        -- Icon
        local iconSvg = "internal/ui/icons/armor";    -- default armour icon
        if pickup.type == PICKUP_TYPE_ARMOR50 then
            iconColor = Color(0,255,0);
        elseif pickup.type == PICKUP_TYPE_ARMOR100 then
            iconColor = Color(255,255,0);
        elseif pickup.type == PICKUP_TYPE_ARMOR150 then
            iconColor = Color(255,8,8);
        elseif pickup.type == PICKUP_TYPE_HEALTH100 then
            iconSvg = "internal/ui/icons/health";
            iconColor = Color(74,164,255);
        elseif pickup.type == PICKUP_TYPE_POWERUPCARNAGE then
            iconSvg = "internal/ui/icons/carnage";
            iconColor = Color(255,120,128);
        end

        -- Time
        local t = FormatTime(pickup.timeUntilRespawn);
        local time = t.seconds + 60 * t.minutes;

        if time == 5 then

            -- Frame background
            nvgBeginPath();
            nvgRect(-55,-16,110,36);
            nvgFillColor(Color(240,240,240,100));
            nvgFill();

            -- Set up font
            nvgFontSize(30);
            nvgFontFace("roboto-regular");
            nvgTextAlign(NVG_ALIGN_CENTER, NVG_ALIGN_MIDDLE);

            -- Show item icon as well
            nvgFillColor(iconColor);
            nvgSvg(iconSvg, iconX, iconY, iconRadius);

            -- Print message
            local x = 0;
            local y = 0;

            nvgFontBlur(10);
            nvgFillColor(Color(0, 0, 0, 255));
            nvgText(x, y, "Spawning");

            nvgFontBlur(0);
            nvgFillColor(iconColor);
            nvgText(x, y, "Spawning");

        end

    end
end

Hope that was OK with you Benz.

Share this post


Link to post
Share on other sites

I have not tested your latest version, but one thing I did note was that when two or more items time out at the same time they will overlap on-screen. Not a huge issue, since you only show them for 1 second... but in my tests I had the reminder text on longer for testing.

 

Would be nice to have better formatting in the source code in the first post, e.g. change

 -- Early out if HUD shouldn't be shown.

to

 -- Early out if HUD should not be shown.

 to avoid the ' comment mess-ups.

Share this post


Link to post
Share on other sites

I have not tested your updated version, but I really love my tweaked one... your widget is really useful. Been running around in my AEdm7R map... when I see the reminder with icon... and rush over to the Quad or the MH... neat.

Share this post


Link to post
Share on other sites

Yeah, it's much more "relaxed" to play like that i think :D. I don't even watch the timers ... glad you like it! Yeah..feel free to tweak however you want it. Personally i simply don't want icons on the reminder..because..it's too much for me :D. Colors are enough for my taste.

 

Yeah, the updated version is basically just a repositioned timer-bar with greyed out icons for non-active timers. Imo better overview.

Share this post


Link to post
Share on other sites

The greyed-out icons is a neat idea... I was thinking for a while now... about doubling the size of the items timers on the right side of the screen, once they count down... but greying-out inactive ones is also good.

 

Something like that, the greying out, would probably also be something to use for the ammo bar, on the left side of the screen by default. I.e. tone down any info that is not presently relevant and colour and possibly enlarge anything that is relevant.

 

Might give those things a try. Anyway your example code will help get there I would imagine.

Share this post


Link to post
Share on other sites

I was thinking about a small icon of each powerup that appears with 5 seconds till spawn at a certain height, then gradually goes down to a line where it would respawn.  Maybe I'll learn enough lua to do something like that...

 

Also, I took green armor out of the popups for my version of this.  I don't need an alert for those.

Share this post


Link to post
Share on other sites

I was thinking about a small icon of each powerup that appears with 5 seconds till spawn at a certain height, then gradually goes down to a line where it would respawn.  Maybe I'll learn enough lua to do something like that...

 

Also, I took green armor out of the popups for my version of this.  I don't need an alert for those.

Guitar Hero style item timers? It'd be possible and would make me laugh.

Share this post


Link to post
Share on other sites

Guitar Hero style item timers? It'd be possible and would make me laugh.

 

whoa, what about a circle growing/shrinking in another circle? like a empty circle with a black border, it fills up as red is coming close to spawning. if its picked up, the circle becomes empty, and a tiny red dot forms and grows to begin to fill the rest of the circle

Share this post


Link to post
Share on other sites

whoa, what about a circle growing/shrinking in another circle? like a empty circle with a black border, it fills up as red is coming close to spawning. if its picked up, the circle becomes empty, and a tiny red dot forms and grows to begin to fill the rest of the circle

 

Humans are really bad at judging things like that. A item dropping on a line gives us a much better estimation of how much time is left than watching a circle fill, and so the circle fill will feel more "fuzzy" to you as to how much time is left to wait, if that makes sense.

 

There's been research done on this for pie charts. If you show someone a normal pie chart with no percentage labels, people are very accurate at guessing the percentage represented by each slice, because we make subconscious evaluations of the angle of each pie slice from the centre point because there's a simple linear frame of reference for how "big" the slice is. In exploded pie charts or donut charts you lose the centre point as an explicit linear frame of reference and people become very bad at guessing at a glance how much a section of the chart represents. Think about how much easier it is to play Guitar Hero than to do those stupid kickoff controls in Madden.

 

Anyway, not saying it wouldn't look cool, it's just bad UI design.

Share this post


Link to post
Share on other sites

Edd:

 

  • Copy/paste the first post source text from the code box e.g. to 
 SteamsteamappscommonReflexbaseinternaluiwidgets_customItemReminder.lua
  • Then add these lines to your Reflexgame.cfg (at the bottom of the file):
ui_show_widget ItemReminder
ui_set_widget_scale ItemReminder 1.0000
ui_set_widget_anchor ItemReminder 0 0
ui_set_widget_offset ItemReminder 0.0000 50.0000
  •  The ItemReminder widget should then show up in Reflex when you launch the game and load a map.

Share this post


Link to post
Share on other sites

 

Edd:

 

  • Copy/paste the first post source text from the code box e.g. to 
 SteamsteamappscommonReflexbaseinternaluiwidgets_customItemReminder.lua
  • Then add these lines to your Reflexgame.cfg (at the bottom of the file):
ui_show_widget ItemReminder
ui_set_widget_scale ItemReminder 1.0000
ui_set_widget_anchor ItemReminder 0 0
ui_set_widget_offset ItemReminder 0.0000 50.0000
  •  The ItemReminder widget should then show up in Reflex when you launch the game and load a map.

 

 

Is there a way I could move the small boxes up to the left side of the screen? Since im using a custom hud.

Share this post


Link to post
Share on other sites

Played a few games with the item spawn reminder script yesterday. Seemed like it was working fine on BDM3, and then on CPM22 it went haywire. It kept saying the wrong items were spawning.

 

I took out the 2nd 1/2 of the script (the pickup timers) and placed the code into another lua file so I could adjust the scale on its own.

 

The only thing I changed in the 1st 1/2 of the script was removing the reminders for the green armor. perhaps I did something wrong

 

I removed the

 

if pickup.type == PICKUP_TYPE_ARMOR50 then
iconColor = Color(0,255,0);

 

 

and changed the else to if for the 100 armor

 

 

Anyone else having any problems with this, or can you spot something I did incorrectly?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×