Implementing a combo system

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
cinnagoat_
Posts: 9
Joined: Mon Dec 07, 2020 3:35 pm

Implementing a combo system

Post by cinnagoat_ »

I need some assistance on how I should go about writing a codebase that essentially functions like Hotline Miami's combos.

Whenever you get a kill, I want it to display HUD images depending on how many kills you get, and disappear whenever you haven't killed anything in a period of time. What would be the best way to format it? I tried to find other WADs so I could reference and learn the code, but to no avail. :D
User avatar
Dan_The_Noob
Posts: 873
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support

Re: Implementing a combo system

Post by Dan_The_Noob »

maybe look into buffs/debuffs
use enemy sprites or a counter as the display etc etc.
User avatar
cinnagoat_
Posts: 9
Joined: Mon Dec 07, 2020 3:35 pm

Re: Implementing a combo system

Post by cinnagoat_ »

I was moreso wanting something built into the HUD system.
User avatar
Dan_The_Noob
Posts: 873
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support

Re: Implementing a combo system

Post by Dan_The_Noob »

yeah, usually buff/debuff mods show something on the screen. you could easily use a timed buff in the same way as a combo counter.
Jarewill
 
 
Posts: 1790
Joined: Sun Jul 21, 2019 8:54 am

Re: Implementing a combo system

Post by Jarewill »

I've made an ACS script like this:
Spoiler:
However, it has no way of detecting what killed the monster, so if another monster kills it, it will add to the combo.

Edit: Figured out a way to detect who killed the monster using ZScript.
User avatar
cinnagoat_
Posts: 9
Joined: Mon Dec 07, 2020 3:35 pm

Re: Implementing a combo system

Post by cinnagoat_ »

I implemented and tested the code and it doesn't seem to count if you get a multi-kill. Is there anything that can make it possibly detect multiple kills in one go? Like a rocket killing a group of zombiemen.
Jarewill
 
 
Posts: 1790
Joined: Sun Jul 21, 2019 8:54 am

Re: Implementing a combo system

Post by Jarewill »

My bad.
In the ZScript file replace:

Code: Select all

e.Thing.ACS_NamedExecute("ComboGet",0,0,0,0);
With:

Code: Select all

e.Thing.ACS_NamedExecuteAlways("ComboGet",0,0,0,0);
User avatar
cinnagoat_
Posts: 9
Joined: Mon Dec 07, 2020 3:35 pm

Re: Implementing a combo system

Post by cinnagoat_ »

Thanks a bunch, yo! I'll make sure to credit you when I complete my mod. I'm not very well versed in ACS/ZScript unless it has to do with mapping, so this is extremely useful.
User avatar
LossForWords
Posts: 679
Joined: Fri Jan 13, 2017 9:08 pm

Re: Implementing a combo system

Post by LossForWords »

Tweaked the ACS a bit to display combo numbers past 10.

Code: Select all

#library "SCORE"
#include "zcommon.acs"

int combokills; //Amount of kills
int combotimer; //Timer before combo ends

Script "ComboSystem" ENTER
{
    str combomessage;
    While(true)
    {
        If(combokills>0)
        {
            SetFont("BIGFONT");
            HudMessage(s:"\cf",i:combokills,s:"x"; HUDMSG_PLAIN, 100, 0, 0.5, 0.2, 0);
            int time = Ceil(FixedDiv(combotimer<<16,35.0));
            SetFont("SMALLFONT");
            HudMessage(f:time; HUDMSG_PLAIN, 101, 0, 0.5, 0.22, 0);
            If(combotimer<=0){combokills=0;} //When timer runs out, combo ends
            Else{combotimer--;}
        }
        Else
        {
            HudMessage(s:" "; HUDMSG_PLAIN, 100, 0, 0.5, 0.2, 0);
            HudMessage(s:" "; HUDMSG_PLAIN, 101, 0, 0.5, 0.2, 0);
        }
        Delay(1);
    }
}

Script "ComboGet" (void)
{
    combokills++; //Add to the counter
    combotimer=175; //5 seconds
} 
You do not have the required permissions to view the files attached to this post.

Return to “Scripting”