Jump to content

Photo

Item Action Scrtipt Request (SFX)


  • Please log in to reply
79 replies to this topic

#16 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 02 April 2016 - 11:07 PM

//D0: SFX to play

item script SpawnLWeaponBomb
{
    void run(int sound)
    {
        Game->PlaySound(sound);
        lweapon bomb = Screen->CreateLWeapon(6);
        if(Link->Dir==0){ bomb->X = Link->X; bomb->Y = Link->Y-16;
        else if(Link->Dir==1){ bomb->X = Link->X; bomb->Y = Link->Y+16;
        else if(Link->Dir==2){ bomb->X = Link->X-16; bomb->Y = Link->Y;
        else { bomb->X = Link->X+16; bomb->Y = Link->Y;
    }
}
pass 1: parsing
Line [10 in this post]: syntax error, unexpected else, on token else

 

fatal error p00: can’t open or parse input file!

 



#17 ywkls

ywkls

    Master

  • Members

Posted 02 April 2016 - 11:16 PM

Try this alternative. The functions InFrontX and InFrontY automatically handle the placement of stuff relative to objects like Link based on the direction he's facing. If you want it further away simply change the second arguments from 2 to something else.

item script SpawnLWeaponBomb{
     void run(int sound){
          Game->PlaySound(sound);
          lweapon bomb = Screen->CreateLWeapon(6);
          bomb->X = Link->X+ InFrontX(Link->Dir,2);
          bomb->Y = Link->Y+ InFrontY(Link->Dir,2);
     }
}

Edited by ywkls, 02 April 2016 - 11:17 PM.

  • Cukeman likes this

#18 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 02 April 2016 - 11:21 PM

If you have an opening brace, it needs a closing brace to match.

#19 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 02 April 2016 - 11:34 PM

If you have an opening brace, it needs a closing brace to match.


Noticed that, but wasn't sure how much the brace was supposed to enclose.
 

item script SpawnLWeaponBomb{
     void run(int sound){
          Game->PlaySound(sound);
          lweapon bomb = Screen->CreateLWeapon(6);
          bomb->X = Link->X+ InFrontX(Link->Dir,0);
          bomb->Y = Link->Y+ InFrontY(Link->Dir,0);
     }
}

That's awesome! It will need some tinkering to act like a real bomb though. Right now I have an infinite supply (even after I set the Counter Reference to Bombs and the Increase Amount to 4 [using this item doesn't decrease the bomb count]), and I can place a whole bunch on the screen really quickly.
 
EDIT: Also, as grayswandir pointed out, it's not damaging enemies, just stunning them.


Edited by Cukeman, 03 April 2016 - 12:19 AM.


#20 ywkls

ywkls

    Master

  • Members

Posted 03 April 2016 - 03:17 AM

Having it actually affect your bomb count isn't too hard. As for making it damage enemies, that shouldn't be too difficult either.

const int BOMB_DAMAGE = 0;//Change to something other than zero. Regulates how much damage the bomb does.

item script SpawnLWeaponBomb{
     void run(int sound){
          if(Game->Counter[CR_BOMBS] >0){
	        Game->PlaySound(sound);
	        lweapon bomb = Screen->CreateLWeapon(LW_BOMB);
		bomb->X = Link->X+ InFrontX(Link->Dir,1);
		bomb->Y = Link->Y+ InFrontY(Link->Dir,1);
	        bomb->Damage = BOMB_DAMAGE;
		Game->Counter[CR_BOMBS]--;
	   } 
     }
}

One of the reasons constants like that are used is so people using scripts can change things to meet their needs. The other is because they can be easier to remember than whatever number they stand for. Especially if you use that number a lot.

 

I'd recommend putting at least 1 pixel of distance between yourself and the bomb. Bombs only set off triggers that they are directly on top of, so 8 pixels might be better.


Edited by ywkls, 03 April 2016 - 03:20 AM.


#21 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 03 April 2016 - 03:51 AM

Having it actually affect your bomb count isn't too hard. As for making it damage enemies, that shouldn't be too difficult either.

const int BOMB_DAMAGE = 0;//Change to something other than zero. Regulates how much damage the bomb does.

item script SpawnLWeaponBomb{
     void run(int sound){
          if(Game->Counter[CR_BOMBS] >0){
	        Game->PlaySound(sound);
	        lweapon bomb = Screen->CreateLWeapon(LW_BOMB);
		bomb->X = Link->X+ InFrontX(Link->Dir,1);
		bomb->Y = Link->Y+ InFrontY(Link->Dir,1);
	        bomb->Damage = BOMB_DAMAGE;
		Game->Counter[CR_BOMBS]--;
	   } 
     }
}
One of the reasons constants like that are used is so people using scripts can change things to meet their needs. The other is because they can be easier to remember than whatever number they stand for. Especially if you use that number a lot.

 
Cool, I didn't realize you could use "LW_BOMB" instead of "6", that is easier to read. Excited to test this script modification really soon :)
 

I'd recommend putting at least 1 pixel of distance between yourself and the bomb. Bombs only set off triggers that they are directly on top of, so 8 pixels might be better.


I took screenshots with default bombs and found that they are normally placed 4 pixels away from Link. The original script said "2" placing the bombs 2 pixels away from Link. When I changed it to 4 the bombs were placed 0 pixels away from Link, so the distance must be inverted somehow. That's why I changed it to "0" -to make bombs appear 4 pixels away from Link as they do by default.

Edited by Cukeman, 03 April 2016 - 04:15 AM.


#22 grayswandir

grayswandir

    semi-genius

  • Members

Posted 03 April 2016 - 05:45 AM

InFrontX and InFrontY are broken, yeah. Always have been.



#23 idontknow8

idontknow8

    Senior

  • Members

Posted 03 April 2016 - 03:15 PM

I don't know if I missed this somewhere but how do you add this to other existing item use scripts so that you can have a custom sound play every time you also use a custom item (with a custom function)?

 

More specifically, I'm looking to add this to the new Invisibility Cloak item in the Script Database so that when you use the cloak to dash/warp forward, you also hear it happening.



#24 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 03 April 2016 - 11:32 PM

const int BOMB_DAMAGE = 4;

item script SpawnLWeaponBomb{
     void run(int sound){
          if(Game->Counter[CR_BOMBS] >0){
	        Game->PlaySound(sound);
	        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;
		Game->Counter[CR_BOMBS]--;
	   } 
     }
}

 

 

• Okay, so the counter is working, excellent!

• I am still able to place a whole lot of bombs on the screen at a time, which I'd like to fix (the default is one bomb onscreen at a time).

• The custom bombs are now damaging enemies, which is excellent, but they are dealing twice as much damage to Link as they should. Is there a way to correct that?

 

So close to recreating true bombs! :D


  • ywkls likes this

#25 ywkls

ywkls

    Master

  • Members

Posted 03 April 2016 - 11:55 PM

• I am still able to place a whole lot of bombs on the screen at a time, which I'd like to fix (the default is one bomb onscreen at a time).

The only way I know to limit the number of bombs on screen is to do something like the following...

const int BOMB_DAMAGE = 2;//How much damage the Lweapon does.

//Lweapon bombs. Spawns a bomb in front of Link with a different sound effect than normal.

//D0- Sound to make.

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 && 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.
		Game->Counter[CR_BOMBS]--;
	   } 
     }
}

This isn't tested, but it should work.

 

Edit: Changed custom function to one included in StdFunctions.zh, part of std.zh. Because there's no need to reinvent the wheel...

 

 

• The custom bombs are now damaging enemies, which is excellent, but they are dealing twice as much damage to Link as they should. Is there a way to correct that?

 

You probably have the constant at too high a value. Try a setting of 2 as in the revised script.


Edited by ywkls, 04 April 2016 - 12:20 AM.


#26 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 04 April 2016 - 12:24 AM

The discrepancy in damage dealt to enemies vs. damage dealt to Link is an obscure bug in ZC. The workaround in that thread would be effective if you were spawning explosions, but actual bomb eweapons behave very differently from bomb lweapons. Replicating proper bomb functionality would take more than a simple item script at that point.
  • Cukeman likes this

#27 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 04 April 2016 - 12:28 AM

The only way I know to limit the number of bombs on screen is to do something like the following...

const int BOMB_DAMAGE = 2;//How much damage the Lweapon does.

//Lweapon bombs. Spawns a bomb in front of Link with a different sound effect than normal.

//D0- Sound to make.

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 && 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.
		Game->Counter[CR_BOMBS]--;
	   } 
     }
}

This isn't tested, but it should work.

 

Edit: Changed custom function to one included in StdFunctions.zh, part of std.zh. Because there's no need to reinvent the wheel...

 

The if line doesn't have a closing parenthesis... any idea where it goes?


Edited by Cukeman, 04 April 2016 - 02:02 AM.


#28 ywkls

ywkls

    Master

  • Members

Posted 04 April 2016 - 09:45 AM

Right before the brace.
 

const int BOMB_DAMAGE = 2;//How much damage the Lweapon does.

//Lweapon bombs. Spawns a bomb in front of Link with a different sound effect than normal.

//D0- Sound to make.

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 && 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.
		Game->Counter[CR_BOMBS]--;
	   } 
     }
}

I should note that this is one of the main raasons I try to use Notepad++ for all my scripting these days. I wrote this one off the top of my head, directly in this thread.


  • Cukeman likes this

#29 justin

justin

    Adept

  • Members

Posted 04 April 2016 - 10:13 AM

Could turn off Link's bombs hurt link rule. Run a global script that looks for lweapon bomb blast and drops an eweapon bomb blast in the same spot with the appropriate damage set.
  • Cukeman likes this

#30 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 04 April 2016 - 02:50 PM

Right before the brace.
 

const int BOMB_DAMAGE = 2;//How much damage the Lweapon does.

//Lweapon bombs. Spawns a bomb in front of Link with a different sound effect than normal.

//D0- Sound to make.

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 && 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.
		Game->Counter[CR_BOMBS]--;
	   } 
     }
}

I should note that this is one of the main raasons I try to use Notepad++ for all my scripting these days. I wrote this one off the top of my head, directly in this thread.

 

Thank you, screen bomb limit accomplished! :D




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users