Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add blaster_BC_buttons #582

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
df02d64
add destruct
NoSloppy Feb 6, 2023
6fe4def
Merge branch 'profezzorn:master' into Add-BC-Blaster
NoSloppy Aug 1, 2023
6e23e0d
Add files via upload
NoSloppy Aug 1, 2023
21fa83e
ifdef or operand syntax fix
NoSloppy Aug 4, 2023
842d2ce
adjust button held timing for on/off
NoSloppy Aug 20, 2023
4e965d1
swap mode cycle and reload button action
NoSloppy Aug 21, 2023
bf997f6
Delete blaster_BC_buttons.h
NoSloppy Aug 24, 2023
1a3205e
Add files via upload
NoSloppy Aug 24, 2023
9a15317
allow derived classes
NoSloppy Aug 24, 2023
54aef0c
SB_Effect override change to SB_Effect2
NoSloppy Mar 23, 2024
3325b63
Update SB_Effect to use EffectLocation
NoSloppy Mar 24, 2024
3b225b5
PVLOG syntax adjust
NoSloppy Dec 7, 2024
171c981
add IsEmpty
NoSloppy Jan 22, 2025
b7db818
no virtual needed
NoSloppy Jan 22, 2025
4245a37
full overhaul
NoSloppy Jan 22, 2025
2a8b0ff
restructured Fire() with helpers
NoSloppy Jan 22, 2025
11f2d4e
oops. updated with old file. now correct.
NoSloppy Jan 22, 2025
7fb9a40
Merge branch 'master' into Add-BC-Blaster
NoSloppy Jan 22, 2025
a69751b
Split into helper functions
NoSloppy Jan 23, 2025
aa0780d
Revamp from 2 years ago PR
NoSloppy Jan 23, 2025
c114f04
line returns
NoSloppy Jan 23, 2025
15bd253
exit -> exiting
NoSloppy Jan 23, 2025
09536ae
rm newline
NoSloppy Jan 26, 2025
73c533c
move consts
NoSloppy Jan 26, 2025
b477cae
move Setup() and override
NoSloppy Jan 26, 2025
8fc2962
Add EFFECT_BOOM
NoSloppy Jan 27, 2025
91e2096
add EFFECT_BOOM to hybrid_font
NoSloppy Jan 27, 2025
1ac807c
add BOOM printout
NoSloppy Jan 27, 2025
06306c1
move const initialization
NoSloppy Jan 30, 2025
a79d3a0
condense preprocessor dirs
NoSloppy Jan 30, 2025
e60a4e0
remove dupe
NoSloppy Jan 30, 2025
397a6ad
move int GetBulletCount()
NoSloppy Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions common/saber_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ extern SaberBase* saberbases;
DEFINE_EFFECT(UNJAM) \
DEFINE_EFFECT(PLI_ON) \
DEFINE_EFFECT(PLI_OFF) \
DEFINE_EFFECT(DESTRUCT) \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self-destruct is usually an off-type rather than an effect...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is,

        case NEXT_ACTION_BLOW:
          Off(OFF_BLAST);
          break;

But having EFFECT_DESTRUCT allows for blade animations.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to add a way for TrInOut to handle EFFECT_DESTRUCT so we can have a transition from the on to the off color.

Copy link
Contributor Author

@NoSloppy NoSloppy Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. oh, you mean like an "explosion"? Wouldn't that just be the OUT->IN transition, something like

InOutTrL<TrInstant,TrConcat<TrInstant,Blinking<White,Black,75,500>,TrFade<600>>>

That would play with boom.wav.
I'm not sure what you're saying the integration with EFFECT_DESTRUCT should be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh well that's not right. It works for Destruct, but also shows if powering off normally.
So what did you have in mind?
I glanced at styles/inout_helper.h, but do not know what should happen here.
Maybe if EFFECT_DESTRUCT happens, we somehow bypass in_tr_.begin(); ?

Copy link
Contributor Author

@NoSloppy NoSloppy Jan 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe we just have an EFFECT_BOOM that layers in the blade style on top of the InOutTrL?
Actually, my blaster styles don't even use an InOutTrL.
It's just always on not showing anything most of the time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added EFFECT_BOOM, tested, works well for Boom, unless you had a different idea?

DEFINE_EFFECT(BOOM) \
/* Mini game effects */ \
DEFINE_EFFECT(GAME_START) \
DEFINE_EFFECT(GAME_ACTION1) \
Expand Down
107 changes: 65 additions & 42 deletions props/blaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Optional #defines on your config file that customize the blaster's behavior.
Optional defines:
#define ENABLE_BLASTER_AUTO - DEPRECATED. Enable Autofire/rapid fire mode. Please replace with BLASTER_ENABLE_AUTO.
#define BLASTER_ENABLE_AUTO - Enable Autofire/rapid fire mode.
#define BLASTER_DEFAULT_MODE - Sets the mode at startup MODE_STUN|MODE_KILL|MODE_AUTO. Defaulst to MODE_STUN.
#define BLASTER_DEFAULT_MODE - Sets the mode at startup MODE_STUN|MODE_KILL|MODE_AUTO. Defaulst to MODE_STUN.
#define BLASTER_SHOTS_UNTIL_EMPTY 15 - Whatever number, not defined = unlimited shots.
#define BLASTER_JAM_PERCENTAGE - Range 0-100 percent. If this is not defined, random from 0-100%.

Expand All @@ -29,9 +29,8 @@ This prop manages up to six different buttons.
*Dual Buttons Mode*
-Buttons: FIRE and MODE
This is the "stock" configuration.
-Weapon will always start on the default mode (define with BLASTER_DEFAULT_MODE,
STUN is default).
Default is to powered on if it finds poweron.wav file present or off otherwise.
Weapon will always start on the default mode (define with BLASTER_DEFAULT_MODE, STUN is default).
Default is to start powered OFF if the font has a poweron.wav file, otherwise ON.

Fire - Click FIRE.
Cycle Modes - Click MODE.
Expand Down Expand Up @@ -129,7 +128,13 @@ class Blaster : public PROP_INHERIT_PREFIX PropBase {
};

BlasterMode blaster_mode = BLASTER_DEFAULT_MODE;


#ifdef BLASTER_SHOTS_UNTIL_EMPTY
const int max_shots_ = BLASTER_SHOTS_UNTIL_EMPTY;
#else
const int max_shots_ = -1;
#endif

int GetBlasterMode() const {
return blaster_mode;
}
Expand Down Expand Up @@ -159,59 +164,73 @@ class Blaster : public PROP_INHERIT_PREFIX PropBase {
}
}

bool auto_firing_ = false;
int shots_fired_ = 0;
bool is_jammed_ = false;

#ifdef BLASTER_SHOTS_UNTIL_EMPTY
const int max_shots_ = BLASTER_SHOTS_UNTIL_EMPTY;
#else
const int max_shots_ = -1;
#endif
bool CheckEmpty() const {
return max_shots_ != -1 && shots_fired_ >= max_shots_;
}

virtual int GetBulletCount() {
int GetBulletCount() {
return max_shots_ - shots_fired_;
}

virtual bool DoEmpty() {
if (CheckEmpty()) {
SaberBase::DoEffect(EFFECT_EMPTY, 0); // Trigger the empty effect
return true;
}
return false;
}

virtual bool CheckJam(int percent) {
int random = rand() % 100;
return random < percent;
}

virtual void Fire() {
#ifdef ENABLE_MOTION
#ifdef BLASTER_JAM_PERCENTAGE
bool DoJam() {
#if defined(ENABLE_MOTION) && defined(BLASTER_JAM_PERCENTAGE)
// If we're already jammed then we don't need to recheck. If we're not jammed then check if we just jammed.
is_jammed_ = is_jammed_ ? true : CheckJam(BLASTER_JAM_PERCENTAGE);

if (is_jammed_) {
SaberBase::DoEffect(EFFECT_JAM, 0);
return;
return true;
} else {
return false;
}
#endif
#endif
}

if (max_shots_ != -1) {
if (shots_fired_ >= max_shots_) {
SaberBase::DoEffect(EFFECT_EMPTY, 0);
return;
}
}
virtual void DoStun() {
SaberBase::DoEffect(EFFECT_STUN, 0);
shots_fired_++;
}

if (blaster_mode == MODE_AUTO) {
SelectAutoFirePair(); // Set up the autofire pairing if the font suits it.
SaberBase::SetLockup(LOCKUP_AUTOFIRE);
SaberBase::DoBeginLockup();
auto_firing_ = true;
} else {
if (blaster_mode == MODE_STUN) {
SaberBase::DoEffect(EFFECT_STUN, 0);
} else {
SFX_blast.Select(-1);
SaberBase::DoEffect(EFFECT_FIRE, 0);
}
virtual void DoKill() {
SFX_blast.Select(-1);
SaberBase::DoEffect(EFFECT_FIRE, 0);
shots_fired_++;
}

virtual void DoAutoFire() {
SelectAutoFirePair(); // Set up the auto-fire pairing if the font suits it
SaberBase::SetLockup(LOCKUP_AUTOFIRE);
SaberBase::DoBeginLockup();
auto_firing_ = true;
}

shots_fired_++;
virtual void Fire() {
if (DoJam()) return;
if (DoEmpty()) return;

switch (blaster_mode) {
case MODE_STUN:
DoStun();
break;
case MODE_KILL:
DoKill();
break;
case MODE_AUTO:
DoAutoFire();
break;
}
}

Expand Down Expand Up @@ -286,7 +305,7 @@ class Blaster : public PROP_INHERIT_PREFIX PropBase {
SetNextAction(what, when * 1000);
}

void PollNextAction() {
virtual void PollNextAction() {
if (millis() - time_base_ > next_event_time_) {
switch (next_action_) {
case NEXT_ACTION_NOTHING:
Expand Down Expand Up @@ -314,7 +333,7 @@ class Blaster : public PROP_INHERIT_PREFIX PropBase {
SetNextActionF(NEXT_ACTION_ARM, len);
}

void selfDestruct() {
virtual void selfDestruct() {
SaberBase::DoEndLockup();
#ifdef ENABLE_AUDIO
float len = hybrid_font.GetCurrentEffectLength();
Expand Down Expand Up @@ -484,7 +503,11 @@ class Blaster : public PROP_INHERIT_PREFIX PropBase {
break;
}
}

bool auto_firing_ = false;
int shots_fired_ = 0;
bool is_jammed_ = false;

};

#endif

Loading