CODE
const int Stunframes = 360;
const int twobytwoice = 3260;
const int threebythreeice = 10580;
const int icecset = 7;
bool opaqueice = false;
const int freezesound = 44;
const int iceblocknpc = 178;
const int watericeoffset = 11;
const int FWaterSound = 44;
const int IceRodID = 25;
const int BookID = 32;
const int DummyID = 100;
int foriceone;
int foricetwo;
int foricethree;
int foricefour;
bool Groundling(npc t){
if(t->Type==NPCT_PEAHAT || t->Type==NPCT_GHINI || t->Type==NPCT_KEESE || t->Type==NPCT_FAIRY)
return(false);
return(true);
}
int IceLayer(npc f){
if(Groundling(f)) return(3);
return(5);
}
int icetransparency(){
if(opaqueice) return(128);
return(64);
}
bool CanFreeze(npc t){
if(t->Type==NPCT_AQUAMENTUS || t->Type==NPCT_PEAHAT || t->Type==NPCT_ROCK || t->Type==NPCT_MOLDORM ||
t->Type==NPCT_MANHANDLA || t->Type==NPCT_GOHMA || t->Type==NPCT_LANMOLA || t->Type==NPCT_PATRA ||
t->Type==NPCT_SPINTILE) return(false);
return(true);
}
void RandDir(npc r){
int rdir = Rand(8);
for(; rdir == r->Dir;){
rdir = Rand(8);
}
r->Dir = rdir;
}
void IceTurn(npc me){
int cornerx;
int cornery;
int colc;
float SCheck = me->Step/100;
int SDist = Round(SCheck);
if(me->Dir == DIR_LEFT){
cornerx = me->X-SDist;
cornery = me->Y;
}
else if(me->Dir == DIR_LEFTUP){
cornerx = me->X-SDist;
cornery = me->Y-SDist;
}
else if(me->Dir == DIR_UP){
cornerx = me->X;
cornery = me->Y-SDist;
}
else if(me->Dir == DIR_RIGHTUP){
cornerx = me->X+SDist;
cornery = me->Y-SDist;
}
else if(me->Dir == DIR_RIGHT){
cornerx = me->X+SDist;
cornery = me->Y;
}
else if(me->Dir == DIR_RIGHTDOWN){
cornerx = me->X+SDist;
cornery = me->Y+SDist;
}
else if(me->Dir == DIR_DOWN){
cornerx = me->X;
cornery = me->Y+SDist;
}
else if(me->Dir == DIR_LEFTDOWN){
cornerx = me->X-SDist;
cornery = me->Y+SDist;
}
for(colc = 1; colc <= Screen->NumNPCs(); colc++){
npc cc = Screen->LoadNPC(colc);
if(cc->ID == iceblocknpc && RectCollision(cornerx+me->HitXOffset, cornery+me->HitYOffset,
cornerx+me->HitWidth+me->HitXOffset, cornery+me->HitHeight+me->HitYOffset, cc->X, cc->Y, cc->X+cc->HitWidth,
cc->Y+cc->HitHeight)){
RandDir(me);
}
}
}
void Freeze(eweapon flwpn){
if(Screen->ComboT[ComboAt(flwpn->X, flwpn->Y)] == CT_DIVEWARP || Screen->ComboT[ComboAt(flwpn->X,
flwpn->Y)] == CT_DIVEWARPB || Screen->ComboT[ComboAt(flwpn->X, flwpn->Y)] == CT_DIVEWARPC ||
Screen->ComboT[ComboAt(flwpn->X, flwpn->Y)] == CT_DIVEWARPD || Screen->ComboT[ComboAt(flwpn->X, flwpn->Y)] ==
CT_SHALLOWWATER || Screen->ComboT[ComboAt(flwpn->X, flwpn->Y)] == CT_SWIMWARP ||
Screen->ComboT[ComboAt(flwpn->X, flwpn->Y)] == CT_SWIMWARPB || Screen->ComboT[ComboAt(flwpn->X, flwpn->Y)] ==
CT_SWIMWARPC || Screen->ComboT[ComboAt(flwpn->X, flwpn->Y)] == CT_SWIMWARPD || Screen->ComboT[ComboAt(flwpn->X,
flwpn->Y)] == CT_WATER){
if(Screen->ComboD[ComboAt(flwpn->X, flwpn->Y)] == 1){
;
}
Screen->ComboD[ComboAt(flwpn->X, flwpn->Y)] += watericeoffset;
Game->PlaySound(FWaterSound);
}
if(Screen->ComboT[ComboAt(flwpn->X+15, flwpn->Y)] == CT_DIVEWARP || Screen->ComboT[ComboAt(flwpn->X+15,
flwpn->Y)] == CT_DIVEWARPB || Screen->ComboT[ComboAt(flwpn->X+15, flwpn->Y)] == CT_DIVEWARPC ||
Screen->ComboT[ComboAt(flwpn->X+15, flwpn->Y)] == CT_DIVEWARPD || Screen->ComboT[ComboAt(flwpn->X+15,
flwpn->Y)] == CT_SHALLOWWATER || Screen->ComboT[ComboAt(flwpn->X+15, flwpn->Y)] == CT_SWIMWARP ||
Screen->ComboT[ComboAt(flwpn->X+15, flwpn->Y)] == CT_SWIMWARPB || Screen->ComboT[ComboAt(flwpn->X+15,
flwpn->Y)] == CT_SWIMWARPC || Screen->ComboT[ComboAt(flwpn->X+15, flwpn->Y)] == CT_SWIMWARPD ||
Screen->ComboT[ComboAt(flwpn->X+15, flwpn->Y)] == CT_WATER){
if(Screen->ComboD[ComboAt(flwpn->X+15, flwpn->Y)] == 1){
;
}
Screen->ComboD[ComboAt(flwpn->X+15, flwpn->Y)] += watericeoffset;
Game->PlaySound(FWaterSound);
}
if(Screen->ComboT[ComboAt(flwpn->X, flwpn->Y+15)] == CT_DIVEWARP || Screen->ComboT[ComboAt(flwpn->X,
flwpn->Y+15)] == CT_DIVEWARPB || Screen->ComboT[ComboAt(flwpn->X, flwpn->Y+15)] == CT_DIVEWARPC ||
Screen->ComboT[ComboAt(flwpn->X, flwpn->Y+15)] == CT_DIVEWARPD || Screen->ComboT[ComboAt(flwpn->X,
flwpn->Y+15)] == CT_SHALLOWWATER || Screen->ComboT[ComboAt(flwpn->X, flwpn->Y+15)] == CT_SWIMWARP ||
Screen->ComboT[ComboAt(flwpn->X, flwpn->Y+15)] == CT_SWIMWARPB || Screen->ComboT[ComboAt(flwpn->X,
flwpn->Y+15)] == CT_SWIMWARPC || Screen->ComboT[ComboAt(flwpn->X, flwpn->Y)] == CT_SWIMWARPD ||
Screen->ComboT[ComboAt(flwpn->X, flwpn->Y+15)] == CT_WATER){
if(Screen->ComboD[ComboAt(flwpn->X, flwpn->Y+15)] == 1){
;
}
Screen->ComboD[ComboAt(flwpn->X, flwpn->Y+15)] += watericeoffset;
Game->PlaySound(FWaterSound);
}
if(Screen->ComboT[ComboAt(flwpn->X+15, flwpn->Y+15)] == CT_DIVEWARP || Screen->ComboT[ComboAt(flwpn->X+15,
flwpn->Y+15)] == CT_DIVEWARPB || Screen->ComboT[ComboAt(flwpn->X+15, flwpn->Y+15)] == CT_DIVEWARPC ||
Screen->ComboT[ComboAt(flwpn->X+15, flwpn->Y+15)] == CT_DIVEWARPD || Screen->ComboT[ComboAt(flwpn->X+15,
flwpn->Y+15)] == CT_SHALLOWWATER || Screen->ComboT[ComboAt(flwpn->X+15, flwpn->Y+15)] == CT_SWIMWARP ||
Screen->ComboT[ComboAt(flwpn->X+15, flwpn->Y+15)] == CT_SWIMWARPB || Screen->ComboT[ComboAt(flwpn->X+15,
flwpn->Y+15)] == CT_SWIMWARPC || Screen->ComboT[ComboAt(flwpn->X+15, flwpn->Y+15)] == CT_SWIMWARPD ||
Screen->ComboT[ComboAt(flwpn->X+15, flwpn->Y+15)] == CT_WATER){
if(Screen->ComboD[ComboAt(flwpn->X+15, flwpn->Y+15)] == 1){
;
}
Screen->ComboD[ComboAt(flwpn->X+15, flwpn->Y+15)] += watericeoffset;
Game->PlaySound(FWaterSound);
}
}
global script Slot2{
void run(){
while(true){
for(foriceone = 1; foriceone <= Screen->NumEWeapons(); foriceone++){
eweapon tweapon = Screen->LoadEWeapon(foriceone);
if(tweapon->Misc[4] == 42){
for(foricetwo = 1; foricetwo <= Screen->NumNPCs(); foricetwo++){
npc tnpc = Screen->LoadNPC(foricetwo);
if(RectCollision(tweapon->X, tweapon->Y, tweapon->X+15, tweapon->Y+15,
tnpc->X+tnpc->HitXOffset, tnpc->Y+tnpc->HitYOffset, tnpc->X+tnpc->HitXOffset+tnpc->HitWidth,
tnpc->Y+tnpc->HitYOffset+tnpc->HitHeight)){
Game->PlaySound(freezesound);
if(CanFreeze(tnpc) && tnpc->ID != iceblocknpc){
tnpc->HP -= tweapon->Misc[10];
if(tnpc->HP<=0){
tnpc->HP=500;
tnpc->Misc[12]=145;
}
else tnpc->Misc[12] = 144;
tnpc->Stun = Stunframes+1;
npc IceCol = Screen->CreateNPC(iceblocknpc);
IceCol->X = tnpc->X-8;
IceCol->Y = tnpc->Y-8;
if(tnpc->TileHeight == 2 && tnpc->TileWidth == 2){
IceCol->HitHeight = 48;
IceCol->HitWidth = 48;
}
else{
IceCol->HitHeight = 32;
IceCol->HitWidth = 32;
}
}
tweapon->DeadState = WDS_DEAD;
}
}
Freeze(tweapon);
}
}
for(foricethree = 1; foricethree <= Screen->NumNPCs(); foricethree++){
npc itnpc = Screen->LoadNPC(foricethree);
if(itnpc->Misc[12] == 144 || itnpc->Misc[12] == 145){
if(itnpc->Stun > 1){
itnpc->CollDetection = false;
if(itnpc->TileWidth == 2 && itnpc->TileHeight == 2){
Screen->DrawTile(IceLayer(itnpc), itnpc->X-8, itnpc->Y-8, threebythreeice, 3, 3,
icecset, -1, -1, 0, 0, 0, 0, true, icetransparency());
}
else{
Screen->DrawTile(IceLayer(itnpc), itnpc->X-8, itnpc->Y-8, twobytwoice, 2, 2, icecset,
-1, -1, 0, 0, 0, 0, true, icetransparency());
}
}
else{
itnpc->CollDetection = true;
eweapon Melt = Screen->CreateEWeapon(EW_SCRIPT1);
Melt->X = itnpc->X;
Melt->Y = itnpc->Y;
Melt->DrawStyle = DS_CLOAKED;
for(foricefour = 1; foricefour <= Screen->NumNPCs(); foricefour++){
npc ibnpc = Screen->LoadNPC(foricefour);
if(Collision(Melt, ibnpc) && ibnpc->ID == iceblocknpc){
ibnpc->X = 256;
ibnpc->Y = 176;
ibnpc->HP = 0;
}
}
Melt->DeadState = WDS_DEAD;
if(itnpc->Misc[12]==145) itnpc->HP=0;
}
}
else{
IceTurn(itnpc);
}
}
//Uncomment the code between the comment after this and the Waitframe
//if you need to use a Wand because you have not allowed the player to select their A button item
//if(Link->Item[DummyID] == false){
//Link->Item[DummyID] = Link->Item[BookID];
//}
//if(GetEquipmentB() == IceRodID){
//Link->Item[BookID] = false;
//}
//else{
//Link->Item[BookID] = Link->Item[DummyID];
//}
Waitframe();
}
}
}
item script IceRod{
void run(int damage, int sprite, int step){
eweapon Ice = Screen->CreateEWeapon(EW_SCRIPT1);
Ice->Dir = Link->Dir;
Ice->Damage = 0;
Ice->Step = step;
Ice->Misc[4] = 42;
Ice->Misc[10] = damage;
Ice->UseSprite(sprite);
Ice->CollDetection=false;
if(Link->Dir == DIR_LEFT){
Ice->X = Link->X-16;
Ice->Y = Link->Y;
}
else if(Link->Dir == DIR_UP){
Ice->X = Link->X;
Ice->Y = Link->Y-16;
}
else if(Link->Dir == DIR_RIGHT){
Ice->X = Link->X+16;
Ice->Y = Link->Y;
}
else if(Link->Dir == DIR_DOWN){
Ice->X = Link->X;
Ice->Y = Link->Y+16;
}
}
}
Edit by Russ: I fixed the broken code tags for you, to make the post easier to read.
Edited by Russ, 02 July 2012 - 07:04 PM.