//////////////////////////////////// /// Global Constants & Variables /// //////////////////////////////////// const int MISC_LWEAPON_ITEM = 0; // The id of the item used to create an lweapon. int LastItemUsed = 0; // The item id of the last item Link has used. ///////////////////// /// Global Script /// ///////////////////// global script active{ void run(){ while (true){ //UpdateEWeapons(); //CleanUpGhostFFCs(); // Only needed if __GH_USE_DRAWCOMBO is 0 UpdateLWeapons(); UpdateLastItem(); //if (Link->PressB) {LastItemUsed = GetEquipmentB();} //if (Link->PressA) {LastItemUsed = GetEquipmentA();} Waitdraw(); //XP(); //AutoGhost(); //DrawGhostFFCs(); //lastScreen = Game->GetCurDMapScreen(); //Update last screen/DMap //lastDMap = Game->GetCurDMap(); Waitframe(); } } } //////////////////////// /// Global Functions /// //////////////////////// void UpdateLWeapons() { // Updates every LWeapon on screen. Call in the active script. for (int i = 1; i <= Screen->NumLWeapons(); i++) { UpdateLWeapon(Screen->LoadLWeapon(i)); } } void UpdateLWeapon(lweapon lw) { // Update a given LWeapon. // If the weapon does not have it's source item marked, mark it as // being created by the last item that Link has used. if (lw->Misc[MISC_LWEAPON_ITEM] == 0) { lw->Misc[MISC_LWEAPON_ITEM] = LastItemUsed; } } //// Updates the LastItemUsed variable to our best guess at what was //// most recently used. This should be called at the end of the loop, //// right before Waitdraw or Waitframe, because the item marked in //// LastItemUsed isn't actually used until after the Waitdraw or //// Waitframe. void UpdateLastItem() { // Since we don't know which button has priority if both are pressed // at once, cancel the B button press if A has also been pressed // this frame. if ( Link->PressA && Link->PressB ) { Link->PressB = false; } // If Link is currently in an action where he obviously can't use // items, then ignore his button presses. if ( Link->Action != LA_NONE && Link->Action != LA_WALKING ) { return; } // Check which button is being pressed, if any. Also check for the // appopriate Jinx. if ( Link->PressA && Link->SwordJinx == 0 ) { LastItemUsed = GetEquipmentA(); } else if ( Link->PressB && Link->ItemJinx == 0 ) { LastItemUsed = GetEquipmentB(); } } bool IsFromItem(lweapon lw, int itemNumber) { // Return true if the given lweapon is from the given item. return lw->Misc[MISC_LWEAPON_ITEM] == itemNumber; } bool IsFromItemClass(lweapon lw, int itemClass) { // Return true if the given lweapon is from the given item class. itemdata data = Game->LoadItemData(lw->Misc[MISC_LWEAPON_ITEM]); return data->Family == itemClass; } ///////////////////////////////////// /// Enemy Vulnerabilities /// /// Modified from: the Gibdo Burn /// /// Script by MoscowModder /// /// Combined with the FFC Trigger /// /// Script by: grayswandir /// ///////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////// /// Place on screen with an enemy, so that if it is killed by a specific type of weapon /// /// it spawms a different enemy. or produces a different effect. /// /// D0: Enemy Number of SOurce Enemy to Affect. /// /// D1: Enemy to Replace D0 with on Contact with Trigger. /// /// D2: Trigger - Positive Number for Specific Item Number; Negative Number of LW Type. /// ///////////////////////////////////////////////////////////////////////////////////////////// /// Place one FFC of this script on the screen for each enemy to affect by it. /// /// You can cascade this by setting the replacement enemy type as a source type in /// /// a second instance of this FFC. /// /// THis can be especially useful for spells: You can have enemies that are outwardly /// /// invincible, but are changed once affected by a spell or item. You can use the same /// /// sprite, or a variation of itl to reflect the change int he state of the enemy, or to /// /// make the change invisible to the player. /// ///////////////////////////////////////////////////////////////////////////////////////////// ffc script specialEnemyVulnerability{ void run(int enemy1, int enemy2, int trigger) { while(true){ for(int i = 1; i < Screen->NumNPCs(); i++){ //Check every enemy npc enem = Screen->LoadNPC(i); if(enem->ID == gibdo){ //If it's a gibdo2 for(int j = 1; j < Screen->NumLWeapons(); j++){ //Check every weapon lweapon weap = Screen->LoadLWeapon(j); if (weap->CollDetection && Collision(enem, lw)) { //if the LW touches the enemy, if (IsFromItem(weap, trigger)) { // If LW is from right item type. npc newEnem = CreateNPCAt(skeleton, enem->X, enem->Y); //Create the skeleton newEnem->HP = enem->HP; //Set its HP to gibdo's HP (optional; can remove this) Remove(enem); //Remove gibdo quietly } else if (IsFromItemClass(lw, -trigger)) { npc newEnem = CreateNPCAt(skeleton, enem->X, enem->Y); //Create the skeleton newEnem->HP = enem->HP; //Set its HP to gibdo's HP (optional; can remove this) Remove(enem); //Remove gibdo quietly } } } } Waitframe(); } } } }