Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //LWeapons.zh Version 1.0.8
- //
- //Library for doing custom LWeapon movement, death effects, sounds and lifespans. Without FFCS.
- import "std.zh"
- import "string.zh"
- import "stdExtra.zh"
- import "ffcscript.zh"
- import "ghost.zh"
- //import "LW_ZH/deprecated.z"
- //import "LW_ZH/global.z"
- //import "LW_ZH/genfunction.zh"
- //import "LW_ZH/common.z"
- //import "LW_ZH/update.z"
- //import "LW_ZH/movement.z"
- //import "LW_ZH/lweaponLife.z"
- //import "LW_ZH/other.z"
- //import "LW_ZH/scripts.z"
- //import "LW_ZH/caneofsomaria.z"
- int LW_Vars[65536];//Array for extra LWeapon functions.
- //Misc Constants
- const int MAX_STUN_TIME = 180;//Maximum time to stun an enemy.
- //Npc constants
- const int NPC_ITEMSET = 180; // ID of a dummy enemy with type different from "none"
- //Sound constants
- const int SFX_POT_BREAK = 75;//Sound made by breaking pots.
- const int SFX_THROW = 61;//Sound of an object being thrown.
- const int SFX_HEFT = 0;//Sound of picking up an object.
- //Item constants
- const int I_CSOMARIA = 0;//Item id of Cane of Somaria.
- // Sprite constants
- const int SPR_BUSH_CUT = 52;
- const int SPR_FLOWER_CUT = 53;
- const int SPR_GRASS_CUT = 54;
- const int SPR_POT_BREAK = 23;
- const int SPR_WAND_FIRE = 85;
- const int SPR_ICE_MAGIC = 83;
- const int SPR_SOMARIA_BLOCK = 90;
- const int SPR_SOMARIA_FIRE = 91;
- //const int SPR_ROCK = 0;
- const int SPR_BUSH = 44;
- const int SPR_NULL = 93;
- //const int SPR_POT = 0;
- //const int SPR_ICE_BLOCK = 0;
- //Flags for category Screen->Flags[SF_SECRETS]
- const int SF_BLOCK_SHUT = 0x01;//Blocks set shutters open.
- const int SF_NOT_PERM = 0x02;//Secrets are temporary
- const int SF_HIT_ALL_PERM = 0x04;//Hit all triggers to set permanent secrets.
- const int SF_HIT_ALL_16_31 = 0x08;//Hit all triggers to trigger flags 16-31.
- //NPC Misc Indices
- const int NPC_MISC_TARGET_NUMBER = 3;//Npc index to store the fact that it has been targeted.
- //Lweapon Misc Indices
- //These must be unique numbers between 0 and 15.
- const int LW_ZH_I_FLAGS = 15; // Every index but this one can be used by non-lweapons.zh Lweapons
- const int LW_ZH_I_WORK_3 = 1;//Used to calculate things, like MP drain.
- const int LW_ZH_I_FLAGS_2 = 2;//Index for more Lweapon flags. Most are used internally, not set by script.
- const int LW_ZH_I_FX = 3;//Misc index used to make lweapon sounds continuous.
- const int LW_ZH_I_WORK_2 = 4;// Only used by a few movement types
- const int LW_ZH_I_WORK = 5;//Uses for a variety of things by lweapons.zh.
- const int LW_ZH_I_MOVEMENT_ARG = 6;//First lweapon misc index for movement.
- const int LW_ZH_I_MOVEMENT_ARG2 = 7;//Second lweapon misc index for movement.
- const int LW_ZH_I_MOVEMENT = 8;//Lweapon index used to indicate how it moves.
- const int LW_ZH_I_XPOS = 9;//Lweapon index of it's X position.
- const int LW_ZH_I_YPOS = 10;//Lweapon index of it's Y position.
- const int LW_ZH_I_LIFESPAN = 11;//Lweapon index for lifespan
- const int LW_ZH_I_LIFESPAN_ARG = 12;//Lweapon index to tell how long lifespan is.
- const int LW_ZH_I_ON_DEATH = 13;//Lweapon index for death effects.
- const int LW_ZH_I_ON_DEATH_ARG = 14;//Lweapon index to determine what death effect does.
- //Lweapon movement flags.
- const int LWM_SINE_WAVE = 1;//Lweapon that moves in a sine wave.
- const int LWM_CIRCLE = 2;//LWeapon that moves in a circle around Link.
- const int LWM_HOMING = 3;//Lweapon that homes in on enemies.
- const int LWM_BRANG = 5;//LWeapon that acts like a boomerang.
- const int LWM_THROW = 15;//Lweapon that is thrown.
- const int LWM_FALL = 19;//Lweapon that falls from the air.
- const int LWM_CARRY = 8;//This lweapon remains at rest relative to link.
- const int LWM_HOOKSHOT = 4;//Lweapon that acts like a hookshot.
- const int LWM_DUAL_FX = 7;//This lweapon causes one of more types of flags to be hit.
- //const int LWM_MELEE = 6;//LWeapon that acts like a melee weapon.
- // Flags used by certain Lweapon movement types
- const int LWMF_DIE = 00000000001b;//This weapon dies when it stops moving.
- const int LWMF_REST= 00000000010b;//This weapon rests when it stops moving.
- //Arguments used by certain lweapon types.
- //const int LWM_R_GRENADE = 1;//This is a grenade.
- //const int LWM_R_SOMARIA = 2;//This is a cane of Somaria block.
- //const int LWM_R_MAGNET = 3;//This is a magnetic glove.
- // Arguments to SetLWeaponLifespan()
- const int LWL_TIMER = 1;//This lweapon runs on a timer.
- const int LWL_MP_COST = 4;//This lweapon continuously uses mp. If you don't have enough MP,it dies.
- const int LWL_EDGE = 15;//This weapon dies at the edge of the screen.
- //LWeapon Flags, use with LW_ZH_I_FLAGS
- const int LWF_ITEM_PICKUP = 00000000001b;//Can pickup items.
- const int LWF_PIERCES_ENEMIES = 00000000010b;//Pierces enemies.
- const int LWF_STUNS_ENEMIES = 00000000100b;//Stuns enemies.
- const int LWF_ZERO_G = 00000001000b;//Ignores gravity.
- const int LWF_POISON = 00000010000b;//Poisons enemies.
- const int LWF_INSTA_DELIVER = 00000100000b;//Used with item pickup. Insta-delivers item to Link.
- const int LWF_LINK_NO_COLL = 00001000000b;//Link can't be hurt while this lweapon is active.
- const int LWF_CAN_REFLECT = 00010000000b;//Reflected off of magic mirrors.
- //const int LWF_IS_MELEE = 00001000000b;//Used to tell that this is a melee item.
- // Internal LWeapon flags
- const int __LWFI_DEAD = 00100000000b;//This lweapon is dead.
- const int __LWFI_IS_LWZH_LWPN = 01000000000b;//A Lweapon.zh lweapon
- const int __LWFI_DEATH_EFFECT_DONE = 10000000000b;//The lweapon death effect is over.
- //LWeapon Flags, use with LW_ZH_I_FLAGS_2
- const int LWF_LEVEL_1 = 00000000001b;//Simulated level 1 of a particular weapon type.
- const int LWF_LEVEL_2 = 00000000011b;//Simulated level 2 of a particular weapon type..
- const int LWF_LEVEL_3 = 00000000111b;//Simulated level 3 of a particular weapon type.
- const int LWF_LEVEL_4 = 00000001111b;//Simulated level 4 of a particular weapon type.
- const int LWF_NO_COLLISION = 00001000000b;//This lweapon's collision is off.
- const int LWF_WAS_REFLECTED = 00010000000b;//This lweapon was just reflected.
- const int LWF_IS_REFLECTED = 00100000000b;//This is a reflected lweapon.
- //Internal LWeapon Flags, use with LW_ZH_I_FLAGS_2
- const int LWF_RETURN = 00000010000b;//This lweapon is returning to the user.
- const int LWF_HS_GRAB = 00000100000b;//A hookshot target has been grabbed.
- const int LWF_LINK_FROZEN = 01000000000b;//Link can't move while this lweapon is active.
- // Arguments to SetLWeaponDeathEffect()
- const int LWD_VANISH = 1;//This lweapon vanishes at death.
- const int LWD_AIM_AT_NPC = 2;//At death, this lweapon aims at an enemy on screen and head in that direction.
- const int LWD_EXPLODE = 3;//At death, this lweapon creates a bomb blast.
- const int LWD_SBOMB_EXPLODE = 4;//At death, this lweapon creates a super bomb blast.
- const int LWD_4_FIREBALLS_HV = 5;//At death, this lweapon makes 4 horizontal and vertical lweapons.
- const int LWD_4_FIREBALLS_DIAG = 6;//At death, this lweapon makes 4 diagonal lweapons.
- const int LWD_4_FIREBALLS_RANDOM = 7;//At death, this lweapon makes 4 random lweapons.
- const int LWD_8_FIREBALLS = 8;//At death, this lweapon makes 8 lweapons in all directions.
- const int LWD_FREEZE = 9;//At death, make an immobile ice block over the enemy.
- //Ghost ZH compatiblilty stuff. Not needed, really.
- const int LWD_4_FIRES_DIAG = 10;//At death, this lweapon makes 4 diagonal lweapons.
- const int LWD_4_FIRES_RANDOM = 11;//At death, this lweapon makes 4 random lweapons.
- const int LWD_8_FIRES = 12;//At death, this lweapon makes 8 lweapons in all directions.
- const int LWD_FIRE = 14;//At death, this lweapon makes another lweapon at its location.
- //LWeapons Melee Item Duplication
- //const int LW_IS_SWORD = 1;//This is a fake sword.
- //const int LW_IS_HAMMER = 2;//This is a fake hammer.
- //const int LW_IS_WAND = 3;//This is a fake wand.
- //Internal Melee Item Flags
- //const int LW_HAS_SLASH = 00000000001b;//This sword slashes.
- //const int LW_HAS_WHIM_RING = 00000000010b;//The weapon occassionally performs a critical attack.
- //const int LW_HAS_PERIL = 00000000100b;//This sword can shoot peril beams.
- //const int LW_HAS_BOOK = 00100000000b;//This wand has the magic book.
- //Common LW_ZH functions
- // Fire an lweapon
- lweapon FireLWeapon(int weaponID, int x, int y, float angle, int step, int damage, int sprite, int sound, int flags)
- {
- lweapon wpn=Screen->CreateLWeapon(weaponID);
- wpn->X=x;
- wpn->Y=y;
- wpn->Step=step;
- wpn->Damage=damage;
- wpn->Angular=true;
- wpn->Angle=angle;
- if(sprite>=0)
- wpn->UseSprite(sprite);
- wpn->Misc[LW_ZH_I_FLAGS]=flags|__LWFI_IS_LWZH_LWPN;
- //if((wpn->Misc[LW_ZH_I_FLAGS]&LWF_CAN_REFLECT)!=0)wpn->Misc[LW_ZH_I_WORK]= sprite;
- SetLWeaponDir(wpn); // After flags so unblockability is detected
- Game->PlaySound(sound);
- return wpn;
- }
- // Fire an lweapon aimed based on an enemy's position
- lweapon FireAimedLWeapon(int weaponID, int x, int y, float angle, int step, int damage, int sprite, int sound, int flags)
- {
- lweapon wpn;
- float targetAngle;
- if(Screen->NumNPCs()>0){
- if(wpn->Misc[LW_ZH_I_WORK]==0)wpn->Misc[LW_ZH_I_WORK] = Rand(1,Screen->NumNPCs());
- npc target_enemy = Screen->LoadNPC(wpn->Misc[LW_ZH_I_WORK]);
- target_enemy->Misc[NPC_MISC_TARGET_NUMBER]=wpn->Misc[LW_ZH_I_WORK];
- if(target_enemy->HP<=0)wpn->Misc[LW_ZH_I_WORK]= 0;
- if(target_enemy->Misc[NPC_MISC_TARGET_NUMBER]==wpn->Misc[LW_ZH_I_WORK]){
- targetAngle=RadianAngle(wpn->X, wpn->Y, target_enemy->X, target_enemy->Y);
- if(targetAngle<0)
- targetAngle+=6.2832;
- }
- }
- return FireLWeapon(weaponID, x, y, targetAngle+angle, step, damage, sprite, sound, flags);
- }
- // Fire a non-angular lweapon
- lweapon FireNonAngularLWeapon(int weaponID, int x, int y, int dir, int step, int damage, int sprite, int sound, int flags)
- {
- lweapon wpn=Screen->CreateLWeapon(weaponID);
- wpn->X=x;
- wpn->Y=y;
- wpn->Step=step;
- wpn->Damage=damage;
- wpn->Angular=false;
- wpn->Dir=dir;
- if(sprite>=0)
- wpn->UseSprite(sprite);
- wpn->Misc[LW_ZH_I_FLAGS]=flags|__LWFI_IS_LWZH_LWPN;
- //if((wpn->Misc[LW_ZH_I_FLAGS]&LWF_CAN_REFLECT)!=0)wpn->Misc[LW_ZH_I_WORK]= sprite;
- Game->PlaySound(sound);
- return wpn;
- }
- // Fire an lweapon larger than 1x1
- lweapon FireBigLWeapon(int weaponID, int x, int y, float angle, int step, int damage, int sprite, int sound, int flags, int width, int height)
- {
- lweapon wpn= Screen->CreateLWeapon(weaponID);
- wpn->X=x;
- wpn->Y=y;
- wpn->Step=step;
- wpn->Damage=damage;
- wpn->Angular=true;
- wpn->Angle=angle;
- if(sprite>=0)
- wpn->UseSprite(sprite);
- wpn->Misc[LW_ZH_I_FLAGS]=flags|__LWFI_IS_LWZH_LWPN;
- wpn->Extend=3;
- wpn->TileWidth=width;
- wpn->TileHeight=height;
- wpn->HitWidth=16*width;
- wpn->HitHeight=16*height;
- SetLWeaponDir(wpn);
- Game->PlaySound(sound);
- return wpn;
- }
- // Fire an lweapon larger than 1x1 aimed based on an enemy's position
- lweapon FireBigAimedLWeapon(int weaponID, int x, int y, float angle, int step, int damage, int sprite, int sound, int flags, int width, int height)
- {
- lweapon wpn=FireAimedLWeapon(weaponID, x, y, angle, step, damage, sprite, sound, flags);
- float targetAngle;
- if(Screen->NumNPCs()>0){
- if(wpn->Misc[LW_ZH_I_WORK]==0)wpn->Misc[LW_ZH_I_WORK] = Rand(1,Screen->NumNPCs());
- npc target_enemy = Screen->LoadNPC(wpn->Misc[LW_ZH_I_WORK]);
- target_enemy->Misc[NPC_MISC_TARGET_NUMBER]=wpn->Misc[LW_ZH_I_WORK];
- if(target_enemy->HP<=0)wpn->Misc[LW_ZH_I_WORK]= 0;
- if(target_enemy->Misc[NPC_MISC_TARGET_NUMBER]==wpn->Misc[LW_ZH_I_WORK]){
- targetAngle=RadianAngle(wpn->X, wpn->Y, target_enemy->X, target_enemy->Y);
- if(targetAngle<0)
- targetAngle+=6.2832;
- }
- }
- return FireBigLWeapon(weaponID, x, y, targetAngle+angle, step, damage, sprite, sound, flags,width,height);
- }
- // Fire a non-angular lweapon larger than 1x1
- lweapon FireBigNonAngularLweapon(int weaponID, int x, int y, int dir, int step, int damage, int sprite, int sound, int flags, int width, int height)
- {
- lweapon wpn=FireNonAngularLWeapon(weaponID, x, y, dir, step, damage, sprite, sound, flags);
- wpn->Extend=3;
- wpn->TileWidth=width;
- wpn->TileHeight=height;
- wpn->HitWidth=16*width;
- wpn->HitHeight=16*height;
- return wpn;
- }
- //Included for compatiblilty with other scripts.
- //Fires a scripted Lweapon.
- //D0- Type of weapon
- //D1- X coords to fire at.
- //D2- Y coords to fire at.
- //D3- Sprite to use.
- //D4- Speed of Lweapon.
- //D5- Damage Lweapon does.
- lweapon FireScriptedLWeapon(int type, int X, int Y,int Sprite, int Speed, int Damage,int flags){
- lweapon thing = Screen->CreateLWeapon(type);
- thing->X = X;
- thing->Y = Y;
- thing->Step = Speed;
- thing->Damage = Damage;
- thing->UseSprite(Sprite);
- thing->Dir= Link->Dir;
- if(thing->Dir == DIR_LEFTUP||thing->Dir == DIR_RIGHTUP
- ||thing->Dir == DIR_LEFTDOWN||thing->Dir == DIR_RIGHTDOWN){
- if(thing->NumFrames!=0)thing->Tile+=(thing->NumFrames*2);
- else thing->Tile+=2;
- if(thing->Dir==DIR_LEFTUP)
- thing->Flip = FLIP_H;
- else if(thing->Dir==DIR_RIGHTDOWN)
- thing->Flip = FLIP_V;
- else if(thing->Dir==DIR_LEFTDOWN)
- thing->Flip = FLIP_B;
- }
- else if(thing->Dir==DIR_LEFT||thing->Dir==DIR_RIGHT){
- if(thing->NumFrames!=0)thing->Tile+=thing->NumFrames;
- else thing->Tile+=1;
- if(thing->Dir ==DIR_LEFT)thing->Flip= FLIP_H;
- }
- else{
- if(thing->Dir == DIR_DOWN)
- thing->Flip = FLIP_V;
- }
- thing->Misc[LW_ZH_I_FLAGS]=flags|__LWFI_IS_LWZH_LWPN;
- return thing;
- }
- lweapon FireIndependentLWeapon(int type, int X, int Y,int dir,int Sprite, int Speed, int Damage,int flags){
- lweapon thing = Screen->CreateLWeapon(type);
- thing->X = X;
- thing->Y = Y;
- thing->Step = Speed;
- thing->Damage = Damage;
- thing->UseSprite(Sprite);
- thing->Dir= dir;
- if(thing->Dir == DIR_LEFTUP||thing->Dir == DIR_RIGHTUP
- ||thing->Dir == DIR_LEFTDOWN||thing->Dir == DIR_RIGHTDOWN){
- if(thing->NumFrames!=0)thing->Tile+=(thing->NumFrames*2);
- else thing->Tile+=2;
- if(thing->Dir==DIR_LEFTUP)
- thing->Flip = FLIP_H;
- else if(thing->Dir==DIR_RIGHTDOWN)
- thing->Flip = FLIP_V;
- else if(thing->Dir==DIR_LEFTDOWN)
- thing->Flip = FLIP_B;
- }
- else if(thing->Dir==DIR_LEFT||thing->Dir==DIR_RIGHT){
- if(thing->NumFrames!=0)thing->Tile+=thing->NumFrames;
- else thing->Tile+=1;
- if(thing->Dir ==DIR_LEFT)thing->Flip= FLIP_H;
- }
- else{
- if(thing->Dir == DIR_DOWN)
- thing->Flip = FLIP_V;
- }
- thing->Misc[LW_ZH_I_FLAGS]=flags|__LWFI_IS_LWZH_LWPN;
- return thing;
- }
- // Set the weapon's direction based on its angle;
- void SetLWeaponDir(lweapon wpn){
- float angle=wpn->Angle%6.2832;
- int dir;
- int tile = wpn->OriginalTile;
- int flip= wpn->Flip;
- if(angle<0)
- angle+=6.2832;
- if(angle<0.3927 || angle>5.8905){
- dir=DIR_RIGHT;
- if(wpn->NumFrames!=0)tile = wpn->OriginalTile+wpn->NumFrames;
- else tile = wpn->OriginalTile+1;
- }
- else if(angle<1.1781){
- dir=DIR_RIGHTDOWN;
- if(wpn->NumFrames!=0)tile = wpn->OriginalTile+(wpn->NumFrames*2);
- else tile = wpn->OriginalTile+2;
- flip = FLIP_V;
- }
- else if(angle<1.9635){
- dir=DIR_DOWN;
- if(wpn->TileWidth==1)
- flip = FLIP_V;
- }
- else if(angle<2.7489){
- dir=DIR_LEFTDOWN;
- if(wpn->NumFrames!=0)tile = wpn->OriginalTile+(wpn->NumFrames*2);
- else tile = wpn->OriginalTile+2;
- flip = FLIP_B;
- }
- else if(angle<3.5343){
- dir=DIR_LEFT;
- if(wpn->NumFrames!=0)tile = wpn->OriginalTile+wpn->NumFrames;
- else tile = wpn->OriginalTile+1;
- if(wpn->TileWidth==1)
- flip= FLIP_H;
- }
- else if(angle<4.3197){
- dir=DIR_LEFTUP;
- if(wpn->NumFrames!=0)tile = wpn->OriginalTile+(wpn->NumFrames*2);
- else tile = wpn->OriginalTile+2;
- flip = FLIP_H;
- }
- else if(angle<5.1051)
- dir=DIR_UP;
- else{
- dir=DIR_RIGHTUP;
- if(wpn->NumFrames!=0)tile = wpn->OriginalTile+(wpn->NumFrames*2);
- else tile = wpn->OriginalTile+2;
- }
- wpn->Dir=dir;
- wpn->Tile = tile;
- wpn->Flip = flip;
- }
- // Flip the weapon's sprite to match its direction
- void SetLWeaponRotation(lweapon wpn, int dir){
- float angle=wpn->Angle%6.2832;
- if(angle<0)
- angle+=6.2832;
- int tile = wpn->OriginalTile;
- int flip= wpn->Flip;
- wpn->Angular = true;
- if(angle<0)
- angle+=6.2832;
- if(angle<0.3927 || angle>5.8905){
- dir=DIR_RIGHT;
- if(wpn->NumFrames!=0)tile = wpn->OriginalTile+wpn->NumFrames;
- else tile = wpn->OriginalTile+1;
- }
- else if(angle<1.1781){
- dir=DIR_RIGHTDOWN;
- if(wpn->NumFrames!=0)tile = wpn->OriginalTile+(wpn->NumFrames*2);
- else tile = wpn->OriginalTile+2;
- flip = FLIP_V;
- }
- else if(angle<1.9635){
- dir=DIR_DOWN;
- flip = FLIP_V;
- }
- else if(angle<2.7489){
- dir=DIR_LEFTDOWN;
- if(wpn->NumFrames!=0)tile = wpn->OriginalTile+(wpn->NumFrames*2);
- else tile = wpn->OriginalTile+2;
- flip = FLIP_B;
- }
- else if(angle<3.5343){
- dir=DIR_LEFT;
- if(wpn->NumFrames!=0)tile = wpn->OriginalTile+wpn->NumFrames;
- else tile = wpn->OriginalTile+1;
- flip= FLIP_H;
- }
- else if(angle<4.3197){
- dir=DIR_LEFTUP;
- if(wpn->NumFrames!=0)tile = wpn->OriginalTile+(wpn->NumFrames*2);
- else tile = wpn->OriginalTile+2;
- flip = FLIP_H;
- }
- else if(angle<5.1051)
- dir=DIR_UP;
- else{
- dir=DIR_RIGHTUP;
- if(wpn->NumFrames!=0)tile = wpn->OriginalTile+(wpn->NumFrames*2);
- else tile = wpn->OriginalTile+2;
- }
- wpn->Dir=dir;
- wpn->Tile = tile;
- wpn->Flip = flip;
- }
- // Kill an lweapon, triggering any death effects
- // Kill an lweapon, triggering any death effects
- void KillLWeapon(lweapon wpn){
- wpn->Misc[LW_ZH_I_FLAGS]|=__LWFI_DEAD;
- if(wpn->Misc[LW_ZH_I_ON_DEATH]==0){
- if((wpn->Misc[LW_ZH_I_FLAGS]&LWF_PIERCES_ENEMIES)!=0){
- wpn->Misc[LW_ZH_I_FLAGS]&= ~LWF_PIERCES_ENEMIES;
- wpn->DeadState = 0;
- Remove(wpn);
- }
- else
- Remove(wpn);
- }
- }
- //Removes a specific lweapon type.
- void RemoveLWeaponType(int type){
- for(int i = 1;i<=Screen->NumLWeapons();i++){
- lweapon e = Screen->LoadLWeapon(i);
- if(e->ID==type)Remove(e);
- }
- }
- //A function to adjust an lweapon's hitbox size.
- //D0- Lweapon to adjust
- //D1- HitWidth
- //D2- HitHeight
- //D3- HitXOffset
- //D4- HitYOffset
- void SetLWeaponHitbox(lweapon wpn, int HitWidth, int HitHeight, int HitXOffset, int HitYOffset){
- wpn->HitHeight = HitHeight;
- wpn->HitWidth = HitWidth;
- wpn->HitXOffset = HitXOffset;
- wpn->HitYOffset = HitYOffset;
- }
- //A function to quickly change the size of an lweapon.
- //D0- Lweapon to adjust.
- //D1- Tile Width
- //D2- Tile Height
- void SetLWeaponSize(lweapon wpn, int TileWidth, int TileHeight){
- wpn->Extend = 3;
- wpn->TileHeight = TileHeight;
- wpn->TileWidth = TileWidth;
- }
- //Find a previously saved lweapon.
- lweapon FindMiscLWeapon(int Weapon_ID){
- lweapon wpn;
- for(int i= Screen->NumLWeapons();i>0;i--){
- wpn = Screen->LoadLWeapon(i);
- //This is the right lweapon.
- if(wpn->Misc[LW_ZH_I_WORK_3]==Weapon_ID)
- return wpn;
- }
- }
- //Finds an lweapon of a certain type.
- lweapon FindLWeaponType(int type){
- for(int i = 1;i<=Screen->NumLWeapons();i++){
- lweapon e = Screen->LoadLWeapon(i);
- if(e->ID==type)return e;
- }
- }
- //Functions used by LWeapons.zh that may be included with other headers.
- //Preserved to allow internal functionality.
- //Checks if one is true and the other is false.
- bool Xor(bool A, bool B){
- if((A&&!B)||(B&&!A))
- return true;
- return false;
- }
- // Returns true if FFC collides with a combo which has specific placed flag
- bool ComboFlagCollision (int loc, int flag, lweapon l){
- if (ComboFI(loc,flag)){
- if (ComboCollision(loc, l->X,l->Y,l->X+16,l->Y+16)) return true;
- }
- return false;
- }
- // Returns true if FFC collides with a combo which has specific placed flag
- bool ComboFlagCollision (int loc, int flag, int type,lweapon l){
- if (ComboFIT(loc,flag,type)){
- if (ComboCollision(loc, l->X,l->Y,l->X+16,l->Y+16)) return true;
- }
- return false;
- }
- // Returns TRUE if there is a collision between the combo and an arbitrary rectangle.
- // From stdWeapons.
- bool ComboCollision (int loc, int x1, int y1, int x2, int y2){
- return RectCollision( ComboX(loc), ComboY(loc), (ComboX(loc)+16), (ComboY(loc)+16), x1, y1, x2, y2);
- }
- bool ComboCollision(int loc, lweapon wpn){
- int wpnX = wpn->X+wpn->HitXOffset;
- int wpnY = wpn->Y+wpn->HitYOffset;
- int wpnXWidth = wpnX+wpn->HitWidth;
- int wpnYHeight = wpnY+wpn->HitHeight;
- return ComboCollision (loc, wpnX, wpnY, wpnXWidth, wpnYHeight);
- }
- bool ComboCollision(lweapon wpn, int loc){
- return ComboCollision(loc,wpn);
- }
- //Check if you're using an item.
- bool PressButtonItem(int itm){
- if(GetEquipmentA()==itm&&Link->PressA)return true;
- else if(GetEquipmentB()==itm&&Link->PressB)return true;
- return false;
- }
- bool InputButtonItem(int itm){
- if(GetEquipmentA()==itm&&Link->InputA)return true;
- else if(GetEquipmentB()==itm&&Link->InputB)return true;
- return false;
- }
- //Returns true if a weapon is on screen.
- //Returns TRUE, if lweapon is inside screen boundaries.
- bool OnScreen (lweapon wpn){
- int lwx = wpn->X + wpn->HitXOffset;
- int lwy = wpn->Y + wpn->HitYOffset;
- if (lwx<0-wpn->HitWidth) return false;
- if (lwy<0-wpn->HitHeight) return false;
- if (lwx>256) return false;
- if (lwy>176) return false;
- return true;
- }
- //Returns TRUE, if lweapon is inside screen boundaries.
- bool OnScreen (eweapon wpn){
- int lwx = wpn->X + wpn->HitXOffset;
- int lwy = wpn->Y + wpn->HitYOffset;
- if (lwx<0-wpn->HitWidth) return false;
- if (lwy<0-wpn->HitHeight) return false;
- if (lwx>256) return false;
- if (lwy>176) return false;
- return true;
- }
- //Returns TRUE, if lweapon is inside screen boundaries.
- bool OnScreen (ffc wpn){
- int lwx = wpn->X;
- int lwy = wpn->Y;
- if (lwx<0-wpn->EffectWidth) return false;
- if (lwy<0-wpn->EffectHeight) return false;
- if (lwx>256) return false;
- if (lwy>176) return false;
- return true;
- }
- //Returns TRUE, if lweapon is inside screen boundaries.
- bool OnScreen (npc wpn){
- int lwx = wpn->X + wpn->HitXOffset;
- int lwy = wpn->Y + wpn->HitYOffset;
- if (lwx<0-wpn->HitWidth) return false;
- if (lwy<0-wpn->HitHeight) return false;
- if (lwx>256) return false;
- if (lwy>176) return false;
- return true;
- }
- //Returns TRUE, if lweapon is touching screen boundaries.
- bool OnScreenEdge(lweapon lw){
- int lwx = lw->X + lw->HitXOffset;
- int lwy = lw->Y + lw->HitYOffset;
- if ((lwx>=0-lw->HitWidth)&&(lwx<=0)){
- if (InsideScreen(lw)) return true;
- }
- if ((lwy>=0-lw->HitHeight)&&(lwy<=0)){
- if (InsideScreen(lw)) return true;
- }
- if ((lwx>=256-lw->HitWidth)&&(lwx<=256)){
- if (InsideScreen(lw)) return true;
- }
- if ((lwy>=176-lw->HitHeight)&&(lwy<=176)){
- if (InsideScreen(lw)) return true;
- }
- return false;
- }
- //Returns TRUE, if lweapon is inside screen boundaries.
- bool InsideScreen (lweapon f){
- int lwx = f->X + f->HitXOffset;
- int lwy = f->Y + f->HitYOffset;
- if (lwx<0-f->HitWidth) return false;
- if (lwy<0-f->HitHeight) return false;
- if (lwx>256) return false;
- if (lwy>176) return false;
- return true;
- }
- bool CanMove(npc e,int dir,int imprecision){
- int eX = e->X+e->HitXOffset;
- int eY = e->Y+e->HitYOffset;
- int eRtX = eX+e->HitWidth;
- int eBtY = eY+e->HitHeight;
- int eCentX = eX+(e->HitWidth/2);
- int eCentY = eY+(e->HitHeight/2);
- if(dir==DIR_UP){
- if(Screen->isSolid(eCentX,eY-imprecision))return false;
- if(ComboFI(ComboAt(eCentX,eY-imprecision),CF_NOENEMY))return false;
- if(Screen->ComboT[ComboAt(eCentX,eY-imprecision)]==CT_NOENEMY)return false;
- }
- else if(dir==DIR_DOWN){
- if(Screen->isSolid(eCentX,eBtY+imprecision))return false;
- if(ComboFI(ComboAt(eCentX,eBtY+imprecision),CF_NOENEMY))return false;
- if(Screen->ComboT[ComboAt(eCentX,eBtY+imprecision)]==CT_NOENEMY)return false;
- }
- else if(dir==DIR_LEFT){
- if(Screen->isSolid(eX-imprecision,eCentY))return false;
- if(ComboFI(ComboAt(eX-imprecision,eCentY),CF_NOENEMY))return false;
- if(Screen->ComboT[ComboAt(eX-imprecision,eCentY)]==CT_NOENEMY)return false;
- }
- else if(dir==DIR_RIGHT){
- if(Screen->isSolid(eRtX+imprecision,eCentY))return false;
- if(ComboFI(ComboAt(eRtX+imprecision,eCentY),CF_NOENEMY))return false;
- if(Screen->ComboT[ComboAt(eRtX+imprecision,eCentY)]==CT_NOENEMY)return false;
- }
- return true;
- }
- bool CanMove(ffc e,int dir,int imprecision){
- int eX = e->X;
- int eY = e->Y;
- int eRtX = eX+e->EffectWidth;
- int eBtY = eY+e->EffectHeight;
- int eCentX = eX+(e->EffectWidth/2);
- int eCentY = eY+(e->EffectHeight/2);
- if(dir==DIR_UP){
- if(Screen->isSolid(eCentX,eY-imprecision))return false;
- }
- else if(dir==DIR_DOWN){
- if(Screen->isSolid(eCentX,eBtY+imprecision))return false;
- }
- else if(dir==DIR_LEFT){
- if(Screen->isSolid(eX-imprecision,eCentY))return false;
- }
- else if(dir==DIR_RIGHT){
- if(Screen->isSolid(eRtX+imprecision,eCentY))return false;
- }
- return true;
- }
- bool CanMove(eweapon e,int dir,int imprecision){
- int eX = e->X+e->HitXOffset;
- int eY = e->Y+e->HitYOffset;
- int eRtX = eX+e->HitWidth;
- int eBtY = eY+e->HitHeight;
- int eCentX = eX+(e->HitWidth/2);
- int eCentY = eY+(e->HitHeight/2);
- if(dir==DIR_UP){
- if(Screen->isSolid(eCentX,eY-imprecision))return false;
- if(Screen->ComboT[ComboAt(eCentX,eY-imprecision)]==CT_BLOCKALL)return false;
- }
- else if(dir==DIR_DOWN){
- if(Screen->isSolid(eCentX,eBtY+imprecision))return false;
- if(Screen->ComboT[ComboAt(eCentX,eBtY+imprecision)]==CT_BLOCKALL)return false;
- }
- else if(dir==DIR_LEFT){
- if(Screen->isSolid(eX-imprecision,eCentY))return false;
- if(Screen->ComboT[ComboAt(eX-imprecision,eCentY)]==CT_BLOCKALL)return false;
- }
- else if(dir==DIR_RIGHT){
- if(Screen->isSolid(eRtX+imprecision,eCentY))return false;
- if(Screen->ComboT[ComboAt(eRtX+imprecision,eCentY)]==CT_BLOCKALL)return false;
- }
- return true;
- }
- bool CanMove(lweapon e,int dir,int imprecision){
- int eX = e->X+e->HitXOffset;
- int eY = e->Y+e->HitYOffset;
- int eRtX = eX+e->HitWidth;
- int eBtY = eY+e->HitHeight;
- int eCentX = eX+(e->HitWidth/2);
- int eCentY = eY+(e->HitHeight/2);
- if(dir==DIR_UP){
- if(Screen->isSolid(eCentX,eY-imprecision))return false;
- if(Screen->ComboT[ComboAt(eCentX,eY-imprecision)]==CT_BLOCKALL)return false;
- }
- else if(dir==DIR_DOWN){
- if(Screen->isSolid(eCentX,eBtY+imprecision))return false;
- if(Screen->ComboT[ComboAt(eCentX,eBtY+imprecision)]==CT_BLOCKALL)return false;
- }
- else if(dir==DIR_LEFT){
- if(Screen->isSolid(eX-imprecision,eCentY))return false;
- if(Screen->ComboT[ComboAt(eX-imprecision,eCentY)]==CT_BLOCKALL)return false;
- }
- else if(dir==DIR_RIGHT){
- if(Screen->isSolid(eRtX+imprecision,eCentY))return false;
- if(Screen->ComboT[ComboAt(eRtX+imprecision,eCentY)]==CT_BLOCKALL)return false;
- }
- return true;
- }
- bool DistX(lweapon a, int distance) {
- int dist;
- if ( a->X > Link->X ) dist = a->X - Link->X;
- else dist = Link->X - a->X;
- return ( dist <= distance );
- }
- bool DistY(lweapon a, int distance) {
- int dist;
- if ( a->Y > Link->Y ) dist = a->Y - Link->Y;
- else dist = Link->Y - a->Y;
- return ( dist <= distance );
- }
- //Returns the amount in radians for a direction.
- float __DirtoRad(int dir){
- if(dir==DIR_UP)return DegtoRad(270);
- else if(dir==DIR_RIGHTUP)return DegtoRad(315);
- else if(dir==DIR_RIGHT)return DegtoRad(0);
- else if(dir==DIR_RIGHTDOWN)return DegtoRad(45);
- else if(dir==DIR_DOWN)return DegtoRad(90);
- else if(dir==DIR_LEFTDOWN)return DegtoRad(135);
- else if(dir==DIR_LEFT)return DegtoRad(180);
- else if(dir==DIR_LEFTUP)return DegtoRad(225);
- }
- //Draws a screen specified by 'sourceMap and sourceScreen;, from layers specified by 'layerMin and layerMax',
- //at a desired opacity, to the layer specified by 'destLayer' of the current screen.
- void ScreenToLayer(int sourceMap, int sourceScreen, int layerMin, int layerMax, int drawOpacity, int destLayer){
- for (int i = layerMin; i < layerMax; i++){
- Screen->DrawLayer(destLayer, sourceMap, sourceScreen, i, 0, 0, 0, drawOpacity);
- }
- }
- //Draws all layers of a screen specified by 'sourceMap and sourceScreen;,
- //at a desired opacity, to the layer specified by 'destLayer' of the current screen.
- void ScreenToLayer(int sourceMap, int sourceScreen, int drawOpacity, int destLayer){
- for (int i = 0; i < 6; i++){
- Screen->DrawLayer(destLayer, sourceMap, sourceScreen, i, 0, 0, 0, drawOpacity);
- }
- }
- int ItemsToPickup[]={ I_ARROWAMMO1, I_ARROWAMMO5, I_ARROWAMMO10, I_ARROWAMMO30, //Stock arrow ammo.
- I_BOMBAMMO1, I_BOMBAMMO4, I_BOMBAMMO8, I_BOMBAMMO30, //Stock bomb ammo.
- I_FAIRY, I_FAIRYSTILL, I_HEART, I_MAGICJAR1, I_MAGICJAR2, //Stock refills.
- I_CLOCK, //Stock clock item.
- I_RUPEE1, I_RUPEE5, I_RUPEE10, I_RUPEE20, I_RUPEE50, I_RUPEE100, I_RUPEE200, //Stock Rupee Items
- I_KEY, I_LEVELKEY, //Stock keys.
- I_COMPASS, //Stock Dungeon Compass
- I_MAP, //Stock dungeon map.
- I_BOSSKEY, //Stock dungeon/level master key.
- I_HCPIECE};
- //General Functions Zelda Header 1.1
- //Extra Constants
- //Misc Screen Flags
- const int SF_MISC_SCRIPT1 = 0x0004; //General use 1 (Scripts)
- const int SF_MISC_SCRIPT2 = 0x0008; //General use 2 (Scripts)
- const int SF_MISC_SCRIPT3 = 0x0010; //General use 3 (Scripts)
- const int SF_MISC_SCRIPT4 = 0x0020; //General use 4 (Scripts)
- const int SF_MISC_SCRIPT5 = 0x0040; //General use 5 (Scripts)
- //Scripted Lens Constants
- const int INVISIBLE_MISC_INDEX = 0;//Used by scripted lens. Stores combo to draw.
- const int DRAWN_MISC_INDEX = 1;//Used by scripted lens. Tells whether or not to draw enemy.
- const int LENS_RADIUS = 60;//Width of scripted lens aperture.
- //LW_ZH bools
- //Test if one location is between two others.
- //D0- Location to test
- //D1- Lower bound
- //D2- Higher bound
- bool Between(int loc,int greaterthan, int lessthan){
- if(loc>=greaterthan && loc<=lessthan)return true;
- return false;
- }
- //Randomly set a bool's value to true or false.
- bool ChooseBool() {
- if (Rand(0,1)==0) return true;
- else return false;
- }
- //Checks for matching combo flag and type.
- //D0- On scren location.
- //D1- Combo Flag to check.
- //D2- Combo Type to check.
- bool ComboFIT(int loc,int flag,int type){
- if(ComboFI(loc,flag)&& Screen->ComboT[loc]==type)return true;
- return false;
- }
- //Checks for matching combo flag and type.
- //D0- On scren location.
- //D1- Combo Flag to check.
- //D2- Combo Type to check.
- bool ComboFIT(int X, int Y,int flag,int type){
- int loc = ComboAt(X,Y);
- if(ComboFI(loc,flag)&& Screen->ComboT[loc]==type)return true;
- return false;
- }
- //Checks if a screen flag has been toggled.
- //D0- Category of flag
- //D1- Actual flag, in hex.
- bool ScreenFlagTest(int category,int flag){
- return Screen->Flags[category]&flag;
- }
- //Uses to make a boss using the Gen_Explode_Waitframe wait for a certain number of frames before doing something.
- void Gen_Explode_Waitframes(ffc this, npc ghost,int frames){
- for(;frames>0;frames--){
- Gen_Explode_Waitframe(this,ghost);
- }
- }
- //A general utility function to make a boss explode on death.
- void Gen_Explode_Waitframe(ffc this, npc ghost){
- if(!Ghost_Waitframe(this, ghost, false, false)){
- Ghost_DeathAnimation(this, ghost, 2);
- Quit();
- }
- }
- //General utility function for spawning another enemy when the main one dies.
- //Has same effects as Gen_Explode_Waitframe.
- //Set the original enemy's Misc 1 attribute to what enemy to spawn.
- //If no enemy is to be spawned, leave it at zero.
- void Gen_Spawn_Waitframe(ffc this, npc ghost){
- if(!Ghost_Waitframe(this, ghost, false, false)){
- Ghost_DeathAnimation(this, ghost, 2);
- int EnemyToSpawn = Ghost_GetAttribute(ghost,0,0);
- if(EnemyToSpawn!=0){
- npc n = Screen->CreateNPC(EnemyToSpawn);
- n->X = ghost->X;
- n->Y = ghost->Y;
- }
- Quit();
- }
- }
- void Gen_Spawn_Waitframes(ffc this, npc ghost, int frames){
- for(;frames>0;frames--)
- Gen_Spawn_Waitframe(this,ghost);
- }
- //Kills all npcs on screen when this enemy dies.
- void Gen_Leader_Waitframe(ffc this, npc ghost){
- if(!Ghost_Waitframe(this, ghost, false, false)){
- Ghost_DeathAnimation(this, ghost, 2);
- for(int i =Screen->NumNPCs();i>0;i--){
- npc n = Screen->LoadNPC(i);
- n->HP = 0;
- }
- Quit();
- }
- }
- void Gen_Leader_Waitframes(ffc this, npc ghost, int frames){
- for(;frames>0;frames--)
- Gen_Leader_Waitframe(this,ghost);
- }
- //A function to adjust an eweapon's hitbox size.
- //D0- Eweapon to adjust
- //D1- HitWidth
- //D2- HitHeight
- //D3- HitXOffset
- //D4- HitYOffset
- void SetEWeaponHitbox(eweapon wpn, int HitWidth, int HitHeight, int HitXOffset, int HitYOffset){
- wpn->HitHeight = HitHeight;
- wpn->HitWidth = HitWidth;
- wpn->HitXOffset = HitXOffset;
- wpn->HitYOffset = HitYOffset;
- }
- //A function to quickly change the size of an eweapon.
- //D0- EWeapon to adjust.
- //D1- Tile Width
- //D2- Tile Height
- void SetEWeaponSize(eweapon wpn, int TileWidth, int TileHeight){
- wpn->Extend = 3;
- wpn->TileHeight = TileHeight;
- wpn->TileWidth = TileWidth;
- }
- //A function to change the current combo at a location.
- //Changes id, cset and type.
- //D0- Location to change.
- //D1- Combo Id to change to.
- //D2- Combo Cset to change to.
- //D3- Combo Type to change to.
- void ChangeCombo(int loc, int comboid, int cset, int type){
- if(comboid>-1)Screen->ComboD[loc] = comboid;
- if(cset>-1)Screen->ComboC[loc]= cset;
- if(type>-1)Screen->ComboT[loc] = type;
- }
- //D0- Location to change.
- //D1- Combo Id to change to.
- //D2- Combo Cset to change to.
- //D3- Combo Type to change to.
- //D4- Placed flag to change to.
- void ChangeCombo(int loc, int comboid,int cset,int type, int flag){
- if(comboid>-1)Screen->ComboD[loc] = comboid;
- if(cset>-1)Screen->ComboC[loc]= cset;
- if(type>-1)Screen->ComboT[loc] = type;
- if(flag>-1)Screen->ComboF[loc] = flag;
- }
- //D0- Location to change.
- //D1- Combo Id to change to.
- //D2- Combo Cset to change to.
- //D3- Combo Type to change to.
- //D4- Placed flag to change to.
- //D5- Inherent flag to change to.
- void ChangeCombo(int loc, int comboid,int cset,int type, int flag, int inh_flag){
- if(comboid>-1)Screen->ComboD[loc] = comboid;
- if(cset>-1)Screen->ComboC[loc]= cset;
- if(type>-1)Screen->ComboT[loc] = type;
- if(flag>-1)Screen->ComboF[loc] = flag;
- if(inh_flag>-1)Screen->ComboI[loc] = inh_flag;
- }
- //A function to quickly change the size of an npc.
- //D0- Npc to adjust.
- //D1- Tile Width
- //D2- Tile Height
- void EnemyResize(npc enemy, int TileWidth, int TileHeight){
- enemy->Extend = 3;
- enemy->TileHeight = TileHeight;
- enemy->TileWidth = TileWidth;
- }
- //A function to adjust an enemy's hitbox size.
- //D0- Enemy to adjust
- //D1- HitWidth
- //D2- HitHeight
- //D3- HitXOffset
- //D4- HitYOffset
- void SetEnemyHitbox(npc enemy, int HitWidth, int HitHeight, int HitXOffset, int HitYOffset){
- enemy->HitHeight = HitHeight;
- enemy->HitWidth = HitWidth;
- enemy->HitXOffset = HitXOffset;
- enemy->HitYOffset = HitYOffset;
- }
- //Combines enemy reaize and enemy set hitbox functions.
- //D0- Enemy to set.
- //D1- Tile width. Hit Width will be this times 16.
- //D2- Tile Height. Hit height will be this times 16.
- void Enemy_ExtendSimple(npc enemy,int TileWidth,int TileHeight){
- EnemyResize(enemy,TileWidth,TileHeight);
- SetEnemyHitbox(enemy,TileWidth*16,TileHeight*16,0,0);
- }
- //Draw an inverted circle (fill whole screen except circle)
- //Also draws an enemy if it is invisible and ghosted.
- void InvertedLensCircle(int bitmapID, int layer, int x, int y, int radius, int scale, int fillcolor,npc ghost){
- Screen->SetRenderTarget(bitmapID); //Set the render target to the bitmap.
- Screen->Rectangle(layer, 0, 0, 256, 176, fillcolor, 1, 0, 0, 0, true, 128); //Cover the screen
- Screen->Circle(layer, x, y, radius, 0, scale, 0, 0, 0, true, 128); //Draw a transparent circle.
- if(ghost->Dir==DIR_UP||ghost->Dir==DIR_LEFTUP)Screen->DrawCombo(layer, ghost->X, ghost->Y, ghost->Misc[INVISIBLE_MISC_INDEX], ghost->TileWidth, ghost->TileHeight, ghost->Attributes[8], -1, -1, 0, 0, 0, -1, 0, true, OP_OPAQUE);
- else if(ghost->Dir==DIR_DOWN ||ghost->Dir== DIR_RIGHTDOWN)Screen->DrawCombo(layer, ghost->X, ghost->Y, ghost->Misc[INVISIBLE_MISC_INDEX]+1, ghost->TileWidth, ghost->TileHeight, ghost->Attributes[8], -1, -1, 0, 0, 0, -1, 0, true, OP_OPAQUE);
- else if(ghost->Dir==DIR_LEFT||ghost->Dir== DIR_LEFTDOWN)Screen->DrawCombo(layer, ghost->X, ghost->Y, ghost->Misc[INVISIBLE_MISC_INDEX]+2, ghost->TileWidth, ghost->TileHeight, ghost->Attributes[8], -1, -1, 0, 0, 0, -1, 0, true, OP_OPAQUE);
- else if(ghost->Dir==DIR_RIGHT||ghost->Dir== DIR_RIGHTUP)Screen->DrawCombo(layer, ghost->X, ghost->Y, ghost->Misc[INVISIBLE_MISC_INDEX]+3, ghost->TileWidth, ghost->TileHeight, ghost->Attributes[8], -1, -1, 0, 0, 0, -1, 0, true, OP_OPAQUE);
- Screen->SetRenderTarget(RT_SCREEN); //Set the render target back to the screen.
- Screen->DrawBitmap(layer, bitmapID, 0, 0, 256, 176, 0, 0, 256, 176, 0, true); //Draw the bitmap
- }
- //Draws scripted enemies with scripted lens.
- void Drawn_Enemy_Waitframe(ffc this, npc ghost){
- if(Ghost_Waitframe(this,ghost,false,false)){
- if(ghost->Misc[DRAWN_MISC_INDEX]==1)InvertedLensCircle(4, 6, CenterLinkX(), CenterLinkY(), LENS_RADIUS, 1, 15,ghost);
- }
- else if(!Ghost_Waitframe(this, ghost, false, false)){
- Ghost_DeathAnimation(this, ghost, 2);
- Quit();
- }
- }
- //Same as above, but multiple frames.
- void Drawn_Enemy_Waitframes(ffc this,npc ghost,int frames){
- for(;frames>0;frames--)
- Drawn_Enemy_Waitframe(this,ghost);
- }
- //Removes a specific eweapon type.
- void RemoveEWeaponType(int type){
- for(int i = 1;i<=Screen->NumEWeapons();i++){
- eweapon e = Screen->LoadEWeapon(i);
- if(e->ID==type)Remove(e);
- }
- }
- //Traces Current Dmap and Screen numbers.
- void TraceDMapScreen(){
- int DMAP[]= "The current DMap number is ";
- int SCREEN[]= "The current screen number is ";
- TraceS(DMAP);
- Trace(Game->GetCurDMap());
- TraceNL();
- TraceS(SCREEN);
- Trace(Game->GetCurDMapScreen());
- }
- //Calculates Average distance between two points, for a certain number of times.
- //D0- First X or Y.
- //D1- Second X or Y.
- //D2- Number of times to divide.
- int CalcXY(int XY1,int XY2, int NumberOfParts){
- return (Abs(XY1-XY2))/NumberOfParts;
- }
- int CalcX(int X1,int X2, int NumberOfParts){
- return (Abs(X1-X2))/NumberOfParts;
- }
- int CalcY(int Y1,int Y2, int NumberOfParts){
- return (Abs(Y1-Y2))/NumberOfParts;
- }
- //Returns the correct offset to be 'dist' pixels away from the front of a sprite facing in the direction 'dir'
- int FixedInFrontX(int dir, int dist) {
- int x = 0;
- if(dir == DIR_LEFT) x = -dist;
- else if(dir == DIR_RIGHT) x = dist;
- return x;
- }
- int FixedInFrontY(int dir, int dist){
- int y = 0;
- if(dir == DIR_UP) y = -dist;
- else if(dir == DIR_DOWN) y = 16+dist;
- return y;
- }
- int TrueFixedInFrontY(int dir, int dist){
- int y = 0;
- if(dir == DIR_UP) y = -dist;
- else if(dir == DIR_DOWN) y = dist;
- return y;
- }
- //Example LWeapons.zh global script
- global script LW_Active{
- void run(){
- while(true){
- //Various commands here.
- //Call LWeapon handling, for before waitdraw stuff.
- UpdateLWZH1();
- Waitdraw();
- //Call LWeapon Handling.
- UpdateLWZH2();
- //TraceLWeapons();
- Waitframe();
- }
- }
- }
- void TraceLWeapons(){
- for(int i= Screen->NumLWeapons();i>0;i--){
- lweapon wpn = Screen->LoadLWeapon(i);
- if((wpn->Misc[LW_ZH_I_FLAGS]&__LWFI_IS_LWZH_LWPN)==0)
- continue;
- int buffer []= "Flags are ";
- TraceS(buffer);
- Trace(wpn->Misc[LW_ZH_I_FLAGS]);
- int buffer2 []= "Lifespan is ";
- TraceS(buffer2);
- Trace(wpn->Misc[LW_ZH_I_LIFESPAN_ARG]);
- int buffer3 []= "Movement is ";
- TraceS(buffer3);
- Trace(wpn->Misc[LW_ZH_I_MOVEMENT]);
- int buffer4[]= "Death effect is ";
- TraceS(buffer4);
- Trace(wpn->Misc[LW_ZH_I_ON_DEATH]);
- }
- }
- //LW_ZH Life and Death Functions
- // Set an lweapon's lifespan
- void SetLWeaponLifespan(lweapon wpn, int type, int arg)
- {
- wpn->Misc[LW_ZH_I_LIFESPAN]=type;
- wpn->Misc[LW_ZH_I_LIFESPAN_ARG]=arg;
- //wpn->Misc[LW_ZH_I_FLAGS]|=__LWFI_IS_LWZH_LWPN;
- }
- // Set an lweapon to use a standard death effect
- void SetLWeaponDeathEffect(lweapon wpn, int type, int arg)
- {
- wpn->Misc[LW_ZH_I_ON_DEATH]=type;
- wpn->Misc[LW_ZH_I_ON_DEATH_ARG]=arg;
- //wpn->Misc[LW_ZH_I_FLAGS]|=__LWFI_IS_LWZH_LWPN;
- }
- //LWeapon Death Effects
- //This lweapon aims at an enemy.
- void __DoLWeaponDeathAimAtNPC(lweapon wpn){
- wpn->Step=0;
- wpn->Misc[LW_ZH_I_WORK]=0;
- wpn->Misc[LW_ZH_I_ON_DEATH_ARG]-=1;
- float targetAngle;
- npc target_enemy;
- if(wpn->Misc[LW_ZH_I_ON_DEATH_ARG]<=0){
- if(Screen->NumNPCs()>0){
- wpn->Misc[LW_ZH_I_WORK] = Rand(1,Screen->NumNPCs());
- for(int i=1;i<=Screen->NumNPCs();i++){
- target_enemy = Screen->LoadNPC(i);
- if(target_enemy->ID==wpn->Misc[LW_ZH_I_WORK] &&
- target_enemy->Defense[LWDefense(wpn->ID)]!=NPCDT_BLOCK||
- target_enemy->Defense[LWDefense(wpn->ID)]!=NPCDT_IGNORE)
- target_enemy->Misc[NPC_MISC_TARGET_NUMBER]=wpn->Misc[LW_ZH_I_WORK];
- }
- if(target_enemy->HP<=0)wpn->Misc[LW_ZH_I_WORK]=0;
- if(target_enemy->Misc[NPC_MISC_TARGET_NUMBER]==wpn->Misc[LW_ZH_I_WORK])
- targetAngle=RadianAngle(wpn->X, wpn->Y, target_enemy->X, target_enemy->Y);
- wpn->Angle=targetAngle;
- SetLWeaponDir(wpn);
- wpn->Step=300;
- wpn->Misc[LW_ZH_I_ON_DEATH]=0;
- }
- else
- wpn->DeadState = 0;
- }
- // Spin while waiting
- wpn->Angle+=0.3;
- return;
- // Pick a direction based on the counter
- int dir=wpn->Misc[LW_ZH_I_ON_DEATH_ARG]&110b;
- if(dir==110b)
- SetLWeaponRotation(wpn, DIR_UP);
- else if(dir==100b)
- SetLWeaponRotation(wpn, DIR_RIGHT);
- else if(dir==010b)
- SetLWeaponRotation(wpn, DIR_DOWN);
- else
- SetLWeaponRotation(wpn, DIR_LEFT);
- }
- // Some of these could probably be combined...
- //This lweapon explodes in a bomb blast.
- void __DoLWeaponDeathExplode(lweapon wpn)
- {
- FireNonAngularLWeapon(LW_BOMBBLAST, CenterX(wpn)-8, CenterY(wpn)-8, wpn->Dir, 0, wpn->Misc[LW_ZH_I_ON_DEATH_ARG], -1, 0, LWF_PIERCES_ENEMIES);
- wpn->DeadState=0;
- }
- //This lweapon explodes in a super bomb blast.
- void __DoLWeaponDeathSBombExplode(lweapon wpn)
- {
- FireNonAngularLWeapon(LW_SBOMBBLAST, CenterX(wpn)-8, CenterY(wpn)-8, wpn->Dir, 0, wpn->Misc[LW_ZH_I_ON_DEATH_ARG], -1, 0, LWF_PIERCES_ENEMIES);
- wpn->DeadState=0;
- }
- //This lweapon produces 4 horizontal and vertical lweapons.
- void __DoLWeaponDeath4FireballsHV(lweapon wpn)
- {
- for(int i=0; i<270; i+=90)
- FireLWeapon(LW_SCRIPT1, CenterX(wpn)-8, CenterY(wpn)-8, DegtoRad(i), 200, wpn->Damage/2, wpn->Misc[LW_ZH_I_ON_DEATH_ARG], 0, 0);
- wpn->DeadState=0;
- }
- //This lweapon produces 4 diagonal lweapons.
- void __DoLWeaponDeath4FireballsDiag(lweapon wpn)
- {
- for(int i=45; i<315; i+=90)
- FireLWeapon(LW_SCRIPT1, CenterX(wpn)-8, CenterY(wpn)-8, DegtoRad(i), 200, wpn->Damage/2, wpn->Misc[LW_ZH_I_ON_DEATH_ARG], 0, 0);
- wpn->DeadState=0;
- }
- //This lweapon produces 4 random lweapons.
- void __DoLWeaponDeath4FireballsRand(lweapon wpn)
- {
- if(Rand(2)==0)
- {
- for(int i=0; i<270; i+=90)
- FireLWeapon(LW_SCRIPT1, CenterX(wpn)-8, CenterY(wpn)-8, DegtoRad(i), 200, wpn->Damage/2, wpn->Misc[LW_ZH_I_ON_DEATH_ARG], 0, 0);
- }
- else
- {
- for(int i=45; i<315; i+=90)
- lweapon new = FireNonAngularLWeapon(LW_SCRIPT1, CenterX(wpn)-8, CenterY(wpn)-8, DegtoRad(i), 200, wpn->Damage/2, wpn->Misc[LW_ZH_I_ON_DEATH_ARG], 0, 0);
- }
- wpn->DeadState=0;
- }
- //This lweapon makes lweapons in all 8 directions.
- void __DoLWeaponDeath8Fireballs(lweapon wpn)
- {
- for(int i=0; i<315; i+=45)
- FireLWeapon(LW_SCRIPT1, CenterX(wpn)-8, CenterY(wpn)-8, DegtoRad(i), 200, wpn->Damage/2, wpn->Misc[LW_ZH_I_ON_DEATH_ARG], 0, 0);
- wpn->DeadState=0;
- }
- //This lweapon creates an lweapon that freezes (stuns) enemies when it dies..
- void __DoLWeaponDeathFreeze(lweapon wpn){
- lweapon new = FireLWeapon(LW_SCRIPT1, wpn->X, wpn->Y, 0, 0, 0, wpn->Misc[LW_ZH_I_ON_DEATH_ARG], SFX_ICE, LWF_STUNS_ENEMIES|LWF_PIERCES_ENEMIES);
- SetLWeaponLifespan(new,LWL_TIMER,wpn->Misc[LW_ZH_I_LIFESPAN_ARG]);
- wpn->DeadState=0;
- }
- //Handles lweapon that creates a projectile on death.
- //void __DoLWeaponDeathLW(lweapon wpn){
- //if(wpn->Misc[LW_ZH_I_ON_DEATH_ARG]!=LWDT_FIRE_ROD &&
- //wpn->Misc[LW_ZH_I_ON_DEATH_ARG]!=LWDT_ICE_ROD &&
- //wpn->Misc[LW_ZH_I_ON_DEATH_ARG]!=LWDT_POT &&
- //wpn->Misc[LW_ZH_I_ON_DEATH_ARG]!=LWDT_BUSH &&
- //wpn->Misc[LW_ZH_I_ON_DEATH_ARG]!=LWDT_ROCK &&
- //wpn->Misc[LW_ZH_I_ON_DEATH_ARG]<=40)
- //FireLWeapon(wpn->Misc[LW_ZH_I_ON_DEATH_ARG], wpn->X+InFrontX(wpn->Dir,2),
- //wpn->Y+InFrontY(wpn->Dir,2), RadianAngleDir8(wpn->Dir), 200,
- //wpn->Damage/2, wpn->Misc[LW_ZH_I_WORK], wpn->Misc[LW_ZH_I_FX], wpn->Misc[LW_ZH_I_FLAGS]);
- //else{
- //if(wpn->Misc[LW_ZH_I_ON_DEATH_ARG]==LWDT_FIRE_ROD){
- //if(!Link->Item[I_BOOK])Link->Item[I_BOOK]= true;
- //lweapon new = FireLWeapon(LW_MAGIC, wpn->X+InFrontX(wpn->Dir,2),
- //wpn->Y+InFrontY(wpn->Dir,2), RadianAngleDir8(wpn->Dir), 200,
- //wpn->Damage/2, wpn->Misc[LW_ZH_I_WORK], SFX_WAND, wpn->Misc[LW_ZH_I_FLAGS]);
- //SetLWeaponLifespan(new,LWL_EDGE,I_BOOK);
- //lweapon new1 = FireLWeapon(LW_SCRIPT1, wpn->X+InFrontX(wpn->Dir,2),
- //wpn->Y+InFrontY(wpn->Dir,2), RadianAngleDir8(wpn->Dir), 200,
- //wpn->Damage/2, wpn->Misc[LW_ZH_I_WORK], 0, wpn->Misc[LW_ZH_I_FLAGS]);
- //SetLWeaponMovement(new1,LWM_FOLLOW,LW_MAGIC,0);
- //SetLWeaponDeathEffect(new1,LWD_FIRE,SPR_WAND_FIRE);
- //new1->Misc[LW_ZH_I_FLAGS_2]|=LWF_LEVEL_1|LWF_LEVEL_2|LWF_LEVEL_3;
- //}
- //else if(wpn->Misc[LW_ZH_I_ON_DEATH_ARG]==LWDT_ICE_ROD){
- //lweapon new = FireLWeapon(LW_MAGIC, wpn->X+InFrontX(wpn->Dir,2),
- //wpn->Y+InFrontY(wpn->Dir,2), RadianAngleDir8(wpn->Dir), 200,
- //wpn->Damage/2, wpn->Misc[LW_ZH_I_WORK], SFX_WAND, wpn->Misc[LW_ZH_I_FLAGS]);
- //SetLWeaponLifespan(new,LWL_EDGE,0);
- //lweapon new1 = FireLWeapon(LW_SCRIPT1, wpn->X+InFrontX(wpn->Dir,2),
- //wpn->Y+InFrontY(wpn->Dir,2), RadianAngleDir8(wpn->Dir), 200,
- //wpn->Damage/2, wpn->Misc[LW_ZH_I_WORK], 0, wpn->Misc[LW_ZH_I_FLAGS]|LWF_FREEZE);
- //SetLWeaponMovement(new1,LWM_FOLLOW,LW_MAGIC,0);
- //SetLWeaponDeathEffect(new1,LWD_LW,LWDT_ICE_BLOCK);
- //}
- //else if(wpn->Misc[LW_ZH_I_ON_DEATH_ARG]==LWDT_POT
- //||wpn->Misc[LW_ZH_I_ON_DEATH_ARG]==LWDT_BUSH
- //||wpn->Misc[LW_ZH_I_ON_DEATH_ARG]==LWDT_ROCK
- //||wpn->Misc[LW_ZH_I_ON_DEATH_ARG]==LWDT_THR_SOM
- //||wpn->Misc[LW_ZH_I_ON_DEATH_ARG]==LWDT_GRENADE){
- //lweapon new;
- //if(wpn->Misc[LW_ZH_I_ON_DEATH_ARG]==LWDT_POT)
- //new= FireLWeapon(LW_SCRIPT1,wpn->X,wpn->Y,RadianAngleDir8(Link->Dir),200,
- //wpn->Damage/2,SPR_POT,SFX_THROW,wpn->Misc[LW_ZH_I_FLAGS]);
- //else if(wpn->Misc[LW_ZH_I_ON_DEATH_ARG]==LWDT_BUSH)
- //new = FireLWeapon(LW_SCRIPT1,wpn->X,wpn->Y,RadianAngleDir8(Link->Dir),200,
- //wpn->Damage/2,SPR_BUSH,SFX_THROW,wpn->Misc[LW_ZH_I_FLAGS]);
- //else if(wpn->Misc[LW_ZH_I_ON_DEATH_ARG]==LWDT_ROCK)
- //new = FireLWeapon(LW_SCRIPT1,wpn->X,wpn->Y,RadianAngleDir8(Link->Dir),200,
- //wpn->Damage/2,SPR_ROCK,SFX_THROW,wpn->Misc[LW_ZH_I_FLAGS]);
- //else if(wpn->Misc[LW_ZH_I_ON_DEATH_ARG]==LWDT_THR_SOM){
- //new = FireLWeapon(LW_SCRIPT1,wpn->X,wpn->Y,RadianAngleDir8(Link->Dir),200,
- //wpn->Damage/2,SPR_SOMARIA_BLOCK,0,wpn->Misc[LW_ZH_I_FLAGS]);
- //SetLWeaponLifespan(new,LWL_ITEM_PRESS,I_CSOMARIA);
- //SetLWeaponMovement(new,LWM_THROW,0,LWMF_REST);
- //SetLWeaponDeathEffect(new,LWD_4_FIREBALLS_DIAG,SPR_SOMARIA_FIRE);
- //}
- //else if(wpn->Misc[LW_ZH_I_ON_DEATH_ARG]==LWDT_GRENADE){
- //new = FireLWeapon(LW_BOMB,wpn->X,wpn->Y,RadianAngleDir8(Link->Dir),200,
- //wpn->Damage/2,SPR_SOMARIA_BLOCK,0,wpn->Misc[LW_ZH_I_FLAGS]);
- //SetLWeaponDeathEffect(new,LWD_EXPLODE,new->Damage);
- //}
- //if(new->Misc[LW_ZH_I_MOVEMENT]==0)
- //SetLWeaponMovement(new,LWM_THROW,0,LWMF_DIE);
- //}
- //else if(wpn->Misc[LW_ZH_I_ON_DEATH_ARG]==LWDT_SOMARIA){
- //lweapon new = FireLWeapon(LW_SCRIPT10,wpn->X,wpn->Y,RadianAngleDir8(wpn->Dir),0,
- //wpn->Damage/2,SPR_SOMARIA_BLOCK,0,wpn->Misc[LW_ZH_I_FLAGS]);
- //SetLWeaponMovement(new,LWM_REST,LWM_R_SOMARIA,0);
- //SetLWeaponDeathEffect(new,LWL_ITEM_PRESS,I_CSOMARIA);
- //}
- //else if(wpn->Misc[LW_ZH_I_ON_DEATH_ARG]==LWDT_ICE_BLOCK)
- //lweapon new = FireLWeapon(LW_SCRIPT1,wpn->X,wpn->Y,RadianAngleDir8(wpn->Dir),0,
- //wpn->Damage/2,SPR_ICE_BLOCK,0,wpn->Misc[LW_ZH_I_FLAGS]);
- //}
- //wpn->DeadState=0;
- //}
- //Handles lweapon that throws an object on death.
- //void __DoLweaponDeathThrow(lweapon wpn){
- //if((wpn->Misc[LW_ZH_I_ON_DEATH_ARG]&LW_THR_POT)!=0)
- //if((wpn->Misc[LW_ZH_I_ON_DEATH_ARG]&LW_THR_BUSH)!=0)
- //if((wpn->Misc[LW_ZH_I_ON_DEATH_ARG]&LW_THR_SOM)!=0)
- //FireLWeapon(LW_SCRIPT1,wpn->X,wpn->Y,DegtoRad(270),200,
- //wpn->Damage/2,SPR_SOMARIA,SFX_THROW,wpn->Misc{LW_ZH_I_FLAGS])
- //if((wpn->Misc[LW_ZH_I_ON_DEATH_ARG]&LW_THR_BOMB)!=0)
- //FireLWeapon(LW_BOMB,wpn->X,wpn->Y,DegtoRad(270),200,
- //wpn->Damage/2,SPR_BOMB,SFX_THROW,wpn->Misc{LW_ZH_I_FLAGS])
- //SetLWeaponMovement(FireLWeapon,LWM_THROW,0);
- //wpn->DeadState=0;
- //}
- //Same as above... Redundant?
- //void __DoLWeaponDeath4FiresHV(lweapon wpn)
- //{
- //for(int i=0; i<4; i++)
- //FireNonAngularLWeapon(LW_SCRIPT1, CenterX(wpn)-8, CenterY(wpn)-8, i, 100, wpn->Damage/2, wpn->Misc[LW_ZH_I_ON_DEATH_ARG], 0, 0);
- //Game->PlaySound(SFX_FIRE); // Only play sound once
- //wpn->DeadState=0;
- //}
- void __DoLWeaponDeath4FiresDiag(lweapon wpn)
- {
- for(int i=45; i<315; i+=90)
- FireLWeapon(LW_SCRIPT1, CenterX(wpn)-8, CenterY(wpn)-8, DegtoRad(i), 71, wpn->Damage/2, wpn->Misc[LW_ZH_I_ON_DEATH_ARG], 0, 0);
- Game->PlaySound(SFX_FIRE);
- wpn->DeadState=0;
- }
- void __DoLWeaponDeath4FiresRand(lweapon wpn)
- {
- if(Rand(2)==0)
- {
- for(int i=0; i<270; i+=90)
- FireNonAngularLWeapon(LW_SCRIPT1, CenterX(wpn)-8, CenterY(wpn)-8, DegtoRad(i), 100, wpn->Damage/2, wpn->Misc[LW_ZH_I_ON_DEATH_ARG], 0, 0);
- }
- else
- {
- for(int i=45; i<315; i+=90)
- FireLWeapon(LW_SCRIPT1, CenterX(wpn)-8, CenterY(wpn)-8, DegtoRad(i), 71, wpn->Damage/2, wpn->Misc[LW_ZH_I_ON_DEATH_ARG], 0, 0);
- }
- Game->PlaySound(SFX_FIRE);
- wpn->DeadState=0;
- }
- void __DoLWeaponDeath8Fires(lweapon wpn)
- {
- for(int i=0; i<270; i+=90)
- FireLWeapon(LW_SCRIPT1, CenterX(wpn)-8, CenterY(wpn)-8, DegtoRad(i), 100, wpn->Damage/2, wpn->Misc[LW_ZH_I_ON_DEATH_ARG], 0, 0);
- for(int i=45; i<315; i+=90)
- FireNonAngularLWeapon(LW_SCRIPT1, CenterX(wpn)-8, CenterY(wpn)-8, DegtoRad(i), 71, wpn->Damage/2, wpn->Misc[LW_ZH_I_ON_DEATH_ARG], 0, 0);
- Game->PlaySound(SFX_FIRE);
- wpn->DeadState=0;
- }
- void __DoLWeaponDeathSingleFire(lweapon wpn)
- {
- FireLWeapon(LW_FIRE, CenterX(wpn)-8, CenterY(wpn)-8, wpn->Dir, 0, wpn->Damage/2, wpn->Misc[LW_ZH_I_ON_DEATH_ARG], 0, 0);
- Game->PlaySound(SFX_FIRE);
- wpn->DeadState=0;
- }
- //Causes lweapon to home on given point. If "accel" boolean is set to TRUE, the function affects FFC`s
- //acceleration, instead of velocity.
- void __DoLWeaponDeathReturn(lweapon wpn){
- //This is a boomerang.
- if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_BRANG){
- //Calculate the X and Y center of the weapon.
- int fx = CenterX (wpn);
- int fy = CenterY (wpn);
- //Calculate angle from Link to Lweapon
- int hdir = Angle(fx, fy, CenterLinkX(),CenterLinkY());
- //Move weapon along that path towards Link.
- wpn->Misc[LW_ZH_I_XPOS]= wpn->X+ ((wpn->Step/100)*Cos(hdir));
- wpn->Misc[LW_ZH_I_YPOS]= wpn->Y+ ((wpn->Step/100)*Sin(hdir));
- wpn->X=wpn->Misc[LW_ZH_I_XPOS];
- wpn->Y=wpn->Misc[LW_ZH_I_YPOS];
- //Set the weapon to pierce if it doesn't already.
- if((wpn->Misc[LW_ZH_I_FLAGS]&LWF_PIERCES_ENEMIES)==0)
- wpn->Misc[LW_ZH_I_FLAGS]|=LWF_PIERCES_ENEMIES;
- //Set it not to collide with enemies.
- wpn->Misc[LW_ZH_I_FLAGS_2]|=LWF_NO_COLLISION;
- //This lweapon has reached Link. Kill it.
- if(LinkCollision(wpn))
- wpn->DeadState = 0;
- }
- else if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_HOOKSHOT){
- wpn->Misc[LW_ZH_I_FLAGS_2]|=LWF_NO_COLLISION;
- if(wpn->Dir==DIR_LEFT||wpn->Dir==DIR_RIGHT){
- if(Abs(wpn->X-Link->X+8)>0){
- if(wpn->Dir==DIR_LEFT)wpn->Misc[LW_ZH_I_XPOS]++;
- else if(wpn->Dir==DIR_RIGHT)wpn->Misc[LW_ZH_I_XPOS]--;
- for(int i =0;i<=wpn->Misc[LW_ZH_I_WORK];i++){
- lweapon particle = FireScriptedLWeapon(LW_SCRIPT2, Calc(wpn->X,Link->X+8,wpn->Misc[LW_ZH_I_MOVEMENT_ARG]), wpn->Y, wpn->Misc[LW_ZH_I_MOVEMENT_ARG2], 0, 0,LWF_NO_COLLISION);
- SetLWeaponLifespan(particle,LWL_TIMER,1);
- SetLWeaponDeathEffect(particle,LWD_VANISH,0);
- }
- NoAction();
- }
- else{
- KillLWeapon(wpn);
- Link->CollDetection = true;
- RemoveLWeaponType(LW_SCRIPT2);
- }
- }
- else{
- if(Abs(wpn->Y-Link->Y+8)>0){
- if(wpn->Dir==DIR_UP)wpn->Misc[LW_ZH_I_YPOS]++;
- else if(wpn->Dir==DIR_DOWN)wpn->Misc[LW_ZH_I_YPOS]--;
- for(int i =0;i<=wpn->Misc[LW_ZH_I_MOVEMENT_ARG];i++){
- lweapon particle = FireScriptedLWeapon(LW_SCRIPT2, wpn->X, Calc(wpn->Y,Link->Y+8,wpn->Misc[LW_ZH_I_MOVEMENT_ARG]), wpn->Misc[LW_ZH_I_MOVEMENT_ARG2], 0, 0,LWF_NO_COLLISION);
- SetLWeaponLifespan(particle,LWL_TIMER,1);
- SetLWeaponDeathEffect(particle,LWD_VANISH,0);
- }
- NoAction();
- }
- else{
- KillLWeapon(wpn);
- Link->CollDetection = true;
- RemoveLWeaponType(LW_SCRIPT2);
- }
- }
- }
- SetLWeaponDir(wpn);
- }
- //LW_ZH Movement functions
- //Set up an lweapon's movement.
- //D0- Lweapon to alter.
- //D1= Type of movement.
- //D2- Movement argument one.
- //D3- Movement argument two.
- // Set an lweapon's movement type
- void SetLWeaponMovement(lweapon wpn, int type, int arg, int arg2)
- {
- wpn->Misc[LW_ZH_I_XPOS]= wpn->X;
- wpn->Misc[LW_ZH_I_YPOS]= wpn->Y;
- wpn->Misc[LW_ZH_I_WORK]=0;
- wpn->Misc[LW_ZH_I_MOVEMENT]=type;
- wpn->Misc[LW_ZH_I_MOVEMENT_ARG]=arg;
- wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]=arg2;
- //wpn->Misc[LW_ZH_I_FLAGS]|=__LWFI_IS_LWZH_LWPN;
- if(type!=LWM_FALL)wpn->Angular = true;
- if(type==LWM_THROW){
- wpn->Misc[LW_ZH_I_WORK_2]=wpn->Z;
- // Necessary upward velocity to reach Link for thrown weapons
- if(arg<=0){
- if(Screen->NumNPCs()>0){
- if(wpn->Misc[LW_ZH_I_WORK]==0)wpn->Misc[LW_ZH_I_WORK] = Rand(1,Screen->NumNPCs());
- npc target_enemy = Screen->LoadNPC(wpn->Misc[LW_ZH_I_WORK]);
- target_enemy->Misc[NPC_MISC_TARGET_NUMBER]=wpn->Misc[LW_ZH_I_WORK];
- if(target_enemy->HP<=0)wpn->Misc[LW_ZH_I_WORK]=0;
- if(target_enemy->Misc[NPC_MISC_TARGET_NUMBER]==wpn->Misc[LW_ZH_I_WORK]){
- float time=Distance(wpn->X, wpn->Y, target_enemy->X,target_enemy->Y)/(wpn->Step/100);
- wpn->Misc[LW_ZH_I_MOVEMENT_ARG]=GH_GRAVITY*time/2;
- }
- }
- }
- }
- else if(type==LWM_FALL){
- wpn->Z=arg;
- wpn->Misc[LW_ZH_I_WORK_2]=arg;
- wpn->Misc[LW_ZH_I_WORK]=GH_GRAVITY;
- }
- else if(type==LWM_CIRCLE)
- wpn->Misc[LW_ZH_I_WORK]= RadtoDeg(wpn->Angle);
- }
- //Other Lweapons stuff
- void SetLWeaponSFX(lweapon wpn, int type, int arg){
- wpn->Misc[LW_ZH_I_FX]= type;
- wpn->Misc[LW_ZH_I_WORK_2]= arg;
- }
- //Set up the lweapon and ffc to track one another.
- void SetLWeaponScript(lweapon wpn, int script_num, int Misc_Num){
- wpn->Misc[LW_ZH_I_WORK_3]= Misc_Num;//Save a specific number.
- //Send that number to the ffc.
- int Args[8]= {Misc_Num};
- RunFFCScript(script_num,Args);
- }
- //Returns the right index in Npc->Defense for a lweapon type.
- int LWDefense(int type){
- if(type==LW_ARROW)return NPCD_ARROW;
- else if(type == LW_BEAM)return NPCD_BEAM;
- else if(type == LW_BRANG)return NPCD_BRANG;
- else if(type == LW_BOMBBLAST)return NPCD_BOMB;
- else if(type == LW_SBOMBBLAST)return NPCD_SBOMB;
- else if(type == LW_FIRE)return NPCD_FIRE;
- else if(type == LW_MAGIC)return NPCD_MAGIC;
- else if(Between(type,LW_SCRIPT1,LW_SCRIPT10))return NPCD_SCRIPT;
- }
- //Calculate average distance.
- //D0- First coordinate
- //D1- Second coordinate
- //D2- Divisor
- int Calc(int x1, int x2, int numParts){
- return (Abs(x1-x2))/numParts;
- }
- //Returns what combo types block this LWeapon
- int LWBlockType(lweapon wpn){
- if(wpn->ID==LW_MAGIC)return CT_BLOCKMAGIC;
- else if(wpn->ID==LW_BEAM)return CT_BLOCKSWORDBEAM;
- else if(wpn->ID==LW_ARROW){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_1)!=0)return CT_BLOCKARROW1;
- else if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_2)!=0)return CT_BLOCKARROW2;
- else
- return CT_BLOCKARROW3;
- }
- else if(wpn->ID==LW_BRANG){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_1)!=0) return CT_BLOCKBRANG1;
- else if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_2)!=0)return CT_BLOCKBRANG2;
- else
- return CT_BLOCKBRANG3;
- }
- else
- return CT_BLOCKALL;
- }
- //Returns the combo type that blocks an lweapon. Uses for dual lweapons.
- int LWBlockType(int wpn_id,lweapon wpn){
- if(wpn_id==LW_MAGIC)return CT_BLOCKMAGIC;
- else if(wpn_id==LW_BEAM)return CT_BLOCKSWORDBEAM;
- else if(wpn_id==LW_ARROW){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_1)!=0)return CT_BLOCKARROW1;
- else if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_2)!=0)return CT_BLOCKARROW2;
- else
- return CT_BLOCKARROW3;
- }
- else
- return CT_BLOCKALL;
- }
- //Returns sprite for a combo type.
- //int GetComboSprite(int type){
- //if(type==CT_SLASH||type==CT_SLASHNEXT||type==CT_SLASHNEXTITEM)return SPR_POT_BREAK;
- //else if(type== CT_FLOWERS)return SPR_FLOWER_CUT;
- //else if(type==CT_BUSH||type==CT_BUSHNEXT)return SPR_BUSH_CUT;
- //else if(type==CT_TALLGRASS||type==CT_TALLGRASSNEXT)return SPR_GRASS_CUT;
- //}
- //Returns sound made by slashed combo.
- //int GetComboSound(int type){
- //if(type==CT_SLASH||type==CT_SLASHNEXT||type==CT_SLASHNEXTITEM)return SFX_POT_BREAK;
- //else
- //return SFX_GRASSCUT;
- //}
- //Creates a sprite at a location.
- //D0- Sprite to create.
- //D1- X location
- //D2- Y location
- //int CreateGraphicAt(int sprite, int x, int y){
- //eweapon e = Screen->CreateEWeapon(EW_SCRIPT1);
- //e->HitXOffset = 500;
- //e->UseSprite(sprite);
- //e->DeadState = e->NumFrames*e->ASpeed;
- //e->X = x;
- //e->Y = y;
- //return e->DeadState;
- //}
- //Find X center of a lweapon.
- int CenterWpnX(lweapon wpn){
- int x = wpn->X+wpn->HitXOffset;
- if(wpn->HitWidth>16)
- x+=(wpn->HitWidth/2);
- else
- x+=8;
- return x;
- }
- //Find Y center of a lweapon.
- int CenterWpnY(lweapon wpn){
- int y = wpn->Y+wpn->HitYOffset;
- if(wpn->HitWidth>16)
- y+=(wpn->HitHeight/2);
- else
- y+=8;
- return y;
- }
- //Returns combo type in front of Link.
- int ComboLocInFront(){
- if(Link->Dir==DIR_UP)
- return ComboAt(Link->X,Link->Y-8);
- else if(Link->Dir==DIR_DOWN)
- return ComboAt(Link->X,Link->Y+16);
- else if(Link->Dir==DIR_LEFT)
- return ComboAt(Link->X-16,Link->Y+8);
- else if(Link->Dir==DIR_RIGHT)
- return ComboAt(Link->X+16,Link->Y+8);
- }
- //Returns combo type in front of Link.
- int ComboTypeInFront(){
- if(Link->Dir==DIR_UP)
- return Screen->ComboT[ComboAt(Link->X,Link->Y-8)];
- else if(Link->Dir==DIR_DOWN)
- return Screen->ComboT[ComboAt(Link->X,Link->Y+16)];
- else if(Link->Dir==DIR_LEFT)
- return Screen->ComboT[ComboAt(Link->X-16,Link->Y+8)];
- else if(Link->Dir==DIR_RIGHT)
- return Screen->ComboT[ComboAt(Link->X+16,Link->Y+8)];
- }
- //Counts number of Lweapons with a certain flag set.
- int NumMiscLWeapons(int index,int flag){
- int ret;
- for(int i = Screen->NumLWeapons();i>0;i--){
- lweapon wpn = Screen->LoadLWeapon(i);
- if((wpn->Misc[index]&flag)!=0)
- ret++;
- }
- return ret;
- }
- int NumMoveLWeapons(int type){
- int ret;
- for(int i = Screen->NumLWeapons();i>0;i--){
- lweapon wpn = Screen->LoadLWeapon(i);
- if(wpn->Misc[LW_ZH_I_MOVEMENT]==type)
- ret++;
- }
- return ret;
- }
- //Combo Type at weapon location.
- int ComboTAtWpn(lweapon wpn){
- return Screen->ComboT[ComboAt(CenterWpnX(wpn),CenterWpnY(wpn))];
- }
- //Returnss an lweapon with a particular movement type.
- lweapon FindLWeaponMove(int type){
- for(int i = Screen->NumLWeapons();i>0;i--){
- lweapon wpn = Screen->LoadLWeapon(i);
- if(wpn->Misc[LW_ZH_I_MOVEMENT]==type)
- return wpn;
- }
- }
- bool ComboFIAtWpn(lweapon wpn,int flag){
- return (ComboFI(ComboAt(wpn->X + 3, wpn->Y + 3),flag)
- || ComboFI(ComboAt(wpn->X + 8, wpn->Y + 3),flag)
- || ComboFI(ComboAt(wpn->X + 13, wpn->Y + 3),flag)
- || ComboFI(ComboAt(wpn->X + 3, wpn->Y + 8),flag)
- || ComboFI(ComboAt(wpn->X + 8, wpn->Y + 8),flag)
- || ComboFI(ComboAt(wpn->X + 13, wpn->Y + 8),flag)
- || ComboFI(ComboAt(wpn->X + 3,wpn->Y + 13),flag)
- || ComboFI(ComboAt(wpn->X + 8, wpn->Y + 13),flag)
- || ComboFI(ComboAt(wpn->X + 13, wpn->Y + 13),flag));
- }
- bool ComboFITAtWpn(lweapon wpn,int flag,int type){
- return (ComboFIT(ComboAt(wpn->X + 3, wpn->Y + 3),flag,type)
- || ComboFIT(ComboAt(wpn->X + 8, wpn->Y + 3),flag,type)
- || ComboFIT(ComboAt(wpn->X + 13, wpn->Y + 3),flag,type)
- || ComboFIT(ComboAt(wpn->X + 3, wpn->Y + 8),flag,type)
- || ComboFIT(ComboAt(wpn->X + 8, wpn->Y + 8),flag,type)
- || ComboFIT(ComboAt(wpn->X + 13, wpn->Y + 8),flag,type)
- || ComboFIT(ComboAt(wpn->X + 3,wpn->Y + 13),flag,type)
- || ComboFIT(ComboAt(wpn->X + 8, wpn->Y + 13),flag,type)
- || ComboFIT(ComboAt(wpn->X + 13, wpn->Y + 13),flag,type));
- }
- bool ComboTAtWpn(lweapon wpn,int type){
- return ((Screen->ComboT[ComboAt(wpn->X + 3, wpn->Y + 3)]==type)
- || (Screen->ComboT[ComboAt(wpn->X + 8, wpn->Y + 3)]==type)
- || (Screen->ComboT[ComboAt(wpn->X + 13, wpn->Y + 3)]==type)
- || (Screen->ComboT[ComboAt(wpn->X + 3, wpn->Y + 8)]==type)
- || (Screen->ComboT[ComboAt(wpn->X + 8, wpn->Y + 8)]==type)
- || (Screen->ComboT[ComboAt(wpn->X + 13, wpn->Y + 8)]==type)
- || (Screen->ComboT[ComboAt(wpn->X + 3,wpn->Y + 13)]==type)
- || (Screen->ComboT[ComboAt(wpn->X + 8, wpn->Y + 13)]==type)
- || (Screen->ComboT[ComboAt(wpn->X + 13, wpn->Y + 13)]==type));
- }
- //Example Item Scripts.
- item script Firebar{
- void run(int dummy, int Damage, int sprite){
- int i;
- lweapon fireball;
- for(i=1;i<=7;i++){
- fireball= FireLWeapon(LW_SCRIPT1, Link->X + 8,
- Link->Y+8, __DirtoRad(Link->Dir),
- 100, Damage, sprite, SFX_SWORD, 0);
- SetLWeaponLifespan(fireball,LWL_TIMER,180);
- SetLWeaponMovement(fireball,LWM_CIRCLE,(16*i),10);
- SetLWeaponDeathEffect(fireball,LWD_AIM_AT_NPC,10);
- }
- }
- }
- item script OmniByrna{
- void run(int dummy, int Damage, int sprite){
- lweapon fireball1;
- lweapon fireball2;
- lweapon fireball3;
- lweapon fireball4;
- if(NumLWeaponsOf(LW_SCRIPT1)==0){
- fireball1= FireLWeapon(LW_SCRIPT1, Link->X + 8*Cos(0),
- Link->Y+ 8*Sin(0), DegtoRad(0),
- 100, Damage, sprite, SFX_SWORD, LWF_LINK_NO_COLL);
- SetLWeaponLifespan(fireball1,LWL_MP_COST,5);
- SetLWeaponMovement(fireball1,LWM_CIRCLE,32,10);
- SetLWeaponDeathEffect(fireball1,LWD_VANISH,0);
- fireball2= FireLWeapon(LW_SCRIPT1, Link->X + 8*Cos(90),
- Link->Y+ 8*Sin(90), DegtoRad(90),
- 100, Damage, sprite, SFX_SWORD, LWF_LINK_NO_COLL);
- SetLWeaponLifespan(fireball2,LWL_MP_COST,-1);
- SetLWeaponMovement(fireball2,LWM_CIRCLE,32,10);
- SetLWeaponDeathEffect(fireball2,LWD_VANISH,0);
- fireball3= FireLWeapon(LW_SCRIPT1, Link->X + 8*Cos(180),
- Link->Y+ 8*Sin(180), DegtoRad(180),
- 100, Damage, sprite, SFX_SWORD, LWF_LINK_NO_COLL);
- SetLWeaponLifespan(fireball3,LWL_MP_COST,-1);
- SetLWeaponMovement(fireball3,LWM_CIRCLE,32,10);
- SetLWeaponDeathEffect(fireball3,LWD_VANISH,0);
- fireball4= FireLWeapon(LW_SCRIPT1, Link->X + 8*Cos(270),
- Link->Y+ 8*Sin(270), DegtoRad(270),
- 100, Damage, sprite, SFX_SWORD, LWF_LINK_NO_COLL);
- SetLWeaponLifespan(fireball4,LWL_MP_COST,-1);
- SetLWeaponMovement(fireball4,LWM_CIRCLE,32,10);
- SetLWeaponDeathEffect(fireball4,LWD_VANISH,0);
- }
- else{
- if(fireball1->isValid())
- KillLWeapon(fireball1);
- if(fireball2->isValid())
- KillLWeapon(fireball2);
- if(fireball3->isValid())
- KillLWeapon(fireball3);
- if(fireball4->isValid())
- KillLWeapon(fireball4);
- }
- }
- }
- item script Grenade{
- void run(int dummy, int Damage, int sprite){
- if(Game->Counter[CR_BOMBS]>0){
- lweapon fireball;
- fireball= FireLWeapon(LW_SCRIPT1, Link->X+8, Link->Y, __DirtoRad(Link->Dir),
- 100, Damage, sprite, SFX_THROW, 0);
- SetLWeaponMovement(fireball,LWM_THROW,3,LWMF_DIE);
- SetLWeaponDeathEffect(fireball,LWD_EXPLODE,8);
- Link->Action = LA_ATTACKING;
- Game->Counter[CR_BOMBS]--;
- }
- }
- }
- item script Boulder{
- void run(int dummy, int Damage, int sprite){
- if(NumLWeaponsOf(LW_SCRIPT1)==0){
- lweapon fireball;
- fireball= FireBigLWeapon(LW_SCRIPT1, Link->X+8, Link->Y, __DirtoRad(Link->Dir),
- 100, Damage, sprite, SFX_THROW, 0,2,2);
- SetLWeaponMovement(fireball,LWM_THROW,3,LWMF_DIE);
- SetLWeaponDeathEffect(fireball,LWD_4_FIREBALLS_RANDOM,99);
- Link->Action = LA_ATTACKING;
- }
- }
- }
- item script Message{
- void run(int message){
- Screen->Message(message);
- }
- }
- item script ScriptBoomerang{
- void run(int dummy, int range,int level, int Damage, int sprite,int script_id){
- lweapon brang;
- if(NumLWeaponsOf(LW_SCRIPT1)==0){
- brang = FireLWeapon(LW_SCRIPT1, Link->X+InFrontX(Link->Dir,2), Link->Y+InFrontY(Link->Dir,2),
- __DirtoRad(Link->Dir), 100, Damage, sprite, SFX_BRANG, LWF_STUNS_ENEMIES|LWF_ITEM_PICKUP);
- SetLWeaponMovement(brang,LWM_BRANG,range,15);
- SetLWeaponSFX(brang,SFX_BRANG,30);
- SetLWeaponDeathEffect(brang,LWD_VANISH,0);
- brang->Misc[LW_ZH_I_FLAGS_2]|=level;
- if(level==LWF_LEVEL_2)
- SetLWeaponLifespan(brang,LWL_EDGE,SPR_MAGIC_SPARKLE);
- else if(level==LWF_LEVEL_3)
- SetLWeaponLifespan(brang,LWL_EDGE,SPR_FIRE_SPARKLE);
- else
- SetLWeaponLifespan(brang,LWL_EDGE,0);
- }
- }
- }
- const int SPR_MAGIC_SPARKLE = 31;
- const int SPR_FIRE_SPARKLE = 32;
- item script BombArrows{
- void run(int dummy, int damage, int sprite){
- if(Game->Counter[CR_ARROWS]!=0 && Game->Counter[CR_BOMBS]!=0){
- lweapon bombarrow;
- bombarrow = FireLWeapon(LW_SCRIPT1, Link->X+InFrontX(Link->Dir,2), Link->Y+InFrontY(Link->Dir,2),
- __DirtoRad(Link->Dir), 200, damage, sprite, SFX_ARROW, 0);
- SetLWeaponMovement(bombarrow,LWM_DUAL_FX,LW_ARROW,LW_BOMBBLAST);
- SetLWeaponDeathEffect(bombarrow,LWD_EXPLODE,8);
- bombarrow->Misc[LW_ZH_I_FLAGS_2]|=LWF_LEVEL_1;
- Link->Action = LA_ATTACKING;
- Game->Counter[CR_ARROWS]--;
- Game->Counter[CR_BOMBS]--;
- }
- }
- }
- item script Fire_Rod{
- void run(int dummy, int MPCost, int damage, int spritemagic, int spritewand){
- if(Link->MP>=MPCost){
- lweapon magic;
- lweapon wand;
- wand = FireLWeapon(LW_SCRIPT1,Link->X+InFrontX(Link->Dir,2), Link->Y+InFrontY(Link->Dir,2),
- __DirtoRad(Link->Dir), 0, damage, spritewand, 0, 0);
- SetLWeaponLifespan(wand,LWL_TIMER,10);
- SetLWeaponDeathEffect(wand,LWD_VANISH,0);
- magic = FireLWeapon(LW_MAGIC,Link->X+InFrontX(Link->Dir,2), Link->Y+InFrontY(Link->Dir,2),
- __DirtoRad(Link->Dir), 200, damage, spritemagic, SFX_WAND, LWF_CAN_REFLECT);
- SetLWeaponLifespan(magic,LWL_EDGE,spritemagic);
- SetLWeaponDeathEffect(magic,LWD_FIRE,85);
- magic->Misc[LW_ZH_I_FLAGS_2]|=LWF_LEVEL_3;
- Link->Action = LA_CASTING;
- Link->MP-=MPCost;
- }
- }
- }
- item script Ice_Rod{
- void run(int dummy, int MPCost, int damage, int spritemagic, int spritewand){
- if(Link->MP>=MPCost){
- lweapon magic;
- lweapon wand;
- wand = FireLWeapon(LW_SCRIPT1,Link->X+InFrontX(Link->Dir,2), Link->Y+InFrontY(Link->Dir,2),
- __DirtoRad(Link->Dir), 0, damage, spritewand, 0, 0);
- SetLWeaponLifespan(wand,LWL_TIMER,10);
- SetLWeaponDeathEffect(wand,LWD_VANISH,0);
- magic = FireLWeapon(LW_SCRIPT1,Link->X+InFrontX(Link->Dir,2), Link->Y+InFrontY(Link->Dir,2),
- __DirtoRad(Link->Dir), 200, 0,
- spritemagic, SFX_WAND, LWF_STUNS_ENEMIES);
- SetLWeaponLifespan(magic,LWL_EDGE,60);
- SetLWeaponDeathEffect(magic,LWD_FREEZE,24);
- Link->Action = LA_CASTING;
- Link->MP-=MPCost;
- }
- }
- }
- const int SPR_WAVE_SHARDS = 57;
- item script Wave_Sword_Beam{
- void run(int dummy1, int dummy2, int Damage, int percent, int sprite){
- Game->PlaySound(SFX_BEAM);
- Link->Action = LA_ATTACKING;
- lweapon beam;
- lweapon fakesword;
- beam = FireScriptedLWeapon(LW_BEAM, Link->X+InFrontX(Link->Dir,2), Link->Y+InFrontY(Link->Dir,2),
- sprite, 200, Damage,LWF_ZERO_G);
- beam->Misc[LW_ZH_I_FLAGS_2]|=LWF_LEVEL_3;
- SetLWeaponLifespan(beam,LWL_EDGE,0);
- if(beam->Dir==DIR_UP || beam->Dir==DIR_DOWN)SetLWeaponMovement(beam, LWM_SINE_WAVE, 6, 4);
- else
- SetLWeaponMovement(beam, EWM_SINE_WAVE, 4, 6);
- if(Link->HP>=(Link->MaxHP * 0.01 * percent))
- SetLWeaponDeathEffect(beam,LWD_4_FIREBALLS_DIAG,SPR_WAVE_SHARDS);
- beam->Angle = __DirtoRad(Link->Dir);
- }
- }
- const int SPR_ARROW_1 = 10;//Sprite for normal missile.
- const int SPR_ARROW_2 = 11;//Sprite for ice missile.
- const int SPR_ARROW_3 = 34;//Sprite for hyper missile.
- item script Variable_Strength_Arrow{
- void run(int dummy1, int dummy2, int level, int Damage){
- //Create and position Lweapon.
- lweapon beam;//Lweapon created by charge.
- if(level==1){
- beam = FireScriptedLWeapon(LW_ARROW, Link->X+InFrontX(Link->Dir,2), Link->Y+InFrontY(Link->Dir,2),
- SPR_ARROW_1, 200, Damage,LWF_ZERO_G);
- beam->Misc[LW_ZH_I_FLAGS_2]|=LWF_LEVEL_1;
- SetLWeaponDeathEffect(beam,LWD_VANISH,0);
- }
- else if(level==2){
- beam = FireScriptedLWeapon(LW_ARROW, Link->X+InFrontX(Link->Dir,2), Link->Y+InFrontY(Link->Dir,2),
- SPR_ARROW_2, 200, Damage,LWF_ZERO_G);
- beam->Misc[LW_ZH_I_FLAGS_2]|=LWF_LEVEL_2;
- SetLWeaponLifespan(beam,LWL_TIMER,60);
- SetLWeaponDeathEffect(beam,LWD_8_FIREBALLS,75);
- }
- else if(level ==3){
- beam = FireScriptedLWeapon(LW_ARROW, Link->X+InFrontX(Link->Dir,2), Link->Y+InFrontY(Link->Dir,2),
- SPR_ARROW_3, 200, Damage,LWF_ZERO_G);
- beam->Misc[LW_ZH_I_FLAGS_2]|=LWF_LEVEL_3;
- if(Screen->NumNPCs()>0){
- beam->Angle = __DirtoRad(Link->Dir);
- SetLWeaponMovement(beam, LWM_HOMING, 15, -1);
- }
- SetLWeaponDeathEffect(beam,LWD_VANISH,0);
- }
- Game->PlaySound(SFX_ARROW);
- Link->Action = LA_ATTACKING;
- Game->Counter[CR_ARROWS]--;
- SetLWeaponLifespan(beam,LWL_EDGE,0);
- }
- }
- item script Meteor{
- void run(int dummy, int Damage, int sprite, int num){
- int i;
- lweapon fireball;
- for(i=0;i<=num;i++){
- fireball= FireLWeapon(LW_SCRIPT1, Rand(32,240),Rand(32,120),
- DegtoRad(90), 0, Damage, sprite, SFX_FALL, 0);
- SetLWeaponMovement(fireball,LWM_FALL,200,LWMF_DIE);
- SetLWeaponDeathEffect(fireball,LWD_SBOMB_EXPLODE,8);
- }
- }
- }
- //D0- Weapon type that triggers this.
- //D1- Level of weapon.
- // Binary- 1= level one
- // 2= level two
- // 4= level three
- // 8= level four
- //D2- Screen->D register to store secrets in.
- ffc script LWeapon_Index_Trigger{
- void run(int type, int level, int perm){
- lweapon thing;
- int i;
- bool triggered = false;
- if(Screen->D[perm]!=0)triggered = true;
- while(!triggered){
- for(i = 1;i<=Screen->NumLWeapons();i++){
- thing = Screen->LoadLWeapon(i);
- if(thing->ID ==type && Collision(this,thing))
- if(level!=0 && ((thing->Misc[LW_ZH_I_FLAGS_2]&level)!=0))
- triggered = true;
- else if(level==0)
- triggered = true;
- }
- Waitframe();
- }
- Screen->TriggerSecrets();
- Screen->State[ST_SECRET]= true;
- Screen->D[perm] = 1;
- }
- }
- const int LINK_HOLD_2_COMBO = 32380;
- ffc script Large_Item{
- void run(int item_to_give,int width, int height){
- item anitem;
- if(!Screen->State[ST_ITEM]){
- anitem = Screen->CreateItem(item_to_give);
- anitem->X = this->X;
- anitem->Y = this->Y;
- }
- int timer;
- int tile = anitem->OriginalTile;
- int cset = anitem->CSet;
- while(anitem->isValid()){
- anitem->Extend = 3;
- anitem->TileWidth = width;
- anitem->TileHeight = height;
- if(LinkCollision(anitem)){
- anitem->X = Link->X;
- anitem->Y = Link->Y;
- Game->PlaySound(SFX_PICKUP);
- while(timer<30){
- Link->Invisible = true;
- Screen->DrawTile(0, Link->X+8-((width*16)/2), Link->Y-(height*16),
- tile, width, height, cset, -1, -1, 0, 0, 0, 0, true, 128);
- Screen->DrawCombo(0, Link->X, Link->Y, LINK_HOLD_2_COMBO,
- 1, 1, 6, -1, -1, 0, 0, 0, -1, 0, true, 128);
- timer++;
- WaitNoAction();
- }
- Link->Invisible = false;
- Screen->State[ST_ITEM]= true;
- }
- Waitframe();
- }
- }
- }
- item script Bracelet{
- void run(int dummy, int Strength, int damage, int this_id){
- lweapon Carried;
- lweapon Thrown;
- int ComboType;
- int Sprite;
- if(Strength == 1){
- if(NumLWeaponsOf(LW_SCRIPT1)==0){
- if(ComboTypeInFront()== CT_BUSH ||
- ComboTypeInFront()== CT_BUSHNEXT){
- ComboType = Screen->ComboT[ComboLocInFront()];
- Carried= FireLWeapon(LW_SCRIPT1, Link->X,Link->Y-16,
- DegtoRad(270), 0, damage, SPR_BUSH, SFX_HEFT, LWF_PIERCES_ENEMIES);
- SetLWeaponMovement(Carried,LWM_CARRY,ComboType,0);
- if(ComboTypeInFront()==CT_BUSH)
- Screen->ComboD[ComboLocInFront()]= Screen->UnderCombo;
- else
- Screen->ComboD[ComboLocInFront()]++;
- Link->Action = LA_ATTACKING;
- }
- }
- else if(NumLWeaponsOf(LW_SCRIPT2)==0){
- Carried = FindLWeaponType(LW_SCRIPT1);
- if(Carried->Misc[LW_ZH_I_MOVEMENT_ARG]== CT_BUSH ||
- Carried->Misc[LW_ZH_I_MOVEMENT_ARG]== CT_BUSHNEXT)
- Sprite = SPR_BUSH;
- RemoveLWeaponType(LW_SCRIPT1);
- Thrown = FireLWeapon(LW_SCRIPT2, Link->X,Link->Y-16, __DirtoRad(Link->Dir),
- 100, damage*Strength, Sprite, SFX_THROW, 0);
- SetLWeaponMovement(Thrown,LWM_THROW,3,LWMF_DIE);
- Link->Action = LA_ATTACKING;
- }
- }
- }
- }
- item script Hookshot{
- void run(int dummy, int Damage, int sprite, int chain_sprite, int sfx){
- int i;
- lweapon hookshot;
- hookshot= FireLWeapon(LW_SCRIPT1, Link->X+InFrontX(Link->Dir,2), Link->Y+InFrontY(Link->Dir,2),
- __DirtoRad(Link->Dir), 100, Damage, sprite, sfx,
- LWF_ITEM_PICKUP|LWF_STUNS_ENEMIES|LWF_LINK_NO_COLL);
- SetLWeaponLifespan(hookshot,LWL_EDGE,0);
- SetLWeaponMovement(hookshot,LWM_HOOKSHOT,32,chain_sprite);
- SetLWeaponSFX(hookshot,sfx,30);
- hookshot->Misc[LW_ZH_I_FLAGS_2]|=LWF_LINK_FROZEN;
- }
- }
- //LW_ZH Update functions.
- //Fixes Link's collision detection if it needs it.
- void UpdateLWZH1(){
- __CollDetectFix();
- }
- //Handle restoring Link's collision detection.
- void __CollDetectFix(){
- //Link's collision detection is off.
- if(!Link->CollDetection){
- //No Lweapons exist that turn it off.
- if(NumMiscLWeapons(LW_ZH_I_FLAGS,LWF_LINK_NO_COLL)==0)
- //Turn it on again.
- Link->CollDetection = true;
- }
- }
- // Calls UpdateLWeapon() on every eweapon on the screen
- void UpdateLWZH2(){
- lweapon wpn;
- for(int i=Screen->NumLWeapons(); i>0; i--){
- wpn=Screen->LoadLWeapon(i);
- // If this is a dummy, or if it's not a ghost.zh weapon, don't do anything
- if((wpn->Misc[LW_ZH_I_FLAGS]&__LWFI_IS_LWZH_LWPN)==0)
- continue;
- UpdateLWZH(wpn);
- }
- }
- //Updates fancy lweapon movement stuff.
- // Update a weapon's movement, lifespan, and death effects
- void UpdateLWZH(lweapon wpn){
- // Is the weapon still active?
- if((wpn->Misc[LW_ZH_I_FLAGS]&__LWFI_DEAD )==0){
- // Start movement updates
- if(wpn->Misc[LW_ZH_I_MOVEMENT]!=0){
- if(wpn->Misc[LW_ZH_I_MOVEMENT]!=0){
- if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_SINE_WAVE)
- __UpdateLWMSineWave(wpn);
- else if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_HOMING)
- __UpdateLWMHoming(wpn);
- else if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_THROW)
- __UpdateLWMThrow(wpn);
- else if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_FALL)
- __UpdateLWMFall(wpn);
- else if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_CIRCLE)
- __UpdateLWM_Circle(wpn);
- else if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_HOOKSHOT
- && (wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_RETURN)==0
- && (wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_HS_GRAB)==0)
- __UpdateLWM_Hookshot(wpn);
- else if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_BRANG)
- __UpdateLWM_BRang(wpn);
- //else if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_MELEE){
- //__UpdateLWM_Melee(wpn);
- //__UpdateLWE_Melee(wpn);
- //}
- else if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_CARRY)
- __UpdateLWM_Carry(wpn);
- else if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_DUAL_FX)
- __UpdateLWM_Dual(wpn);
- }
- } // End movement updates
- // Start lifespan updates
- if(wpn->Misc[LW_ZH_I_LIFESPAN]!=0)
- {
- if(wpn->Misc[LW_ZH_I_LIFESPAN]==LWL_TIMER){
- wpn->Misc[LW_ZH_I_LIFESPAN_ARG]-=1;
- if(wpn->Misc[LW_ZH_I_LIFESPAN_ARG]<=0)
- KillLWeapon(wpn);
- }
- else if(wpn->Misc[LW_ZH_I_LIFESPAN]==LWL_MP_COST){
- if(wpn->Misc[LW_ZH_I_LIFESPAN_ARG]>0){
- if(Game->Generic[GEN_MAGICDRAINRATE]==0)
- wpn->Misc[LW_ZH_I_WORK_3]= (wpn->Misc[LW_ZH_I_WORK_3]+1)%wpn->Misc[LW_ZH_I_LIFESPAN_ARG];
- else
- wpn->Misc[LW_ZH_I_WORK_3]= (wpn->Misc[LW_ZH_I_WORK_3]+1)
- %(wpn->Misc[LW_ZH_I_LIFESPAN_ARG]*2);
- if(wpn->Misc[LW_ZH_I_WORK_3]==0 && Link->MP>0)
- Link->MP--;
- if(Link->MP<=0){
- KillLWeapon(wpn);
- Link->MP =0;
- }
- }
- else{
- if(Link->MP<=0){
- KillLWeapon(wpn);
- Link->MP =0;
- }
- }
- }
- else if(wpn->Misc[LW_ZH_I_LIFESPAN]==LWL_EDGE){
- if(OnScreenEdge(wpn)){
- if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_BRANG)
- wpn->Misc[LW_ZH_I_FLAGS_2]|=LWF_RETURN;
- }
- }
- } // End lifespan updates
- if(wpn->Misc[LW_ZH_I_FX]>0)
- __UpdateLWE_Sound(wpn);
- __UpdateLWE_BlockFlags(wpn);
- __NPCCollision(wpn);
- __FlagTrigger(wpn);
- //LWeapon flags, level 2
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_NO_COLLISION)!=0)
- __UpdateLWF_Collision(wpn);
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_HS_GRAB)!=0)
- __HookshotPull(wpn);
- if((wpn->Misc[LW_ZH_I_FLAGS]&LWF_LINK_FROZEN)!=0)
- __UpdateLWF_Link_FreezeOn();
- if((wpn->Misc[LW_ZH_I_FLAGS]&LWF_LINK_NO_COLL)!=0)
- __UpdateLWF_Link_CollOff();
- }
- // Start death effects
- else if(wpn->Misc[LW_ZH_I_ON_DEATH]!=0 && (wpn->Misc[LW_ZH_I_FLAGS]&__LWFI_DEATH_EFFECT_DONE)==0)
- {
- //LWeapon flags, level 2
- if((wpn->Misc[LW_ZH_I_FLAGS]&LWF_PIERCES_ENEMIES)!=0)
- wpn->Misc[LW_ZH_I_FLAGS]&= ~LWF_PIERCES_ENEMIES;
- if(wpn->Misc[LW_ZH_I_ON_DEATH]<8){
- if(wpn->Misc[LW_ZH_I_ON_DEATH]==LWD_VANISH)
- wpn->DeadState=0;
- else if(wpn->Misc[LW_ZH_I_ON_DEATH]==LWD_AIM_AT_NPC)
- __DoLWeaponDeathAimAtNPC(wpn);
- else if(wpn->Misc[LW_ZH_I_ON_DEATH]==LWD_EXPLODE)
- __DoLWeaponDeathExplode(wpn);
- else if(wpn->Misc[LW_ZH_I_ON_DEATH]==LWD_SBOMB_EXPLODE)
- __DoLWeaponDeathSBombExplode(wpn);
- else if(wpn->Misc[LW_ZH_I_ON_DEATH]==LWD_4_FIREBALLS_HV)
- __DoLWeaponDeath4FireballsHV(wpn);
- else if(wpn->Misc[LW_ZH_I_ON_DEATH]==LWD_4_FIREBALLS_DIAG)
- __DoLWeaponDeath4FireballsDiag(wpn);
- else if(wpn->Misc[LW_ZH_I_ON_DEATH]==LWD_4_FIREBALLS_RANDOM)
- __DoLWeaponDeath4FireballsRand(wpn);
- }
- else // wpn->Misc[LW_ZH_I_ON_DEATH]>=8
- {
- if(wpn->Misc[LW_ZH_I_ON_DEATH]==EWD_8_FIREBALLS)
- __DoLWeaponDeath8Fireballs(wpn);
- //else if(wpn->Misc[LW_ZH_I_ON_DEATH]==LWD_4_FIRES_HV)
- //__DoLWeaponDeath4FiresHV(wpn);
- else if(wpn->Misc[LW_ZH_I_ON_DEATH]==LWD_4_FIRES_DIAG)
- __DoLWeaponDeath4FiresDiag(wpn);
- else if(wpn->Misc[LW_ZH_I_ON_DEATH]==LWD_4_FIRES_RANDOM)
- __DoLWeaponDeath4FiresRand(wpn);
- else if(wpn->Misc[LW_ZH_I_ON_DEATH]==LWD_8_FIRES)
- __DoLWeaponDeath8Fires(wpn);
- else if(wpn->Misc[LW_ZH_I_ON_DEATH]==LWD_FIRE)
- __DoLWeaponDeathSingleFire(wpn);
- else if(wpn->Misc[LW_ZH_I_ON_DEATH]==LWD_FREEZE)
- __DoLWeaponDeathFreeze(wpn);
- }
- } // End death effects
- //LWeapon flags, level 1
- if((wpn->Misc[LW_ZH_I_FLAGS]&LWF_ITEM_PICKUP)!=0)
- __UpdateLWF_Pickup(wpn);
- if((wpn->Misc[LW_ZH_I_FLAGS]&LWF_PIERCES_ENEMIES)!=0)
- __UpdateLWF_Pierce(wpn);
- if((wpn->Misc[LW_ZH_I_FLAGS]&LWF_STUNS_ENEMIES)!=0)
- __UpdateLWF_Stun(wpn);
- if((wpn->Misc[LW_ZH_I_FLAGS]&LWF_CAN_REFLECT)!=0)
- __UpdateLWF_Reflect(wpn);
- if((wpn->Misc[LW_ZH_I_FLAGS]&LWF_ZERO_G)!=0)
- __UpdateLWF_G_Force(wpn);
- if((wpn->Misc[LW_ZH_I_FLAGS]&LWF_POISON)!=0)
- __UpdateLWF_Poison(wpn);
- }
- //Handles LWeapons that continuously make sounds.
- void __UpdateLWE_Sound(lweapon wpn){
- if(wpn->Misc[LW_ZH_I_WORK_2]>0){
- wpn->Misc[LW_ZH_I_WORK]=(wpn->Misc[LW_ZH_I_WORK]+1)%wpn->Misc[LW_ZH_I_WORK_2];
- if(wpn->Misc[LW_ZH_I_WORK]==0)Game->PlaySound(wpn->Misc[LW_ZH_I_FX]);
- }
- }
- //Handles lweapon that's blocked by a combo.
- void __UpdateLWE_BlockFlags(lweapon wpn){
- if(ComboTAtWpn(wpn)==LWBlockType(wpn)||(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_HOOKSHOT
- && ComboTAtWpn(wpn)!=CT_HOOKSHOTONLY && ComboTAtWpn(wpn)!=CT_LADDERHOOKSHOT)){
- if(wpn->Misc[LW_ZH_I_MOVEMENT]!=LWM_BRANG && wpn->Misc[LW_ZH_I_MOVEMENT]!=LWM_HOOKSHOT){
- KillLWeapon(wpn);
- Game->PlaySound(SFX_CLINK);
- }
- else{
- if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_HOOKSHOT && ComboTAtWpn(wpn)==CT_HSGRAB)
- wpn->Misc[LW_ZH_I_FLAGS_2]|=LWF_HS_GRAB;
- else
- wpn->Misc[LW_ZH_I_FLAGS_2]|=LWF_RETURN;
- }
- }
- }
- void __UpdateLWM_Dual(lweapon wpn){
- if(ComboTAtWpn(wpn)==LWBlockType(wpn->Misc[LW_ZH_I_MOVEMENT_ARG],wpn)
- ||ComboTAtWpn(wpn)==LWBlockType(wpn->Misc[LW_ZH_I_MOVEMENT_ARG2],wpn)){
- KillLWeapon(wpn);
- Game->PlaySound(SFX_CLINK);
- }
- bool trigger = false;
- if(wpn->Misc[LW_ZH_I_MOVEMENT_ARG]==LW_ARROW
- ||wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]==LW_ARROW){
- if(ComboFIAtWpn(wpn,CF_ARROW)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_1)!=0)trigger = true;
- }
- if(ComboFIAtWpn(wpn,CF_ARROW2)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_2)!=0)trigger = true;
- }
- if(ComboFIAtWpn(wpn,CF_ARROW3)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_3)!=0)trigger = true;
- }
- }
- if(wpn->Misc[LW_ZH_I_MOVEMENT_ARG]==LW_BOMBBLAST
- ||wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]==LW_BOMBBLAST){
- if(ComboFIAtWpn(wpn,CF_BOMB))trigger = true;
- }
- if(wpn->Misc[LW_ZH_I_MOVEMENT_ARG]==LW_SBOMBBLAST
- ||wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]==LW_SBOMBBLAST){
- if(ComboFIAtWpn(wpn,CF_SBOMB))trigger = true;
- }
- if(wpn->Misc[LW_ZH_I_MOVEMENT_ARG]==LW_FIRE
- ||wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]==LW_FIRE){
- if(ComboFIAtWpn(wpn,CF_CANDLE1)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_1)!=0)trigger = true;
- }
- if(ComboFIAtWpn(wpn,CF_CANDLE2)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_2)!=0)trigger = true;
- }
- }
- if((wpn->Misc[LW_ZH_I_MOVEMENT_ARG]==LW_MAGIC
- ||wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]==LW_MAGIC)
- && ComboFIAtWpn(wpn,CF_WANDMAGIC)
- && (wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_IS_REFLECTED)==0)trigger = true;
- if((wpn->Misc[LW_ZH_I_MOVEMENT_ARG]==LW_MAGIC
- ||wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]==LW_MAGIC)
- && ComboFIAtWpn(wpn,CF_REFMAGIC)
- && (wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_IS_REFLECTED)!=0)trigger = true;
- //else if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_MELEE){
- //if(wpn->Misc[LW_ZH_I_MOVEMENT_ARG]==LW_IS_SWORD){
- //if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_1)!=0)return CF_SWORD1;
- //else if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_2)!=0)return CF_SWORD2;
- //else if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_3)!=0)return CF_SWORD3;
- //else
- //return CF_SWORD4;
- //}
- //else if(wpn->Misc[LW_ZH_I_MOVEMENT_ARG]==LW_IS_HAMMER)
- //return CF_HAMMER;
- //else if(wpn->Misc[LW_ZH_I_MOVEMENT_ARG]==LW_IS_WAND)
- //return CF_WAND;
- //}
- if(wpn->Misc[LW_ZH_I_MOVEMENT_ARG]==LW_BEAM
- ||wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]==LW_BEAM){
- if(ComboFIAtWpn(wpn,CF_SWORD1BEAM)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_1)!=0)trigger = true;
- }
- if(ComboFIAtWpn(wpn,CF_SWORD2BEAM)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_2)!=0)trigger = true;
- }
- if(ComboFIAtWpn(wpn,CF_SWORD3BEAM)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_3)!=0)trigger = true;
- }
- if(ComboFIAtWpn(wpn,CF_SWORD4BEAM)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_4)!=0)trigger = true;
- }
- }
- //else if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_HOOKSHOT)
- //return CF_HOOKSHOT;
- if(trigger){
- KillLWeapon(wpn);
- Screen->TriggerSecrets();
- Screen->State[ST_SECRET] = true;
- Game->PlaySound(SFX_SECRET);
- }
- }
- //Handles melee weapon behavior.
- //void __UpdateLWE_Melee(lweapon wpn){
- //for(int i=0; i<176; i++){
- //if(wpn->Misc[LW_ZH_I_MOVEMENT]==LW_IS_SWORD){
- //if((Screen->ComboT[i]==CT_SLASH||Screen->ComboT[i]==CT_BUSH
- //||Screen->ComboT[i]==CT_FLOWERS||Screen->ComboT[i]==CT_TALLGRASS
- //||Screen->ComboT[i]==CT_SLASHITEM||Screen->ComboT[i]==CT_SLASHNEXT)
- //&& ComboCollision(i,wpn->X,wpn->Y,wpn->X+wpn->HitWidth,wpn->Y+wpn->HitHeight)){
- //if(Screen->ComboT[i]!=CT_SLASH && Screen->ComboT[i]==CT_SLASHNEXT){
- //CreateGraphicAt(GetComboSprite(Screen->ComboT[i]),ComboX(i),ComboY(i));
- //ItemSetAt(IS_COMBOS,i);
- //Game->PlaySound(GetComboSound(Screen->ComboT[i]));
- //}
- //if(Screen->ComboT[i]==CT_SLASHNEXT){
- //Game->PlaySound(GetComboSound(Screen->ComboT[i]));
- //Screen->ComboD[i]++;
- //}
- //else{
- //Game->PlaySound(GetComboSound(Screen->ComboT[i]));
- //Screen->ComboD[i]= Screen->UnderCombo;
- //}
- //}
- //else if(Screen->ComboT[i]==CT_BUSHNEXT
- //||Screen->ComboT[i]==CT_TALLGRASSNEXT
- //||Screen->ComboT[i]==CT_SLASHNEXTITEM){
- //CreateGraphicAt(GetComboSprite(Screen->ComboT[i]),ComboX(i),ComboY(i));
- //ItemSetAt(IS_COMBOS,i);
- //Game->PlaySound(GetComboSound(Screen->ComboT[i]));
- //Screen->ComboD[i]++;
- //}
- //}
- //else if(wpn->Misc[LW_ZH_I_MOVEMENT]==LW_IS_HAMMER){
- //if(Screen->ComboT[i]==CT_POUND
- //&& ComboCollision(i,wpn->X,wpn->Y,wpn->X+wpn->HitWidth,wpn->Y+wpn->HitHeight)){
- //Screen->ComboD[i]++;
- //Game->PlaySound(SFX_HAMMER);
- //}
- //}
- //}
- //if((wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]&LW_HAS_SLASH)!=0)
- //__UpdateLWM_Slash(wpn);
- //if((wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]&LW_HAS_PERIL_SCR)!=0)
- //__UpdateLWE_Peril(wpn);
- //if((wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]&LW_HAS_WHIM_RING)!=0)
- //__UpdateLWE_Whim(wpn);
- //if((wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]&LW_HAS_BOOK)!=0)
- //__UpdateLWE_Book(wpn);
- //}
- //Handles sword beam slash effects.
- //void __UpdateLWM_Slash(lweapon wpn){
- //}
- //This weapon has the peril beam.
- //void __UpdateLWE_Peril(lweapon wpn){
- //}
- //This weapon has the whimsical ring.
- //void __UpdateLWE_Whim(lweapon wpn){
- //}
- //This wand has the magic book.
- //void __UpdateLWE_Book(lweapon weapon){
- //}
- //Handles interaction with combos and Somaria blocks.
- //void __UpdateLWE_Somaria(lweapon wpn){
- //for(int i=0; i<176; i++){
- //if(ComboFI(i,CF_BLOCKTRIGGER)
- //&& ComboCollision(i,wpn->X,wpn->Y,wpn->X+wpn->HitWidth,wpn->Y+wpn->HitHeight)){
- //if(!ScreenFlagTest(SF_SECRETS,SF_HIT_ALL_16_31) &&
- //!ScreenFlagTest(SF_SECRETS,SF_HIT_ALL_PERM))
- //Screen->TriggerSecrets();
- //if(!ScreenFlagTest(SF_SECRETS,SF_NOT_PERM))
- //Screen->State[ST_SECRET]= true;
- //wpn->Misc[LW_ZH_I_WORK]=Screen->ComboD[i];
- //wpn->Misc[LW_ZH_I_WORK_2]=i;
- //if(wpn->DeadState==0){
- //Screen->ComboD[i]=wpn->Misc[LW_ZH_I_WORK];
- //Screen->State[ST_SECRET]= false;
- //}
- //Screen->ComboD[i]++;
- //}
- //if((Screen->ComboT[i]== CT_STEP||Screen->ComboT[i]==CT_STEPALL
- //||Screen->ComboT[i]== CT_STEPSAME)
- //&& ComboCollision(i,wpn->X,wpn->Y,wpn->X+wpn->HitWidth,wpn->Y+wpn->HitHeight)){
- //wpn->Misc[LW_ZH_I_WORK]=Screen->ComboD[i];
- //Screen->ComboD[i]++;
- //if(wpn->DeadState==0)Screen->ComboD[i]=wpn->Misc[LW_ZH_I_WORK];
- //}
- //}
- //if(wpn->Misc[LW_ZH_I_WORK]!=0){
- //for(int i=0; i<176; i++){
- //if(wpn->Misc[LW_ZH_I_WORK]==CT_STEPALL && Screen->ComboT[i]==CT_STEPCOPY){
- //wpn->Misc[LW_ZH_I_WORK_2]=Screen->ComboD[i];
- //Screen->ComboD[i]++;
- //if(wpn->DeadState==0)Screen->ComboD[i]=wpn->Misc[LW_ZH_I_WORK_2];
- //}
- //else if(wpn->Misc[LW_ZH_I_WORK]==CT_STEPSAME && Screen->ComboT[i]== CT_STEPSAME)
- //Screen->ComboD[i]++;
- //else{
- //if(!ComboCollision(i,wpn->X,wpn->Y,wpn->X+wpn->HitWidth,wpn->Y+wpn->HitHeight)
- //&& Screen->ComboD[i]!=wpn->Misc[LW_ZH_I_WORK])
- //Screen->ComboD[i]=wpn->Misc[LW_ZH_I_WORK];
- //if(wpn->DeadState==0)
- //Screen->ComboD[wpn->Misc[LW_ZH_I_WORK_2]]=wpn->Misc[LW_ZH_I_WORK];
- //}
- //}
- //}
- //}
- //Handles magnetic glove interaction.
- //void __UpdateLWE_Magnet(lweapon wpn){
- //}
- //Handles lweapons that move in a sine wave.
- void __UpdateLWMSineWave(lweapon wpn){
- float offset;
- wpn->Misc[LW_ZH_I_WORK]+=wpn->Misc[LW_ZH_I_MOVEMENT_ARG2];
- // Adjust the weapon's position at an angle
- // perpendicular to that of its forward movement.
- offset=wpn->Misc[LW_ZH_I_MOVEMENT_ARG]*Sin(wpn->Misc[LW_ZH_I_WORK]);
- wpn->Misc[LW_ZH_I_XPOS]+=(wpn->Step/100)*RadianCos(wpn->Angle);
- wpn->Misc[LW_ZH_I_YPOS]+=(wpn->Step/100)*RadianSin(wpn->Angle);
- wpn->X=wpn->Misc[LW_ZH_I_XPOS]+offset*RadianCos(wpn->Angle+1.5708);
- wpn->Y=wpn->Misc[LW_ZH_I_YPOS]+offset*RadianSin(wpn->Angle+1.5708);
- }
- //Handles homing lweapons.
- void __UpdateLWMHoming(lweapon wpn){
- // Wrap angle to 0..2*PI
- float currentAngle=wpn->Angle%6.2832;
- if(currentAngle<0)
- currentAngle+=6.2832;
- npc target_enemy;
- int target_number;
- // Find angle to Link and wrap it
- if(Screen->NumNPCs()>0){
- if(wpn->Misc[LW_ZH_I_WORK]==0)wpn->Misc[LW_ZH_I_WORK] = Rand(1,Screen->NumNPCs());
- for(int i=Screen->NumNPCs();i>0;i--){
- target_enemy = Screen->LoadNPC(i);
- if(target_enemy->ID==wpn->Misc[LW_ZH_I_WORK] &&
- target_enemy->Defense[LWDefense(wpn->ID)]!=NPCDT_BLOCK||
- target_enemy->Defense[LWDefense(wpn->ID)]!=NPCDT_IGNORE)
- target_enemy->Misc[NPC_MISC_TARGET_NUMBER]=wpn->Misc[LW_ZH_I_WORK];
- }
- if(target_enemy->HP<=0)wpn->Misc[LW_ZH_I_WORK]=0;
- if(target_enemy->Misc[NPC_MISC_TARGET_NUMBER]==wpn->Misc[LW_ZH_I_WORK]){
- float targetAngle=RadianAngle(wpn->X, wpn->Y, target_enemy->X, target_enemy->Y);
- if(targetAngle<0)
- targetAngle+=6.2832;
- float diff=Abs(currentAngle-targetAngle);
- // Turn toward Link
- if(diff<wpn->Misc[LW_ZH_I_MOVEMENT_ARG] || diff>6.2832-wpn->Misc[LW_ZH_I_MOVEMENT_ARG])
- wpn->Angle=targetAngle;
- // Can't turn enough to point directly at him...
- else if(Sign(currentAngle-targetAngle)==Sign(diff-PI)) // current>target and diff>pi or
- wpn->Angle+=wpn->Misc[LW_ZH_I_MOVEMENT_ARG]; // current<target and diff<pi
- else // - Turn CW or CCW?
- wpn->Angle-=wpn->Misc[LW_ZH_I_MOVEMENT_ARG];
- SetLWeaponDir(wpn);
- // Decrement timer, unless it was negative to begin with
- if(wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]>0){
- wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]--;
- if(wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]<=0)
- Remove(wpn);
- }
- }
- }
- }
- //Handles Lweapons thrown in an arc.
- void __UpdateLWMThrow(lweapon wpn)
- {
- // LW_ZH_I_WORK: Current jump
- // LW_ZH_I_WORK_2: Current Z position
- // LW_ZH_I_MOVEMENT_ARG: Initial jump
- wpn->Jump=0; // Override engine handling of Z movement
- // Just thrown
- if(wpn->Misc[LW_ZH_I_WORK]==0 && wpn->Misc[LW_ZH_I_MOVEMENT_ARG]!=0)
- {
- wpn->Misc[LW_ZH_I_WORK]=wpn->Misc[LW_ZH_I_MOVEMENT_ARG];
- wpn->Misc[LW_ZH_I_MOVEMENT_ARG]=0;
- }
- // Fall
- wpn->Misc[LW_ZH_I_WORK_2]=Max(wpn->Misc[LW_ZH_I_WORK_2]+wpn->Misc[LW_ZH_I_WORK], 0);
- wpn->Z=wpn->Misc[LW_ZH_I_WORK_2];
- // Hit the ground
- // Still in the air; adjust velocity
- if(wpn->Misc[LW_ZH_I_WORK_2]>0) // Z>0
- wpn->Misc[LW_ZH_I_WORK]=Max(wpn->Misc[LW_ZH_I_WORK]-GH_GRAVITY, -GH_TERMINAL_VELOCITY);
- // Hit the ground
- else{
- if((wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]&LWMF_DIE)!=0)
- KillLWeapon(wpn);
- //if((wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]&LWMF_REST)!=0){
- //lweapon new = FireLWeapon(LW_SCRIPT1,wpn->X,wpn->Y,DegtoRad(0),0,
- //wpn->Damage/2,SPR_SOMARIA_BLOCK,0,wpn->Misc[LW_ZH_I_FLAGS]);
- //SetLWeaponLifespan(new,LWL_ITEM_PRESS,I_CSOMARIA);
- //SetLWeaponMovement(new,LWM_REST,LWM_R_SOMARIA,0);
- //SetLWeaponDeathEffect(new,LWD_4_FIREBALLS_DIAG,SPR_SOMARIA_FIRE);
- //KillLWeapon(wpn);
- //}
- }
- }
- //Handles Lweapons that fall from the sky.
- void __UpdateLWMFall(lweapon wpn)
- {
- wpn->Jump=0; // Override engine handling of Z movement
- wpn->Misc[LW_ZH_I_WORK_2]-=wpn->Misc[LW_ZH_I_WORK];
- wpn->Z=wpn->Misc[LW_ZH_I_WORK_2];
- wpn->Misc[LW_ZH_I_WORK]=Min(wpn->Misc[LW_ZH_I_WORK]+GH_GRAVITY, GH_TERMINAL_VELOCITY);
- // Hit the ground?
- if(wpn->Misc[LW_ZH_I_WORK_2]<=0){
- if((wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]&LWMF_DIE)!=0)
- KillLWeapon(wpn);
- //if((wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]&LWMF_REST)!=0){
- //lweapon new = FireLWeapon(LW_SCRIPT1,wpn->X,wpn->Y,DegtoRad(0),0,
- //wpn->Damage/2,SPR_SOMARIA_BLOCK,0,wpn->Misc[LW_ZH_I_FLAGS]);
- //SetLWeaponLifespan(new,LWL_ITEM_PRESS,I_CSOMARIA);
- //SetLWeaponMovement(new,LWM_REST,LWM_R_SOMARIA,0);
- //SetLWeaponDeathEffect(new,LWD_4_FIREBALLS_DIAG,SPR_SOMARIA_FIRE);
- //KillLWeapon(wpn);
- //}
- }
- }
- //Handles Lweapons that circle Link.
- void __UpdateLWM_Circle(lweapon wpn){
- wpn->Misc[LW_ZH_I_WORK]= (wpn->Misc[LW_ZH_I_WORK]
- +((wpn->Step/100)*wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]))%360;
- wpn->Misc[LW_ZH_I_XPOS]= Link->X+wpn->Misc[LW_ZH_I_MOVEMENT_ARG]*Sin(wpn->Misc[LW_ZH_I_WORK]);
- wpn->Misc[LW_ZH_I_YPOS]= Link->Y+wpn->Misc[LW_ZH_I_MOVEMENT_ARG]*Cos(wpn->Misc[LW_ZH_I_WORK]);
- wpn->Angle = DegtoRad(wpn->Misc[LW_ZH_I_WORK]);
- SetLWeaponDir(wpn);
- wpn->X=wpn->Misc[LW_ZH_I_XPOS];
- wpn->Y=wpn->Misc[LW_ZH_I_YPOS];
- }
- //Handles Lweapons that act like the hookshot.
- void __UpdateLWM_Hookshot(lweapon wpn){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_RETURN)==0
- &&(wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_HS_GRAB)==0){
- if(wpn->Dir==DIR_LEFT||wpn->Dir==DIR_RIGHT){
- if(Abs(wpn->X-Link->X+8)<=(wpn->Misc[LW_ZH_I_MOVEMENT_ARG]*16)){
- if(wpn->Dir==DIR_LEFT)wpn->Misc[LW_ZH_I_XPOS]--;
- else if(wpn->Dir==DIR_RIGHT)wpn->Misc[LW_ZH_I_XPOS]++;
- for(int i =0;i<=wpn->Misc[LW_ZH_I_MOVEMENT_ARG];i++){
- lweapon particle = FireScriptedLWeapon(LW_SCRIPT1, Calc(wpn->X,Link->X+8,wpn->Misc[LW_ZH_I_MOVEMENT_ARG]),
- wpn->Y, wpn->Misc[LW_ZH_I_MOVEMENT_ARG2], 0, 0,LWF_NO_COLLISION);
- SetLWeaponLifespan(particle,LWL_TIMER,1);
- SetLWeaponDeathEffect(particle,LWD_VANISH,0);
- }
- }
- else
- wpn->Misc[LW_ZH_I_FLAGS_2]|=LWF_RETURN;
- }
- else{
- if(Abs(wpn->Y-Link->Y+8)<=(wpn->Misc[LW_ZH_I_MOVEMENT_ARG]*16)){
- if(wpn->Dir==DIR_UP)wpn->Misc[LW_ZH_I_YPOS]--;
- else if(wpn->Dir==DIR_DOWN)wpn->Misc[LW_ZH_I_YPOS]++;
- for(int i =0;i<=wpn->Misc[LW_ZH_I_MOVEMENT_ARG];i++){
- lweapon particle = FireScriptedLWeapon(LW_SCRIPT1, wpn->X, Calc(wpn->Y,Link->Y+8,wpn->Misc[LW_ZH_I_MOVEMENT_ARG]),
- wpn->Misc[LW_ZH_I_MOVEMENT_ARG2], 0, 0,LWF_NO_COLLISION);
- SetLWeaponLifespan(particle,LWL_TIMER,1);
- SetLWeaponDeathEffect(particle,LWD_VANISH,0);
- }
- }
- else
- wpn->Misc[LW_ZH_I_FLAGS_2]|=LWF_RETURN;
- }
- if(!OnScreen(wpn))
- wpn->Misc[LW_ZH_I_FLAGS_2]|=LWF_RETURN;
- Link->CollDetection = false;
- NoAction();
- }
- SetLWeaponDir(wpn);
- wpn->X= wpn->Misc[LW_ZH_I_XPOS];
- wpn->Y= wpn->Misc[LW_ZH_I_YPOS];
- }
- void __HookshotPull(lweapon wpn){
- wpn->Step = 0;
- if(Link->X!=wpn->X && Link->Y!=wpn->Y){
- if(Link->X<wpn->X)Link->X++;
- else
- Link->X--;
- if(Link->Y<wpn->Y)Link->Y++;
- else
- Link->Y--;
- Link->CollDetection = false;
- NoAction();
- }
- else{
- Link->CollDetection = true;
- KillLWeapon(wpn);
- }
- }
- void __NPCCollision(lweapon wpn){
- for(int i=Screen->NumNPCs();i>0;i--){
- npc n = Screen->LoadNPC(i);
- if(Collision(wpn,n)){
- if(n->Defense[LWDefense(wpn->ID)]==NPCDT_BLOCK||
- n->Defense[LWDefense(wpn->ID)]==NPCDT_IGNORE){
- Game->PlaySound(SFX_CLINK);
- if((wpn->Misc[LW_ZH_I_FLAGS]&LWF_PIERCES_ENEMIES)!=0)
- KillLWeapon(wpn);
- }
- if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_BRANG ||
- wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_HOOKSHOT)
- wpn->Misc[LW_ZH_I_FLAGS_2]|=LWF_RETURN;
- else{
- if((wpn->Misc[LW_ZH_I_FLAGS]&LWF_PIERCES_ENEMIES)==0)
- KillLWeapon(wpn);
- }
- }
- }
- }
- //Handles Lweapon that moves like a boomerang.
- void __UpdateLWM_BRang(lweapon wpn){
- float currentAngle=wpn->Angle%6.2832;
- int RandX;
- int RandY;
- int PartX;
- int PartY;
- if(currentAngle<0)
- currentAngle+=6.2832;
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_RETURN)==0){
- if(wpn->Misc[LW_ZH_I_MOVEMENT_ARG]>0){
- //This boomerang isn't farther from Link than it's range.
- if(Abs(wpn->X-wpn->Misc[LW_ZH_I_XPOS])>wpn->Misc[LW_ZH_I_MOVEMENT_ARG]
- ||Abs(wpn->Y-wpn->Misc[LW_ZH_I_YPOS])>wpn->Misc[LW_ZH_I_MOVEMENT_ARG])
- wpn->Misc[LW_ZH_I_FLAGS_2]|=LWF_RETURN;
- }
- if(OnScreenEdge(wpn))
- wpn->Misc[LW_ZH_I_FLAGS_2]|=LWF_RETURN;
- }
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_RETURN)!=0){
- //Set it not to collide with enemies.
- wpn->Misc[LW_ZH_I_FLAGS_2]|=LWF_NO_COLLISION;
- float targetAngle=RadianAngle(wpn->X, wpn->Y, CenterLinkX(), CenterLinkY());
- if(targetAngle<0)
- targetAngle+=6.2832;
- float diff=Abs(currentAngle-targetAngle);
- //Turn toward Link
- if(diff<wpn->Misc[LW_ZH_I_MOVEMENT_ARG2] || diff>6.2832-wpn->Misc[LW_ZH_I_MOVEMENT_ARG2])
- wpn->Angle=targetAngle;
- // Can't turn enough to point directly at him...
- else if(Sign(currentAngle-targetAngle)==Sign(diff-PI)) // current>target and diff>pi or
- wpn->Angle+=wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]; // current<target and diff<pi
- else // - Turn CW or CCW?
- wpn->Angle-=wpn->Misc[LW_ZH_I_MOVEMENT_ARG2];
- SetLWeaponDir(wpn);
- if(LinkCollision(wpn))
- KillLWeapon(wpn);
- }
- //This boomerang makes sparkles.
- if(wpn->Misc[LW_ZH_I_LIFESPAN_ARG]>0){
- //Every 30 frames, create a sparkle.
- //This sparkle dies in 30 frames.
- wpn->Misc[LW_ZH_I_WORK_3]= (wpn->Misc[LW_ZH_I_WORK_3]+1)%5;
- if(wpn->Misc[LW_ZH_I_WORK_3]==0){
- if(wpn->Dir ==DIR_LEFT||wpn->Dir==DIR_RIGHT){
- RandY = Rand(-4,4);
- PartY = wpn->Y;
- PartX = CenterWpnX(wpn);
- }
- else{
- RandX = Rand(-4,4);
- PartX = wpn->X;
- PartY = CenterWpnY(wpn);
- }
- lweapon particle = FireLWeapon(LW_SCRIPT1,PartX+RandX,PartY+RandY,
- DegtoRad(0), 0, wpn->Damage, wpn->Misc[LW_ZH_I_LIFESPAN_ARG], 0, 0);
- SetLWeaponLifespan(particle,LWL_TIMER,60);
- SetLWeaponDeathEffect(particle,LWD_VANISH,0);
- }
- }
- }
- //Handles Lweapon that has melee movement.
- //void __UpdateLWM_Melee(lweapon wpn){
- //}
- //Handles lweapon that is carried.
- void __UpdateLWM_Carry(lweapon wpn){
- wpn->Misc[LW_ZH_I_XPOS]= Link->X;
- wpn->Misc[LW_ZH_I_YPOS]= Link->Y-16;
- wpn->X = wpn->Misc[LW_ZH_I_XPOS];
- wpn->Y = wpn->Misc[LW_ZH_I_YPOS];
- //else if(wpn->Misc[LW_ZH_I_MOVEMENT_ARG]== LWM_CARRY_SOM){
- //if((Link->X+16)==wpn->X && Between(Link->Y+8,wpn->Y,wpn->Y+wpn->HitHeight)
- //&& (Link->PressRight ||Link->InputRight)
- //&& !Screen->isSolid(wpn->X+wpn->HitWidth,wpn->Y)
- //&& !Screen->isSolid(wpn->X+wpn->HitWidth,wpn->Y+wpn->HitHeight)){
- //wpn->Misc[LW_ZH_I_XPOS]++;
- //}
- //else if((Link->X+16)==wpn->X && Between(Link->Y+8,wpn->Y,wpn->Y+wpn->HitHeight)
- //&& (Link->PressRight ||Link->InputRight)
- //&& Screen->isSolid(wpn->X+wpn->HitWidth,wpn->Y)
- //&& Screen->isSolid(wpn->X+wpn->HitWidth,wpn->Y+wpn->HitHeight)){
- //Link->PressRight = false;
- //Link->InputRight = false;
- //}
- //else if((Link->Y+16)==wpn->Y && Between(Link->X+8,wpn->X,wpn->X+wpn->HitWidth)
- //&& (Link->PressDown ||Link->InputDown)
- //&& !Screen->isSolid(wpn->X,wpn->Y+wpn->HitHeight)
- //&& !Screen->isSolid(wpn->X+wpn->HitWidth,wpn->Y+wpn->HitHeight)){
- //wpn->Misc[LW_ZH_I_YPOS]++;
- //}
- //else if((Link->Y+16)==wpn->Y && Between(Link->X+8,wpn->X,wpn->X+wpn->HitWidth)
- //&& (Link->PressDown ||Link->InputDown)
- //&& Screen->isSolid(wpn->X,wpn->Y+wpn->HitHeight)
- //&& Screen->isSolid(wpn->X+wpn->HitHeight,wpn->Y+wpn->HitHeight)){
- //Link->PressDown = false;
- //Link->InputDown = false;
- //}
- //else if(Link->X==(wpn->X+wpn->HitWidth) && Between(Link->Y+8,wpn->Y,wpn->Y+wpn->HitHeight)
- //&& (Link->PressLeft ||Link->InputLeft)
- //&& !Screen->isSolid(wpn->X-1,wpn->Y)
- //&& !Screen->isSolid(wpn->X-1,wpn->Y+wpn->HitHeight)){
- //wpn->Misc[LW_ZH_I_XPOS]--;
- //}
- //else if(Link->X==(wpn->X+wpn->HitWidth) && Between(Link->Y+8,wpn->Y,wpn->Y+wpn->HitHeight)
- //&& (Link->PressLeft ||Link->InputLeft)
- //&& Screen->isSolid(wpn->X-1,wpn->Y)
- //&& Screen->isSolid(wpn->X-1,wpn->Y+wpn->HitHeight)){
- //Link->PressLeft = false;
- //Link->InputLeft = false;
- //}
- //else if(Link->Y==(wpn->Y+wpn->HitHeight) && Between(Link->X+8,wpn->X,wpn->Y+wpn->HitWidth)
- //&& (Link->PressUp ||Link->InputUp)
- //&& !Screen->isSolid(wpn->X,wpn->Y-1)
- //&& !Screen->isSolid(wpn->X+wpn->HitHeight,wpn->Y-1)){
- //wpn->Misc[LW_ZH_I_YPOS]--;
- //}
- //else if(Link->Y==(wpn->Y+wpn->HitHeight) && Between(Link->X+8,wpn->X,wpn->Y+wpn->HitWidth)
- //&& (Link->PressUp ||Link->InputUp)
- //&& Screen->isSolid(wpn->X,wpn->Y-1)
- //&& Screen->isSolid(wpn->X+wpn->HitHeight,wpn->Y-1)){
- //Link->PressUp = false;
- //Link->InputUp = false;
- //}
- //wpn->X = wpn->Misc[LW_ZH_I_XPOS];
- //wpn->Y = wpn->Misc[LW_ZH_I_YPOS];
- //__UpdateLWE_Somaria(wpn);
- //}
- //else if(wpn->Misc[LW_ZH_I_MOVEMENT_ARG]== LWM_R_MAGNET){
- //if(Link->PressLeft||Link->InputLeft)
- //wpn->Misc[LW_ZH_I_XPOS]--;
- //else if(Link->PressRight||Link->InputRight)
- //wpn->Misc[LW_ZH_I_XPOS]++;
- //if(Link->PressUp||Link->InputUp)
- //wpn->Misc[LW_ZH_I_YPOS]--;
- //else if(Link->PressDown||Link->InputDown)
- //wpn->Misc[LW_ZH_I_YPOS]++;
- //Link->Dir= wpn->Dir;
- //wpn->X = wpn->Misc[LW_ZH_I_XPOS];
- //wpn->Y = wpn->Misc[LW_ZH_I_YPOS];
- //__UpdateLWE_Magnet(wpn);
- //}
- }
- //Handles Lweapons that pickup items.
- void __UpdateLWF_Pickup(lweapon wpn){
- if(Screen->NumItems()>0){
- for(int i=1;i<=Screen->NumItems();i++){
- item anitem = Screen->LoadItem(i);
- for ( int r = 0; r < SizeOfArray(ItemsToPickup); r++ ) {
- if(anitem->isValid()){
- if ( anitem->ID == ItemsToPickup[r]) {
- if (Collision(wpn,anitem)) {
- if((wpn->Misc[LW_ZH_I_FLAGS]&LWF_INSTA_DELIVER)!=0){
- anitem->X = Link->X;
- anitem->Y = Link->Y;
- }
- else{
- if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_BRANG)
- wpn->Misc[LW_ZH_I_FLAGS_2]|= LWF_RETURN;
- anitem->X = wpn->X;
- anitem->Y = wpn->Y;
- if(LinkCollision(wpn)){
- anitem->X = Link->X;
- anitem->Y = Link->Y;
- }
- }
- }
- }
- }
- else
- continue;
- }
- }
- }
- }
- //Handles Lweapons that pierce enemies.
- void __UpdateLWF_Pierce(lweapon wpn){
- wpn->DeadState = WDS_ALIVE;
- }
- //Handles Lweapons that stun enemies.
- void __UpdateLWF_Stun(lweapon wpn){
- if(Screen->NumNPCs()>0){
- for(int i=Screen->NumNPCs();i>0;i--){
- npc thing = Screen->LoadNPC(i);
- if(thing->HP<=0)break;
- if(Collision(thing,wpn) && (thing->Defense[LWDefense(wpn->ID)]==NPCDT_STUN
- || thing->Defense[LWDefense(wpn->ID)]==NPCDT_STUNORBLOCK
- || thing->Defense[LWDefense(wpn->ID)]==NPCDT_STUNORIGNORE)){
- if(thing->Defense[LWDefense(wpn->ID)]!=NPCDT_STUN){
- int StunChance = Rand(0,100);
- if(StunChance>50)thing->Stun= Rand(0,MAX_STUN_TIME);
- }
- else
- thing->Stun = Rand(0,MAX_STUN_TIME);
- KillLWeapon(wpn);
- }
- }
- }
- }
- //Handles lweapons that are reflected off of magic mirrors.
- void __UpdateLWF_Reflect(lweapon wpn){
- float angle;
- lweapon new;
- int XOffset = wpn->X % 16;
- int YOffset = wpn->Y % 16;
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_WAS_REFLECTED)==0){
- if(ComboTAtWpn(wpn,CT_MIRROR)||
- ComboTAtWpn(wpn,CT_MIRRORBACKSLASH)||
- ComboTAtWpn(wpn,CT_MIRRORSLASH)){
- if(ComboTAtWpn(wpn)==CT_MIRRORSLASH){
- if(wpn->Dir==DIR_UP){
- angle = DegtoRad(0);
- wpn->X+=XOffset;
- wpn->Y-=YOffset;
- }
- else if(wpn->Dir==DIR_DOWN){
- angle = DegtoRad(180);
- wpn->X-=XOffset;
- wpn->Y+=YOffset;
- }
- else if(wpn->Dir==DIR_LEFT){
- angle = DegtoRad(270);
- wpn->X+=XOffset;
- wpn->Y-=YOffset;
- }
- else if(wpn->Dir==DIR_RIGHT){
- angle = DegtoRad(90);
- wpn->X-=XOffset;
- wpn->Y+=YOffset;
- }
- }
- else if(ComboTAtWpn(wpn)==CT_MIRRORBACKSLASH){
- if(wpn->Dir==DIR_UP){
- angle = DegtoRad(180);
- wpn->X-=XOffset;
- wpn->Y-=YOffset;
- }
- else if(wpn->Dir==DIR_DOWN){
- angle = DegtoRad(0);
- wpn->X+=XOffset;
- wpn->Y+=YOffset;
- }
- else if(wpn->Dir==DIR_LEFT){
- angle = DegtoRad(90);
- wpn->X-=XOffset;
- wpn->Y+=YOffset;
- }
- else if(wpn->Dir==DIR_RIGHT){
- angle = DegtoRad(270);
- wpn->X+=XOffset;
- wpn->Y-=YOffset;
- }
- }
- if(wpn->TileHeight==0 && wpn->TileWidth==0)
- new = FireLWeapon(wpn->ID, wpn->X, wpn->Y, angle, wpn->Step, wpn->Damage, wpn->Misc[LW_ZH_I_LIFESPAN_ARG], wpn->Misc[LW_ZH_I_FX], wpn->Misc[LW_ZH_I_FLAGS]);
- else
- new = FireBigLWeapon(wpn->ID, wpn->X, wpn->Y, angle, wpn->Step, wpn->Damage, wpn->Misc[LW_ZH_I_LIFESPAN_ARG], wpn->Misc[LW_ZH_I_FX], wpn->Misc[LW_ZH_I_FLAGS],wpn->TileHeight,wpn->TileWidth);
- SetLWeaponLifespan(new, wpn->Misc[LW_ZH_I_LIFESPAN], wpn->Misc[LW_ZH_I_LIFESPAN_ARG]);
- SetLWeaponMovement(new,wpn->Misc[LW_ZH_I_MOVEMENT],wpn->Misc[LW_ZH_I_MOVEMENT_ARG],wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]);
- if(wpn->Misc[LW_ZH_I_FX]>0)
- SetLWeaponSFX(new, wpn->Misc[LW_ZH_I_FX], wpn->Misc[LW_ZH_I_WORK_2]);
- SetLWeaponDeathEffect(new, wpn->Misc[LW_ZH_I_ON_DEATH], wpn->Misc[LW_ZH_I_ON_DEATH_ARG]);
- new->Misc[LW_ZH_I_FLAGS_2]|=wpn->Misc[LW_ZH_I_FLAGS_2]|LWF_WAS_REFLECTED;
- Remove(wpn);
- }
- }
- else if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_WAS_REFLECTED)!=0){
- if(!ComboTAtWpn(wpn,CT_MIRROR)&&
- !ComboTAtWpn(wpn,CT_MIRRORBACKSLASH)&&
- !ComboTAtWpn(wpn,CT_MIRRORSLASH)){
- wpn->Misc[LW_ZH_I_FLAGS_2]&=~LWF_WAS_REFLECTED;
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_IS_REFLECTED)==0)
- wpn->Misc[LW_ZH_I_FLAGS_2]|=LWF_IS_REFLECTED;
- }
- }
- }
- //Makes lweapon ignore gravity
- void __UpdateLWF_G_Force(lweapon wpn){
- wpn->Jump = 0;
- }
- //Turns an lweapons collision detection off.
- void __UpdateLWF_Collision(lweapon wpn){
- wpn->CollDetection= false;
- }
- void __UpdateLWF_Poison(lweapon wpn){
- if(Screen->NumNPCs()>0){
- for(int i=Screen->NumNPCs();i>0;i--){
- npc thing = Screen->LoadNPC(i);
- if(wpn->Misc[LW_ZH_I_WORK]==0){
- if(Collision(thing,wpn) && (thing->Defense[LWDefense(wpn->ID)]==NPCDT_STUN
- || thing->Defense[LWDefense(wpn->ID)]==NPCDT_STUNORBLOCK
- || thing->Defense[LWDefense(wpn->ID)]==NPCDT_STUNORIGNORE)){
- if(thing->Defense[LWDefense(wpn->ID)]!=NPCDT_STUN){
- int PoisonChance = Rand(0,100);
- if(PoisonChance>50){
- if(thing->HP<=0)wpn->Misc[LW_ZH_I_WORK]=0;
- thing->Misc[NPC_MISC_TARGET_NUMBER] = Rand(0,255);
- wpn->Misc[LW_ZH_I_WORK]= thing->Misc[NPC_MISC_TARGET_NUMBER];
- }
- }
- else{
- if(thing->HP<=0)wpn->Misc[LW_ZH_I_WORK]=0;
- thing->Misc[NPC_MISC_TARGET_NUMBER] = Rand(0,255);
- wpn->Misc[LW_ZH_I_WORK]= thing->Misc[NPC_MISC_TARGET_NUMBER];
- }
- }
- }
- else{
- thing = Screen->LoadNPC(wpn->Misc[LW_ZH_I_WORK]);
- if(thing->HP<=0)wpn->Misc[LW_ZH_I_WORK]=0;
- else{
- if(wpn->Misc[LW_ZH_I_WORK_3]<300){
- wpn->Misc[LW_ZH_I_WORK_2]= (wpn->Misc[LW_ZH_I_WORK_2]+1)%30;
- if(wpn->Misc[LW_ZH_I_WORK_2]==0)thing->HP--;
- wpn->Misc[LW_ZH_I_WORK_3]++;
- wpn->X = thing->X;
- wpn->Y = thing->Y;
- wpn->UseSprite(POISON_SPRITE);
- Game->PlaySound(SFX_POISON);
- }
- }
- }
- }
- }
- }
- const int POISON_SPRITE = 0;
- const int SFX_POISON = 0;
- //Makes Link invincible while this is active.
- void __UpdateLWF_Link_CollOff(){
- Link->CollDetection= false;
- }
- //Makes it where Link can't move while this lweapon is active.
- void __UpdateLWF_Link_FreezeOn(){
- NoAction();
- }
- void __FlagTrigger(lweapon wpn){
- bool trigger = false;
- if(wpn->ID==LW_ARROW){
- if(ComboFIAtWpn(wpn,CF_ARROW)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_1)!=0)trigger = true;
- }
- if(ComboFIAtWpn(wpn,CF_ARROW2)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_2)!=0)trigger = true;
- }
- if(ComboFIAtWpn(wpn,CF_ARROW3)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_3)!=0)trigger = true;
- }
- }
- else if(wpn->ID==LW_FIRE){
- if(ComboFIAtWpn(wpn,CF_CANDLE1)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_1)!=0)trigger = true;
- }
- if(ComboFIAtWpn(wpn,CF_CANDLE2)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_2)!=0)trigger = true;
- }
- }
- else if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_BRANG){
- if(ComboFIAtWpn(wpn,CF_BRANG1)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_1)!=0)trigger = true;
- }
- if(ComboFIAtWpn(wpn,CF_BRANG2)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_2)!=0)trigger = true;
- }
- if(ComboFIAtWpn(wpn,CF_BRANG3)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_3)!=0)trigger = true;
- }
- }
- else if(wpn->ID==LW_MAGIC && ComboFIAtWpn(wpn,CF_WANDMAGIC))trigger = true;
- else if(wpn->ID==LW_MAGIC && ComboFIAtWpn(wpn,CF_WANDFIRE)
- && (wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_3)!=0)trigger = true;
- else if(wpn->ID==LW_MAGIC && ComboFIAtWpn(wpn,CF_REFMAGIC)
- && (wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_IS_REFLECTED)!=0)trigger = true;
- //else if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_MELEE){
- //if(wpn->Misc[LW_ZH_I_MOVEMENT_ARG]==LW_IS_SWORD){
- //if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_1)!=0)return CF_SWORD1;
- //else if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_2)!=0)return CF_SWORD2;
- //else if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_3)!=0)return CF_SWORD3;
- //else
- //return CF_SWORD4;
- //}
- //else if(wpn->Misc[LW_ZH_I_MOVEMENT_ARG]==LW_IS_HAMMER)
- //return CF_HAMMER;
- //else if(wpn->Misc[LW_ZH_I_MOVEMENT_ARG]==LW_IS_WAND)
- //return CF_WAND;
- //}
- else if(wpn->ID==LW_BEAM){
- if(ComboFIAtWpn(wpn,CF_SWORD1BEAM)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_1)!=0)trigger = true;
- }
- if(ComboFIAtWpn(wpn,CF_SWORD2BEAM)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_2)!=0)trigger = true;
- }
- if(ComboFIAtWpn(wpn,CF_SWORD3BEAM)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_3)!=0)trigger = true;
- }
- if(ComboFIAtWpn(wpn,CF_SWORD4BEAM)){
- if((wpn->Misc[LW_ZH_I_FLAGS_2]&LWF_LEVEL_4)!=0)trigger = true;
- }
- }
- //else if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_HOOKSHOT)
- //return CF_HOOKSHOT;
- if(trigger){
- if(wpn->Misc[LW_ZH_I_MOVEMENT]==LWM_BRANG)
- wpn->Misc[LW_ZH_I_FLAGS_2]|=LWF_RETURN;
- else
- KillLWeapon(wpn);
- Screen->TriggerSecrets();
- Screen->State[ST_SECRET] = true;
- Game->PlaySound(SFX_SECRET);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement