Jump to content

Photo

1 time item shop, paywall, level specific keys contained in other leve


  • Please log in to reply
18 replies to this topic

#16 Smiles the Death Bringer

Smiles the Death Bringer

    The smiling demon!

  • Members
  • Real Name:William
  • Location:Dream Land

Posted 12 February 2018 - 05:46 AM

So, this script works by itself:

import "std.zh"
																												import "std.zh"
import "ffcscript.zh"
import "string.zh"
import "stdExtra.zh"
import "ghost.zh"
import "Laser.zh"
import "styles.zh"
import "Tango.zh"

import "JudasRising_Shop_v0.7.3.zs"

As does this:

import "std.zh"

//=============================================================================================
//======================================= *FFC Scripts* =======================================
//=============================================================================================

// 1.- Signpost Script by Joe123

//FUNCTIONALITY: Attach this script to an FFC and edit its Arguments to your needs.

ffc script Signpost{
    void run(int m,int input){
        int loc = ComboAt(this->X,this->Y);
        while(true){
            while(!AgainstComboBase(loc) || !SelectPressInput(input)) Waitframe();
            SetInput(input,false);
            Screen->Message(m);
            Waitframe();
        }
    }
    bool AgainstComboBase(int loc){
        return Link->Z == 0 && (Link->Dir == DIR_UP && Link->Y == ComboY(loc)+8 && Abs(Link->X-ComboX(loc)) < 8);
    }
}

//!!These functions should only be included in your script file once!!
bool SelectPressInput(int input){
    if(input == 0) return Link->PressA;
    else if(input == 1) return Link->PressB;
    else if(input == 2) return Link->PressL;
    else if(input == 3) return Link->PressR;
}
void SetInput(int input, bool state){
    if(input == 0) Link->InputA = state;
    else if(input == 1) Link->InputB = state;
    else if(input == 2) Link->InputL = state;
    else if(input == 3) Link->InputR = state;
}

//----------------------------------------------------------------------------------
//2.- Advanced Grass by Raiu

//FUNCTIONALITY: Attach this script to an FFC and edit the Arguments to your needs.
//               (The suggested arguments are fine by default with DoR Hybrid).

// AdvGrass.z
// A script that correctly displays tall grass combos relationally
// (Searches layer 0 for tall grass combos, and draws new combos over them
// Good for grass combos that have a "border" of sorts around them)
// By Raiu
//
// Arrange tiles like this:
// Lone, DownVertEnd, UpVertEnd, Vertical, RightHorzEnd, DownRight, UpRight, Right, LeftHorzEnd, DownLeft, UpLeft, Left, Horizonal, Down, Up, Middle
// (this script does not support inside corner graphics...)
//
// D0 = Combo Type
//		Tallgrass = 57
//		Tallgrass continuous = 136
//		Tallgrass -> next = 141
// D1 = First Tile of the above (DoR Hybrid Default: 13144)
// D2 = Cset to use (DoR Hybrid Default: 3)
// D3 = Layer to Draw on: 0

ffc script AdvGrass{
	void run(int inType, int inTile, int inCset, int inLayer){
		Waitframe();
		int adj=0;
		while(true){
			for(int x = 0; x<16; x++){
				for(int y = 0; y<11; y++){
					if(Screen->ComboT[CIndex(x,y)]==inType){
						if(Screen->ComboT[CIndex(x,y-1)]==inType) adj+=1;
						if(Screen->ComboT[CIndex(x,y+1)]==inType) adj+=2;
						if(Screen->ComboT[CIndex(x-1,y)]==inType) adj+=4;
						if(Screen->ComboT[CIndex(x+1,y)]==inType) adj+=8;
						if(adj!=15){
							Screen->DrawTile(inLayer, x*16, y*16, inTile+adj, 1, 1, inCset, -1,-1, 0, 0, 0, 0, 1, 128);
						}
					adj=0;
					}
				}	
			}
			Waitframe();
		}
	}
	int CIndex(int x, int y){
		if(x<0||x>15||y<0||y>10) return -1;
		return y*16 + x;
	}
}

// This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
//----------------------------------------------------------------------------------





//==============================================================================================
//======================================= *Item Scripts* =======================================
//==============================================================================================

// 1.- Item Pickup Sting by Joe123

//FUNCTIONALITY: Attach this script to the Action slot of an Item within the Scripts Tab.
//               D0 is the string to display for a certain item. 

item script Message{
	void run(int m){
		Screen->Message(m);
	}
}

//----------------------------------------------------------------------------------
// 2.- Heart Piece Message by Moscowmodder

//FUNCTIONALITY: Attach this to the Pickup script slot of an item within its Scripts Tab.
//               Set the arguments to your needs.

//Old version: supports only 4-piece heart containers
//Messages can be set automatically or manually
//D0 = First message
//D1-3 = Second-fourth messages; default to strings after D0

item script heartPieceMessageOld{
	void run (int m1, int m2, int m3, int m4){
		//Set m2-4 to follow m1 if not set explicitly
		if ( m2 == 0 ) m2 = m1+1;
		if ( m3 == 0 ) m3 = m1+2;
		if ( m4 == 0 ) m4 = m1+3;
		
		//Play the appropriate message
		if ( Game->Generic[GEN_HEARTPIECES] == 0 )
			Screen->Message(m1);
		if ( Game->Generic[GEN_HEARTPIECES] == 1 )
			Screen->Message(m2);
		if ( Game->Generic[GEN_HEARTPIECES] == 2 )
			Screen->Message(m3);
		if ( Game->Generic[GEN_HEARTPIECES] == 3 )
			Screen->Message(m4);
	}
}

//FUNCTIONALITY: Attach this to the Pickup script slot of an item within its Scripts Tab.
//               Set the arguments to your needs.

//New version: supports any number of heart containers
//D0 = String # of first message
//All other messages *MUST* follow the first

item script heartPieceMessage{
	void run ( int message ){
		Screen->Message ( message + Game->Generic[GEN_HEARTPIECES] );
	}
}

//-----------------------------------------------------------------------------
// 3.- Item Bundle Script by Nick

//FUNCTIONALITY: Attach this to the Pickup script slot of an item within its Scripts Tab.
//               Set the arguments to your needs.

// This script is a pickup script that will give some items.
// This was mostly made to bundle the Bow and Arrows into one item,
// but it could have other uses.
// Bundle this with an item that increases a counter to also increase counters.
// 	   D0-D7: Items to give.
//		D0: If D0 is negative, it will display an item pickup message containing the positive version of the number entered...
item script itemBundle{
	void run(int item1, int item2, int item3, int item4, int item5, int item6, int item7, int item8)
	{
		if(item1 > 0)
			Link->Item[item1] = true;
		if(item2 > 0)
			Link->Item[item2] = true;
		if(item3 > 0)
			Link->Item[item3] = true;
		if(item4 > 0)
			Link->Item[item4] = true;
		if(item5 > 0)
			Link->Item[item5] = true;
		if(item6 > 0)
			Link->Item[item6] = true;
		if(item7 > 0)
			Link->Item[item7] = true;
		if(item8 > 0)
			Link->Item[item8] = true;
			
		// Display Item pickup message?
		if(item1 < 0)
		{
			Screen->Message(item1 * -1);
		}
	}//!End void run()
}//!End item script itemBundle
//----------------------------------------------------------------------------

const int CR_SWORDPART = 10; //The 'Script / Custom 4' counter.
int I_HUNDRED_PIECE_SWORD = 123; //Custom item 1
 
const int HUNDRED_PIECE_SWORD_BASE_POWER = 1; //The minimum damage of the sword, before it is upgraded.
 
//A pick-up/collect script. Attach to a sword piece item.
//If you want ZC to display a screen string when the player picks it up, assign the ZQuest String ID
//to the D0 arg.
//If you want a special message when the player collects ten pieces, assign that ZQuest
//string to the D1 arg.
//If you want this to play a special sound if the player picks up ten pieces, assign that Sound Effect
//ID to the D2 arg.
//!Dimentio Edit: Fixed decimal values being passed to sword->Power,
//!Fixed bug where having 10-19 sword pieces is the same as having 0-9.
item script swordpart
{
    void run(int msg_id, int special_msg_id, int special_sfx)
    {
        ++Game->Counter[CR_SWORDPART];
        itemdata sword = Game->LoadItemData(I_HUNDRED_PIECE_SWORD);
        sword->Power = Max((Floor(Game->Counter[CR_SWORDPART] / 10) + 1), HUNDRED_PIECE_SWORD_BASE_POWER);
        
        
        if ( Game->Counter[CR_SWORDPART] % 10 || special_msg_id < 1 )
        {
            Screen->Message(msg_id);
        }
        else
        {
            Screen->Message(special_msg_id);
            if ( Game->Counter[CR_SWORDPART] % 10 == 0 && special_sfx )
            {
                Game->PlaySound(special_sfx);
		++I_HUNDRED_PIECE_SWORD;
		Link->Item[I_HUNDRED_PIECE_SWORD] = true;
            }
        }
        
    }
}
 
//Assign this to global slot 4 ('onContinue')
//This re-applies the power modifications to the sword, every time that the player returns to
//the game, after exiting.
//!Dimentio Edit: Fixed decimal values being passed to sword->Power,
//!Fixed bug where having 10-19 sword pieces is the same as having 0-9.
global script OnContinue
{
    void run()
    {
        itemdata sword = Game->LoadItemData(I_HUNDRED_PIECE_SWORD);
        sword->Power = Max((Floor(Game->Counter[CR_SWORDPART] / 10) + 1), HUNDRED_PIECE_SWORD_BASE_POWER);
    }
}
    
//!Dimentio Edit: This entire ffc script + comments. Sorry Zoria, I don't think your method was the most efficient.
//D0: Number of pieces you need to own to trigger
//D1: Flag to trigger
//The way this works is that it changes all combos with flag D1 to the wooden sword trigger flag.
//Leaving things to the engine is generally a safe way to do thing.
//This also means you only need one script of this running.

const int HUNDRED_PIECE_SWORD_FLAG = 102; //Script 5

ffc script sword_power_triggers
{
    void run(int power, int flag)
    {
        if ( flag < 1 ) flag = HUNDRED_PIECE_SWORD_FLAG;
	{
       			while(true)
        		{
	    			if (Game->Counter[CR_SWORDPART] >= power)
	    			{
					for (int i = 0; i < 176; i++)
                			{
                    				if (Screen->ComboF[i] == flag)
                    				{
                        				Screen->ComboF[i] = CF_SWORD1;
                    					}
                    				if (Screen->ComboI[i] == flag)
                    				{
                        Screen->ComboI[i] = CF_SWORD1;
                    }
                }
            }
            Waitframe();
        }
    }
}
}  

But when I merge them together:

import "std.zh"
																												import "std.zh"
import "ffcscript.zh"
import "string.zh"
import "stdExtra.zh"
import "ghost.zh"
import "Laser.zh"
import "styles.zh"
import "Tango.zh"


//import "script/pickUp.z"
//import "script/pickUpHCP.z"
//import "script/RealNPC.z"
//import "script/readsign4.z"
//import "script/Titlescreen.z"
//import "script/potscript.z"
//import "script/newshopnew2.z"
//import "script/doorshop2.z"
import "JudasRising_Shop_v0.7.3.zs"



//import "script/slot_2shop.z"
//import "script/slot_3shop.z"





//=============================================================================================
//======================================= *FFC Scripts* =======================================
//=============================================================================================

// 1.- Signpost Script by Joe123

//FUNCTIONALITY: Attach this script to an FFC and edit its Arguments to your needs.

ffc script Signpost{
    void run(int m,int input){
        int loc = ComboAt(this->X,this->Y);
        while(true){
            while(!AgainstComboBase(loc) || !SelectPressInput(input)) Waitframe();
            SetInput(input,false);
            Screen->Message(m);
            Waitframe();
        }
    }
    bool AgainstComboBase(int loc){
        return Link->Z == 0 && (Link->Dir == DIR_UP && Link->Y == ComboY(loc)+8 && Abs(Link->X-ComboX(loc)) < 8);
    }
}

//!!These functions should only be included in your script file once!!
bool SelectPressInput(int input){
    if(input == 0) return Link->PressA;
    else if(input == 1) return Link->PressB;
    else if(input == 2) return Link->PressL;
    else if(input == 3) return Link->PressR;
}
void SetInput(int input, bool state){
    if(input == 0) Link->InputA = state;
    else if(input == 1) Link->InputB = state;
    else if(input == 2) Link->InputL = state;
    else if(input == 3) Link->InputR = state;
}

//----------------------------------------------------------------------------------
//2.- Advanced Grass by Raiu

//FUNCTIONALITY: Attach this script to an FFC and edit the Arguments to your needs.
//               (The suggested arguments are fine by default with DoR Hybrid).

// AdvGrass.z
// A script that correctly displays tall grass combos relationally
// (Searches layer 0 for tall grass combos, and draws new combos over them
// Good for grass combos that have a "border" of sorts around them)
// By Raiu
//
// Arrange tiles like this:
// Lone, DownVertEnd, UpVertEnd, Vertical, RightHorzEnd, DownRight, UpRight, Right, LeftHorzEnd, DownLeft, UpLeft, Left, Horizonal, Down, Up, Middle
// (this script does not support inside corner graphics...)
//
// D0 = Combo Type
//		Tallgrass = 57
//		Tallgrass continuous = 136
//		Tallgrass -> next = 141
// D1 = First Tile of the above (DoR Hybrid Default: 13144)
// D2 = Cset to use (DoR Hybrid Default: 3)
// D3 = Layer to Draw on: 0

ffc script AdvGrass{
	void run(int inType, int inTile, int inCset, int inLayer){
		Waitframe();
		int adj=0;
		while(true){
			for(int x = 0; x<16; x++){
				for(int y = 0; y<11; y++){
					if(Screen->ComboT[CIndex(x,y)]==inType){
						if(Screen->ComboT[CIndex(x,y-1)]==inType) adj+=1;
						if(Screen->ComboT[CIndex(x,y+1)]==inType) adj+=2;
						if(Screen->ComboT[CIndex(x-1,y)]==inType) adj+=4;
						if(Screen->ComboT[CIndex(x+1,y)]==inType) adj+=8;
						if(adj!=15){
							Screen->DrawTile(inLayer, x*16, y*16, inTile+adj, 1, 1, inCset, -1,-1, 0, 0, 0, 0, 1, 128);
						}
					adj=0;
					}
				}	
			}
			Waitframe();
		}
	}
	int CIndex(int x, int y){
		if(x<0||x>15||y<0||y>10) return -1;
		return y*16 + x;
	}
}

// This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
//----------------------------------------------------------------------------------





//==============================================================================================
//======================================= *Item Scripts* =======================================
//==============================================================================================

// 1.- Item Pickup Sting by Joe123

//FUNCTIONALITY: Attach this script to the Action slot of an Item within the Scripts Tab.
//               D0 is the string to display for a certain item. 

item script Message{
	void run(int m){
		Screen->Message(m);
	}
}

//----------------------------------------------------------------------------------
// 2.- Heart Piece Message by Moscowmodder

//FUNCTIONALITY: Attach this to the Pickup script slot of an item within its Scripts Tab.
//               Set the arguments to your needs.

//Old version: supports only 4-piece heart containers
//Messages can be set automatically or manually
//D0 = First message
//D1-3 = Second-fourth messages; default to strings after D0

item script heartPieceMessageOld{
	void run (int m1, int m2, int m3, int m4){
		//Set m2-4 to follow m1 if not set explicitly
		if ( m2 == 0 ) m2 = m1+1;
		if ( m3 == 0 ) m3 = m1+2;
		if ( m4 == 0 ) m4 = m1+3;
		
		//Play the appropriate message
		if ( Game->Generic[GEN_HEARTPIECES] == 0 )
			Screen->Message(m1);
		if ( Game->Generic[GEN_HEARTPIECES] == 1 )
			Screen->Message(m2);
		if ( Game->Generic[GEN_HEARTPIECES] == 2 )
			Screen->Message(m3);
		if ( Game->Generic[GEN_HEARTPIECES] == 3 )
			Screen->Message(m4);
	}
}

//FUNCTIONALITY: Attach this to the Pickup script slot of an item within its Scripts Tab.
//               Set the arguments to your needs.

//New version: supports any number of heart containers
//D0 = String # of first message
//All other messages *MUST* follow the first

item script heartPieceMessage{
	void run ( int message ){
		Screen->Message ( message + Game->Generic[GEN_HEARTPIECES] );
	}
}

//-----------------------------------------------------------------------------
// 3.- Item Bundle Script by Nick

//FUNCTIONALITY: Attach this to the Pickup script slot of an item within its Scripts Tab.
//               Set the arguments to your needs.

// This script is a pickup script that will give some items.
// This was mostly made to bundle the Bow and Arrows into one item,
// but it could have other uses.
// Bundle this with an item that increases a counter to also increase counters.
// 	   D0-D7: Items to give.
//		D0: If D0 is negative, it will display an item pickup message containing the positive version of the number entered...
item script itemBundle{
	void run(int item1, int item2, int item3, int item4, int item5, int item6, int item7, int item8)
	{
		if(item1 > 0)
			Link->Item[item1] = true;
		if(item2 > 0)
			Link->Item[item2] = true;
		if(item3 > 0)
			Link->Item[item3] = true;
		if(item4 > 0)
			Link->Item[item4] = true;
		if(item5 > 0)
			Link->Item[item5] = true;
		if(item6 > 0)
			Link->Item[item6] = true;
		if(item7 > 0)
			Link->Item[item7] = true;
		if(item8 > 0)
			Link->Item[item8] = true;
			
		// Display Item pickup message?
		if(item1 < 0)
		{
			Screen->Message(item1 * -1);
		}
	}//!End void run()
}//!End item script itemBundle
//----------------------------------------------------------------------------

const int CR_SWORDPART = 10; //The 'Script / Custom 4' counter.
int I_HUNDRED_PIECE_SWORD = 123; //Custom item 1
 
const int HUNDRED_PIECE_SWORD_BASE_POWER = 1; //The minimum damage of the sword, before it is upgraded.
 
//A pick-up/collect script. Attach to a sword piece item.
//If you want ZC to display a screen string when the player picks it up, assign the ZQuest String ID
//to the D0 arg.
//If you want a special message when the player collects ten pieces, assign that ZQuest
//string to the D1 arg.
//If you want this to play a special sound if the player picks up ten pieces, assign that Sound Effect
//ID to the D2 arg.
//!Dimentio Edit: Fixed decimal values being passed to sword->Power,
//!Fixed bug where having 10-19 sword pieces is the same as having 0-9.
item script swordpart
{
    void run(int msg_id, int special_msg_id, int special_sfx)
    {
        ++Game->Counter[CR_SWORDPART];
        itemdata sword = Game->LoadItemData(I_HUNDRED_PIECE_SWORD);
        sword->Power = Max((Floor(Game->Counter[CR_SWORDPART] / 10) + 1), HUNDRED_PIECE_SWORD_BASE_POWER);
        
        
        if ( Game->Counter[CR_SWORDPART] % 10 || special_msg_id < 1 )
        {
            Screen->Message(msg_id);
        }
        else
        {
            Screen->Message(special_msg_id);
            if ( Game->Counter[CR_SWORDPART] % 10 == 0 && special_sfx )
            {
                Game->PlaySound(special_sfx);
		++I_HUNDRED_PIECE_SWORD;
		Link->Item[I_HUNDRED_PIECE_SWORD] = true;
            }
        }
        
    }
}
 
//Assign this to global slot 4 ('onContinue')
//This re-applies the power modifications to the sword, every time that the player returns to
//the game, after exiting.
//!Dimentio Edit: Fixed decimal values being passed to sword->Power,
//!Fixed bug where having 10-19 sword pieces is the same as having 0-9.
global script OnContinue
{
    void run()
    {
        itemdata sword = Game->LoadItemData(I_HUNDRED_PIECE_SWORD);
        sword->Power = Max((Floor(Game->Counter[CR_SWORDPART] / 10) + 1), HUNDRED_PIECE_SWORD_BASE_POWER);
    }
}
    
//!Dimentio Edit: This entire ffc script + comments. Sorry Zoria, I don't think your method was the most efficient.
//D0: Number of pieces you need to own to trigger
//D1: Flag to trigger
//The way this works is that it changes all combos with flag D1 to the wooden sword trigger flag.
//Leaving things to the engine is generally a safe way to do thing.
//This also means you only need one script of this running.

const int HUNDRED_PIECE_SWORD_FLAG = 102; //Script 5

ffc script sword_power_triggers
{
    void run(int power, int flag)
    {
        if ( flag < 1 ) flag = HUNDRED_PIECE_SWORD_FLAG;
	{
       			while(true)
        		{
	    			if (Game->Counter[CR_SWORDPART] >= power)
	    			{
					for (int i = 0; i < 176; i++)
                			{
                    				if (Screen->ComboF[i] == flag)
                    				{
                        				Screen->ComboF[i] = CF_SWORD1;
                    					}
                    				if (Screen->ComboI[i] == flag)
                    				{
                        Screen->ComboI[i] = CF_SWORD1;
                    }
                }
            }
            Waitframe();
        }
    }
}
}   

I get this error message when I try to compile them:

Pass 1: Parsing
Pass 2: Preprocessing
std_functions.zh, line 1190: Error P35: There is already a constant with name AT_RANDANGULAR defined.
std_functions.zh, line 1189: Error P35: There is already a constant with name AT_RAND8DIR defined.
std_functions.zh, line 1188: Error P35: There is already a constant with name AT_RAND4DIR defined.
std_functions.zh, line 1187: Error P35: There is already a constant with name AT_ANGULAR defined.
std_functions.zh, line 1186: Error P35: There is already a constant with name AT_8DIR defined.
std_functions.zh, line 1185: Error P35: There is already a constant with name AT_4DIR defined.
std_functions.zh, line 1184: Error P35: There is already a constant with name AT_NONE defined.


#17 Smiles the Death Bringer

Smiles the Death Bringer

    The smiling demon!

  • Members
  • Real Name:William
  • Location:Dream Land

Posted 28 February 2018 - 09:55 AM

I managed to get it working.

Apparently something in the Uber Shop script broke the Advance Grass script (which was preloaded in my quest template). I just got rid of it since I wasn't using it anyway and it compiled just fine.

Thanks for your help everyone.



#18 judasrising

judasrising

    I play guitar

  • Members
  • Location:Sweden but born in Finland

Posted 01 March 2018 - 09:21 AM

I managed to get it working.

Apparently something in the Uber Shop script broke the Advance Grass script (which was preloaded in my quest template). I just got rid of it since I wasn't using it anyway and it compiled just fine.

Thanks for your help everyone.

Great that its working for you now but in what way that broke the Advance Grass script?



#19 Smiles the Death Bringer

Smiles the Death Bringer

    The smiling demon!

  • Members
  • Real Name:William
  • Location:Dream Land

Posted 01 March 2018 - 10:36 AM

I have no idea, I just deleted a script and some lines that I wasn't using and I stopped getting build errors.

It might not have been the Advance Grass script. it might have been these lines:

//!!These functions should only be included in your script file once!!
bool SelectPressInput(int input){
    if(input == 0) return Link->PressA;
    else if(input == 1) return Link->PressB;
    else if(input == 2) return Link->PressL;
    else if(input == 3) return Link->PressR;
}
void SetInput(int input, bool state){
    if(input == 0) Link->InputA = state;
    else if(input == 1) Link->InputB = state;
    else if(input == 2) Link->InputL = state;
    else if(input == 3) Link->InputR = state;

I don't really know enough about scripting to tell why it worked.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users