Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Simple Somaria
- // ZoriaRPG
- // v0.4 for ZC 2.50+
- const int CMB_SOMARIA = 0;
- const int SPR_SOMARIA_POOF = 0;
- const int SFX_SOMARIA_POOF = 0;
- const int CMB_INVIS = 0;
- ffc script SimpleSomariaBlock
- {
- void run()
- {
- int pos; int x; int y; int blocks;
- while(1)
- {
- if ( Link->Dir == DIR_UP ) { pos = ComboAt(Link->X+8, Link->Y+8));}
- if ( Link->Dir == DIR_DOWN ) { pos = ComboAt(Link->X+7, Link->Y+8));}
- if ( Link->Dir ==DIR_LEFT ) { pos = ComboAt(Link->X+8, Link->Y+7));}
- if ( Link->Dir ==DIR_RIGHT ) { pos = ComboAt(Link->X+8, Link->Y+8));}
- pos = adjacentCombo(pos, Link->Dir); //update
- x = ComboX(pos);
- y = ComboY(pos);
- if ( !Screen->ComboS[pos] ) //not walkable
- {
- //error out
- this->Data = 0; Quit();
- }
- if ( pos % 16 == 0 ) //if on the leftmost column
- {
- //error out
- this->Data = 0; Quit();
- }
- if ( (pos & 15) == 1 ) //rightmost column
- {
- //error out
- this->Data = 0; Quit();
- }
- if ( pos < 0x10 ) //if it's the top row
- {
- //error out
- this->Data = 0; Quit();
- }
- if ( cmb > 0x9F ) //if it's on the bottom rowif ( pos < 0x10 ) combooffsets[11] = 1; //if it's the top row
- {
- //error out
- this->Data = 0; Quit();
- }
- else
- {
- if ( blocks )
- {
- //find and destroy old block
- //we obviously need to mark them in some way when they move!!
- //no, just a unique combo ID.
- for ( int q = 0; q < 176; ++q )
- {
- if ( Screen->ComboD[q] == CMB_SOMARIA )
- {
- //poof anim
- lweapon poof = Screen->CreateLWeapon(LW_SPARKLE);
- poof->X = x;
- poof->Y = y;
- poof->UseSprite(SPR_SOMARIA_POOF);
- //sound
- Game->PlaySound(SFX_SOMARIA_POOF);
- //remove block
- Screen->ComboD[pos] = Screen->Undercombo;
- --blocks;
- while(poof->isValid()) Waitframe();
- break;
- }
- }
- //create new block
- }
- //Creaqte the block.
- //set combo type to a 4-way block
- //poof anim
- lweapon poof = Screen->CreateLWeapon(LW_SPARKLE);
- poof->X = x;
- poof->Y = y;
- poof->UseSprite(SPR_SOMARIA_POOF);
- //sound
- Game->PlaySound(SFX_SOMARIA_POOF);
- ComboD[pos] = CMB_SOMARIA; //must be a 4-way push type, and only used by this script.
- ++blocks;
- }
- Waitframe();
- }
- }
- //Constants for AdjacentCombo()
- //This now uses DIR_* constants, so you can do AdjacentCombo(cmb,Link->Dir)
- //Returns the Nth combo index of a combo based on a central point, and a direction.
- //For example, combo 22 + COMBO_UPRIGHT returns '7',
- //as combo 7 is to the upper-right of combo 22.
- int adjacentCombo(int cmb, int dir)
- {
- int combooffsets[13]={-0x10, 0x10, -1, 1, -0x11, -0x0F, 0x0F, 0x11};
- if ( cmb % 16 == 0 ) combooffsets[9] = 1;
- if ( (cmb & 15) == 1 ) combooffsets[10] = 1;
- if ( cmb < 0x10 ) combooffsets[11] = 1; //if it's the top row
- if ( cmb > 0x9F ) combooffsets[12] = 1; //if it's on the bottom row
- if ( combooffsets[9] && ( dir == DIR_LEFT || dir == DIR_LEFTUP || dir == DIR_LEFTDOWN ) ) return 0; //if the left columb
- if ( combooffsets[10] && ( dir == DIR_RIGHT || dir == DIR_RIGHTUP || dir == DIR_RIGHTDOWN ) ) return 0; //if the right column
- if ( combooffsets[11] && ( dir == DIR_UP || dir == DIR_RIGHTUP || dir == DIR_LEFTUP ) ) return 0; //if the top row
- if ( combooffsets[12] && ( dir == DIR_DOWN || dir == DIR_RIGHTDOWN || dir == DIR_LEFTDOWN ) ) return 0; //if the bottom row
- else if ( cmb >= 0 && cmb <= 176 ) return cmb + combooffsets[dir];
- else return -1;
- }
- void execute(int id)
- {
- // Invalid script
- if ( id < 0 ) return;
- if ( id > 511 ) return;
- ffc f;
- for(int q =1 ; q < 33; ++q)
- {
- f = Screen->LoadFFC(q);
- if (!q->Script ) continue;
- if ( !f->Data ) continue;
- if ( f->Data != CMB_INVIS ) continue;
- if ( f->Flags[FFCF_CHANGER] ) continue;
- f->Data = CMB_INVIS;
- }
- }
- }
- item script SimpleSomariaCane
- {
- void run()
- {
- Link->Action = LA_ATTACKING;
- //if the ffc script isn't running, run it.
- int s[]="SimpleSomariaBlock";
- int a = Game->GetFFCScript(s);
- if ( !countRunning(a) );
- {
- SimpleSomariaBlock.execute(a);
- }
- }
- int countRunning(int id)
- {
- // Invalid script
- if id < 0 ) return -1;
- if ( id > 511 ) return -1;
- ffc f;
- int count;
- for ( int q = 1; q < 33; ++q )
- {
- f = Screen->LoadFFC(q);
- if ( f->Script == id )
- {
- ++count;
- }
- }
- return count;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement