Jump to content

Photo

Sword of 100 Pieces

item sword

  • Please log in to reply
18 replies to this topic

#16 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 12 January 2018 - 12:24 AM

I see a few ways that using an inherent flag here would create potential bugs.

 

None of them, would affect the combo tile.  :shrug:



#17 Smiles the Death Bringer

Smiles the Death Bringer

    The smiling demon!

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

Posted 13 January 2018 - 11:02 AM

Did I modify the script correctly? (Regarding the ++variable as well as the changes to the sword power trigger)

It seems to work fine, though I haven't testing the sword changing yet.

import "std.zh"
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();
        }
    }
}
}   

Edited by Smiles the Death Bringer, 13 January 2018 - 11:04 AM.


#18 Deedee

Deedee

    Bug Frog Dragon Girl

  • Moderators
  • Real Name:Deedee
  • Pronouns:She / Her, They / Them
  • Location:Canada

Posted 13 January 2018 - 09:18 PM

I see a few ways that using an inherent flag here would create potential bugs.

 

None of them, would affect the combo tile.  :shrug:

Zoria, the bug is caused by the inherent flag being set globally sword trigger flag due to a script error. Thus, on a screen with secrets not set properly, all combos would be turned into combo 0 upon swinging the sword.



#19 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 08 July 2020 - 08:19 AM

Zoria, the bug is caused by the inherent flag being set globally sword trigger flag due to a script error. Thus, on a screen with secrets not set properly, all combos would be turned into combo 0 upon swinging the sword.

 

Someone gravedug this outside of the thread. Just wanted to say, that this remark is correct. Writing ComboI[] is a ba way to do this. It presumes that once you collect the require item power, that you want all such triggers in the game to have the sword property as soon as one is triggered. If you do not, then you do not want to use ComboI[] at all. 

 

The script should likely have a bool universe argument, to check and write ComboI[]. This is somewhat surpassed by Generic trigger combos now, as you can set a minimum item level, and select sword weapon types.





Also tagged with one or more of these keywords: item, sword

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users