Trying to understand lockups & how to end them for my detonator prop

I am trying to change the behavior of my thermal detonator prop.

I added these in my saber_base.h:

/* Detonator  effects */                    \
DEFINE_EFFECT(BGNARM)                       \
DEFINE_EFFECT(ENDARM)                       \

Because they are used to trigger some .bmp in my DetonatorDisplayController to play on OLED.

I start the lockup with:

SaberBase::SetLockup(SaberBase::LOCKUP_ARMED);
SaberBase::DoBeginLockup();
SaberBase::DoEffect(EFFECT_BGNARM, 0);

If I understand hybrid_font.h, this should play bgnarm.wav once followed by armhum.wav looped ?

To stop it, I would like to do one of two things:

  • either I want to play endarm.wav once and I do:
SaberBase::DoEndLockup();
SaberBase::SetLockup(SaberBase::LOCKUP_NONE);
SaberBase::DoEffect(EFFECT_ENDARM, 0);
  • or I want to play boom.wav (but not hear endarm.wav)
    can I do:
SaberBase::DoEffect(EFFECT_BOOM, 0);
SaberBase::SetLockup(SaberBase::LOCKUP_NONE); // I don't want to "end the lockup", I just want to stop it.
Off(OFF_BLAST);

Thanks for any help.

That is correct.

That also seems correct.

No need to end the lockup in this case, as Off(OFF_BLAST) will do it for you.
There is also no need to call DoEffect with EFFECT_BOOM as hybrid_font will do that for you.

Off(OFF_BLAST) will do

    if (SaberBase::Lockup()) {
      SaberBase::DoEndLockup();
      SaberBase::SetLockup(SaberBase::LOCKUP_NONE);
    }

DoEndLockup() will do { DoEffect(EFFECT_LOCKUP_END, 0); }

EFFECT_LOCKUP_END will trigger SB_EndLockup();

since at that point I am in LOCKUP_ARMED
SB_EndLockup() will do:

      case SaberBase::LOCKUP_ARMED:
        end = &SFX_endarm;               // <-- this is exactly what I don't want to hear
        break;

I want DoEndLockup() to not trigger a cascade that ends in playing endarm, I just want to stop the current armhum.wav loop (no “graceful” ending with endarm)
Is this possible ?

Is not to play boom.wav, but to play boom.bmp on OLED.

It should be, my detonator does that.
Not sure if OS8 broke this, or if my detonator does something different. I’ll check when I get home.

The DoEffect is in hybrid_font.h, but it is still sent to all things.
however, I don’t think there is any support for “boom.bmp” in the oled code, so you’ll need to write a controller for that. (See the blaster oled controllers for how to do that.)

Your detonator used to play boom.wav & endarm.wav (if endarm.wav exists) simultaneously or almost simultaneously, I can’t tell which one starts playing first. However it has been almost a year since I last played with detonator.h

That is one of the reasons I started writing my own.

Thanks, I found it now.

I can confirm that there isn’t support for it.

Already done. I wrote a DetonatorDisplayController, very similar to BlasterDisplayController.

So it would appear that my TD just uses Off() instead of turning off the lockup, and “pweroff2.wav” instead of endarm.wav.

If that doesn’t work for your use case, some changes would be needed to make it so that Off(OFF_BLAST) does not play endarm.wav.

detonator.h uses:

May I ask what prop are you using ? Or is it detonator.h from an older ProffieOS ?

What does your pweroff2.wav sounds like ? Is it something like this:

I don’t mind making any kind of changes as long as the right sounds play at the right time and the wrong sound doesn’t play at the wrong time.

I just saw a line that I never saw before:
SaberBase::SetLockup(SaberBase::LOCKUP_NONE); from here:

Can I use that to “terminate” (stop armhum, not play endarm) LOCKUP_ARMED before doing Off(OFF_BLAST) ?

I didn’t mean that it it doesn’t use “Off(OFF_BLAST);” I meant that it uses “Off()” when the moves the safety switch back. My TD does not have a way to turn off the lockup and leave the hum going.

Yes. (Although I have two of them, the other one sounds similar, but adds C3PO saying “He agrees!”)

That is exactly what I meant when I said that you don’t need to end the lockup.

The question is really if it’s wrong to play endarm.wav when you turn the TD off. I mean, technically we are ending the lockup. And if we don’t send an endarm event, something might end up looping forever.

No. Pretty sure that ends up playing endarm.wav

Mine too.

When I turn “Off();” my TD, I want endarm to play and it is doing that. Turning off and playing endarm is not and has never been the issue.

The issue is playing endarm & boom (at the same time) when doing Off(OFF_BLAST);

boom.wav should play instead of endarm

Maybe my answer is to add a new LockupType in saber_base: LOCKUP_BOOM

and add these in hybrid_font:

  void SB_BeginLockup() {
...
      case SaberBase::LOCKUP_ARMED:
... 
      case SaberBase::LOCKUP_BOOM:
        break; // Do nothing, just keep doing what LOCKUP_ARMED is already doing
      case SaberBase::LOCKUP_AUTOFIRE:
...

  void SB_EndLockup() {
    Effect *end = nullptr;
    switch (SaberBase::Lockup()) {
      case SaberBase::LOCKUP_ARMED:
        end = &SFX_endarm;
        break;
      case SaberBase::LOCKUP_BOOM:
        end = &SFX_boom;
        break;
...

And instead of doing Off(OFF_BLAST);
I do:

SaberBase::SetLockup(SaberBase::LOCKUP_BOOM);  // SaberBase::LOCKUP_ARMED: has already been started previously
SaberBase::DoEffect(EFFECT_BOOM, 0);
Off(); // or I could even do "Off(OFF_IDLE);" to make sure the detonator is silent after boom

Could/would that work ?

Why?

arm → boom plays boom.wav
arm → unarm pays pwroff.wav

Why do you need endarm?

1 Like

Finally I understand the idea! I thought you didn’t want to use an “endarm” sounding sound in your TD, but you do and it is in your pwroff.wav

endarm.wav is not intended to be used on the thermal detonator. It only took 9+ months of trying to tweak my code to realize that I was trying to do the wrong thing.

If all you have is a hammer, then everything is a nail.

I wouldn’t say you were trying to do the wrong thing, it’s just that sometimes the wrong thing is the right thing. :slight_smile:

2 Likes

What triggers poweronf.wav & pwroff.wav ?

If I understand hybrid_font.h, if both poweroff & pwroff exists, only poweroff will be played ? Is that correct ?

Nothing seems to be using poweronf, it only exists once here:

If I have poweron1, poweron2, poweroff1 & poweroff2, will poweron1 and poweroff1 play in the same on/off “cycle” ?

ProffieOS treats poweroff and pwroff as one set, and chooses randomly between them.

poweronf is a plecter thing that ProffieOS doesn’t use, I should probably remove the EFFECT as well.

short answer: no, they would play randomly

Long answer, it should be possible if you have hum1 and hum2 and link poweron->hum->poweroff in the font config file.

1 Like