Jump to content

Photo

Item Action Scrtipt Request (SFX)


  • Please log in to reply
79 replies to this topic

#61 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 13 June 2016 - 01:59 PM

Use the wand and set it's magic costs so high that its impossible to shoot magic.

 

That works ...until I get double magic or magic rings. I can only set it as high as 255, and it appears that the final magic ring gives infinite magic.

 

I know I could make it work that way in a quest which lacked those items, but I'm trying to create something compatible with other items and upgrades.


Edited by Cukeman, 13 June 2016 - 02:01 PM.


#62 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 17 June 2016 - 05:41 PM

So... I've got this bomb script, which works great:
 

//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 && 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]--;
	   } 
     }
}

but how do I modify it to place a level 2 bomb?

 

full script



#63 ywkls

ywkls

    Master

  • Members

Posted 17 June 2016 - 06:51 PM

but how do I modify it to place a level 2 bomb?

 

Level 2 bomb as in more powerful? As in super bomb? Or as in, sets off different triggers and yet still does all the stuff a normal bomb does?

 

The first one doesn't needs a script. You can do that with item editor and just apply the existing script to its item action slot.

The second one would need to be an alteration of the script that you have.

//D0: SFX to play when Link places a Bomb
 
item script SpawnLWeaponSBomb{
     void run(int sound){
          //You have more than one bomb and there are no bombs on screen.
          if(Game->Counter[CR_SBOMBS] >0 && 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.
		Game->Counter[CR_SBOMBS]--;
	   } 
     }
}

The third would be a bit more complex, but it's also doable. Here's a sample script, which allows for the interaction of multiple scripted items and a triggering ffc.

ffc script Variable_Index_Trigger{
	void run(int type, int level, int perm){
		lweapon thing;
		int i;
		bool triggered = false;
		if(Screen->D[perm]!=0)triggered = true;
		while(!triggered){
			for(i = 1;i<=Screen->NumLWeapons();i++){
				thing = Screen->LoadLWeapon(i);
				if(thing->ID ==type && thing->Misc[LW_MISC_LEVEL_INDEX]>=level
				   && Collision(this,thing))triggered = true;
			}
			Waitframe();
		}
		Screen->TriggerSecrets();
		Screen->State[ST_SECRET]= true;
		Screen->D[perm] = 1;
	}
}

To get this to work with bombs and super bombs, you'd need to assign a value to the Misc index of an LW_BOMBBLAST and LW_SBOMBBLAST that corresponded to the correct level of the item. To do that requires some shenanigans.

 

First, change the item script like so...

item script SpawnLWeaponSBomb{
     void run(int sound,int level){
          //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;
                bomb->Misc[LW_MISC_LEVEL_INDEX]= level;
                //Reduce in-game counter.
		Game->Counter[CR_BOMBS]--;
	   } 
     }
}

Then add this to the global script...

void Bomb_Level(){
       for(i = 1;i<=Screen->NumLWeapons();i++){
            thing = Screen->LoadLWeapon(i);
	    if(thing->ID ==LW_BOMB && thing->DeadState ==0){
                lweapon other = CreateLWeapon(LW_BOMBBLAST);
                other->X = thing->X;
                other->Y = thing->Y;
                other->Damage = thing->Damage;
                other->Misc[LW_MISC_LEVEL_INDEX] = thing->Misc[LW_MISC_LEVEL_INDEX];
       }
}

All of this is untested. I'm not even sure you can check for the value of the weapon's deadstate that way. I'll have to experiment with it on my own time.


Edited by ywkls, 17 June 2016 - 06:51 PM.


#64 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 17 June 2016 - 07:22 PM

Level 2 bomb as in more powerful? As in super bomb? Or as in, sets off different triggers and yet still does all the stuff a normal bomb does?

 

Level 2 Bomb as in a separate item created by duplicating the Bomb Item, setting its Level to 2, setting the Fuse Duration to 0, and setting the Bomb Sprite to a different graphic.

 

The first one doesn't needs a script. You can do that with item editor and just apply the existing script to its item action slot.

 

I'm not seeing how that would work. Currently the scripted bomb I am using is a "Custem Itemclass 01" Class Item. I have the existing script attached to it and it places a Level 1 bomb.



#65 ywkls

ywkls

    Master

  • Members

Posted 17 June 2016 - 07:26 PM

Level 2 Bomb as in a separate item created by duplicating the Bomb Item, setting its Level to 2, setting the Fuse Duration to 0, and setting the Bomb Sprite to a different graphic.

 

 

I'm not seeing how that would work. Currently the scripted bomb I am using is a "Custem Itemclass 01" Class Item. I have the existing script attached to it and it places a Level 1 bomb.

Custom itemclass items can have levels as well. The highest one has the priority and as long as it has the script attached; it would do the same thing as the other one. Changing the graphic is actually a bit harder... you'd have to add a line to the script that defined what sprite the bomb used.

//D0: SFX to play when Link places a Bomb
//D1: Sprite to use for the bomb.
 
item script SpawnLWeaponBomb{
     void run(int sound, int sprite){
          //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;
                bomb->UseSprite(sprite);
                //Reduce in-game counter.
		Game->Counter[CR_BOMBS]--;
	   } 
     }
}

That should do it... I think.


Edited by ywkls, 17 June 2016 - 07:26 PM.


#66 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 17 June 2016 - 07:40 PM

Custom itemclass items can have levels as well. The highest one has the priority and as long as it has the script attached; it would do the same thing as the other one. Changing the graphic is actually a bit harder... you'd have to add a line to the script that defined what sprite the bomb used.

//D0: SFX to play when Link places a Bomb
//D1: Sprite to use for the bomb.
 
item script SpawnLWeaponBomb{
     void run(int sound, int sprite){
          //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;
                bomb->UseSprite(sprite);
                //Reduce in-game counter.
		Game->Counter[CR_BOMBS]--;
	   } 
     }
}

That should do it... I think.

 

 

It's working except for the fuse duration. It's acting like a regular bomb, not a remote bomb.


  • idontknow8 likes this

#67 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 29 June 2016 - 08:24 PM

So... I've got this bomb script, which works great:
 

//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 && 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]--;
	   } 
     }
}

but how do I modify it to place a level 2 bomb?

 

full script

 

Huh. Came across a weird issue today. Link has the infinite bomb bag, but after placing a certan number of scripted bombs, I can't get Link to place any more.



#68 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 29 June 2016 - 08:39 PM

Because the infinite bomb bag doesn't actually make your bomb counter infinite. It just makes normal bombs ignore it and stops displaying its real value on the subscreen. But this scripted bomb continues to reference the real counter.
 
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]--;
	   } 
     }
}
This should fix it. I did not test it, so there may be a small, 15% at most, chance that this will ruin everything.
  • Cukeman likes this

#69 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 30 June 2016 - 03:50 PM

Thank you Lejes! Seems to work fine :)

 

Would it be simple to tell the script to make the enemy blast invisible? Since both the bomb and enemy bomb blasts are being drawn it creates a bit of a visual distortion effect.

 

EDIT: Of course I would only want this to apply to enemy blasts produced from this scripted weapon


Edited by Cukeman, 30 June 2016 - 03:51 PM.


#70 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 30 June 2016 - 09:01 PM

You would think changing a weapon sprite would be trivial. And it normally is. But explosions are different, because ZC is dumb sometimes. They are completely hardcoded, and the only way to change them is to overwrite the tile (I have no idea which tile it uses off the top of my head). You'll probably have to end up creating a sparkle weapon with the full explosion graphic instead. Sparkles (the ones produced by gold arrows) have the special effect that they only stay around for one cycle of their animation, then kindly remove themselves from existence.

#71 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 30 June 2016 - 09:20 PM

If it's hard,  I can do without



#72 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 01 July 2016 - 11:01 PM

That would essentially be this... First, I change the sprite for explosions to use a blank tile, then:
 
 
void DrawLWeaponExplosions(int sprite){
    int q; a[0] = Screen->NumLWeapons(); a[1] = 1;
    lweapon spryte[255];
    for ( q = 1; q <= Screen_>NumLWeapons(); q++ ) {
        spryte[0] = Screen->LoadLWeapon(a[0]);
        if ( spryte[0]->ID == LW_BOMBBLAST ) {
            spryte[q] = Screen->CreateLWeapon(LW_SPARKLE);
            spryte[q]->UseSprite = sprite;
            spryte[q]->X = spryte[0]->X;
            spryte[q]->Y = spryte[0]->Y;
            spryte[q]->CollDetection = false;
        }
    }
}
 
 
As an alternative though, if you can write to the lweapon's Misc[] indices...leave the ordinary explosion sprite intact, and for your special explosions, do this:
 
 
const int LW_SPECIAL_EXPLOSION = 1; //Effect ID
const int LW_MISC_SPECIAL_FX = 9; //l->Misc[]
 
void DrawLWeaponSpecialExplosions(int sprite){
    int q; a[0] = Screen->NumLWeapons(); a[1] = 1;
    lweapon spryte[255];
    for ( q = 1; q <= Screen_>NumLWeapons(); q++ ) {
        spryte[0] = Screen->LoadLWeapon(a[0]);
        if ( spryte[0]->ID == LW_BOMBBLAST && spryte[0]->Misc[LW_MISC_SPECIAL_FX] == LW_SPECIAL_EXPLOSION ) {
            spryte[0]->DrawXOffset = -4096;
            spryte[0]->DrawYOffset = -4096;
            spryte[q] = Screen->CreateLWeapon(LW_SPARKLE);
            spryte[q]->UseSprite = sprite;
            spryte[q]->X = spryte[0]->X;
            spryte[q]->Y = spryte[0]->Y;
            spryte[q]->CollDetection = false;
        }
    }
}
 
 
That will hide the normal explosion, and substitute a custom one, if the misc index of the lweapon so instructs.

Edited by ZoriaRPG, 01 July 2016 - 11:25 PM.


#73 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 02 July 2016 - 04:23 PM

ZoriaRPG, I am not fully understanding what you posted.

 

Let's start with the first example, which sprite are you changing to blank?

One of the defaults: Link's explosion? Link's super explosion? enemy explosion? enemy super explosion?

One of the two explosions resulting from the scripted bomb: Link's explosion? enemy explosion?

If enemy explosion, all onscreen or just the ones onscreen resulting from the scripted bomb?



#74 Lejes

Lejes

    Seeker of Runes

  • Members
  • Location:Flying High Above Monsteropolis

Posted 02 July 2016 - 04:50 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.
  • Cukeman likes this

#75 Cukeman

Cukeman

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

  • Banned
  • Location:Hyrule/USA

Posted 02 July 2016 - 06:08 PM

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.

 

Why didn't I think of that? :P

Thanks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users