Jump to content

Photo

How to trigger a custom flag?


  • Please log in to reply
5 replies to this topic

#1 notmichaeljfox

notmichaeljfox

    Initiate

  • Members
  • Real Name:Michael

Posted 10 July 2022 - 04:40 AM

Hi everyone,

 

I've built an area that is on fire, and have created an item (a bucket of water) to put the individual fires out. Is there a way to connect the custom item to one of the custom flags, and how would I set a secret combo to show that a fire has been put out?


Edited by notmichaeljfox, 10 July 2022 - 04:40 AM.


#2 eNJuR

eNJuR

    Junior

  • Members
  • Real Name:Nathan
  • Location:Sol system

Posted 10 July 2022 - 09:42 AM

Sounds fun!
 
Here's what you do (assuming you're using a 2.55 version, there should be a way to do it in earlier versions, but it'll be much more complicated)
 
Combo: make it type: Generic (see Edit2) and on the triggers tab check the box next to Custom Weapon 1 and the box next to ->Next (meaning when triggered, it will change to the next combo). (Also note that depending on your quest rules, custom triggers might not work on layers)
 
Next, the Item: Make a new item, set it a "Custom Weapon 01" type. On the Action tab, give it a SFX on UseSound (55 is the default splash sound). In Weapon Data tab, make sure Type is Custom Weapon 1, and for default defense set to ignore. 
On the Graphics/Sprites tab, set sprite 0 to a sprite representing a splash of water (set it up in Sprite Data editor). Lastly, the script tab: Load the script below and set the first value to a number (about or under 15 seemed good to me).

 

Edit to clairify: it's the Weapon Script tab in the item editor, and you'll have to have compiled the script first and assigned it to an lweapon slot.
 
here's the script: (it just deletes the assigned weapon sprite after d0 frames)

#include "std.zh"

lweapon script WaitThenDelete{
  void run (int delay){
    Waitframes(delay);
    this->DeadState = WDS_DEAD;
  }
}

------

I did a quick test, I think this should work. I'm not the most active, but let me know if it has problems!

 

Edit2: just realized you might want the fire to damage you. Well, I just tested doing the same but with the combo-type set to a damage type, and it still worked as intended, so no worries!


Edited by eNJuR, 10 July 2022 - 10:04 AM.

  • Twilight Knight and notmichaeljfox like this

#3 notmichaeljfox

notmichaeljfox

    Initiate

  • Members
  • Real Name:Michael

Posted 11 July 2022 - 08:44 AM

Thanks eNJuR.

I downloaded 2.55 and that kind of makes sense, but because I am new to this I stuck with 2.53 because I didn't want to deal with the dev process. Could I modify an existing class instead? I wasn't planning on using the wand trigger.



#4 eNJuR

eNJuR

    Junior

  • Members
  • Real Name:Nathan
  • Location:Sol system

Posted 11 July 2022 - 06:21 PM

It should be possible to cludge together something approximating it using 2.53 scripts. I'm away from my computer right now, bit I will try to write a script soon. But here's the pseudo code:
When use bucket  Create a static magic attack with zero attack power directly in front of link  Set it up so the weapon self-destructs after a few frames (might need global script integration for this, I'll have to check
Also: Will you still be giving or a wand that the player will have access to at any point that the fire is active? If so, the wand will still trigger the flags, which can be fixed with pseudo code below on an ffc on the screen. Note that if the player has both the bucket and wand equiped at the same time (or if they just switch really quickly), the wand will still activate the trigger. I can't think of anything off the top of my head that would be a simple fix; maybe with some super complex scripting but it's probably not worth it for the edge case unless it's critical that the player can't extinguish a non-adjacent fire.
While true  If Bucket is not equipped    Change all wand trigger combos into something else    Else change them back

  • notmichaeljfox likes this

#5 eNJuR

eNJuR

    Junior

  • Members
  • Real Name:Nathan
  • Location:Sol system

Posted 11 July 2022 - 10:22 PM

Alright; I got a few hours tonight, so I cranked this out for you!
 
I ended up simplifying it considerably by using the "Reflected Magic" trigger flag, which should be easy enough to avoid having real reflected magic on applicable screens. Anyway this script ended up being very simple, here it is:

import "std.zh"

const int TILE_EMPTY = 19;

item script MakeSplash{
    void run(int sprite, int duration, int distance, int sound){
        Game->PlaySound(sound);
        int xOffset = 0; int yOffset = 0;
        if(Link->Dir==DIR_UP) yOffset -= distance;
        if(Link->Dir==DIR_DOWN) yOffset += distance;
        if(Link->Dir==DIR_LEFT) xOffset -= distance;
        if(Link->Dir==DIR_RIGHT) xOffset += distance;
        lweapon splash = CreateLWeaponAt(
            LW_REFMAGIC, Link->X + xOffset, Link->Y +2 + yOffset
        );
        splash->OriginalTile=TILE_EMPTY; splash->Tile=TILE_EMPTY;
        splash->NumFrames=0;
        splash->DeadState = duration;
        Link->Action=LA_ATTACKING;
        lweapon splashSprite = CreateLWeaponAt(
            LW_SPARKLE, Link->X + xOffset, Link->Y +2 + yOffset
        );
        splashSprite->UseSprite(sprite);
        WaitNoAction();
    }
}

Item Set-up: (my numbers are from a starting point using the default tileset, and I changed Sprite: Ice Magic to use tile 27444, 2 frames, 6 speed; Change those as appropriate for your Tileset. Also change the value of "TILE_EMPTY" to a blank tile) Give the item a no-built-in-fuction class, like "Custom Itemclass 01". Attach the "MakeSplash" script to the Action slot in the script tab and fill out D0, D1, D2, and D3 as, respectively, sprite # to use, how long the triggering dummy weapon lasts (in earlier versions, this variable had more function, now it only has meaning if a combo cycles into a triggerable fire combo), how far in front of the player the splash apears (0 would be right on top), and the sound effect to play when used. In my test file, I used 83, 12, 12, and 55 and it worked fine.
 
Combo Set-up: It doesn't matter what "type" it is, I used "Damage (1 heart)" when testing. The important thing is to set the inherent flag to "77 (Magic Trigger (Reflected)" and then (making sure you are on the right layer, I know putting flags on the wrong layer is a common mistake I make) using the set combo flag tool, set all these combos with "94 Trigger -> Self Only"
 
Personally, I found setting the fire combos on layer 1 and leaving the reflected-magic secret tile blank worked well, but you can use it any way you'd like.
 
Also, it'd be wise to change your "secret activated" sound in Screen Data (I used 4) and maybe "hit all triggers -> perm secret".
 
If you have any more questions, let me know!
 

 

Additional: I decided to add an alternate version that makes you have to refill the bucket. It has a filled bucket that splashes water and an empty version that can be filled at water. The filled bucket is mostly the same as above, but Make sure the water bucket is a higher level in the same class as the empty bucket, and that you have "keep lower level items" enabled on the pickup tab as well as "remove item when used" on the action tab of the filled bucket.

 

You can make one filling of the bucket last several uses if you make duplicates of the filled bucket item and give each a higher level.

 

Make a new Empty Bucket item that is the same class but a lower level and give it the "FillBucket" action script.

 

In the script below, D0 = the sound effect to play, and Ds 1 through 7 are items added when used when standing on or facing water or shallow water.

item script FillBucket{
    void run(int sound, int item1, int item2, int item3, int item4, int item5, int item6, int item7){
        int testX = Link->X+8;
        int testY = Link->Y+12;
        testX = Clamp(testX,0,255);
        testY = Clamp(testY,0,175);
        int comboStandingAt = ComboAt(testX,testY);
        if(Link->Dir==DIR_UP) testY -= 16;
        if(Link->Dir==DIR_DOWN) testY += 16;
        if(Link->Dir==DIR_LEFT) testX -= 16;
        if(Link->Dir==DIR_RIGHT) testX += 16;
        testX = Clamp(testX,0,255);
        testY = Clamp(testY,0,175);
        int comboLookingAt = ComboAt(testX,testY);
        comboStandingAt = Screen-> ComboT[comboStandingAt];
        comboLookingAt = Screen-> ComboT[comboLookingAt];
        if(
            comboStandingAt==CT_SHALLOWWATER || comboStandingAt==CT_WATER || comboStandingAt==CT_SWIMWARP || comboStandingAt==CT_SWIMWARPB || comboStandingAt==CT_SWIMWARPC || comboStandingAt==CT_SWIMWARPD || comboStandingAt==CT_DIVEWARP || comboStandingAt==CT_DIVEWARPB || comboStandingAt==CT_DIVEWARPC || comboStandingAt==CT_DIVEWARPD
            ||
            comboLookingAt==CT_SHALLOWWATER || comboLookingAt==CT_WATER || comboLookingAt==CT_SWIMWARP || comboLookingAt==CT_SWIMWARPB || comboLookingAt==CT_SWIMWARPC || comboLookingAt==CT_SWIMWARPD || comboLookingAt==CT_DIVEWARP || comboLookingAt==CT_DIVEWARPB || comboLookingAt==CT_DIVEWARPC || comboLookingAt==CT_DIVEWARPD
        ){
            Game->PlaySound(sound);
            if(item1>0) Link->Item[item1]=true;
            if(item2>0) Link->Item[item2]=true;
            if(item3>0) Link->Item[item3]=true;
            if(item4>0) Link->Item[item4]=true;
            if(item5>0) Link->Item[item5]=true;
            if(item6>0) Link->Item[item6]=true;
            if(item7>0) Link->Item[item7]=true;
        }
        Link->Action=LA_ATTACKING;
        WaitNoAction();
    }
}

Let me know if this is what you're after and if you have any questions! Do note that this will now activate any "magic (reflected) flags. Rather than fixing this with more scripting, I think the easiest way to handle that would be to either simply disable use of filled bucket items in dmaps that need to use reflected magic flags (which smart players might notice), or just make sure that any reflected magic targets would be out of reach of using the bucket; which can be done on even targets you can walk up to by clever use of step->next family of combos types.


Edited by eNJuR, 11 July 2022 - 10:28 PM.

  • Twilight Knight and notmichaeljfox like this

#6 notmichaeljfox

notmichaeljfox

    Initiate

  • Members
  • Real Name:Michael

Posted 18 July 2022 - 09:32 AM

Wow, thank you so much! A refillable bucket is what I was thinking of (and didn't comprehend that this was something that I needed to state).

I can't test it until the weekend but I'm really eager to try it.


  • eNJuR likes this


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users