Jump to content

Photo

Item Action Scrtipt Request (SFX)


  • Please log in to reply
79 replies to this topic

#76 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 04 July 2016 - 11:28 PM

Unfortunate Zoria's idea won't work. Bomb explosions ignore draw offsets. I did some checking, and explosions do have a sprite you can blank out, rather than a hardcoded tile. I don't think the sparkle idea will work after all, because explosions draw in a very strange way, different from most other sprites. Frame advance with F4 through an explosion and you'll see what I mean. It does that even though the sprite itself has no frames or animation speed set.

If you only have these scripted bombs in your quest, blanking out Link's bomb explosion sprite (and leaving the enemy explosion alone) seems like the simplest solution to the double explosion issue.

 

Oh huzzah. Another undocumented bug. So, my other method was to use DrawTile(), over where the sprite should be, after blanking the sprite.

 

Of course, you can do CopyTile() instead, but that's also quite a lot of work.



#77 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 11 July 2016 - 09:18 PM

Ok, so I'm gonna see if I can re-edit this script to work with Super Bombs.

 

The original:

const int BOMB_DAMAGE = 4;//Damage to Enemies from Scripted Bombs
const int LW_MISC_MARKED = 0;//Index used for Scripted Bombs
const int BOMB_DAMAGE_TO_LINK = 8;//Quarter Heart Damage to Link from Scripted Bombs


BombBlastFake();


void BombBlastFake()
{
 lweapon w;
 eweapon ew;
 for (int i = Screen->NumLWeapons(); i > 0; i--)
 {
  w = Screen->LoadLWeapon(i);
  if (w->ID == LW_BOMBBLAST && w->Misc[LW_MISC_MARKED] != 1)
  {
   w->Misc[LW_MISC_MARKED] = 1;
   ew = Screen->CreateEWeapon(EW_BOMBBLAST);
   ew->X = w->X;
   ew->Y = w->Y;
   ew->Damage = BOMB_DAMAGE_TO_LINK;
  }
 }
}


//D0: SFX to play when Link places a Bomb

item script SpawnLWeaponBomb{
     void run(int sound){
          //You have more than one bomb and there are no bombs on screen.
          if((Game->Counter[CR_BOMBS] >0 || Link->Item[I_BOMBBAG4]) && NumLWeaponsOf(LW_BOMB)==0){
	        Game->PlaySound(sound);//Play the sound.
                //Spawn the bomb in front of Link and set the damage.
	        lweapon bomb = Screen->CreateLWeapon(LW_BOMB);
		bomb->X = Link->X+ InFrontX(Link->Dir,0);
		bomb->Y = Link->Y+ InFrontY(Link->Dir,0);
	        bomb->Damage = BOMB_DAMAGE;
                //Reduce in-game counter.
		if (!Link->Item[I_BOMBBAG4])
		Game->Counter[CR_BOMBS]--;
	   } 
     }
}

My edit:

const int SBOMB_DAMAGE = 16;//Damage to Enemies from Scripted Bombs
const int LW_MISC_MARKED = 0;//Index used for Scripted Bombs
const int SBOMB_DAMAGE_TO_LINK = 8;//Quarter Heart Damage to Link from Scripted Bombs


SBombBlastFake();


void SBombBlastFake()
{
 lweapon w;
 eweapon ew;
 for (int i = Screen->NumLWeapons(); i > 0; i--)
 {
  w = Screen->LoadLWeapon(i);
  if (w->ID == LW_SBOMBBLAST && w->Misc[LW_MISC_MARKED] != 1)
  {
   w->Misc[LW_MISC_MARKED] = 1;
   ew = Screen->CreateEWeapon(EW_SBOMBBLAST);
   ew->X = w->X;
   ew->Y = w->Y;
   ew->Damage = SBOMB_DAMAGE_TO_LINK;
  }
 }
}


//D0: SFX to play when Link places a Bomb

item script SpawnSuperLWeaponBomb{
     void run(int sound){
          //You have more than one bomb and there are no bombs on screen.
          if((Game->Counter[CR_SBOMBS] >0 || Link->Item[I_BOMBBAG4]) && NumLWeaponsOf(LW_SBOMB)==0){
	        Game->PlaySound(sound);//Play the sound.
                //Spawn the bomb in front of Link and set the damage.
	        lweapon bomb = Screen->CreateLWeapon(LW_SBOMB);
		bomb->X = Link->X+ InFrontX(Link->Dir,0);
		bomb->Y = Link->Y+ InFrontY(Link->Dir,0);
	        bomb->Damage = SBOMB_DAMAGE;
                //Reduce in-game counter.
		if (!Link->Item[I_BOMBBAG4])
		Game->Counter[CR_SBOMBS]--;
	   } 
     }
}

I... think that should do it. I didn't change line 2 "const int LW_MISC_MARKED = 0;//Index used for Scripted Bombs" because I don't understand what that does.

 

EDIT: Aaand the line I didn't change is causing a compiling error, saying there is already a constant defined


Edited by Cukeman, 11 July 2016 - 09:41 PM.


#78 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 11 July 2016 - 09:50 PM

The reason you're getting a compiler error is because that line is declaring a constant. If you copy paste it, you're declaring two constants with the same name. The compiler doesn't like that. You can just delete it from your duplicate script; it only needs to exist in the script file once.

(If you're curious about what it does, the script needs to only affect each BombBlast LWeapon once. All LWeapons have an array of Misc values associated with them that just exist for scripting. So the script is checking to see if a certain Misc value isn't set to 1. If it's set to 1, it's marked as having already had the script do something to it, so if it's not 1, the script does the thing, then sets it to one. LW_MISC_MARKED just exists so that you can tell the script which Misc value to use as the flag to check, in case you have other scripts using Misc values.)
  • Cukeman likes this

#79 Cukeman

Cukeman

    "Tra la la, look for Sahasrahla. ... ... ..."

  • Banned
  • Location:Hyrule/USA

Posted 11 July 2016 - 11:10 PM

Thanks! I am curious about what it does, and your description helped, but I still don't fully understand. I don't get why I can use both regular(scripted) and super(scripted) bombs at the same time if they both use the same index.


Edited by Cukeman, 11 July 2016 - 11:11 PM.


#80 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 11 July 2016 - 11:48 PM

The reason is that Misc variables are weapon-specific. Think of it sort of like this. If you go to screen data on any screen, and go to the Screen Flags 2 tab, you'll see 5 general purpose script flags. Every screen has five of these. So let's say you write a global script that does, I dunno,plays an sfx on any screen with a certain script flag checked. It could be any, so you just say script flag 1. Because every screen has its own script flag 1, it doesn't matter.

That's the situation here. LW_MISC_MARKED is defined as 1 by the line in question. That means it's gonna look at every weapon's Misc[1] value. So it doesn't matter that it's look at Misc[1] for both the bombs and superbombs, because each individual bomb and superbomb has its own Misc[1] value to be checked, just like every screen in the quest has it's own script flag 1 that can be checked or unchecked.
  • Cukeman likes this


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users