const int SFX_CV3_ACID_HIT_GROUND = 13;//Sound to play when falling acid hits ground.
const int SFX_CV3_ACID_FALL = 38;//Sound to play, when falling acid spawns.
const int SPR_CV3_ACID_HIT_GROUND = 22;//Sprite to display, when falling acid hits ground.
const int CV3_ACID_HITBOX_MARGIN = 1;//Hitbox margin for falling acid drops.
const int CF_CV3_ACID_IMMUNITY = 67;//Combos flagged with this flag cannot be destroyed by dripping acid.
//CV3 Acid Rain.
//Acid raining from seiling/sky. Very dangerous, can destroy solid combos underneath.
//Requires ghost.zh.
//1. Import and compile the script. 2 FFC scripts to be assigned.
//2. Place invisible FFC at top left corner of acid rain area. Assign "CV3AcidSpawner" FFC script to it.
// Data - Combo used by falling acid.
// CSet - CSet used by falling acid.
// D0 - Acid rain width, in combos/tiles.
// D1 - Damage by being hit by falling acid in midair, in 1/4th of heart.
// D2 - Delay between acid spawning, in frames.
ffc script CV3AcidSpawner{
void run(int width, int dam, int cooldown){
int str[]="CV3AcidDrop";
int scr = Game->GetFFCScript(str);
int timer = cooldown;
int stackx = 0;
while(true){
timer--;
if (timer<=0){
stackx = this->X+Rand(width)*16;
int args[3]={GRAVITY,TERMINAL_VELOCITY,dam};
ffc f = RunFFCScriptOrQuit(scr,args);
f->X = stackx;
f->Y = this->Y;
f->Data = this->Data;
f->CSet = this->CSet;
f->EffectWidth=16;
f->EffectHeight=16;
f->TileWidth=1;
f->TileHeight=1;
f->Vx=0;
f->Vy=0;
Game->PlaySound(SFX_CV3_ACID_FALL);
timer = cooldown;
}
Waitframe();
}
}
}
ffc script CV3AcidDrop{
void run(int grav, int term, int dam){
while(true){
this->Vy = Min(term, this->Vy+grav);
if ((RectCollision(Link->X, Link->Y, Link->X+15, Link->Y+Cond(IsSideview(),16,8), this->X+CV3_ACID_HITBOX_MARGIN, this->Y+CV3_ACID_HITBOX_MARGIN, this->X+15-CV3_ACID_HITBOX_MARGIN*2, this->Y+15-CV3_ACID_HITBOX_MARGIN*2))){
eweapon e = FireEWeapon(EW_SCRIPT10, Link->X+InFrontX(Link->Dir, 12), Link->Y+InFrontY(Link->Dir, 12), 0, 0, dam, -1, -1, EWF_UNBLOCKABLE);
e->Dir = Link->Dir;
e->DrawYOffset = -1000;
SetEWeaponLifespan(e, EWL_TIMER, 1);
SetEWeaponDeathEffect(e, EWD_VANISH, 0);
if (SPR_CV3_ACID_HIT_GROUND>0){
lweapon s = CreateLWeaponAt(LW_SPARKLE, this->X, this->Y);
s->UseSprite(SPR_CV3_ACID_HIT_GROUND);
s->CollDetection=false;
}
Game->PlaySound(SFX_CV3_ACID_HIT_GROUND);
this->Data=0;
this->Vx=0;
this->Vy=0;
Quit();
}
if (!CanWalk(this->X, this->Y, DIR_DOWN, this->Vy, true)){
int cmb = ComboAt(CenterX(this),CenterY(this))+16;
if (cmb<176){
if (!ComboFI(cmb,CF_CV3_ACID_IMMUNITY)){
Screen->ComboD[cmb]=Screen->UnderCombo;
Screen->ComboC[cmb]=Screen->UnderCSet;
if (SPR_CV3_ACID_HIT_GROUND>0){
lweapon s = CreateLWeaponAt(LW_SPARKLE, ComboX(cmb), ComboY(cmb));
s->UseSprite(SPR_CV3_ACID_HIT_GROUND);
s->CollDetection=false;
}
Game->PlaySound(SFX_CV3_ACID_HIT_GROUND);
}
else if (SPR_CV3_ACID_HIT_GROUND>0){
lweapon s = CreateLWeaponAt(LW_SPARKLE, this->X, this->Y);
s->UseSprite(SPR_CV3_ACID_HIT_GROUND);
s->CollDetection=false;
}
}
this->Data=0;
this->Vx=0;
this->Vy=0;
Quit();
}
if (this->Y>176){
this->Data=0;
this->Vx=0;
this->Vy=0;
this->Y=0;
this->Y=0;
Quit();
}
Waitframe();
}
}
}