@Alucard648
Can you explain the sound argument in the LweaponInit() function?
Is it the sound that plays when the item is picked up or the sound it plays when being used?
I was wondering this because because I am trying to make a Gameboy style sword and it used multiple random sounds when the sword was swung.
Edit: also what do I put for the sprite argument in LweaponInit() if I have multiple sprites?
I'm trying to make a gameboy sword
here is my script even though it is unfinished and I was in the process of renaming stuff
Spoilerconst int SWORD_BASE_DAMAGE = 1 const int SWORD_SLASH_SPRITE = 0 const int SWORD_SLASH_DAMAGE_MODIFIER = 1; const int SWORD_SLASH_DELAY = 2 const int SWORD_SLASH_SPEED = 2 const int SWORD_SLASH_OFFSET = 8; const int SWORD_SLASH_SFX = 0 const int SWORD_SLASH_TRIGGER_FLAG = 0 const int SWORD_SLASH_SECRET_FLAG = 0 const int SWORD_SLASH_ENEMY_DEFENSE = NPCD_SWORD; //The enemy defence flag for this item const int SWORD_CHARGE_SPRITE = 0 const int SWORD_CHARGE_DAMAGE_MODIFIER = 2; const int SWORD_CHARGE_DELAY = 2 const int SWORD_CHARGE_SPEED = 2 const int SWORD_CHARGE_OFFSET = 8; const int SWORD_CHARGE_SFX = 0; const int SWORD_CHARGE_TRIGGER_FLAG = 0 const int SWORD_CHARGE_SECRET_FLAG = 0 const int SWORD_CHARGE_ENEMY_DEFENSE = NPCD_SWORD; //The enemy defence flag for this item const int SWORD_STAB_SPRITE = 0 const int SWORD_STAB_DAMAGE_MODIFIER = 1; const int SWORD_STAB_DELAY = 2 const int SWORD_STAB_SPEED = 2 const int SWORD_STAB_OFFSET = 8; const int SWORD_STAB_SFX = 0 const int SWORD_STAB_TRIGGER_FLAG = 0 const int SWORD_STAB_SECRET_FLAG = 0 const int SWORD_STAB_ENEMY_DEFENSE = NPCD_SWORD; //The enemy defence flag for this item const int SWORD_SPIN_SPRITE = 0 const int SWORD_SPIN_DAMAGE_MODIFIER = 2; const int SWORD_SPIN_DELAY = 2 const int SWORD_SPIN_SPEED = 2 const int SWORD_SPIN_OFFSET = 8; const int SWORD_SPIN_SFX = 0; const int SWORD_SPIN_TRIGGER_FLAG = 0 const int SWORD_SPIN_SECRET_FLAG = 0 const int SWORD_SPIN_ENEMY_DEFENSE = NPCD_SWORD; //The enemy defence flag for this item const int SWORD_BEAM_SPRITE = 0 const int SWORD_BEAM_DAMAGE_MODIFIER = 1; const int SWORD_BEAM_DELAY = 2; const int SWORD_BEAM_SPEED = 300 const int SWORD_BEAM_OFFSET = 8; const int SWORD_BEAM_SFX = 0; const int SWORD_BEAM_TRIGGER_FLAG = 0 const int SWORD_BEAM_SECRET_FLAG = 0 const int SWORD_BEAM_ENEMY_DEFENSE = NPCD_SWORD; //The enemy defence flag for this item const int SWORD_DESTROY_COMBO1 = 0; //Type of combo to be destroyed by this lweapon. 0 to disable. const int SWORD_DESTROY_COMBO1_SFX = 0; //Type of combo to be destroyed by this lweapon. 0 to disable. const int SWORD_DESTROY_COMBO1 = 0; //Type of combo to be destroyed by this lweapon. 0 to disable. const int SWORD_DESTROY_COMBO1_SFX = 0; //Type of combo to be destroyed by this lweapon. 0 to disable. const int SWORD_BEAM_PIERL_HP_THRESHOLD = 16; const int SWORD_BEAM_NORMAL_HP_THRESHOLD = 0; // Hearts required to shoot peirl beams. set to 0 if const int SWORD_NORMAL_SPIN_NUMSPINS = 1 const int SWORD_HURRICANE_SPIN_NUMSPINS = 3 //D0-Sword sprite used //D1-Sword damage //D2-Beam sprite used //D3-Beam damage ffc script Sword { void run(int sword_sprite, int sword_damage, int beam_sprite, int beam_damage) { lweapon = sword = LweaponInit(this, LW_GHOSTED, SWORD_BASE_DAMAGE + sword_damage, sword_sprite, 30) int OrigHitboxData[4]={2, 2, 6, 16}; int counter = 0; int numspins=0; int chargetype = 0; int hurricane = 256; int spinattack = 128; SetLweaponHitboxOffsets(sword, 2, 2, 6, 16); //Check if Slash Flag is off and preform stab if (! Game->Generic[GEN_CANSLASH]) { sword->Damage *= SWORD_STAB_DAMAGE_MODIFIER; MeleeWeaponStab(this, sword, sword->Misc[LWEAPON_MISC_ORIGTILE], SWORD_STAB_DELAY, SWORD_STAB_OFFSET, SWORD_STAB_TRIGGER_FLAG, SWORD_DESTROY_COMBO1, SWORD_STAB_ENEMY_DEFENSE, SWORD_DESTROY_COMBO1_SFX, SWORD_STAB_SPEED); } //Else perform slash else { sword->Damage *= SWORD_SLASH_DAMAGE_MODIFIER; MeleeWeaponSLASH90Alt(this, sword, sword->Misc[LWEAPON_MISC_ORIGTILE], SWORD_SLASH_DELAY_DELAY, SWORD_SLASH_OFFSET, SWORD_SLASH_TRIGGER_FLAG, SWORD_DESTROY_COMBO1, SWORD_SLASH_ENEMY_DEFENSE, SWORD_DESTROY_COMBO1_SFX, SWORD_SLASH_SPEED); } //If link does not has item spin scroll termeate script WE ARE DONE if (!Link->Item[I_SPINSCROLL1]) { LaunchSwordBeam(SWORD_DAMAGE, BEAM_COMBO, Link->Dir, beamhearts, this->InitD[7]); MeleeWeaponEndStrike(this, sword, sword->Misc[LWEAPON_MISC_ORIGTILE], 2, SWORD_STAB_OFFSET, SWORD_STAB_DELAY*2); } MeleeWeaponDraw(this, sword, sword->Misc[LWEAPON_MISC_ORIGTILE], SWORD_STAB_DELAY, SWORD_STAB_OFFSET); if (Link->Item[I_CHARGERING2]) spinattack=32; else if (Link->Item[I_CHARGERING1]) spinattack=64; if (Link->Item[I_CHARGERING2]) hurricane=64; else if (Link->Item[I_CHARGERING1]) hurricane=128; while (UsingItem(this->InitD[7])) { if (Link->Dir!=sword->Dir){ MeleeWeaponDraw(this, sword, sword->Misc[LWEAPON_MISC_ORIGTILE], SWORD_CHARGE_DELAY, SWORD_CHARGE_OFFSET); AutoRotateLweaponHitbox(sword, OrigHitboxData); } counter++; if ((counter >= spinattack) && (chargetype == 0)) { Game->PlaySound(SFX_CHARGE1); chargetype=1; } if ((counter >= hurricane) && (Link->Item[I_SPINSCROLL2])) { if (chargetype == 1) { if (AmmoManager(CR_MAGIC, 8, 118, false)){ Game->PlaySound(SFX_CHARGE2); chargetype=2; } } } if ((chargetype > 0) && (counter % 15 == 0)) { TapForSecretFlags(this, sword, secrettapdetect1, secrettapdetect2); } LweaponWaitframe (this, sword, true); LweaponWaitframe (this, sword, true); } LweaponUnSetFlag(sword, LWF_SWING_WHILE_WALKING); if (chargetype == 2) { numspins = HURRICANE_SPIN_NUMSPINS; sword->Damage*=HURRICANE_SPIN_DAMAGE_MODIFIER; } else if (chargetype == 1) { numspins = NORMAL_SPIN_NUMSPINS; sword->Damage*=SPIN_ATTACK_DAMAGE_MODIFIER; } if (numspins > 1) LweaponSetFlag(sword, LWF_SWING_WHILE_WALKING); for (int i = 1; i <= numspins; i++) { Game->PlaySound(SFX_SPINATTACK); MeleeWeaponSlash360(this, sword, sword->Misc[LWEAPON_MISC_ORIGTILE], SWORD_SPIN_DELAY, SWORD_SPIN_OFFSET, SECRET_TAP_FLAG2, 141, NPCD_SWORD, 41, 1); } } } void LaunchSwordBeam(int damage, int sprite, int dir, int hearts, int itm) { if (damage <= 0) return; bool canshoot = false; if ((Link->HP<=PERIL_SCROLL_HP_THRESHOLD)&&(Link->Item[I_PERILSCROLL])) canshoot = true; if ((hearts<0)&&(Link->HP>=((Link->MaxHP)*(Abs(hearts)/100)))) canshoot = true; if ((hearts>0)&&(Link->HP>=hearts)) canshoot=true; if (!canshoot) return; //Game->PlaySound(32); int args[8] = { damage, sprite, SWORD_BEAM_SPEED/100, dir, 0, 0, itm }; int buffer[] = "SwordBeam"; int scr = Game->GetFFCScript(buffer); ffc beam = LaunchScriptedLweapon(scr, args); } void TapForSecretFlags(ffc f, lweapon sword, int flag1, int flag2) { if (!IsTappingSolidCombo(sword)) return; MeleeWeaponDraw(f, sword, sword->Misc[LWEAPON_MISC_ORIGTILE], SWORD_STAB_DELAY, SWORD_STAB_OFFSET+8); if (ComboAnyFlagCollision (SECRET_TAP_FLAG1, sword, false, -1))Game->PlaySound(SFX_TAP2); else if(ComboAnyFlagCollision (SECRET_TAP_FLAG2, sword, false, -1))Game->PlaySound(SFX_TAP2); else Game->PlaySound(SFX_TAP1); MeleeWeaponDraw(f, sword, sword->Misc[LWEAPON_MISC_ORIGTILE], SWORD_STAB_DELAY, SWORD_STAB_OFFSET); } //Returns TRUE if Link tries to tap solid combo with scripted sword. bool IsTappingSolidCombo (lweapon sword){ if (Screen->isSolid((Link->X + 8), (Link->Y - 1))){ if ((Link->InputUp)&&(sword->Dir == DIR_UP)) return true; } if (Screen->isSolid((Link->X + 8), (Link->Y + 17))){ if ((Link->InputDown)&&(sword->Dir == DIR_DOWN)) return true; } if (Screen->isSolid((Link->X - 1), (Link->Y + 8))){ if ((Link->InputLeft)&&(sword->Dir == DIR_LEFT)) return true; } if (Screen->isSolid((Link->X + 17), (Link->Y + 8))){ if ((Link->InputRight)&&(sword->Dir == DIR_RIGHT)) return true; } return false; } ffc script SwordBeam { void run (int damage, int sprite, int speed, int particle, int dir) { lweapon sword = LweaponInit (this, LW_GHOSTED, Abs(damage), sprite, SFX_BEAM); SetLweaponHitboxOffsets(sword, 2, 2, 6, 16); int OrigHitboxData[4]={2, 2, 6, 16}; if (dir==DIR_UP) this->Y-=12; if (dir==DIR_DOWN) this->Y+=12; if (dir==DIR_LEFT) this->X-=12; if (dir==DIR_LEFT) this->X+=12; if (damage<0) LweaponSetFlag(sword, LWF_PENETRATING); LweaponSetFlag(sword, LWF_AUTO_DIR_UPDATE); LweaponSetFlag(sword, LWF_AUTO_SPRITE_UPDATE); LweaponSetFlag(sword, LWF_NO_FALL); SetEnemyDefense(sword, NPCD_BEAM); SetStraightMotion4(this, dir, speed); while (sword->isValid()) { AutoRotateLweaponHitbox (sword, OrigHitboxData); LweaponWaitframe (this,sword, false); } int angle = 45; int flip[4] = { 3, 2, 0, 1 }; } }
LweaponInit last argument plays sound on creation of ghosted lweapon (i.e. when using item). You could, for instance, create array of sound ID`s, choose one at random and pass in chosen sound ID into LweaponInit to play random sound on each sword swing.