PDA

View Full Version : Armos->Next



SUCCESSOR
03-07-2014, 05:30 PM
Now that the kinks are worked out...(I think). This is a script request by BigJoe. It is an Armos FFC. It can spawn any enemy you want. I can be solid. If you leave the layer combo at 0 the FFC Combo swaps with the one under the FFC. Any other layer invisible combos will be used to avoid scrolling issues. For solidity and spawning sake the FFC will snap to the combo grid. Make sure the top right corner is in the combo you want it placed on.

This script also doubles as a Touch->Next (also BigJoe's idea) If you leave enemy(D0) argument at 0 the delay counter will determine how long Link must touch the combo before it changes. This only works with solid(D3) set to true or else the change will be instant.

The FFC can leave an item as with normal Armos. This will store a bit (D7) to a Screen->D slot (D6) so the item only drops once. As the namee suggests when the script is done the FFC switches to the combo to the immediate right of the FFC Combo.


//invisible combos used when setting to layers.
const int CMB_SOLID = 9; //an invisible solid combo.
const int CMB_INVIS = 8; //a non-solid invisible combo.

ffc script ArmosNext
{
void run(int enemy, int sfx, int delay, bool solid, int layer, int itemDrop, int d, int bit)
{
this->X = (this->X>>4)<<4; this->Y = (this->Y>>4)<<4; //align to combo grid
int posX = this->X;
item it;
int wait = delay;

if(solid){
if(!layer)
SetLayerComboD(layer, ComboAt(this->X, this->Y), this->Data);
else
SetLayerComboD(layer, ComboAt(this->X, this->Y), CMB_SOLID);
}

while(!LinkCollision(this)) Waitframe();

if(!enemy){

if(solid){
while(delay){
if(LinkCollision(this)){
delay--;
this->X = posX + Rand(2);
Game->PlaySound(sfx);
Waitframe();
}
else delay = wait;
this->X = posX;
Waitframe();
}
}
}
else{
for(;delay>0;delay--){
this->X = posX + Rand(3)-1;
Game->PlaySound(sfx);
Waitframe();
}
this->X = posX;
CreateNPCAt(enemy, this->X, this->Y);
}
if(solid) {
if(!layer)
SetLayerComboD(layer, ComboAt(this->X, this->Y), this->Data+1);
else
SetLayerComboD(layer, ComboAt(this->X, this->Y), CMB_INVIS);
}
this->Data++;

if(itemDrop && !(Screen->D[d]&bit)){
it = CreateItemAt(itemDrop, this->X, this->Y);
Game->PlaySound(SFX_SECRET);
}
while(itemDrop && it->isValid() && !(Screen->D[d]&bit)) Waitframe();
Screen->D[d] |= bit;
} //end run()
} //end script

//D0 the enemy number to spawn (if 0 no enemy spawns)
//D1 Sound to play while "Armos" shakes
//D2 how long to shake the FFC before spawning the enemy
//D3 whether or not the armos is solid (0 is false; 1 is true; FFC Combo must be solid)
//D4 what layer the FFC combo is placed on. (Solidity only works on layer 0, 1, and 2)
//D5 item to drop
//D6 Screen Data slot to store to
//D7 Bit to store


Please post if you find an issue.

bigjoe
03-08-2014, 05:45 PM
To anyone who wants to use this script here is a tip: Make copies of the enemies you want to spawn and set their spawn type to instant. This will make the spawning look better.

bigjoe
03-12-2014, 08:49 PM
A bug with the hitboxes causes the item saving portion of this script to sometimes not work. In order to fix it, you should change !LinkCollision(it) to it->isValid().

That should be easy enough, but for those who can't be bothered, here is the corrected script:



//invisible combos used when setting to layers.
const int CMB_SOLID = 9; //an invisible solid combo.
const int CMB_INVIS = 8; //a non-solid invisible combo.

ffc script ArmosNext
{
void run(int enemy, int sfx, int delay, bool solid, int layer, int itemDrop, int d, int bit)
{
this->X = (this->X>>4)<<4; this->Y = (this->Y>>4)<<4; //align to combo grid
int posX = this->X;
item it;
int wait = delay;

if(solid){
if(!layer)
SetLayerComboD(layer, ComboAt(this->X, this->Y), this->Data);
else
SetLayerComboD(layer, ComboAt(this->X, this->Y), CMB_SOLID);
}

while(!LinkCollision(this)) Waitframe();

if(!enemy){

if(solid){
while(delay){
if(LinkCollision(this)){
delay--;
this->X = posX + Rand(2);
Game->PlaySound(sfx);
Waitframe();
}
else delay = wait;
this->X = posX;
Waitframe();
}
}
}
else{
for(;delay>0;delay--){
this->X = posX + Rand(3)-1;
Game->PlaySound(sfx);
Waitframe();
}
this->X = posX;
CreateNPCAt(enemy, this->X, this->Y);
}
if(solid) {
if(!layer)
SetLayerComboD(layer, ComboAt(this->X, this->Y), this->Data+1);
else
SetLayerComboD(layer, ComboAt(this->X, this->Y), CMB_INVIS);
}
this->Data++;

if(itemDrop && !(Screen->D[d]&bit)){
it = CreateItemAt(itemDrop, this->X, this->Y);
Game->PlaySound(SFX_SECRET);
}
while(itemDrop && it->isValid() && !(Screen->D[d]&bit)) Waitframe();
Screen->D[d] |= bit;
} //end run()
} //end script

//D0 the enemy number to spawn (if 0 no enemy spawns)
//D1 Sound to play while "Armos" shakes
//D2 how long to shake the FFC before spawning the enemy
//D3 whether or not the armos is solid (0 is false; 1 is true; FFC Combo must be solid)
//D4 what layer the FFC combo is placed on. (Solidity only works on layer 0, 1, and 2)
//D5 item to drop
//D6 Screen Data slot to store to
//D7 Bit to store

SUCCESSOR
03-12-2014, 10:36 PM
I'll modify the original post to include BigJoe's fix. I am still trying to think of the best way to do it. If anyone has any ideas check out my thread in Scripting Discussion.