Jump to content

Photo

Generic FFC Trigger


  • Please log in to reply
46 replies to this topic

#16 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 04 August 2013 - 06:11 PM

That would be awesome. That way, I could set up a burnable tree that can also be burned down by the fire sword, and my quake sword will be able to trigger bomb triggers... well, technically, it won't, but it should amount to the same thing, ideally. I originally was trying to get it to trigger an SBomb blast on impact, but that ended up being a pain in the ass. Being able to do this is better. 



#17 grayswandir

grayswandir

    semi-genius

  • ZC Developers

Posted 04 August 2013 - 06:26 PM

I haven't tested this, but it should work.

ffc script Trigger {
  void run(int fromCombo, int toCombo, int itemNo) {
    int loc = ComboAt(this->X + 8, this->Y + 8);
    int underCombo = Screen->ComboD[loc];
 
    // Wait until
    while (// We're hit by the right item type, or
           !CollisionAllLWeapon(this, LWEAPON_MISC_SOURCE, itemNo) &&
           // The combo on layer 0 changes.
           Screen->ComboD[loc] == underCombo) {
      Waitframe();}
 
    // Cancel out if the underlying combo changed.
    if (Screen->ComboD[loc] != underCombo) {
      return;}
 
    // Otherwise, we were hit by the item, so change the combos on screen.
    for (int i = 0; i < 176; i++) {
      if (Screen->ComboD[i] == fromCombo) {
        Screen->ComboD[i] = toCombo;}}}}

 

Also, remember that you don't have to use the item number as the actual itemNo value if you don't want. You could give all fire type items one value instead of their actual item number if you wanted.



#18 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 04 August 2013 - 06:37 PM

Hmmmm, that's an interesting thought, but other than Din's Fire, if I have any other fire weapons in game, they'll only do elemental damage (long story, short version, there's an element table in my quest), I wouldn't want them to activate the triggers.

 

 

EDIT: I haven't gotten a chance to test it yet, but at very least, it compiles all right :)

 

 

EDIT EDIT: Maybe I set it up wrong, but I can't get it to work. I tried to make a cave appear, so I set the FFC, set the D0 argument to the same combo as the surrounding wall (25), set the D1 argument to the cave entrance (135), and the D2 argument to the same item ID that my Quake Sword had assigned to it's ItemId slot (142). Is there any way to set it to just activate secret tile 16, instead?


Edited by Lineas, 04 August 2013 - 07:30 PM.


#19 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 06 August 2013 - 08:50 AM

I'll try this out ASAP. if it works, I will need you to PM PayPal address to me, and I will send you the bounty as soon as I am able.

 

I just got back on-line after three days of no connection.



#20 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 06 August 2013 - 10:21 AM

Please do, cuz I can't get it to work.

 

EDIT: Nvm, I must've had something set incorrectly. Be warned, though, it changes ALL identical tiles on the screen, so all of your triggers better have unique tiles (or just duplicate any tiles you need to use the ffc on)

 

EDIT (Again): Ok, whatever I fixed to make it work that one time got unfixed when I tried to change the combo so that all my mountain tiles didn't turn into caves. So... I'm having problems, again. Damn. BUT! At least we know it CAN work.... I just need to figure out HOW I did it last time, though....

 

EDIT (Another one): Ok, I located the issue. The FFC can't be on top of the tile you want to change, it has to be at LEAST a little off center or the tile won't change. Also, it has to be completely off center, or it will change the tile, but block any tile warps that would be present. (I was specifically testing this with a cave). Oh, and if you're using any "sword beam" projectiles, the trigger won't activate unless it's on the edge of the screen, you'll have to hit it melee style (I don't know if there's any way to fix this, though, short of a script to force sword beams to respect walkability). 


Edited by Lineas, 06 August 2013 - 10:57 AM.


#21 grayswandir

grayswandir

    semi-genius

  • ZC Developers

Posted 06 August 2013 - 11:05 AM

This should work with flags as well (untested):

// When hit by an lweapon with Misc[LWEAPON_MISC_SOURCE] set to
// itemNo, change all target combos on screen to toCombo. If the combo
// this FFC is placed on top of changes, this kills itself without
// triggering anything.
//
// int target - What combos on the screen to change. If >= 0, it
//   changes every combo with that number on the screen. If < 0, it
//   changes every combo with the flag of the negative on the
//   screen. (So set to -16 to change the Secret 0 flag.)
// int toCombo - the combo to change the target to.
// int itemNo - the item number to respond to.
ffc script Trigger {
  void run(int target, int toCombo, int itemNo) {
    int loc = ComboAt(this->X + 8, this->Y + 8);
    int underCombo = Screen->ComboD[loc];
 
    // Wait until
    while (// We're hit by the right item type, or
           !CollisionAllLWeapon(this, LWEAPON_MISC_SOURCE, itemNo) &&
           // The combo on layer 0 changes.
           Screen->ComboD[loc] == underCombo) {
      Waitframe();}
 
    // Cancel out if the underlying combo changed.
    if (Screen->ComboD[loc] != underCombo) {
      return;}
 
    //// Otherwise, we were hit by the item, so change the combos on screen.
    // Transform from a combo.
    if (target >= 0) {
      for (int i = 0; i < 176; i++) {
        if (Screen->ComboD[i] == target) {
          Screen->ComboD[i] = toCombo;}}}
 
    // Transform from a flag.
    else {
      for (int i = 0; i < 176; i++) {
        if (ComboFI(i, -target)) {
          Screen->ComboD[i] = toCombo;}}}}}

Edit: Lineas, in response to your last edit, have you tried to set the FFC to ethereal in its options? That may be interfering with things.


Edited by grayswandir, 06 August 2013 - 11:07 AM.


#22 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 06 August 2013 - 11:15 AM

Nope, I had no idea what that does, lol. Actually that (setting the FFC to ethereal) fixed all the problems except the sword beam issue, and now it's not activating even when it's on the edge of the screen (maybe it wasn't activating before and I just THOUGHT it did...)

 

 

EDIT: Not sure if this would be affecting the trigger issues, but the sword beams I'm generating with my swords are scripted LWeapons, not the built-in beams, would that be affecting their ability to trigger? It just looks like (from what I can read of the code, and admittedly, my comprehension isn't the greatest) it should be triggered by any LWeapon generated by the item with the correct itemNo attribute, yes? I'm very confused by this.

 

ANOTHER EDIT: This is really a very minor issue, but is there any way to make the triggered "secret" (D1) permanent after you activate it the first time? If not, it's no big deal, just looking at the idea for consistency's sake.


Edited by Lineas, 06 August 2013 - 01:10 PM.


#23 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 07 August 2013 - 11:54 AM

I saved the script, and I am going to try using it tonight. What I want to clarify is this:
 
When hit by an lweapon with Misc[LWEAPON_MISC_SOURCE] set to itemNo
 
I'm not understanding the reference to this assignment (LWEAPON_MISC_SOURCE), as I have never seen this before, and I presume that it needs to be established somewhere for this to function... In reading this, I seem to take it that this does not read the actual item number from A/B, but that I need to somehow set an item number to place into an array, and put that into the active script for each item? That seems to circumvent what I was trying to do, as it would still eat an argument slot; or is this supposed to read the item number of an item from another source?
 
Perhaps a portion of code to add to a global active script (or a subscript activated by a command in the active global script) that deduces what item is in A or B, and assigns this value, or is this already happening from some header?
 
In other words, I don't see anything in the script to set the assign on LWEAPON_MISC_SOURCE... Is that already included in a header?
 
Some instructions on set-up and usage on combos to change them would be useful. The int i seems to be the combo at present, and then what? I presume that I set the combo to change and the combo for it to become in the FFC arguments, from what I'm seeing.
 
I'm not understanding what this (below) is doing, or how to set it via a flag? Do I set the flag type as an argument? Hmm.. No, no int set for that.
 

// Transform from a flag.
    else {
      for (int i = 0; i < 176; i++) {
        if (ComboFI(i, -target)) {
          Screen->ComboD[i] = toCombo;}}}

How do I use flags to set this, and what would be the purpose if the FFC already causes a triggered event?


Edited by ZoriaRPG, 07 August 2013 - 12:04 PM.


#24 grayswandir

grayswandir

    semi-genius

  • ZC Developers

Posted 07 August 2013 - 01:46 PM

Sorry about the confusion. It was just updates to the version I posted earlier. I still don't know a good way to read the item number without using an argument.

 

You can try this to avoid using an argument, but it'll probably be very buggy. Just put this somewhere in your main loop:

if (Link->PressB) {LastItemUsed = GetEquipmentB();}
if (Link->PressA) {LastItemUsed = GetEquipmentA();}

For the flag thing: The target argument, when positive, is the combo to transform from. When negative, it is the flag to transform from. So when target is 16, it transforms all the combos with id 16. When target is -16, it transforms all the combos with flag 16.


Edited by grayswandir, 07 August 2013 - 01:47 PM.

  • Binx likes this

#25 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 08 August 2013 - 03:44 AM

In other words, the final form is this?
 

const int LWEAPON_MISC_SOURCE = 0;

global script Active {
void run() {
while (true) {
for (int i = 1; i <= Screen->NumLWeapons(); i++) {
lweapon lw = Screen->LoadLWeapon(i);
if (lw->Misc[LWEAPON_MISC_SOURCE] == 0) {
lw->Misc[LWEAPON_MISC_SOURCE] = LastItemUsed;}}
        if (Link->PressB) {LastItemUsed = GetEquipmentB();}
        if (Link->PressA) {LastItemUsed = GetEquipmentA();}
Waitframe();}}}
 
// Return if this ffc collides with an lweapon that has the given
// misc attribute at the given value.
bool CollisionAllLWeapon(ffc this, int attrIndex, int attrValue) {
  for (int i = 1; i <= Screen->NumLWeapons(); i++) {
    lweapon lw = Screen->LoadLWeapon(i);
    if (lw->Misc[attrIndex] == attrValue && Collision(this, lw)) {
      return true;}}
  return false;} 


// When hit by an lweapon with Misc[LWEAPON_MISC_SOURCE] set to
// itemNo, change all target combos on screen to toCombo. If the combo
// this FFC is placed on top of changes, this kills itself without
// triggering anything.
//
// int target - What combos on the screen to change. If >= 0, it
//   changes every combo with that number on the screen. If < 0, it
//   changes every combo with the flag of the negative on the
//   screen. (So set to -16 to change the Secret 0 flag.)
// int toCombo - the combo to change the target to.
// int itemNo - the item number to respond to.
ffc script Trigger {
  void run(int target, int toCombo, int itemNo) {
    int loc = ComboAt(this->X + 8, this->Y + 8);
    int underCombo = Screen->ComboD[loc];
 
    // Wait until
    while (// We're hit by the right item type, or
           !CollisionAllLWeapon(this, LWEAPON_MISC_SOURCE, itemNo) &&
           // The combo on layer 0 changes.
           Screen->ComboD[loc] == underCombo) {
      Waitframe();}
 
    // Cancel out if the underlying combo changed.
    if (Screen->ComboD[loc] != underCombo) {
      return;}
 
    //// Otherwise, we were hit by the item, so change the combos on screen.
    // Transform from a combo.
    if (target >= 0) {
      for (int i = 0; i < 176; i++) {
        if (Screen->ComboD[i] == target) {
          Screen->ComboD[i] = toCombo;}}}
 
    // Transform from a flag.
    else {
      for (int i = 0; i < 176; i++) {
        if (ComboFI(i, -target)) {
          Screen->ComboD[i] = toCombo;}}}}}
		  
		  
// int LastItemUsed = 0; //Is this not replaced by the constant int above and the global if functions?
 
item script EveryWeapon {
  void run(int thisItemId) {
    LastItemUsed = thisItemId;}}
 


I slashed out the int LastItemUsed = 0; as this seems to be superseded by the const int of the same assign value.

 

I'd appreciate any clean-up to make this a complete package with those new if statements; then I'll give it a test-drive.

 

(This, BTW, is why I always post entire scripts whenever I update them.)



#26 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 11 August 2013 - 01:45 PM

Is there any way to link two of these ffcs together on the same screen? I have a double-wide cave door that uses two different tiles (one tile for the left, one for the right), and I wanted to make it so they BOTH open, I was sort of able to make it work by just placing two FFCs side by side on visually identical, but different combos, and it worked.... sort of. It does exactly what I want it to, but only if you hit both FFCs with the triggering item, and that can lead to some.... interesting, graphics issues, like the right side of the cave being open and the left side being closed, which looks really freaking weird with the tiles I'm using.

 

EDIT: BTW, here's a picture of the specific cave entrance I want to block

 

http://i19.photobuck.../zelda025-1.png


Edited by Lineas, 11 August 2013 - 01:50 PM.


#27 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 12 August 2013 - 01:08 PM

I had thought of this as well and was pondering how to resolve it: I have an area that is to be 4x4, that should be triggered by striking any of the four spaces with the desired item, but as I have yet to incorporate this (and am still awaiting a response to my post above), I hadn't dwelled on the matter.

 

I think that I could use draw commands to stretch the 'source' and 'destination' FFCs, although that is not ideal. I expect that there is a way to trigger all FFCs on a scree that use these resources, but that would also mean that you could not have two different triggered on the screen which defeats the purpose of having this.

 

I think the best way to handle this is to set it up for special uses, so that if you want to change two or four combos, you code a variant of this script that contains the source and replacement combos and activates all at once when it is triggered by any means.

 

Once I get back into ZQ mode, I'll try to find a solution, but I need to see if the solution grayswandir provided to read the current item works before I do anything else with this.



#28 grayswandir

grayswandir

    semi-genius

  • ZC Developers

Posted 12 August 2013 - 01:27 PM

Sorry, you were waiting for me? I seem to have missed your last post somehow. I'll try to get back to you on that tonight.

 

As for changing several combos, what if I set up a version that copied over a specific screen instead of a specific combo? So it replaces every target combo on the current screen with the corresponding combo on the screen you specify.



#29 Binx

Binx

    Formerly Lineas

  • Members
  • Real Name:Brian
  • Location:Lancaster, CA

Posted 12 August 2013 - 01:30 PM

So, basically it would work like a "screen secrets layer" of sorts?



#30 grayswandir

grayswandir

    semi-genius

  • ZC Developers

Posted 12 August 2013 - 01:32 PM

Yeah, pretty much. Except you could selectively select which part of the screen gets copied over, based on what combos/flags are on the current screen.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users