CODE
//import "std.zh"
//Constants used by Ice Combos
const int CT_ICECOMBO = 142; //The combotype (Script1)
const int ICE_ACCELERATION = 1;
const int ICE_DECELERATION = 1;
const int ICE_MAXSTEP = 150;
//Combine this script with your other global scripts.
global script Slot2{
void run(){
//Variables to be used by the ice combo mechanism.
bool isScrolling;
bool onice;
float linkx;
float linky;
int linkxstep;
int linkystep;
int oldscreen = Game->GetCurScreen();
while(true){
//This waitdraw prevents Link's sprite from vibrating and incorporates his movement THIS frame.
Waitdraw();
//If Link is on a ice combo and onice is false, set onice to true, store his position, and set his velocity to 0.
if((!onice || oldscreen != Game->GetCurScreen()) && OnIce()){
onice = true;
//Check if Link's on the ground and if so store his position and set his velocity to 0.
linkx = Link->X;
linky = Link->Y;
linkxstep = 0;
linkystep = 0;
}
//Otherwise set onice to the state of OnIce() but only if not scrolling and on the ground.
else if(Link->Action != LA_SCROLLING && Link->Z == 0) onice = OnIce();
//If Link is not scrolling and isScrolling is true then set linkx and linky to his position.
if(isScrolling && Link->Action != LA_SCROLLING){
isScrolling = false;
linkx = Link->X;
linky = Link->Y;
}
//Otherwise iset isScrlling to whether or not Link is scrolling.
else isScrolling = (Link->Action == LA_SCROLLING);
//Now check if onice is true.
if(onice && Link->Z == 0 && Link->Action != LA_HOPPING){
if(Link->Action != LA_SCROLLING){
//Movement along the y axis.
//If Link->InputUp Xor Link->InputDown then accelerate in that direction.
if(Link->InputUp && !Link->InputDown) linkystep -= ICE_ACCELERATION;
else if(Link->InputDown && !Link->InputUp) linkystep += ICE_ACCELERATION;
//Otherwise slowdown.
else{
if(linkystep > 0){
linkystep -= ICE_DECELERATION;
if(linkystep < 0) linkystep = 0;
}
else if(linkystep < 0){
linkystep += ICE_DECELERATION;
if(linkystep > 0) linkystep = 0;
}
}
//Movement along the x axis.
//If Link's left/right input is xored then accelerate in that direction.
if(Link->InputLeft && !Link->InputRight) linkxstep -= ICE_ACCELERATION;
else if(Link->InputRight && !Link->InputLeft) linkxstep += ICE_ACCELERATION;
//Otherwise slowdown.
else{
if(linkxstep > 0){
linkxstep -= ICE_DECELERATION;
if(linkxstep < 0) linkxstep = 0;
}
else if(linkxstep < 0){
linkxstep += ICE_DECELERATION;
if(linkxstep > 0) linkxstep = 0;
}
}
//Cap the xstep and ystep at the max step constant.
if(linkxstep < 0) linkxstep = Max(linkxstep, -ICE_MAXSTEP);
else if(linkxstep > 0) linkxstep = Min(linkxstep, ICE_MAXSTEP);
if(linkystep < 0) linkystep = Max(linkystep, -ICE_MAXSTEP);
else if(linkystep > 0) linkystep = Min(linkystep, ICE_MAXSTEP);
}
}
//If on a ice combo.
if(OnIce() || onice && Link->Z > 0){
if(Link->Action == LA_GOTHURTLAND){
linkx = Link->X;
linky = Link->Y;
}
else if(Link->Action == LA_HOPPING){
linkx = Link->X;
linky = Link->Y;
}
//If Link hit a solid object set the link_step variables to 0.
if(!CanWalk(linkx, linky, RadianAngleDir4(ArcTan(linkxstep, 0)), Abs(linkxstep/100), false)) linkxstep = 0;
if(!CanWalk(linkx, linky, RadianAngleDir4(ArcTan(0, linkystep)), Abs(linkystep/100), false)) linkystep = 0;
//Reposition Link at the link_ variables after incrementing them by the relative link_step variable.
linkx += linkxstep/100;
linky += linkystep/100;
Link->X = linkx;
Link->Y = linky;
}
//Set oldscreen to the current screen.
oldscreen = Game->GetCurScreen();
//Waitframe to prevent freezing.
Waitframe();
}
}
bool OnIce(){
bool condition;
int comboLoc = ComboAt(Link->X, Link->Y+8);
if(Screen->ComboT[comboLoc] == CT_ICECOMBO) condition = true;
if(Link->X % 16 != 0 && Screen->ComboT[comboLoc+1] == CT_ICECOMBO) condition = true;
if(Link->X % 16 != 0 && IsWater(Screen->ComboT[comboLoc+1])) condition = false;
return condition;
}
}
ffc script iceCombos{
void run(){
//Variables to be used by the ice combo mechanism.
bool isScrolling;
bool onice;
float linkx;
float linky;
int linkxstep;
int linkystep;
int oldscreen = Game->GetCurScreen();
while(true){
//This waitdraw prevents Link's sprite from vibrating and incorporates his movement THIS frame.
Waitdraw();
//If Link is on a ice combo and onice is false, set onice to true, store his position, and set his velocity to 0.
if((!onice || oldscreen != Game->GetCurScreen()) && OnIce()){
onice = true;
//Check if Link's on the ground and if so store his position and set his velocity to 0.
linkx = Link->X;
linky = Link->Y;
linkxstep = 0;
linkystep = 0;
}
//Otherwise set onice to the state of OnIce() but only if not scrolling and on the ground.
else if(Link->Action != LA_SCROLLING && Link->Z == 0) onice = OnIce();
//If Link is not scrolling and isScrolling is true then set linkx and linky to his position.
if(isScrolling && Link->Action != LA_SCROLLING){
isScrolling = false;
linkx = Link->X;
linky = Link->Y;
}
//Otherwise iset isScrlling to whether or not Link is scrolling.
else isScrolling = (Link->Action == LA_SCROLLING);
//Now check if onice is true.
if(onice && Link->Z == 0 && Link->Action != LA_HOPPING){
if(Link->Action != LA_SCROLLING){
//Movement along the y axis.
//If Link->InputUp Xor Link->InputDown then accelerate in that direction.
if(Link->InputUp && !Link->InputDown) linkystep -= ICE_ACCELERATION;
else if(Link->InputDown && !Link->InputUp) linkystep += ICE_ACCELERATION;
//Otherwise slowdown.
else{
if(linkystep > 0){
linkystep -= ICE_DECELERATION;
if(linkystep < 0) linkystep = 0;
}
else if(linkystep < 0){
linkystep += ICE_DECELERATION;
if(linkystep > 0) linkystep = 0;
}
}
//Movement along the x axis.
//If Link's left/right input is xored then accelerate in that direction.
if(Link->InputLeft && !Link->InputRight) linkxstep -= ICE_ACCELERATION;
else if(Link->InputRight && !Link->InputLeft) linkxstep += ICE_ACCELERATION;
//Otherwise slowdown.
else{
if(linkxstep > 0){
linkxstep -= ICE_DECELERATION;
if(linkxstep < 0) linkxstep = 0;
}
else if(linkxstep < 0){
linkxstep += ICE_DECELERATION;
if(linkxstep > 0) linkxstep = 0;
}
}
//Cap the xstep and ystep at the max step constant.
if(linkxstep < 0) linkxstep = Max(linkxstep, -ICE_MAXSTEP);
else if(linkxstep > 0) linkxstep = Min(linkxstep, ICE_MAXSTEP);
if(linkystep < 0) linkystep = Max(linkystep, -ICE_MAXSTEP);
else if(linkystep > 0) linkystep = Min(linkystep, ICE_MAXSTEP);
}
}
//If on a ice combo.
if(OnIce() || onice && Link->Z > 0){
if(Link->Action == LA_GOTHURTLAND){
linkx = Link->X;
linky = Link->Y;
}
else if(Link->Action == LA_HOPPING){
linkx = Link->X;
linky = Link->Y;
}
//If Link hit a solid object set the link_step variables to 0.
if(!CanWalk(linkx, linky, RadianAngleDir4(ArcTan(linkxstep, 0)), Abs(linkxstep/100), false)) linkxstep = 0;
if(!CanWalk(linkx, linky, RadianAngleDir4(ArcTan(0, linkystep)), Abs(linkystep/100), false)) linkystep = 0;
//Reposition Link at the link_ variables after incrementing them by the relative link_step variable.
linkx += linkxstep/100;
linky += linkystep/100;
Link->X = linkx;
Link->Y = linky;
}
//Set oldscreen to the current screen.
oldscreen = Game->GetCurScreen();
//Waitframe to prevent freezing.
Waitframe();
}
}
bool OnIce(){
bool condition;
int comboLoc = ComboAt(Link->X, Link->Y+8);
if(Screen->ComboT[comboLoc] == CT_ICECOMBO) condition = true;
if(Link->X % 16 != 0 && Screen->ComboT[comboLoc+1] == CT_ICECOMBO) condition = true;
if(Link->X % 16 != 0 && IsWater(Screen->ComboT[comboLoc+1])) condition = false;
return condition;
}
}