Jump to content

Photo

please help me with combining globals


  • Please log in to reply
10 replies to this topic

#1 Nightmeres

Nightmeres

    Defender

  • Members

Posted 01 February 2018 - 10:09 AM

im trying to combine 2 scripts using moosh's combiner. if it helps i would like the moving platforms and hole/lava components but i dont know how to do this.

 

this 

[spoiler]
const int CMB_FFC_INVIS = 1; //Combo higher than ID 0 with an invisible tile.


// ID's of barrier-related combos
// Barriers in raised state
const int BARRIER_A_RAISED = 15036;
const int BARRIER_B_RAISED = 15038;

// Barriers in lowered state
const int BARRIER_A_LOWERED = 15037;
const int BARRIER_B_LOWERED = 15039;

// Barriers animating to raised state
const int BARRIER_A_ANIMRAISE = 15041;
const int BARRIER_B_ANIMRAISE = 15043;

// Barriers animating to lowered state
const int BARRIER_A_ANIMLOWER = 15040;
const int BARRIER_B_ANIMLOWER = 15042;

// Raised barriers that Link can walk on
const int BARRIER_A_WALKABLE = 15044;
const int BARRIER_B_WALKABLE = 15045;

// Barrier switches
const int BARRIER_A_SWITCH = 15046;
const int BARRIER_B_SWITCH = 15047;

const int BARRIER_SWITCH_DUMMY = 191; // ID of a switch hit detection dummy enemy
const int BARRIER_SWITCH_DUMMY_HP = 32767;

// Global array to store the state of barriers per dmap
// If you have more than 16 dmaps you can change the capacity in the []'s
// You may change the states in other scripts, but the changes will not be visible
// until there is a new screen, so set them before Barriers_NewScreen() is called.
bool barriers[255]; // false = blue barriers raised, true = red barriers raised


const int ffcNumber = 32; //The number of the FFC used. This script will "hijack" this one, so don't use it for anything else on screens when you expect the player to have a follower.
const int firstFollowerCombo = 23568; //combo of the first combo. In order, the concecutive combos must be "still up", "still down", "still left", "still right", "moving up", "moving down", "moving left", "moving right".
const int csetOfFollower = 11;
const int reqItem = 158; //Item that makes the FFC follower follow you
const int BAR_PASTX = 14;
const int BAR_PASTY = 14;

global script slot2 {
void run() {
// Initialize variables used to listen on screen changes
int curscreen = -1;
bool firstCheck = false; //leave this alone
ffc follower;

int followerX[15];
int followerY[15];

int switch_index;

while (true) {
// Keep track of screen changes
// Run a Barrier script on every screen change
if (Game->GetCurScreen() != curscreen) {
curscreen = Game->GetCurScreen();
Barriers_NewScreen();}
if(Link->Item[reqItem] == true){
if(Link->Action != LA_SCROLLING && follower->Data==0){
follower = Screen->LoadFFC(ffcNumber);
follower->Data = firstFollowerCombo;
follower->CSet = csetOfFollower;

followerX[BAR_PASTX] = Link->X;
follower->X = Link->X;
followerY[BAR_PASTY] = Link->Y;
follower->Y = Link->Y;

for ( int i = 0; i < 13; i++ ){
followerX[i] = Link->X;
followerY[i] = Link->Y;
}

firstCheck = true;
}
if(Link->Action != LA_SCROLLING){
if((Link->InputUp || Link->InputDown || Link->InputRight || Link->InputLeft)&&(!(Link->InputA || Link->InputB))){
followerX[BAR_PASTX] = follower->X;
follower->X = followerX[0];
for(switch_index=0; switch_index<12; switch_index++){
followerX[switch_index] = followerX[switch_index + 1];
}
followerX[12] = Link->X;

followerY[BAR_PASTY] = follower->Y;
follower->Y = followerY[0];
for(switch_index=0; switch_index<12; switch_index++){
followerY[switch_index] = followerY[switch_index + 1];
}
followerY[12] = Link->Y;
}

if(follower->Y > followerY[BAR_PASTY]){
follower->Data = firstFollowerCombo + 5;
}
else if(follower->Y < followerY[BAR_PASTY]){
follower->Data = firstFollowerCombo + 4;
}
else if(follower->X > followerX[BAR_PASTX]){
follower->Data = firstFollowerCombo + 7;
}
else if(follower->X < followerX[BAR_PASTX]){
follower->Data = firstFollowerCombo + 6;
}
if(!(Link->InputUp || Link->InputDown || Link->InputRight || Link->InputLeft)){
if((follower->Data == (firstFollowerCombo + 4))||(follower->Data == (firstFollowerCombo + 5))||(follower->Data == (firstFollowerCombo + 6))||(follower->Data == (firstFollowerCombo + 7))){
follower->Data = follower->Data - 4;
}
else if((follower->Data == (firstFollowerCombo + 3))||(follower->Data == (firstFollowerCombo + 2))||(follower->Data == (firstFollowerCombo + 1))||(follower->Data == (firstFollowerCombo))){

}
else{
follower->Data = firstFollowerCombo;
}
}
}
if(Link->Action == LA_SCROLLING){
firstCheck = false;
}}

Waitframe();}}}


// Function that makes preparations for barriers on each screen and starts an FFC script
void Barriers_NewScreen() {

// Search for a barrier-related combo
for (int i = 0; i <= 175; i++) {
int cd = Screen->ComboD[i];
if (cd == BARRIER_A_RAISED || cd == BARRIER_A_LOWERED || cd == BARRIER_A_SWITCH ||
cd == BARRIER_B_RAISED || cd == BARRIER_B_LOWERED || cd == BARRIER_B_SWITCH) {
// A barrier-related combo was found

// Make initial changes to combos
if (barriers[Game->GetCurLevel()]) {
for (int j = i; j <= 175; j++) {
int cd = Screen->ComboD[j];
if (cd == BARRIER_A_RAISED) Screen->ComboD[j] = BARRIER_A_LOWERED;
else if (cd == BARRIER_B_LOWERED) Screen->ComboD[j] = BARRIER_B_RAISED;
else if (cd == BARRIER_A_SWITCH) Screen->ComboD[j] = BARRIER_B_SWITCH;}}
else {
for (int j = i; j <= 175; j++) {
int cd = Screen->ComboD[j];
if (cd == BARRIER_B_RAISED) Screen->ComboD[j] = BARRIER_B_LOWERED;
else if (cd == BARRIER_A_LOWERED) Screen->ComboD[j] = BARRIER_A_RAISED;
else if (cd == BARRIER_B_SWITCH) Screen->ComboD[j] = BARRIER_A_SWITCH;}}

// So run FFCscript to control barriers
int fif[]="Barriers";
ffc f = Screen->LoadFFC(ffcNumber);
f->Script = Game->GetFFCScript(fif);
f->Data = CMB_FFC_INVIS;
f->X = -100;
f->Y = -100;
f->Flags[FFCF_PRELOAD] = true;
break;}
}}

// This lets you toggle barriers on any dmap
bool ToggleBarriers(int dmap) {
if (dmap == Game->GetCurLevel()) ToggleBarriers();
else barriers[dmap] = !barriers[dmap];
return barriers[dmap];}

// This toggles barriers on the current dmap
bool ToggleBarriers() {
int curdmap = Game->GetCurLevel();
if (!barriers[curdmap]) {
barriers[curdmap] = true;
for (int i = 0; i <= 175; i++) {
int cd = Screen->ComboD[i];
if (cd == BARRIER_A_RAISED || cd == BARRIER_A_WALKABLE || cd == BARRIER_A_ANIMRAISE) {
Screen->ComboD[i] = BARRIER_A_ANIMLOWER;}
else if (cd == BARRIER_B_LOWERED || cd == BARRIER_B_ANIMLOWER) {
Screen->ComboD[i] = BARRIER_B_ANIMRAISE;}
else if (cd == BARRIER_A_SWITCH) {Screen->ComboD[i] = BARRIER_B_SWITCH;}}}
else {
barriers[curdmap] = false;
for (int i = 0; i <= 175; i++) {
int cd = Screen->ComboD[i];
if (cd == BARRIER_B_RAISED || cd == BARRIER_B_WALKABLE || cd == BARRIER_B_ANIMRAISE) {
Screen->ComboD[i] = BARRIER_B_ANIMLOWER;}
else if (cd == BARRIER_A_LOWERED || cd == BARRIER_A_ANIMLOWER) {
Screen->ComboD[i] = BARRIER_A_ANIMRAISE;}
else if (cd == BARRIER_B_SWITCH) {Screen->ComboD[i] = BARRIER_A_SWITCH;}}}

return barriers[curdmap];
}

// This script controls barriers on the screen
// The FFC is automatically created by Barriers_NewScreen()
ffc script Barriers {
void run() {

// Initialize storage for bswitch hit dummies
int bswitch_count;
npc bswitch[8];

for (int i = 0; i <= 175; i++) {
if (Screen->ComboD[i] == BARRIER_A_SWITCH || Screen->ComboD[i] == BARRIER_B_SWITCH) {
npc bs = CreateNPCAt(BARRIER_SWITCH_DUMMY, ComboX(i), ComboY(i));
bs->HitWidth = 8; // Smaller hit box to avoid annoying collisions with Link
bs->HitHeight = 8;
bs->HP = BARRIER_SWITCH_DUMMY_HP;
bswitch[bswitch_count++] = bs;}}

// Change raised barriers to walkable ones if Link enters screen on a raised barrier
int lcombo = LinkOnComboD();
bool onbarrier = (lcombo == BARRIER_A_RAISED || lcombo == BARRIER_B_RAISED);
if (onbarrier) for (int i = 0; i < 176; i++) {
if (Screen->ComboD[i] == BARRIER_A_RAISED) {Screen->ComboD[i] = BARRIER_A_WALKABLE;}
else if (Screen->ComboD[i] == BARRIER_B_RAISED) {Screen->ComboD[i] = BARRIER_B_WALKABLE;}}


while (true) {

// Detect hits on bswitches, and change combos accordingly
for (int j = 0; j < bswitch_count; j++) {
if (bswitch[j]->HP < BARRIER_SWITCH_DUMMY_HP) {
bswitch[j]->HP = BARRIER_SWITCH_DUMMY_HP;
ToggleBarriers();
break;}} //break so that only one bswitch hit may register per frame


// Make barriers walkable if Link is on raised barriers, or unwalkable if not
lcombo = LinkOnComboD();
if (!onbarrier && (lcombo == BARRIER_A_RAISED || lcombo == BARRIER_B_RAISED)) {
onbarrier = true;
for (int i = 0; i <= 175; i++) {
if (Screen->ComboD[i] == BARRIER_A_RAISED) {Screen->ComboD[i] = BARRIER_A_WALKABLE;}
else if (Screen->ComboD[i] == BARRIER_B_RAISED) {Screen->ComboD[i] = BARRIER_B_WALKABLE;}}}
else if (onbarrier && !(lcombo == BARRIER_A_WALKABLE || lcombo == BARRIER_B_WALKABLE)) {
onbarrier = false;
for (int i = 0; i <= 175; i++) {
if (Screen->ComboD[i] == BARRIER_A_WALKABLE) {Screen->ComboD[i] = BARRIER_A_RAISED;}
else if (Screen->ComboD[i] == BARRIER_B_WALKABLE) {Screen->ComboD[i] = BARRIER_B_RAISED;}}}

Waitframe();}
}}



// A utility function that returns the ID of the combo that Link appears to stand on
int LinkOnComboD() {
return Screen->ComboD[ComboAt(Link->X+8, Link->Y+13)];
}
[/spoiler]

& This:

https://www.dropbox.... backup1.z?dl=0

 

i end up with this:

https://www.dropbox....combined.z?dl=0

 

i go to compile nd get this error: " Line 460 Unexpected identifier, Expected $End on token angle. where did i go wrong?


Edited by Nightmeres, 01 February 2018 - 03:02 PM.


#2 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 02 February 2018 - 02:01 AM

im trying to combine 2 scripts using moosh's combiner. if it helps i would like the moving platforms and hole/lava components but i dont know how to do this.


i go to compile nd get this error: " Line 460 Unexpected identifier, Expected $End on token angle. where did i go wrong?

I've done this too many times, to the point that I made a permanent paste of it:

Streamlined Old Pit Stuff

Try combining that with the barriers script. (I have some 'corrected' versions of that floating about, too; on the forums here, and on the servers.)

P.S. Oh, right, I patched it last, for you. :D

https://www.purezc.n...71#entry1029701

Because of how the barriers script is written, and because its author forgot to call Waitdraw(), it will likely require hand-editing to merge.
 
Here is a hand-edited merge after some basic clean-up:
 
It combines the streamlined hole/lava+platform, with your barriers + follower stuff, from before.
 
I later noticed, that you added a long list of other stuff to this. Here is a hand-merge of that.

 

You will need to test it and see if anything is missing. If there are errors, post your allegro.log file after compiling, and good luck.



#3 Nightmeres

Nightmeres

    Defender

  • Members

Posted 02 February 2018 - 08:20 AM

https://www.dropbox....llegro.log?dl=0

 

here it is, could not see the errors in compiler because it went to quickly. something bout litterly everything being undeclared. but you'll see more with the link.  



#4 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 02 February 2018 - 09:42 AM

https://www.dropbox....llegro.log?dl=0
 
here it is, could not see the errors in compiler because it went to quickly. something bout litterly everything being undeclared. but you'll see more with the link.



I'm feeling a bit unwell, so, I patched this up on my Android, while laying down.

Here is the revised file.

I'll try to do further variable/array cleanup (reducing wasted registers), when I'm up again, later.

Try it and let me know if there are further problems in the interim. There's so much going on in that file, that it's easy to overlook things; and there are variables that should have not been called by the functions that I revised in the past, and yet, they're still being used.

All of them should be bundled into arrays, as there are already large arrays for these things.

If this compiles, when you go to test the quest, it will need a clean save slot. If you try to continue from an existing save, using the modified quest file, it won't work. This is a good time to bump the quest version in the Quest Header, and to set the minimum version to the same value, so that anyone that you have testing your quest won't run into bugs that stem from incompatible quest versions with their old saves.

On another note, please try to use pastebin to post zscript and log files. I had to jump through some hoops to open them as downloaded data on my mobile, whereas with pastebin, I can view them using a web browser, with syntax highlighting, and line numbers.

#5 Nightmeres

Nightmeres

    Defender

  • Members

Posted 02 February 2018 - 10:11 AM

i got error line 254 syntax error unexpected float expecting assign on token Int. did i forget to assign something? not sure if alegro will help because the last update for it was yesterday. no worries, get some rest & do something with this when your feeling better. here is the script with edited constants that r for my quest https://pastebin.com/z6xXgcZu

 

on  side note, would it matter if im using other scripts, ffc & item ones not in the original files i gave you?


Edited by Nightmeres, 02 February 2018 - 10:38 AM.


#6 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 02 February 2018 - 10:43 AM

i got error line 254 syntax error unexpected float expecting assign on token Int. did i forget to assign something? not sure if alegro will help because the last update for it was yesterday. no worries, get some rest & do something with this when your feeling better. here is the script with edited constants that r for my quest https://pastebin.com/z6xXgcZu
 
on  side note, would it matter if im using other scripts, ffc & item ones not in the original files i gave you?


Fixed. Follow the same link in my last post. It was missing a semicolon on line 253.

External scripts, that are not bound to the global script, do not matter for this at all. :)

#7 Nightmeres

Nightmeres

    Defender

  • Members

Posted 02 February 2018 - 12:02 PM

now its telling me line 258 start ghostzh, line  261 updateghostzh1, & line 270 updateghostzh2 are all undeclared. 

nvmnd didnt import ghost.zh, fixed. now its line 307 could not match type signature onplatform(FFC).


Edited by Nightmeres, 02 February 2018 - 12:12 PM.


#8 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 02 February 2018 - 12:38 PM

now its telling me line 258 start ghostzh, line  261 updateghostzh1, & line 270 updateghostzh2 are all undeclared. 
nvmnd didnt import ghost.zh, fixed. now its line 307 could not match type signature onplatform(FFC).


Oh, I missed that you had another definition for OnPlatform().

Fixed. Same link, above.

#9 Nightmeres

Nightmeres

    Defender

  • Members

Posted 02 February 2018 - 01:15 PM

thnks so much for your support, it compiled  :cheese:  :love:



#10 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 02 February 2018 - 01:40 PM

thnks so much for your support, it compiled  :cheese:  :love:


Heheh. Your avatar alone deserves the support. :D

Let me know if all of it works.


Don't forget to start from a clean/new save slot.

#11 Nightmeres

Nightmeres

    Defender

  • Members

Posted 13 February 2018 - 01:23 PM

everything  pryty much works fine, i mean the bracelet when you pick up the rock it disappears when player press a or b but player has to in order to use it. its finicky but it mostly works. & I cant have the platform go over warps without getting warped but that's not a huge let down it otherwise works perfectly & so does hole/lava. sry for late reply been busy




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users