Jump to content

Photo

combining global scripts


  • Please log in to reply
1 reply to this topic

#1 Kallineon

Kallineon

    Initiate

  • Members
  • Real Name:Phelan
  • Location:Croatia

Posted 03 November 2018 - 10:25 PM

can someone provide example how to combine or merge multiple global script in one active slot? 

 

for example I try combine 2  global scripts: bomb shakes screen and ffc follower.

import "std.zh"

const int BombsScreenShakeFrames = 10; //how many frames a bomb shakes the screen
const int BombsScreenShakeSFrames = 30; //how many frames a superbomb shakes the screen
const int BombsScreenShakeWeaponMisc = 0; //what weapon misc to use for explosion eweapons and lweapons (leave at 0 if no other script uses them)

global script Active {
    void run(){
        while(true){
            BombsScreenShake(); //put this line into your global loop (to combine this script with your global script)
            Waitframe();
        }
    }
}

void BombsScreenShake() {
    for (int i = 1; i <= Screen->NumLWeapons(); i++) { //lweapons
        lweapon lweap = Screen->LoadLWeapon(i);
        if ( lweap->ID == LW_BOMBBLAST && lweap->Misc[BombsScreenShakeWeaponMisc] == 0 ) { //if there is a normal explosion on screen and the misc value is 0
            Screen->Quake = BombsScreenShakeFrames; //shake the screen
            lweap->Misc[BombsScreenShakeWeaponMisc] = 1; //change the misc value to 1
        }
        else if ( lweap->ID == LW_SBOMBBLAST && lweap->Misc[BombsScreenShakeWeaponMisc] == 0 ) { //if there is a super explosion on screen and the misc value is 0
            Screen->Quake = BombsScreenShakeSFrames; //shake the screen
            lweap->Misc[BombsScreenShakeWeaponMisc] = 1; //change the misc value to 1
        }
    }
    for (int i = 1; i <= Screen->NumEWeapons(); i++) { //eweapons
        eweapon eweap = Screen->LoadEWeapon(i);
        if ( eweap->ID == EW_BOMBBLAST && eweap->Misc[BombsScreenShakeWeaponMisc] == 0 ) { //if there is a normal explosion on screen and the misc value is 0
            Screen->Quake = BombsScreenShakeFrames; //shake the screen
            eweap->Misc[BombsScreenShakeWeaponMisc] = 1; //change the misc value to 1
        }
        else if ( eweap->ID == EW_BOMBBLAST && eweap->Misc[BombsScreenShakeWeaponMisc] == 0 ) { //if there is a super explosion on screen and the misc value is 0
            Screen->Quake = BombsScreenShakeSFrames; //shake the screen
            eweap->Misc[BombsScreenShakeWeaponMisc] = 1; //change the misc value to 1
        }
    }
}

and with that

global script slot_2{
	void run(){

		int reqItem = 129; //Item that makes the FFC follower follow you
		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.
		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".
		int csetOfFollower = 3;
		bool firstCheck = false; //leave this alone
		ffc follower;

		int pastX;
		int currentX;
		int followerX[13];

		int pastY;
		int currentY;
		int followerY[13];

		int index;

		while(true){

			if(Link->Item[reqItem] == true){
				if(Link->Action != LA_SCROLLING && firstCheck == false){
					follower = Screen->LoadFFC(ffcNumber);
					follower->Data = firstFollowerCombo;
					follower->CSet = csetOfFollower;

					pastX = Link->X;
					follower->X = Link->X;
					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))){
						pastX = follower->X;
						follower->X = followerX[0];
						for(index=0; index<12; index++){
							followerX[index] = followerX[index + 1];
						}
						followerX[12] = Link->X;

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

					if(follower->Y > pastY){
						follower->Data = firstFollowerCombo + 5;
					}
					else if(follower->Y < pastY){
						follower->Data = firstFollowerCombo + 4;
					}
					else if(follower->X > pastX){
						follower->Data = firstFollowerCombo + 7;
					}
					else if(follower->X < 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();

		}
	}
}

I try stick them one to each other and result is successful compiling with 2 separate global scripts, but one active slot. I just don't understand that with loops in combining nor autocombiner because compiling is full of errors. what I must edit?



#2 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 03 November 2018 - 10:58 PM

Try this first.


For the record, that script is a lot of mess.

Spoiler



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users