Jump to content

Photo

Global script functions interfering with each other...


  • Please log in to reply
10 replies to this topic

#1 Demonlink

Demonlink

    Lurking in the shadows...

  • Members
  • Real Name:Miguel
  • Location:Wouldn't you like to know?

Posted 20 May 2017 - 08:08 PM

As I feared would happen one day, global script functions are interfering with each other. I'm using Justin's Pegasus Boots script alongside Zepinho's GB Power Bracelet script. I want to add Fox's Freeform Shutter script, and here is where the problem begins.

 

Fox's script uses one combo type (CT_SCRIPT1), inherent flags to identify shutters and tells them how to act according to the inherent flag placed on top said shutter; these flags go from CF_SCRIPT1 to CF_SCRIPT5 (inherent flags 98 - 102). The problem is, two of these flags are used by Zepinho's and Justin's scripts as well: Inherent flag 98 (CF_SCRIPT1) for the Power Bracelet script, and Inherent Flag 99 (CF_SCRIPT2) for the Pegasus Boots script.

 

So, let's say I put two shutters on the same screen, one has flag 98 and the other has flag 99. As script developers would guess, one shutter will be able to be picked up by the Power Bracelet and the other shattered by the Pegasus Boots. This, is where the interfering is caused. Certainly, I don't want shutters to be picked up or destroyed, what kind of gameplay is that!? :lol:

 

My question is this. The idea I have is, to add some code to both the Power Bracelet and Pegasus Boots scripts so that they detect if a combo has CT_SCRIPT1 attached to it as well as either inherent flag 98 or 99. If so, the script quits, canceling any interference among these three scripts. But, what lines would I add?

 

My script file is VERY large, so if anybody is wiling to help me out, post here and I will send you my script file via a dropbox link. Thanks in advance to whoever helps. :D

 

  • judasrising likes this

#2 ywkls

ywkls

    Master

  • Members

Posted 20 May 2017 - 08:46 PM

Sounds like something I might be interested in. I have a lot of scripts that use multiple combo flags and types (and combinations of such) for various things. I've used justin's Pegasus Boots script myself, so I know how it works. I don't have a lot fo experience with Zepinho's power bracelet, but I can always learn.

 

Plus, there might be some other scripting goodies I can find or come up with.

 

Edit: How large is very large? I'm currently working with a file that's nearly 700KB myself, so I'm used to large files. Unless we're talking the 3MB that Zodiac had, I should be able to handle it.


Edited by ywkls, 20 May 2017 - 08:48 PM.

  • Demonlink likes this

#3 judasrising

judasrising

    I play guitar

  • Members
  • Location:Sweden but born in Finland

Posted 20 May 2017 - 08:52 PM

As I feared would happen one day, global script functions are interfering with each other. I'm using Justin's Pegasus Boots script alongside Zepinho's GB Power Bracelet script. I want to add Fox's Freeform Shutter script, and here is where the problem begins.

 

Fox's script uses one combo type (CT_SCRIPT1), inherent flags to identify shutters and tells them how to act according to the inherent flag placed on top said shutter; these flags go from CF_SCRIPT1 to CF_SCRIPT5 (inherent flags 98 - 102). The problem is, two of these flags are used by Zepinho's and Justin's scripts as well: Inherent flag 98 (CF_SCRIPT1) for the Power Bracelet script, and Inherent Flag 99 (CF_SCRIPT2) for the Pegasus Boots script.

 

So, let's say I put two shutters on the same screen, one has flag 98 and the other has flag 99. As script developers would guess, one shutter will be able to be picked up by the Power Bracelet and the other shattered by the Pegasus Boots. This, is where the interfering is caused. Certainly, I don't want shutters to be picked up or destroyed, what kind of gameplay is that!? :lol:

 

My question is this. The idea I have is, to add some code to both the Power Bracelet and Pegasus Boots scripts so that they detect if a combo has CT_SCRIPT1 attached to it as well as either inherent flag 98 or 99. If so, the script quits, canceling any interference among these three scripts. But, what lines would I add?

 

My script file is VERY large, so if anybody is wiling to help me out, post here and I will send you my script file via a dropbox link. Thanks in advance to whoever helps. :D

I have the same issue so i would be good if you would share the edited one so i can also learn.



#4 Demonlink

Demonlink

    Lurking in the shadows...

  • Members
  • Real Name:Miguel
  • Location:Wouldn't you like to know?

Posted 20 May 2017 - 10:26 PM

Sounds like something I might be interested in. I have a lot of scripts that use multiple combo flags and types (and combinations of such) for various things. I've used justin's Pegasus Boots script myself, so I know how it works. I don't have a lot fo experience with Zepinho's power bracelet, but I can always learn.

 

Plus, there might be some other scripting goodies I can find or come up with.

 

Edit: How large is very large? I'm currently working with a file that's nearly 700KB myself, so I'm used to large files. Unless we're talking the 3MB that Zodiac had, I should be able to handle it.

Whoa, 700 kb!? Then mine is not as enormous as yours. :lol: (Mine is only 81 kb). I'll PM you the file, since what I meant by large, was that it's very long to post here. :) 



#5 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 21 May 2017 - 07:28 AM

I do not know what the flag on the boots does, but you can specify flags on individual layers, to have differing effects. As an example, if your shutters are always on layer 1, your boot flags on layer 0, and your lift objects on layer 2, then you can avoid conflicts by scanning the layers individually.


  • Demonlink likes this

#6 Demonlink

Demonlink

    Lurking in the shadows...

  • Members
  • Real Name:Miguel
  • Location:Wouldn't you like to know?

Posted 21 May 2017 - 03:11 PM

I do not know what the flag on the boots does, but you can specify flags on individual layers, to have differing effects. As an example, if your shutters are always on layer 1, your boot flags on layer 0, and your lift objects on layer 2, then you can avoid conflicts by scanning the layers individually.

The shutter script has a similar function. It scans layer 1 for a secret flag to keep the shutter closed. Hmmm, you know, I think I might do this in the future to expand my options, just in case similar issues arise like the one I posted in the OP. Thanks for the tip. ;)



#7 ywkls

ywkls

    Master

  • Members

Posted 21 May 2017 - 04:00 PM

I have the same issue so i would be good if you would share the edited one so i can also learn.

 

I'm not sure how similar yours is to the one I looked at, so I don't know if the same things would work. I can look it over if you like, though.



#8 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 22 May 2017 - 04:00 AM

Another good way to manage this sort of thing, is to check both an inherent flag, and a placed flag as a pair; or a combo type and a flag or flag pair. If you combine layers with both inherent, and placed flags, you can have as many as 175 unique object types. If you use additional combo types, every combo type that you add to this mixture increases the number of script identified combos by the same value (175).

Now, remember that in addition to placed and inherent flags, there are five Script combo types, so you have 875 unique combinations possible without leaving the domain of generic 'script' combo types.

Even without using layers, you have 125 combinations (5 types, 5 flags, 5 inherent flags) per position.

Edited by ZoriaRPG, 22 May 2017 - 04:13 AM.


#9 Demonlink

Demonlink

    Lurking in the shadows...

  • Members
  • Real Name:Miguel
  • Location:Wouldn't you like to know?

Posted 23 May 2017 - 08:35 PM

Another good way to manage this sort of thing, is to check both an inherent flag, and a placed flag as a pair; or a combo type and a flag or flag pair. If you combine layers with both inherent, and placed flags, you can have as many as 175 unique object types. If you use additional combo types, every combo type that you add to this mixture increases the number of script identified combos by the same value (175).

Now, remember that in addition to placed and inherent flags, there are five Script combo types, so you have 875 unique combinations possible without leaving the domain of generic 'script' combo types.

Even without using layers, you have 125 combinations (5 types, 5 flags, 5 inherent flags) per position.

Another idea I just had. It might be a bit tedious, but yet it works nonetheless. My idea is, to specify within the scripts, unique combo ids and manage them with if statements. Say, let's say in my quest file, combo #4508 is something I can use for the Pegasus Boots script. So, within it, I can just search the function that scans for what is breakable with the boots, modify it a bit, so I can add combo ids as well, in this case, combo #4508.

 

Hopefully you understand what I meant by that. :P



#10 ywkls

ywkls

    Master

  • Members

Posted 23 May 2017 - 09:53 PM

Another idea I just had. It might be a bit tedious, but yet it works nonetheless. My idea is, to specify within the scripts, unique combo ids and manage them with if statements. Say, let's say in my quest file, combo #4508 is something I can use for the Pegasus Boots script. So, within it, I can just search the function that scans for what is breakable with the boots, modify it a bit, so I can add combo ids as well, in this case, combo #4508.

 

Hopefully you understand what I meant by that. :P

This is done far more often than you might think and is one of the many reasons that large lists of combo ID constants often exist. However, the number of possible combinations of flags both placed and internal; along with the number of combo types sort of makes using this across an entire quest easier than specifying specific combos.

 

For example, there are 5 script combo flags, 5 script combo types and the ability to place flags both in the editor and internally. That means there are the following possible combinations.

5 combo types with no placed or internal flags.

5 combo types with 5 placed flags only. (Total of 25 combinations.)

5 combo types with internal flags only. (25 more combinations.)

5 combo types with placed and internal flags. (Even more combinations.)

 

The chances of running out of these is possible, though slim. However, there are other seldom used combo types and flags which can also be used without negatively affecting a lot of things; thus making it easier to reuse things over the entire quest.



#11 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 24 May 2017 - 12:50 AM

Another idea I just had. It might be a bit tedious, but yet it works nonetheless. My idea is, to specify within the scripts, unique combo ids and manage them with if statements. Say, let's say in my quest file, combo #4508 is something I can use for the Pegasus Boots script. So, within it, I can just search the function that scans for what is breakable with the boots, modify it a bit, so I can add combo ids as well, in this case, combo #4508.

 

Hopefully you understand what I meant by that. :P

 

I do it regularly, like this:

 

//Make a function that checks a value against all the combo IDs that have this special property
//and returns true if the inot value matches any of them.
bool IsSpecialComboTypeThatIWantTomatch(int cmb_id){
    int cmbs[]={50,51,52,53,54,55,100,101,150,3012}; //Array to hold all of the IDs
    int q[2];
    q[1] = SizeOfArray(cmbs);
    for ( ; q[0] < q[1]; q[0]++ ) if ( cmbs[ q[0] ] == cmb_id ) return true; //We found a match
    return false; //Default: We did not find a match.
}
 
//in your code, do this
 
for ( int q = 0; q < 176; q++ ) { //scan every combo position
    if ( IsSpecialComboTypeThatIWantTomatch( Screen>ComboD[q] ) {
        //Do what you want to do with these combos.
    }
}



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users