//////////////////////////////////////////////////////////////// //// Constants // The id of the item used to create an lweapon. const int MISC_LWEAPON_ITEM = 0; //////////////////////////////////////////////////////////////// //// Global Variables // The item id of the last item Link has used. int LastItemUsed = 0; //////////////////////////////////////////////////////////////// //// Functions //////////////// //// Updates every LWeapon on screen. Call in the active script. void UpdateLWeapons() { for (int i = 1; i <= Screen->NumLWeapons(); i++) { UpdateLWeapon(Screen->LoadLWeapon(i));}} //////////////// //// Update a given LWeapon. void UpdateLWeapon(lweapon lw) { // 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();}} //////////////// //// Return true if the given lweapon is from the given item. bool IsFromItem(lweapon lw, int itemNumber) { return lw->Misc[MISC_LWEAPON_ITEM] == itemNumber;} //////////////// //// Return true if the given lweapon is from the given item class. bool IsFromItemClass(lweapon lw, int itemClass) { itemdata data = Game->LoadItemData(lw->Misc[MISC_LWEAPON_ITEM]); return data->Family == itemClass;} 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(); } } } //by MM //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. // Set D0 for the enemy to affect. // Set D1 for the enemy to replace it. //Set D2 for the LW_Type to cause the effct. //Place one copy of this FFC on the screen PER enemy to affect. //YOu can cascade this effect on the replacement enemy. //This will be useful for spells in TGC. //Make enemies that canlt be hurt, but change if affected by a spell. //Possiby combine with FFC_Item script components, to make enemy weak to item by item number. //D0: Enemy to burn //D1: Enemy to spawn //D2 Trigger: A postivie number specifies a specific item. A Negative number specifies an item class (LW_Type). 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(); } } } }