Jump to content

Photo

Bolt Spell (or Item) - Thunder & Lightning

Item FFC

  • This topic is locked This topic is locked
3 replies to this topic

#1 ZoriaRPG

ZoriaRPG

    The Timelord

  • ZC Developers
  • Gender:Unspecified
  • Location:Prydon Academy

Posted 06 August 2013 - 11:10 AM

Bolt! Spell (or Item)


Description

This set of scripts creates a flash of lightning on the screen, with a thundering sound, doing global damage to enemies on the screen, while at the same time, Link hurls a projectile lightning bolt at one enemy.

Screenshots and Demo

Demo Quest:    Bolt.qst

 

Code

import "std.zh" //Disable this if you already have imported std.zh.
import "stdExtra.zh" //Import stdExtra.zh to make the FFC script work. (Disable if you already have this.)
import "ffcscript.zh" //Import ffcscript.zh to make FFC functions work. (Disable if you already have this.)

/////////////////////
/// Bolt! Spell /////
//////////////////////////////////////////////////////////////////////////////////////////////
/// This item creates a flash on the screen, with a thundering sound, dealing damage to all //
/// enemies on the screen, while launching a projectile (lightning bolt) toward one target. //
//////////////////////////////////////////////////////////////////////////////////////////////
// D0: Damage to deal                                                                       //
// D1: Sprite to use for this item. Set in:                                                 //
//           Quest->Graphics->Sprites->Weapons/Misc.                                        //
// D2: Amount of MP to expend when using item.                                              //
// D3: Step Speed of the Projectile.                                                        //
// D4: Set this to the FFC slot number to which you assign the FlashScreen FFC script.      //
// D5: Colour of Flash (suggest 1).                                                         //
// D6: Duration of Flash (suggest 45)                                                       //
// D7: Screen-Wide Damage to Deal during Flash.                                             //
//////////////////////////////////////////////////////////////////////////////////////////////

const int BOLT_NOUSE = 0; //Set to the amount of time in frames that you wish to have as a delay between uses of this item.
const int ThunderSFX = 0; //Set to the sound in Quest->Audio->SFX Data to the sound you wish to use as a thunder effct (.wav option included in this package)
const int SFX_ERROR = 0; //Set to your global error sound effect, or any specific error SFX you wish from Quest->Audio->SFX Data.

item script BoltSpell{
    void run(int power, int arrowSprite, int magicCost, int speed, int Script_ID, int colour, int duration, int screenDamage){
	 if (Game->Counter[CR_MAGIC] >= magicCost) //Fill in the numbers for magic consumption and number of projectiles allowed on screen
        {
	 Screen->Wavy = 10; //Makes the screen waver slightly while screen flashes and bolt projectile emits.
	 Game->Counter[CR_MAGIC] -= magicCost; //Sets the MP cost for using the weapon.
	 int args[8] = {colour, duration}; //Sets the colour and duration of the flash in the FFC script.
 npc enemys; //Reads the enemies on screen...
   for(int i = 1; i<=Screen->NumNPCs(); i++) //Find out how many enemies are onscreen.
         {
         enemys = Screen->LoadNPC(i); //Targets those enemies.
         enemys->HP-=screenDamage; //Deals (value of D7) damage to all enemies on-screen during flash.
         }
        
	
		int startX; //the starting position of the LWeapon sprite (X-axis)
        int startY; //the starting position of the LWeapon sprite (Y-axis)
        int startHP = Link->HP; //Needed if you want to include an HP requirement.
        lweapon bolt; //Creates the LWeapon
        Game->PlaySound(ThunderSFX); //Makes the thunder SFX play.
        startX = Link->X+8; //Sets starting position of LWeapon based on Link's position (+8 pixels)
        startY = Link->Y+8; //Sets starting position of LWeapon based on Link's position (+8 pixels)
        Link->Action = LA_ATTACKING; //Produces Link attacking animation. 
        bolt = NextToLink(LW_ARROW, 8);  //Create in front of Link.
        bolt->UseSprite(arrowSprite); //Sets the sprite to use from Weapons->Misc.
        bolt->Damage = power; //Sets the damage of the projectile.
        bolt->Step = speed; //Sets the Step Speed of the projectile, suggest 200-240.
		RunFFCScript(Script_ID, args); //Runs the FFC script that makes the screen flash.
		Link->ItemJinx = BOLT_NOUSE;
		}
		else{
    Game->PlaySound(SFX_ERROR); //If out of MP, play ERROR Sound Effects.
    }
    }
}



//
ffc script FlashScreen{
    void run(int colour, int duration){
	
        while(duration > 0){
            if(duration % 2 == 0) Screen->Rectangle(6, 0, 0, 256, 172, colour, 1, 0, 0, 0, true, 64);
            duration--;
            Waitframe();
        }
    }
}

Setup
 
Step One: If you do not have them already, download FFCScript.zh and stdExtra.zh and place them in your ZQ directory. If you are using this script as your base, leave the lines at the top that import these scripts (and std.zh) intact. If you are adding this to a script, disable any of these import lines that you already have in your main script, either by deleting them or by placing two slashes before them.
 
Step Two: Add the sound effects (links below, or select your own) to your quest in Quest->Audio->SFX Data, using the unassigned slots (staring at No. 61). Note the number of each sound as you assign them.
 
Step Three: using the number you noted for the sound effects, change these lines in the script to match the numbers of the sound effects as you assigned them.
 



const int ThunderSFX = 0; //Set to the sound in Quest->Audio->SFX Data to the sound you wish to use as a thunder effct (.wav option included in this package)
const int SFX_ERROR = 0; //Set to your global error sound effect, or any specific error SFX you wish from Quest->Audio->SFX Data.

 

For example: If you set the thunder.wav sound to slot 61, and the error.wav sound to slot 62, you would set these lines as follows:
 

const int ThunderSFX = 61; //Set to the sound in Quest->Audio->SFX Data to the sound you wish to use as a thunder effct (.wav option included in this package)
const int SFX_ERROR = 62; //Set to your global error sound effect, or any specific error SFX you wish from Quest->Audio->SFX Data.

 
If you wish to force a delay between when Link uses Bolt and when he can next use Bolt, set the value of NOUSE to a value higher than zero. (Note: This will also affect any other weapon that the player switches to; thus, if Bolt is set to 'B', then fired, and the player changes to a boomerang on 'B', the boomerang will share this delay.)

 

The time is measured in frames and there are generally sixty (60) frames per second, so if you set NOUSE = 60, then Link can only fire at a rate of one shot per second; if you set NOUSE = 90, then Link can fire a shot every 1 1/2 seconds.
 
If you are using little MP for the item, you may wish a longer delay time. If Link must use a good deal of MP to use this item/spell, you should probably set a short delay time. If you set a value of 0 here, Link can continually fire for as long as he has enough MP. If you set both NOUSE and MP cost (later) to zero, link can fire continually.
 
Step Four: Open the tile page sheet for your quest, and click grab; then click file, select the file bolt_sprites.png and click leech. Set colour depthi to 8 and click OK. Note the combo page that the tiles that you just imported are now on. (In an empty quest, this is usually page 47.)
 
Go to the Item Misc. sprite editor (Quest->Graphics->Sprites->Weapons/Misc.) and scroll down until you see the unused slots (starting with zz88). Select one of these, and click edit; change the name from zzXXX to Bolt, then click on the empty (black) tile box. This will open the tile page sheets.
 
Go to the tile page where your imported tiles are located.(Quick Tip: hit the 'P' key on your keyboard and type the page number, followed by Enter/Return.)
 
Select the yellow lightning bolt sprite (ten down from the top, and the second over from the left edge) by double clicking it. This will place it in the box in the Weapons/Misc sprite editor. Then, change animation frames to 2 and animation speed to 5.
 
Be sure to remember the sprite number!

Step Five: Go to the script importation box (Quest->Scripts->Compile ZScript...). Once there, click import. You will be asked if it is acceptable to clear the current buffer: Click yes and select the file Bolt.z, then click OK, and then click compile. The script will now compile, and you will be asked to assign scripts to slots.
 
Step Six: Once you have compiled the script, you will see the script slots assignment pane. This starts you out viewing FFC Scripts. Assign the FFC script Flashscreen to a slot, and note what slot it is in. Then click the tab Item, where you will see the item script slots. Here, you assign the scripts BoltSpell and ffcitem to item script slots. (You do not need to note these numbers.)
 
Check the box 'Output ZASM code to Allegro.log' if you wish to track any errors reported by ZASM, and then click OK. When you see the success report window, click OK there as well.
 
Step Seven: Open the Item Editor (Quest->Items), and select either one of the Custom Items items, or one of the zzXXX items items (e.g. zz101). (For this example, we will use Custom item 01.)
 
Step Eight: In the item editor, change the Item Class to a unique item class that you do not plan to use elsewhere. Select one of the Custom Item Classes, or a zzXXX class (e.g. as zz089). For this example, we use Custom Itemclass 01. (You can change this later, if you desire, but you will also need to change your subscreen to match if you do.)
 
Check the box Equipment Item, and click the GFX tab. Click on the blank (black) tile, and again go to the page where you imported the tilesheet bolt_sprites.png, or to any other page containing the sprite that you want to set for the item. Select a sprite to represent the item, and set its animation frames and animation speed, as you desire. The bolt_sprites.png tilesheet has several alternative wand and staff items, although a medallion or custom sprite is all fine. That's up to you.
 
Next, click on the Scripts tab, and set the action script to the script BoltSpell.
 
Set the arguments (D0-D8) as follows:
 
D0: This is the amount of damage that the projectile lightning bolt does to enemies it hits.
D1: This is the sprite you selected in the Weapons/Misc editor. Therefore, if you set the lightning bolt sprite to be Weapons/Misc. sprite 88, make the value of D1 '88' (no quotes).
D2: Set this to the amount of MP that you wish Link to spend each time he uses this item. Note that a single magic container has 32MP.
D3: Set this to the speed you wish the lightning bolt projectile to travel in pixels per second. A value of 200-240 is good here.
D4: Set this to the FFC slot number that you noted when you set the FFC Script FlashScreen.
D5: Set this to the colour of the flash. If using the classic tileset, a value of '1' (no quotes), which is white, and often works best. If you are using another tileset, or another colour palette, find out where the colour is in your palette that you wish the screen to flash (for lightning effects) in Quest->Graphics->Palettes->Main. The number of this value must be decimal, starting at zero. Each row contains sixteen colours, so count the rows, and then the number of swatches from left to right to deduce what colour number of your palette you are using. 
D6: This is the duration of the flash in frames.The best number here is '45' (no quotes).
D7: This is the amount of damage that the spell does to all enemies on-screen during the flash effect. This is best set to 1, or possibly 2 in a difficult game. You can set this to '0' (no quotes) if you wish no global damage.
 
When you have set all of the arguments, click OK.
 
You have completed set-up of this item.

Resources
Requires
Header: stdExtra.zh
Header: ffcscript.zh
 
Sound Effects
bolt.wav
error.wav
sonic.wav
 
Graphics
bolt_sprites.png
 

Credits (Alphabetical)

Script Concept & Creation:

ZoriaRPG

 

Basecode Resources & Headers
Colossal, Moscowmodder, Saffith

 

Sound Effects & Graphics

(bolt.wav) Freesound.org, (error.wav) Dracula II: Noroi no Fuin, (sonic.wav) Doctor Who (1996, film)

 

Tiles

Saffith, ZoriaRPG


Edited by ZoriaRPG, 22 August 2013 - 10:49 AM.


#2 Rastael

Rastael

    Wizard

  • Members
  • Real Name:Raphael
  • Gender:Male
  • Location:Austria

Posted 06 September 2013 - 01:27 PM

Nice script! It's great that you also share the tiles and soundeffects. :D

To bad, I already have enough items for my quest. :(

 

Btw.: In the demo-quest sometimes the enemies die, sometimes not. Most times, when I use the item the second time on a screen. Should it be this way or is it a bug?

(I'm using RC5)



#3 Three Pendants

Three Pendants

    Recipient of Ways

  • Members
  • Gender:Unspecified

Posted 05 December 2013 - 11:15 AM

This is a really neat idea and the closest we've come to emulating Agahnim's Lightning Bolt attack! Great work!



#4 ZoriaRPG

ZoriaRPG

    The Timelord

  • ZC Developers
  • Gender:Unspecified
  • Location:Prydon Academy

Posted 28 April 2014 - 08:20 AM

Nice script! It's great that you also share the tiles and soundeffects. :D

To bad, I already have enough items for my quest. :(

 

Btw.: In the demo-quest sometimes the enemies die, sometimes not. Most times, when I use the item the second time on a screen. Should it be this way or is it a bug?

(I'm using RC5)

 

The script has an argument for scree-wide damage. Thus, when you sue the spell, not only does it damage one targeted enemy, but it can also deal damage to every enemy on the screen. the demo file (IIRC) is set to deal 1-Damage to all enemies, in addition to the targeted damage, hence why enemies die when you use it multiple times.

 

You can set this to off, by setting the relevant argument to '0', as outlined in the script, which contains the instructions for set-up and use. (See Argument D7.)


Edited by ZoriaRPG, 28 April 2014 - 08:21 AM.




Also tagged with one or more of these keywords: Item, FFC

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users