const int SPEED_SPELL_DISPEL_ON_UNEQUIP = 1;//If>0 - turn off spell on item unequip.
int Speed_Spell_Drain_Rate = 30;//Delay between drains .
int Speed_Spell_Drain_Cost = 4;//Counter 1 cost at drain times.
int Speed_Spell_Drain_Counter = 4;//Counter 1 used for cost at drain times.
int Speed_Spell_Counter = 0;//Timer used for counter draining and SFX playback. Resets every 15600 frames.
int Speed_Spell_SFX = 4;//Sound to play when spell is active.
int Speed_Spell_SFX_Rate = 10;//Delay between sound playbacks when spell is active.
int Speed_Spell_Modifier = 100;//Default spell speed modifier. Must be set to positive value, if Link starts with speed spell.
int Speed_Spell_Status = 0;//On/Off status for spell.
int Speed_Spell_Drain_Cost2 = 1;//Counter 2 cost at drain times.
int Speed_Spell_Drain_Counter2 = 1;//Counter 2 used for cost at drain times.
//Speed modifier spell
//Select item in subscreen and set it to turn on or off. If turned on, drains counter and makes Link move faster.
//Requires LinkMovement.zh
//1. Global script combining:
// Put SpeedSpellInit() before LinkMovement_Init() prior to main loop of Active global script.
// Put UpdateSpeedSpellStatus() before LinkMovement_Update1() prior to Waitdraw() inside main loop of Active global script.
// Put LinkMovement_Update2() after to Waitdraw() inside main loop of Active global script.
//2. Set up Speed Spell item.
// Power - additive speed modifier bestowed by spell, when it`s active.
// UseSound - Sound to play when spell is active.
// D0 - Delay between magic drain rate
// D1 - counter cost at drain times.
// D2 - Delay between sound playbacks when spell is active.
// D3 - ID of counter of used as fuel.
// D4 - ID of 2nd counter of used as fuel.
// D5 - 2nd counter cost at drain times.
//3. Assign SpeedSpellAction to OnAction item script slot and SpeedSpellPickup to OnPickup script slot.
global script SpeedSpell{
void run(){
SpeedSpellInit();
LinkMovement_Init();
while(true){
UpdateSpeedSpellStatus();
LinkMovement_Update1();
Waitdraw();
LinkMovement_Update2();
Waitframe();
}
}
}
void SpeedSpellInit(){
Speed_Spell_Status=0;
}
void UpdateSpeedSpellStatus(){
if (Speed_Spell_Status>0){
Speed_Spell_Counter++;
if ((Speed_Spell_Counter%Speed_Spell_SFX_Rate)==0)Game->PlaySound(Speed_Spell_SFX);
if ((Speed_Spell_Counter%Speed_Spell_Drain_Rate)==0 && Link->Action==LA_WALKING){
if (Game->Counter[Speed_Spell_Drain_Counter]>=Speed_Spell_Drain_Cost)Game->Counter[Speed_Spell_Drain_Counter]-=Speed_Spell_Drain_Cost;
else Speed_Spell_Status=0;
if (Game->Counter[Speed_Spell_Drain_Counter2]>=Speed_Spell_Drain_Cost2 && Speed_Spell_Status>0)Game->Counter[Speed_Spell_Drain_Counter2]-=Speed_Spell_Drain_Cost2;
else Speed_Spell_Status=0;
}
if (Speed_Spell_Counter>=15600)Speed_Spell_Counter=0;
LinkMovement_AddLinkSpeedBoost(Speed_Spell_Modifier/100);
}
if (GetEquipmentB()!=Speed_Spell_Status && GetEquipmentA()!=Speed_Spell_Status) Speed_Spell_Status=0;
}
item script SpeedSpellAction{
void run(){
int itm = GetHighestLevelItemOwned(this->Family);
if (Speed_Spell_Status>0)Speed_Spell_Status=0;
else if (Game->Counter[Speed_Spell_Drain_Counter]>=Speed_Spell_Drain_Cost &&
Game->Counter[Speed_Spell_Drain_Counter2]>=Speed_Spell_Drain_Cost2)Speed_Spell_Status=itm;
}
}
item script SpeedSpellPickup{
void run(int drainrate, int draincost, int soundrate, int counterused, int counter2used, int counter2cost){
int itm = GetHighestLevelItemOwned(this->Family);
if (itm>=0){
itemdata it = Game->LoadItemData(itm);
int lvl = it->Level;
if (this->Level<=lvl) Quit();
}
Speed_Spell_Drain_Rate = drainrate;
Speed_Spell_Drain_Cost = draincost;
Speed_Spell_SFX = this->UseSound;
Speed_Spell_SFX_Rate = soundrate;
Speed_Spell_Modifier = this->Power;
Speed_Spell_Drain_Counter = counterused;
Speed_Spell_Drain_Cost2 = counter2cost;
Speed_Spell_Drain_Counter2 = counter2used;
}
}
//Sandstorm. Reduces Link`s movement speed, if Link does not have specific item.
//Requires LinkMovement.zh
//D0 - item ID
//D1 - speed penalty
ffc script Sandstorm{
void run (int itemid, int slow){
while(true){
if (! Link->Item[itemid])LinkMovement_AddLinkSpeedBoost(-slow);
Waitframe();
}
}
}
//Same as Sandstorm, but restricted to specific combo.
//Requires LinkMovement.zh
//D0 - item ID
//D1 - speed penalty, negative to speed boost
//D2 - ID of specific combo in table
ffc script SpeedModifierCombo{
void run (int itemid, int slow, int modcmb){
int cmb=0;
while(true){
cmb = ComboAt(CenterLinkX(), CenterLinkY());
if ((!Link->Item[itemid]) && (Screen->ComboD[cmb]==modcmb))LinkMovement_AddLinkSpeedBoost(-slow);
Waitframe();
}
}
}