User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16

Thread: Majora/SUCCESSOR/CJC Script Collaboration Thread

  1. #1
    Cor Blimey! CJC's Avatar
    Join Date
    Dec 2002
    Location
    Fading into the darkness
    Age
    31
    Posts
    1,398
    Mentioned
    150 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,457
    Level
    24
    vBActivity - Bars
    Lv. Percent
    74.14%

    Majora/SUCCESSOR/CJC Script Collaboration Thread

    @Majora
    @SUCCESSOR
    and of course
    @CJC


    There, now that the tags are out of the way.

    Majora is trying to get his shield script to work without the muck of Link Tile Modifiers. I've begun to brainstorm a script for this, but I've hit a wall with all the possible actions Link can take while holding a shield.

    Code:
    int WoodenShield = # //Replace with the item number for your wooden shield
    int WoodShieldRaised = ### //Replace with the tile number that corresponds to the wooden shield
    						//When Link is blocking with it.
    						//Make sure you arrange the tiles in the following order:
    						//Face Up, Face Down, Face Left, Face Right.  Keep the two frame-animations together
    int WoodShieldRest = ### //Replace with the tile number that corresponds to the wooden shield
    						//When Link has it at his side.
    						//Use the same arrangement as Raised.
    
    If(Link->Item[WoodenShield]){ //Checks if Link has the Wooden Shield
    	If(Link->InputEx1){ //Button Assigned to the Shield
    		//Insert the block code for your script here
    		FastTile(0, Link->X, Link->Y, WoodShieldRaised + Link->Dir*2, WoodShieldCset, 128) //Draws the shield on
    						//Link's Layer.  It should automatically adjust for direction.
    	}
    	Elseif(Link->Action == 0){ //Standing Still
    		FastTile(0, Link->X, Link->Y, WoodShieldRest + Link->Dir*2, WoodShieldCset, 128) //Draws the shield on
    						//Link's Layer.  It should automatically adjust for direction.
    	Elseif(Link->Action == 1){ //Walking
    		FastTile(0, Link->X, Link->Y, WoodShieldRest + Link->Dir*2 + 1, WoodShieldCset, 128) //
    	}
    }//And so on in that manner.  You've got your work cut out for you on this.
    //Also, we'll have to figure out how to handle moving while the shield is raised.
    //Perhaps  Action == 0 and Action == 1 need to be the uppermost IF statements.
    If either of you can work out how to make this script better/more functional/less bloated, give me a tag. I'm stumped.

    EDIT: Copy the code into a notepad so you can actually read it.
    Last edited by SUCCESSOR; 11-02-2012 at 02:17 AM.

  2. #2
    OBEY GOVERNMENT GOD ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,779
    Mentioned
    256 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,685
    Level
    32
    vBActivity - Bars
    Lv. Percent
    97.01%
    Depends on how you want blocking to work.

    There's Link->Invisible, combined with DrawTile could replace LTMs. Never tried it though.
    LA_ATTACKING, *CASTING, *SWIMMING would be the major things to check for.

    I'm not sure how you are trying to redo the shield, but a simple
    Code:
    if(Input)
    {
      Link-Item[shield_id] = true;
      shield++;
    }
    else if(shield > 0)
    {
      Link-Item[shield_id] = false;
      shield = 0;
    }
    would be built-in behavior + require a button press to block shield effect.
    "Protocols of the Learned Elders of Zion" (British Royal Institute, 1906)
    "The International Jew: The World's Foremost Problem" �Henry Ford
    "Dope Inc. - Britain Opium War Against The U.S." (LaRouche; Konstandinos Kalimtgis; David Goldman; Jeffrey Stienberg, 1978)
    "Fundamental Laws: A Report of the 68th Convocation of the Rose Cross Order" 1916
    "War is a Racket" �Major General Smedley Butler
    "The Secret Destiny of America" �Manly P. Hall
    "A Strategy for Israel in the Nineteen Eighties" Oded Yinon (English Translation)
    The WWI Conspiracy: Part 1 - Part 2 - Part 3 "A New World Order"
    The War You Don't See
    Psywar

    �The modern theory of the perpetuation of debt has drenched the earth with blood, and crushed its inhabitants under burdens ever accumulating.� �Thomas Jefferson
    �It is well enough that the people of the nation do not understand our banking and monetary system for, if they did, I believe there would be a revolution before tomorrow morning.� �Henry Ford
    �Man will ultimately be governed by God or by tyrants.� �Benjamin Franklin

    This post contains the official Gleeok� seal of approval. Look for these and other posts in an area near you.

  3. #3
    Username Kaiser SUCCESSOR's Avatar
    Join Date
    Jul 2000
    Location
    Winning.
    Age
    33
    Posts
    4,435
    Mentioned
    152 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    10,397
    Level
    30
    vBActivity - Bars
    Lv. Percent
    31.77%
    @Majora wants a script that doesn't use LTMs for Active shield(when the button is pressed) or doesn't use LTMs at all, @CJC ? I altered... well rewrote the script he uses for shields to ghost link(make him invisible and draw over him) when he uses the shields instead of LTMs. This simplifies using LTMs to only being needed for the shield when not in use. I could draw a shield tile over link when he walks(has a shield and not using it) but it would be stuck in one place as I can't think of a way to match it with links walking sprites, it would disappear when you use the sword and such, and would have to be adusted for each shield and whatever tiles are used. Best to stick with LTMs for that IMHO.

    Code:
    const int I_FAKESHIELD1		= 140; 	//Extra Items 18, 19, and 20
    const int I_FAKESHIELD2		= 141; 	// -change if these items are 
    const int I_FAKESHIELD3		= 142; 	// -already in use
    const int BUT_SHIELD		= 0; 	// -1 = L, 0 = R, 1 = Ex1, 2 = Ex2, 3 = Ex3, 4 = Ex4 <-Button to use for shield
    const int DO_STRAFE			= 1; 	//Any value other than 0 turns on strafing
    const int SFX_SHIELDUP		= 89;	// The sound to use when Shield is held up. 
    const int TILE_LINK			= 34500; //first tile(Small shield facing up)
    
    int walking;	//keeps track of link walking
    bool lr;		//used for L and R
    global script ExShield
    {
    	void run()
    	{
    		int strafeDir; 	//stores Link's direction
    		bool shield;   	//keeps track on when shield is up
    		
    		
    		while(true)
    		{
    			if(BUT_SHIELD == -1 && Link->InputL){Link->InputL = false; lr = true;}
    			else if(BUT_SHIELD == 0 && Link->InputR){Link->InputR = false; lr = true;}
    			else lr = false;
    			if(!shield)strafeDir = Link->Dir;
    			if(ShieldInput() && !shield && !DoingMore())	//Shield button pressed and shield is inactive.
    			{
    				shield = true;
    				Link->Invisible = true;
    				if(Link->Item[I_FAKESHIELD3]) Link->Item[I_SHIELD3]=true;
                    else if(Link->Item[I_FAKESHIELD2]) Link->Item[I_SHIELD2]=true;
                    else if(Link->Item[I_FAKESHIELD1]) Link->Item[I_SHIELD1]=true;
    				else shield = false;
    				if(shield) Game->PlaySound(SFX_SHIELDUP);
    			}
    			else if((!ShieldInput() && shield) || (DoingMore() && shield))
    			{
    				shield = false;
    				Link->Invisible = false;
    				Link->Item[I_SHIELD3] = false;
                    Link->Item[I_SHIELD2] = false;
                    Link->Item[I_SHIELD1] = false;
    			}
    			if(shield && ShieldInput())
    			{
    				if(DO_STRAFE){ 
    					Waitdraw();
    					GhostLink(strafeDir); 
    					Link->Dir = strafeDir; } //forces link to face the same direction
    				else GhostLink(); //draws link
    			}
    			
    			Waitframe();
    		} //end of while loop
    	}// end of run
    	bool ShieldInput()
    	{
    		if(BUT_SHIELD == 1 && Link->InputEx1) return true;
    		else if(BUT_SHIELD == 2 && Link->InputEx2) return true;
    		else if(BUT_SHIELD == 3 && Link->InputEx3) return true;
    		else if(BUT_SHIELD == 4 && Link->InputEx4) return true;
    		else return lr;
    	}
    	bool DoingMore() //checks for any action besides walking
        {
            for(int i = 2; i < 25; i++)
            {
                if(Link->Action == i) return true;
            }
            return false; //if function reaches the end of for loop returns false
        }
    	void GhostLink() //Draws Link. Three tiles for each direction in order: Up Down Left Right
    	{
    		int val = TILE_LINK; 			//set initial tile
    
    		if(Link->Item[I_FAKESHIELD3]) val += 40;		//move to row for Shield current shield
            else if(Link->Item[I_FAKESHIELD2]) val += 20; 
    		
    		if(Link->Dir == DIR_RIGHT) val += 9;		//move to first tile for direction
    		else if(Link->Dir == DIR_LEFT) val += 6;
    		else if(Link->Dir == DIR_DOWN) val += 3;
    	
    		if(Link->Action == LA_WALKING)walking++;	//alternate for walking
    		if(walking >= 64)walking = 0;
    		else if(walking >= 48)val += 2;
    		else if(walking >= 16 && walking <= 32) val += 1;
    		
    		Screen->FastTile(2, Link->X, Link->Y, val, 6, 128); //draw tile.
    	}
    	void GhostLink(int dir) //Draws Link in one direction.
    	{
    		int val = TILE_LINK; 			//set initial tile
    
    		if(Link->Item[I_FAKESHIELD3]) val += 40;		//move to row for Shield current shield
            else if(Link->Item[I_FAKESHIELD2]) val += 20; 
    		
    		if(dir == DIR_RIGHT) val += 9;		//move to first tile for direction
    		else if(dir == DIR_LEFT) val += 6;
    		else if(dir == DIR_DOWN) val += 3;
    	
    		if(Link->Action == LA_WALKING)walking++;	//alternate for walking
    		if(walking >= 64)walking = 0;
    		else if(walking >= 48)val += 2;
    		else if(walking >= 16 && walking <= 32) val += 1;
    		
    		Screen->FastTile(2, Link->X, Link->Y, val, 6, 128); //draw tile.
    	}	
    } //end of global script
    For anyone that doesn't know how to use this script: You make three custom items, "Dummy Shields," and give those in the quest as you would the real shields. The dummies are the items that show up in the inventory and can be used for LTMs for when the shield isn't in use. Other than that all you need to do is set the constants to your liking.

    Example quest.

    How the tiles it uses are laid out.

  4. #4
    Cor Blimey! CJC's Avatar
    Join Date
    Dec 2002
    Location
    Fading into the darkness
    Age
    31
    Posts
    1,398
    Mentioned
    150 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,457
    Level
    24
    vBActivity - Bars
    Lv. Percent
    74.14%
    @Majora

    Okay, now we're going to work on getting these potion shops to work.

    EDIT: This script will not work as intended. Sorry.

    Spoiler: show
    Code:
    // Basic shop script FFC. These can be purchased multiple times
        // d0 = Item number of the first potion of that color.
        // d1 = The price for the item
        // d2 = The input button to press to buy
                // -1 for A, B, L, and R
                // 0 for A
                // 1 for B
                // 2 for L
                // 3 for R
        // d3 = Message String after obtaining the item (if not included, default S_THANKS string is used)
        // d4 = Message String to display for information (item info, item price, etc.)
        // d5 = Input button to press for information (same input as above. If buy button is set the same
                // as the info button or set to -1, then the information string will never activate
        // d6 = The counter to use. NOTE: These are one below the CR_number in std.zh. 0 is rupees, -1 is life, 2 is arrows, etc.
    ffc script Shop
    {
        void run(int itm, int price, int input, int thanksString, int infoString, int infoInput, int counter)
        {
            counter++;
           
            // Run continuously
            while(true)
            {
                // If Link is below the FFC facing up
                if(ShopCanBuy(this))
                {
                    // If he hits the provided input button
                    if(ShopInput(input))
                    {
                        // Disable that input for the frame
                        ShopSetInput(input,false);
                       
                        // If Link has enough rupees and empty bottle 1
                        if(Game->Counter[counter] >= price && (Link->item[B1] == true && Link->item[itm] == false)) // empty bottle 1, hard-coded.
                        {
    						// Give Link the item
    						ShopItemThanks(itm, thanksString);
                           
                            // Remove the rupees
                            ShopDeductRupees(price, counter);
                        }
                        else if(Game->Counter[counter] >= price && (Link->item[B2] == true && Link->item[itm+1] == false)) // empty bottle 2
    					{
    						// Give Link the item
    						ShopItemThanks(itm+1, thanksString);
                           
                            // Remove the rupees
                            ShopDeductRupees(price, counter);
                        }
    					else if(Game->Counter[counter] >= price && (Link->item[B3] == true && Link->item[itm+2] == false)) // empty bottle 3
    					{
    						// Give Link the item
    						ShopItemThanks(itm+2, thanksString);
                           
                            // Remove the rupees
                            ShopDeductRupees(price, counter);
                        }
    					else if(Game->Counter[counter] >= price && (Link->item[B4] == true && Link->item[itm+3] == false)) // empty bottle 4
    					{
    						// Give Link the item
    						ShopItemThanks(itm+3, thanksString);
                           
                            // Remove the rupees
                            ShopDeductRupees(price, counter);
                        }
    					// Else Link does not have enough rupees
                        else Screen->Message(S_NORUPEES);
                    }
                    // If a informational string is requested and the info button is pressed
                    else if(infoString > 0 && ShopInput(infoInput))
                    {
                        // Disable the input for the selected input button
                        ShopSetInput(infoInput, false);
                       
                        // Display the info string
                        Screen->Message(infoString);
                    }
                    // Else Link is under the FFC but has not hit the correct button
                    else
                    {
                        // Do stuff here if you want something to happen when Link is under the item but hasn't hit the input button
                        // Or draw some graphic to indicate to the player what button to press
                    }
                } //! End of if(ShopCanBuy(this))
               
                Waitframe();
            } //! End of while(true)
        } //! End of void run(int itm, int price, int input)
    }//! End of ffc script Shop


    The idea here is that the script checks if the player has enough rupees, and an empty bottle (IE it does not have a potion in it yet). If either of those conditions fail, it says the purchase can't be made.

    I can try to set it up so that it displays a different thread for full bottles versus insufficient funds, but I can't make any promises about that. Or this, for that matter.

    Also, the numbered potions (Blue1, Blue2, Blue3, and Blue4) need to be in sequential order of Item ID, since this script adds 1 to the FFC-defined variable to fill different bottles.
    And.... it may charge you to fill all the bottles, so we need to play with it a bit and see how it works.
    Last edited by CJC; 10-28-2012 at 10:12 PM.

  5. #5
    Username Kaiser SUCCESSOR's Avatar
    Join Date
    Jul 2000
    Location
    Winning.
    Age
    33
    Posts
    4,435
    Mentioned
    152 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    10,397
    Level
    30
    vBActivity - Bars
    Lv. Percent
    31.77%
    I'm sorry @CJC and @Majora I know I promised to make some functions to get the ball rolling on this idea but I have been lazy and haven't scripted a damn thing in like a week. Just to remind myself:

    The shop is 3 cauldrons, each selling one type of potion(one ffc used 3 times). There are 4 empty bottle items each it's own class. Each bottle class has 7 items(potentially 8 if there are fairy in a bottle): Empty, IngredRED, IngredGREEN, IngredBLUE, Red, Green, Blue. The shop first checks if you have the ingredient for it's potion and if you do gives you a discounted price. If you do not then the shop check for an empty bottle and charges full price or show the No Empty Bottle string. Shop also needs a string for not enough money. Did I forget anything?

  6. #6
    Lynel Majora's Avatar
    Join Date
    Mar 2006
    Age
    28
    Posts
    1,195
    Mentioned
    24 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    4,190
    Level
    20
    vBActivity - Bars
    Lv. Percent
    51.77%
    So should I begin rearranging items to be sequential? or will be it constants-based? Before I commit the change to my quest file.


    EDIT: If it will facilitate the item check process, the "Keep lower level items" can be un-checked and the potions script I have can give link the relevant bottle item once the potion/ingredient is consumed. The potion script I have is basically multiple minorly-edited variant of:

    Code:
    //D0 is item to give
    item script EnadylPotion{
        void run(int asdf, int itm){                   // "int asdf" is skip over the D0 variable which is used by the item-pickup-message script
             Link->HP = Link->MaxHP;
             //Link->Item[itm] = true;
        }
    }
    Last edited by Majora; 11-04-2012 at 01:47 PM.

  7. #7
    Username Kaiser SUCCESSOR's Avatar
    Join Date
    Jul 2000
    Location
    Winning.
    Age
    33
    Posts
    4,435
    Mentioned
    152 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    10,397
    Level
    30
    vBActivity - Bars
    Lv. Percent
    31.77%
    That wont be necessary. I have the function that checks for an empty bottle working. For some reason the function that checks for a relevent ingredient item is screwing things up. Teach me to script at 5am... or 4am damn DST. I meant to only do a couple functions but the shop script was easy to edit and I like to test what I script. I will post what I have when I get home whether or not I figure out wth I am doing wrong.

    EDIT: Figured out my dumb ass mistake. Here's the code. Remember I wrote this at 5 am so it will have bugs and will need polish.

    Spoiler: show
    Code:
    const int IT_BOTTLE1		= -1;//empty bottle item of Bottle Class 1
    	const int IT_ING_RED1	= -1;//ingredient item for red potion
    	const int IT_ING_GRN1	= -1;//ingredient item for green potion
    	const int IT_ING_BLU1	= -1;//ingredient item for blue potion
    	const int IT_POT_RED1	= -1;//red potion item
    	const int IT_POT_GRN1	= -1;//green potion item
    	const int IT_POT_BLU1	= -1;//blue potion item
    	const int IT_BOT_FAIR1	= -1;//Fairy in a bottle
    const int IT_BOTTLE2		= -1;//repeat for bottle class 2
    	const int IT_ING_RED2	= -1;
    	const int IT_ING_GRN2	= -1;
    	const int IT_ING_BLU2	= -1;
    	const int IT_POT_RED2	= -1;
    	const int IT_POT_GRN2	= -1;
    	const int IT_POT_BLU2	= -1;
    	const int IT_BOT_FAIR2	= -1;
    const int IT_BOTTLE3		= -1;//bottle class 2
    	const int IT_ING_RED3	= -1;
    	const int IT_ING_GRN3	= -1;
    	const int IT_ING_BLU3	= -1;
    	const int IT_POT_RED3	= -1;
    	const int IT_POT_GRN3	= -1;
    	const int IT_POT_BLU3	= -1;
    	const int IT_BOT_FAIR3	= -1;
    const int IT_BOTTLE4		= -1;//bottle class 4
    	const int IT_ING_RED4	= -1;
    	const int IT_ING_GRN4	= -1;
    	const int IT_ING_BLU4	= -1;
    	const int IT_POT_RED4	= -1;
    	const int IT_POT_GRN4	= -1;	
    	const int IT_POT_BLU4	= -1;
    	const int IT_BOT_FAIR4	= -1;
    	
    	//Bottle item constants set to negatives are ignored
    	//leave constant at -1 if you are not using that item
    	//item numbers do not need to be sequential
    	
    int bottles[32] = { 
    	IT_BOTTLE1, IT_ING_RED1, IT_ING_GRN1, IT_ING_BLU1, 
    		IT_POT_RED1, IT_POT_GRN1, IT_POT_BLU1, IT_BOT_FAIR1, 
    	IT_BOTTLE2, IT_ING_RED2, IT_ING_GRN2, IT_ING_BLU2, 
    		IT_POT_RED2, IT_POT_GRN2, IT_POT_BLU2, IT_BOT_FAIR2, 
    	IT_BOTTLE3, IT_ING_RED3, IT_ING_GRN3, IT_ING_BLU3, 
    		IT_POT_RED3, IT_POT_GRN3, IT_POT_BLU3, IT_BOT_FAIR3, 
    	IT_BOTTLE4, IT_ING_RED4, IT_ING_GRN4, IT_ING_BLU4, 
    		IT_POT_RED4, IT_POT_GRN4, IT_POT_BLU4, IT_BOT_FAIR4 };
    
    	//constants for bottles[] array do not change	
    	const int BOTT_1 	= 0;
    	const int BOTT_2 	= 8;
    	const int BOTT_3 	= 16;
    	const int BOTT_4 	= 24;
    	const int POTI_RED 	= 4;
    	const int POTI_GRN 	= 5;
    	const int POTI_BLU 	= 6;
    
    
    int EmptyBottle() //checks inventory for an empty bottle.
    {
    	for(int i = 31; i > -1; i--){
    		//skip if value is not a valid item number
    		if(!ValidItemNum(bottles[i])) continue;
    		if(Link->Item[bottles[i]]) { //if item checked is in posession
    			if(i>BOTT_4){ i = BOTT_4; continue;} //isn't empty bottle go to next bottle
    			else if(i == BOTT_4) return i; //is empty bottle return value
    			else if(i>BOTT_3){ i = BOTT_3; continue; }
    			else if(i == BOTT_3) return i;
    			else if(i>BOTT_2){ i = BOTT_2; continue; }
    			else if(i == BOTT_2) return i;
    			else if(i>BOTT_1) break;
    			else if(i == BOTT_1) return i;
    		}
    	}
    	return -1;
    }
    int HasIngred(int potion) //check to see if Link has the right potion ingredient
    {
    	int ingred = potion - 3;
    	if(Link->Item[bottles[ingred + BOTT_4]] && ValidItemNum(bottles[ingred + BOTT_4])){ 
    		return BOTT_4; }
    	if(Link->Item[bottles[ingred + BOTT_3]] && ValidItemNum(bottles[ingred + BOTT_3])){ 
    		return BOTT_3; }
    	if(Link->Item[bottles[ingred + BOTT_2]] && ValidItemNum(bottles[ingred + BOTT_2])){ 
    		return BOTT_2; }
    	if(Link->Item[bottles[ingred]] && ValidItemNum(bottles[ingred])){ 
    		return BOTT_1; }
    	else { return -1;} //return no ingred
    }
    
    //potion use POTI_ constants for potion, disc is cheaper price with ingredient
    void BuyPotion(int potion, int price, int disc, int stringNoBott, int stringNotEnough)
    {
    	bool discount;
    	int bottle = HasIngred(potion);
    	
    	//if HasIngred returns -1 check for empty bottle
    	if(bottle<0)bottle = EmptyBottle();
    	else discount = true;
    	
    	//if EmptyBottle() returns -1 show No Empty Bottle string
    	if(bottle<0){ //No empty bottle
    		Screen->Message(stringNoBott); NoAction(); return; } 
    	
    	if(discount) {
    		//Check to see if Player has enough rupees
    		if(Game->Counter[CR_RUPEES] < disc){
    			Screen->Message(stringNotEnough); 
    			NoAction(); return; 
    		}
    		else {
    			
    			//take away the ingredient
    			Link->Item[bottles[bottle + potion - 3]] = false;
    			//Give link the potion
    			GiveLinkItem(bottles[bottle + potion]);
    			Deduct(CR_RUPEES, disc);
    		}
    	}
    	else{
    		//Check to see if Player has enough rupees
    		if(Game->Counter[CR_RUPEES] < price){
    			Screen->Message(stringNotEnough); 
    			NoAction(); return;
    		}
    		else {
    			//give link the potion
    			GiveLinkItem(bottles[bottle + potion]);
    			Deduct(CR_RUPEES, price);
    		}
    	}
    }
    
    //delete if you use a shop script with this function
    bool ShopCanBuy(ffc buy) 
    {
        return (Abs(Link->X-buy->X) < 8 && Abs(Link->Y-(buy->Y+8)) < 8 && Link->Dir == DIR_UP);
    }
    //end of ShopCanBuy
    
    void GiveLinkItem(int itm)//Gives Link an item and makes him hold it up
    {
        item make = Screen->CreateItem(itm);  
        make->HitWidth = 16; make->HitHeight = 16;
        make->X = Link->X; make->Y = Link->Y;
    	Game->PlaySound(SFX_PICKUP);
        Link->Action = LA_HOLD2LAND;
        Link->HeldItem = itm;
    	while(Link->HeldItem == itm && Link->Action == LA_HOLD2LAND)
    		WaitNoAction();
    }
    void Deduct(int counter, int amount) //deduct amount from counter
    {
    	int comb0 = Screen->ComboT[0];
        Screen->ComboT[0] = CT_SCREENFREEZE;
    	for(int i=0;i<amount;i++)
        {
            Game->PlaySound(SFX_MSG);
            Game->Counter[counter]--;
            WaitNoAction();
        }
    	Screen->ComboT[0] = comb0;
    }
    
    //IF you use another script with these functions
    //either delete these or the one in the other script
    //these ones allows Ex buttons
    //input great than 3 0r -4 allows any button
    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;
    	else if(input == -1) return Link->PressEx1;
        else if(input == -2) return Link->PressEx2;
        else if(input == -3) return Link->PressEx3;
    	else if(input == -4) return Link->PressEx4;
    	else return (Link->PressA || Link->PressB || Link->PressL || Link->PressR ||
    			Link->PressEx1 || Link->PressEx3 || Link->PressEx3 || Link->PressEx4);
    }
    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;
    	else if(input == -1) Link->PressEx1 = state;
        else if(input == -2) Link->PressEx2 = state;
        else if(input == -3) Link->PressEx3 = state;
    	else if(input == -4) Link->PressEx4 = state;
    	else if(!state) NoAction();
    }
    
    //^^^
    
    bool ValidItemNum(int num)
    {
    	return num > -1 && num < 256;
    }
    //D0: The potion this cauldron sells see POTI_ constants (4 is RED, 5 is GREEN, 6 is BLUE)
    //D1: The full price
    //D2: The discounted price when player has ingredient for potion
    //D3: button to press to buy 
    //		0 is A, 1 is B, 2 is L, 3 is R, -1 is Ex1, -2 is Ex2, -3 is Ex3, -4 is Ex4
    //		any other value allows any of the above
    //D4: String that shows when Link approaches for info, price, price with ingred...
    //D5: String that shows if Link has no empty bottles
    //D6: String that shows if Link doesn't have enough rupees
    ffc script Cauldron
    {
        void run(int potion, int price, int disc, int input, int stringInfo, int stringNoBott, int stringNotEnough)
        {
    		//whether or not info string is on screen
    		bool info; 
            // Run continuously
            while(true)
            {
                // If Link is below the FFC facing up
                if(ShopCanBuy(this))
                {
                    // If he hits the provided input button
                    if(SelectPressInput(input))
                    {
    					
                        BuyPotion(potion, price, disc, stringNoBott, stringNotEnough);
    					Waitframes(20);
    					info = false;
                    }
                    // Else Link is under the FFC but has not hit the correct button
                    else
                    {
                        // Do stuff here if you want something to happen when Link is under the item but hasn't hit the input button
                        if(!info){ Screen->Message(stringInfo); info = true; }
                    }
                } //! End of if(ShopCanBuy(this))
                else if(info)info = false;
    			
                Waitframe();
            } //! End of while(true)
        } //! End of void run(int itm, int price, int input)
    }//! End of ffc script Shop


    You do realize that item script is all kinds of jacked right? EDIT: If you want I can write you some item scripts.
    Last edited by SUCCESSOR; 11-05-2012 at 10:51 PM.

  8. #8
    Lynel Majora's Avatar
    Join Date
    Mar 2006
    Age
    28
    Posts
    1,195
    Mentioned
    24 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    4,190
    Level
    20
    vBActivity - Bars
    Lv. Percent
    51.77%
    There are some issues with compiling. it's mostly conflicts so far. Can I use the original shop script with the cauldron one? Because for example, I got a "Function Shopcanbuy was already declared with that type signature" error.

    EDIT: it also conflicts with this script but I commented out some parts and will see if it works:
    EDIT 2: The item scripts for the potions and ingredients are hilariously simple, yeah. they're instant-use potions. I was going to eventually see about scripting the "everything freezes while your health gradually refills" effect that the built-in potions have.
    Code:
    ffc script Chest{    // Allow Link to open the treasure chest at this FFC's location using the
        // set input.
        // D0 = input: set to 0 for A button, 1 for B button, 2 for L, 3 for R.
        void run(int input){
            int loc = ComboAt(this->X,this->Y);
            while(!AgainstComboBase(loc) || !SelectPressInput(input)) {
                // Uncomment to prevent Link from opening the chest normally:
                if (AgainstComboBase(loc)) {
                    Link->InputUp = false;
                }
                Waitframe();
            }
            for (int i = 0; i < 8; i++) { // 8 pixels/frame gives 1/2 of a combo.
                // Similate pressing up for 5 frames, and mark this chest as
                // opened if the combo at this ffc is still a chest type.
                SetInput(input, false);
                Link->InputUp = true;
                Waitframe();
            }
        }
        bool AgainstComboBase(int loc){
            return Link->Z == 0 && (Link->Dir == DIR_UP && Link->Y == ComboY(loc)+8 && Abs(Link->X-ComboX(loc)) < 8);
        }
    }
    
    
    //Only include these two functions once in your script file
    //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;
    //    else if(input == 4) return Link->PressEx2;
    //}
    //
    //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;
        //else if(input == 4) Link->InputEx2 = state;
    //}
    EDIT3: The string for "You don't have a bottle" keeps popping up even though I do have the bottle items and the constants have been set. :/ I'll keep poking around though to see if maybe something was set up wrong by me somewhere.
    Last edited by Majora; 11-04-2012 at 04:09 PM.

  9. #9
    Username Kaiser SUCCESSOR's Avatar
    Join Date
    Jul 2000
    Location
    Winning.
    Age
    33
    Posts
    4,435
    Mentioned
    152 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    10,397
    Level
    30
    vBActivity - Bars
    Lv. Percent
    31.77%
    If there are duplicate function just take one out. My SelectPressInpute() and SetInput() should be able to be used other scripts without there being a problem(LTM's newest shop -1 would be Ex1 instead or A, B, L, or R). ShopCanBuy() should be unchanged from LTM's script. Let me know what other conflicts there may be. I'll test it out more. I only tested out one bottle last night.

  10. #10
    Lynel Majora's Avatar
    Join Date
    Mar 2006
    Age
    28
    Posts
    1,195
    Mentioned
    24 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    4,190
    Level
    20
    vBActivity - Bars
    Lv. Percent
    51.77%
    I just tried this morning and it broke for no reason. This showed up in Allegro.log after wondering why the cauldrons refused to sell me potions.

    Invalid index (25) to local array of size 4
    Invalid index (25) to local array of size 4
    Invalid index (17) to local array of size 4
    Invalid index (17) to local array of size 4
    Invalid index (9) to local array of size 4
    Invalid index (9) to local array of size 4
    Invalid index (31) to local array of size 4
    Invalid index (30) to local array of size 4
    Invalid index (29) to local array of size 4
    Invalid index (28) to local array of size 4
    Invalid index (27) to local array of size 4
    Invalid index (26) to local array of size 4
    Invalid index (25) to local array of size 4
    Invalid index (24) to local array of size 4
    Invalid index (23) to local array of size 4
    Invalid index (22) to local array of size 4
    Invalid index (21) to local array of size 4
    Invalid index (20) to local array of size 4
    Invalid index (19) to local array of size 4
    Invalid index (18) to local array of size 4
    Invalid index (17) to local array of size 4
    Invalid index (16) to local array of size 4
    Invalid index (15) to local array of size 4
    Invalid index (14) to local array of size 4
    Invalid index (13) to local array of size 4
    Invalid index (12) to local array of size 4
    Invalid index (11) to local array of size 4
    Invalid index (10) to local array of size 4
    Invalid index (9) to local array of size 4
    Invalid index (8) to local array of size 4
    Invalid index (7) to local array of size 4
    Invalid index (6) to local array of size 4
    Invalid index (5) to local array of size 4
    Invalid index (4) to local array of size 4

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social