Jump to content

Photo

Generic FFC Trigger


  • Please log in to reply
46 replies to this topic

#1 Binx

Binx

    Formerly Lineas

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

Posted 01 August 2013 - 02:49 PM

So, I don't even know if this is possible, but when I needed to come up with triggers that work with custom LWeapons, I thought maybe it could be done with an FFC. Then, I thought, if it can be done with an FFC, maybe it could be an adjustable one, so like it had maybe 2-3 arguments, that will cause the FFC to change to a secret tile when hit by the LWeapon number (the D0, and possibly D1 argument, if you wanted to be able to set multiple LWeapons, so I could have, say, a sword that shoots wand magic, but have both melee and the projectile trigger it, the last argument would be which secret tile it uses). The main thing i'd that I need to be able to have lots of triggers that can all be set off by items of a single item of the same class (in this case, they're all swords), but I want it to be that each sword can only set off one type of trigger. Right now the problem I'm having is that out of 11 swords, most of them could activate any built in sword trigger, and block flags get really messy and easy to screw up when you have 11 swords, so if I could make each sword have its own individual trigger, so the dry trees can be gotten rid of by the fire sword projectiles OR melee, but the Water sword, or ice sword, or wind swords, etc. wouldn't do anything. Anyways, I'm rambling.

 

 

So, let me try to summarize: I want an FFC Trigger that can be set via argument to only respond to specific items, even if a different item is in the same class and a higher level. Not sure if it can be done, but if it can, I would be supremely grateful.



#2 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 02 August 2013 - 02:39 AM

I'm putting a $50 BOUNTY on a functional script along the lines that i define below. Paid on delivery (or ASAP thereafter) via PayPal.

 

---

 

Just an FYI, you probably want the FFC to affect an on-screen combo of a specific type, and change that combo into something else if it interacts with a weapon or item of a specific item number for maximum flexibility and customisation.
 
You would place that FFC anywhere on the screen, and for example:
 
D0: The base combo number to affect;
D1: The combo number to change D0 into (or the secret combo number);
D2: Specific item to make the change happen;
D3: An item class to make the change (0 for none);
 
The alternative would use combo types, but there are a limited number of script types. This would work as follows:
 
D0 The base combo type (or flag) to affect;
D1: The combo it should become (combo number; or the secret combo number)
D2; The specific item to make the change;
D3: An item class to make the change (0 for none);
 
This follows the same premise as the JumpBlock script that MM made a while back (that I use), where any combo type of Statue(Right) becomes a jump-only obstacle when an invisible FFC with the JumpBlock FFC script is on the screen.
 
As you tried my demo, you may have noticed the trowel (shovel) is surrounded by pits and a fallen warrior with a rusting sword. Those are jump-pits, so you need the Leap! spell (feather at present) to jump over them to claim the trowel, which is needed to dig in other areas of the game to un-bury treasure or key items. I have a cheat-ish way to make that work, by triggering Screen-Secrets on the item, but a script like this, that allows the triggering of a specific combo would be magic to games like mine as well.
 
I simply don;t know want calls to make to have this happen, as I have not seen much along these lines. I will post the JumpBlock script for you here so that you can see how it functions, at least, and mayhaps you can make something from that...
 
Credit for this again goes to MoscowModder, who incidentally forgot that he made it when I messaged him a while back. 8)
 

//============== * Jump-only obstacles * ==============================
const int CT_OBSTACLE        = 12; //Combotype to give hole functionality to (default is Left Statue)
//const int CT_OBSTACLE        = 143; //Uses the script 1 combo type - 143-146 are 2-5

ffc script JumpBlock{
    void run(){
        while(true){
            if(OnBlock() && Link->Dir == DIR_UP){
                Link->Y = Link->Y + 2;
                Link->InputUp = false;
                Link->InputDown = false;
                Link->InputLeft = false;
                Link->InputRight = false;
                Link->InputA = false;
                Link->InputB = false;
            }
            if(OnBlock() && Link->Dir == DIR_RIGHT){
                Link->X = Link->X - 2;
                Link->InputUp = false;
                Link->InputDown = false;
                Link->InputLeft = false;
                Link->InputRight = false;
                Link->InputA = false;
                Link->InputB = false;
            }
            if(OnBlock() && Link->Dir == DIR_DOWN){
                Link->Y = Link->Y - 2;
                Link->InputUp = false;
                Link->InputDown = false;
                Link->InputLeft = false;
                Link->InputRight = false;
                Link->InputA = false;
                Link->InputB = false;
            }
            if(OnBlock() && Link->Dir == DIR_LEFT){
                Link->X = Link->X + 2;
                Link->InputUp = false;
                Link->InputDown = false;
                Link->InputLeft = false;
                Link->InputRight = false;
                Link->InputA = false;
                Link->InputB = false;
            }
            Waitframe();
        }
    }
bool OnBlock(){
        return (Screen->ComboT[ComboAt(Link->X+8,Link->Y+8)] == CT_OBSTACLE && Link->Z <= 0 && Link->Action != LA_FROZEN);
    }    
}


#3 grayswandir

grayswandir

    semi-genius

  • Members

Posted 03 August 2013 - 04:17 PM

Here's a quick, rough attempt. Probably full of bugs and whatnot. You'll need to use the EveryWeapon item script on every single lweapon producing item, as the name indicates. It's really cumbersome, and I'm not quite sure its what you want, but I couldn't think of a better way. :shrug:

const int LWEAPON_MISC_SOURCE = 0;
 
// 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;}
 
ffc script Trigger {
  void run(int fromCombo, int toCombo, int itemNo) {
    while (!CollisionAllLWeapon(this, LWEAPON_MISC_SOURCE, itemNo)) {
      Waitframe();}
    for (int i = 0; i < 176; i++) {
      if (Screen->ComboD[i] == fromCombo) {
        Screen->ComboD[i] = toCombo;}}}}
 
int LastItemUsed = 0;
 
item script EveryWeapon {
  void run(int thisItemId) {
    LastItemUsed = thisItemId;}}
 
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;}}
      Waitframe();}}}

Basically, whenever you use an item with the EveryWeapon script, it sets LastItemUsed to the id supplied by the script. And in the active script, whenever it detects an lweapon without an assigned item, it sets that lweapon's assigned item to LastItemUsed. Then the trigger script checks the lweapon's assigned item to see if it wants to trigger.


Edited by grayswandir, 03 August 2013 - 04:17 PM.


#4 Binx

Binx

    Formerly Lineas

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

Posted 03 August 2013 - 04:34 PM

Ok, let's see if I understand this correctly: I add the global to my global, combine the EveryWeapon item script with any other item scripts I'm using on a weapon (I'm assuming it's an action script, and since you can only have one action script per item, they'd all have to be combined, yes?), say my ice sword, so i set up the FFC and I hit it with my fire sword, which is keyed to a different trigger. Nothing happens because even though it's the right LWeapon type, it has the wrong ItemID, but if I use my ice sword it would trigger, or that's the theory. If my understanding on how this script is supposed to work is correct, then yes, it's EXACTLY what I was looking for. Not sure about Zoria, though.



#5 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 03 August 2013 - 09:20 PM

This seems to be the main downfall at a glance:
 

item script EveryWeapon {
  void run(int thisItemId) {
    LastItemUsed = thisItemId;}}

 
I was looking for a script that reads the internal ID of an item being used (the item number from the editor), as having to add this to each item will steal one valuable argument slot; else I will need to add a separate action script for every item in the game, with a hard-coded value. There has to be a way to read what the current item for A and the current item for B is, and if one of those is the same type set on the FFC for the trigger, and is used on the trigger, it activates the trigger via the FFC.
 
That way, I only need to set the FFC in the code one time, and have it trigger if hit by item-XXX or LWeapon(Type) X, or Item Class(X), with item-XXX preferred, and an else if for the other two as backup arguments (e.g. for scripted LWeapon types). .



#6 grayswandir

grayswandir

    semi-genius

  • Members

Posted 03 August 2013 - 09:44 PM

If you're worried about argument slots, aren't you already adding a separate action script for that item? Or are a lot of your pickup scripts going to be using every argument slot?

 

There's GetEquipmentA() and GetEquipmentB(), but how do you tell which is being used? I guess you could check Link->PressA and Link->PressB, but what if they're both pressed at once? What if there's already an arrow on screen, and the bow fails to fire? There are many, many cases to check for to see if that button press actually went through and made Link use that item. By far the easiest way to tell when an item has been used is by setting a flag at the start of its action script.

 

There's just no easy way to tell which item number generated which lweapon.



#7 Binx

Binx

    Formerly Lineas

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

Posted 03 August 2013 - 10:39 PM

Hmmmm..... Well, is it really so hard to hard-code something that's usually static, like the counter, costs or sound effects? I mean, if you hard code those three functions, that frees up three whole arguments that can be used for other things, right?



#8 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 03 August 2013 - 10:40 PM

Yes, many of my weapons and items use, or will use all of the item arguments available.
 

There's GetEquipmentA() and GetEquipmentB(), but how do you tell which is being used? I guess you could check Link->PressA and Link->PressB, but what if they're both pressed at once? What if there's already an arrow on screen, and the bow fails to fire? There are many, many cases to check for to see if that button press actually went through and made Link use that item. By far the easiest way to tell when an item has been used is by setting a flag at the start of its action script.

 
I need a way to avoid using any arguments from an item to make this work. Now that I know that a weapon or item can store valiues in weapon->Misc, I would think that you could script the item to store the item number (from the item editor) into one of those values, and to store that value in the LWeapon projectile.
 
As I said, I don't know the best, or easiest way to do this, but when you have an arsenal of unique effects, you need to be able to use them, preferably without eating up dozens of script slots because you need to hard-code the values of each item just to make the triggers work.
 
 
 
I know this is a huge pain, but I'm already running out of arguments and needing to duplicate scripts just to hard-code values. Perhaps, if there is a way to use the address information from items to do this, that would be perfect, as nothing else is using those values. I don't know if you could make use of them...
 

Well, is it really so hard to hard-code something that's usually static, like the counter, costs or sound effects? I mean, if you hard code those three functions, that frees up three whole arguments that can be used for other things, right?


Those are the first things that I already sacrifice. Error SFX is a gamewide value, so i don;t need to use it on each item; counter handling and other things comes next, until I run out of options. As I have stated before, if I has sixteen arguments, I think I could do just about anything, but with only eight, I need to avoid eating any that i can save. 

 

While some items use only two or three, the script for the swords in the end will eat all eight, unless I want to script each weapon individually.

 

I'm happy to try this script as-is, but it isn't quite ripe enough... If there is a way to use the address data from an item to achieve this goal, then it might just work perfectly.


Edited by ZoriaRPG, 03 August 2013 - 10:46 PM.


#9 Binx

Binx

    Formerly Lineas

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

Posted 03 August 2013 - 10:57 PM

Wow.... Glad I'm so unimaginative, then. Cuz except for the ice and wind swords, pretty much all of my swords could just use this, as is, cuz none of them have any special characteristics, or at least none that can't be faked with fancy tile work. And... I'm not sure about the ice and wind swords, but I think most of their values are hard-coded, so I'd be able to use this, still.



#10 grayswandir

grayswandir

    semi-genius

  • Members

Posted 03 August 2013 - 11:38 PM

What exactly do you mean by address data?

 

If you're dead set on not using an argument, then there's really no good way for detecting what item Link is currently using. Like I said, you'll have to check when the buttons are pressed, and then compare them to the equipment in the A and B slots. But the script will be filled with edge cases you have to consider, and take quite a lot of effort overall.

 

Exactly how efficiently are you using your item arguments? Do you have more than one 'effect' for each argument? If you really squeezed it in there, theoretically the item id would only take a quarter of an argument.



#11 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 04 August 2013 - 12:05 AM

What about just checking Level variable? I don't think that anyone has mentioned that yet.

I'm putting a $50 BOUNTY on a functional script along the lines that i define below. Paid on delivery (or ASAP thereafter) via PayPal.


Hi. Is this a serious post or not? It's hard to tell. ;)

#12 grayswandir

grayswandir

    semi-genius

  • Members

Posted 04 August 2013 - 01:20 AM

What about just checking Level variable? I don't think that anyone has mentioned that yet.

The point is, how do you know which item you're using in the first place?



#13 Binx

Binx

    Formerly Lineas

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

Posted 04 August 2013 - 03:59 AM

Just a thought, since in a lot of cases you'll have to combine that every weapon script with another action script anyways, couldn't you just hardcode the item id for it? Well, I guess that wouldn't work in cases where you're using the same script for multiple weapons....



#14 Binx

Binx

    Formerly Lineas

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

Posted 04 August 2013 - 04:57 PM

So, random thought: If you were to place this FFC on top of, say, a Burn (Din's Fire) flag, would it be activated by both the item keyed to the FFC (Say a sword beam) and Din's fire, or would one take precedence over the other?



#15 grayswandir

grayswandir

    semi-genius

  • Members

Posted 04 August 2013 - 05:58 PM

The burn flag would operate as normal. The FFC will still work, no matter what happens to the underlying tile. So, in theory, if you trigger the burn flag with Din's fire, you'll still be able to hit the FFC with a sword beam. And vice versa, as long as the FFC doesn't cancel out the burn flag.

 

I can write up a quick version that causes the FFC to cancel itself if the underlying tile changes, if you want.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users