Jump to content

Photo

Additional counters/ arrow ammo types

Counter Arrow Guns Ammo Bombs Ruppee

  • Please log in to reply
5 replies to this topic

#1 Fullmetalryuzaki

Fullmetalryuzaki

    Newbie

  • Members

Posted 03 July 2013 - 01:44 AM

I am working on a game that has guns. And as we all know, not all guns have the same ammo!

So far there are three ammo types: Pistol (currently using the arrow counter); revolver; rifle; sub-machine gun! Each of these require a separate counter for each. meaning with some subscreen tweeking and seperate ammo types, only pistols use pistol ammo and rifles use rifle rounds etc. as well as appear on the subscreen as a counter much like the arrow/bomb/rupee counters do!

I do believe scripting is the answer! If there is already a script for this I apologize! But if not, if any of you fellow dungeoneers could create said script for me I would be most grateful!!

Edited by Fullmetalryuzaki, 03 July 2013 - 01:45 AM.


#2 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 03 July 2013 - 03:34 AM

Yes, you can make items that use the CR_SCRIPT* counter reference, and add them to your subscreens. I added scrolls to TGC and once I was instructed on how to use this, it was easy-peasy. The harder part will be scripting your custom weapons.

Do you already have scripts for your weapons, and if not, assuming you want help, please detail exactly how each should work.


You can download all of the scripts in TGC 0,50r11N here:
http://zoriarpg.com/...11N_Scripts.zip

The global scripts and the timestop scripts should help you if you wish to see some examples.

Edited by ZoriaRPG, 03 July 2013 - 03:45 AM.


#3 Fullmetalryuzaki

Fullmetalryuzaki

    Newbie

  • Members

Posted 03 July 2013 - 12:47 PM

Yes, I would much desire help! Admittedly, I have zero to low skill with scripting as of yet! I do now how to compile correctly and implement them to most things as long as I have step-by-step directions hahah XD (in other words I suck still)

As for the weapons and specifics ill try my best to get as detailed as possible (if I leave something out let me know) okay! So for each:

Pistols do low damage (2) for each successful hit, and it can fire up to 2 rounds per second. It has 12 rounds and once they are used it reloads (player is unable to fire for a second and it plays a reloading Sfx that I have)!

Revolver: a powerful gun which deals 8 damage (most powerful but rare to find ammo); only fires once per 1.5 seconds. Naturally it only has 6 rounds in the chamber and reloads for 2 seconds.

The rifle is also very strong (6 damage) and also fires once per second. It has 8 rounds in the chamber and takes 2 seconds to reload.
(In making rifle ammo easier to squire so it evens out between it and the revolver)

Now for the final one (sub machine gun) I had an epiphany! I don't have a shotgun! So I changed this to the SHOTGUN: it does 4 damage to everything the player faces much like the "slash" attack does. It only has 4 in the chamber and can fire once per second. Reload time is 2 seconds!

Fyew! I hope this covers everything! If I missed something (highly probable) just let me know!

#4 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 09 July 2013 - 03:46 PM

When you say that a weapon fires one round per X-seconds, do you want the player to hold the item button for autofire, or for there to be a delay between the ability to fire shots?

#5 Fullmetalryuzaki

Fullmetalryuzaki

    Newbie

  • Members

Posted 11 July 2013 - 03:52 AM

I would say the second one: the delay between shots :)

#6 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 28 July 2013 - 02:38 AM

I'll see what I can do for you. This doesn't sound terribly hard, and I'm working on LWepon items at present, so I can likely tie this into the other scripting work. I'm going to make this as one script that uses attributes to cover ROF, damage, counter, etc., so that you need only assign the variables once you start to use it. The tricky part will be in covering reload time.
 
Do you want a secondary item (ammo) to use to (manually) reload, so the counter max is always fixed (per weapon) and the reload item replenishes the stock? (That would probably make this easier and more logical.)
 
This would mean needing two counters per weapon: One for ammo loaded, and a second for reloads on hand, and to reload the player would need to either select the ammo box, or have it selected already, and press the button to reload the firearm used by that ammo type. (Reading the pistol, way you described it earlier, it seems as if the player would have infinite ammunition, which I suspect was not your goal by reading about different ammo types in 'revolver' and 'rifle'.)
 
FYI, a machine gun that the player can fire continually with a 50R drum would be easy-peasy to make if you still want it. Limiting the ROF and maximum projectiles is harder than making something that the player can fire constantly.
 
What is the time period of this quest? From the descriptions of desired weapons, barring the 'submachine gun', I am picturing 1850s-1920s, although a semi-automatic pistol wasn't common until the Great War era and later.
 
I will work on the weapons first, and then on the reloading, so that you can test them and see if they come out as you want.
 
Here's something quick and basic for you to try. it doesn't include ROF, but it does allow you to start trying out firearm weapons. Please note that this is merely put of my head. It compiles, but I haven't tested it. I see no reason that it would not work, but if you have any problems, please let me know so that I can fix them.
 

import "std.zh"

/////////////////////////////////////////////////
//Import mandatory script headers and packages.//
/////////////////////////////////////////////////

//import "ffcscript.zh"
//import "string.zh"
//import "ghost.zh"
//import "ghost_legacy.zh"
//import "std_extra.zh"

/////////////////////////////////////////////////////////////////////
// Set up environment, Base Ints, Consts, Floats, Bools, Vars, etc.//
// Set Sounds in Quest->Audio->SFX Data  ////////////////////////////
/////////////////////////////////////////////////////////////////////
const int SFX_ERROR = 61;  //In case you want an error SFX
const int SFX_GUN = 71; //Set to a bang SFX as desired.
const int SFX_RELOAD = 72; //Set to a bang SFX as desired.

/////////////////
/// Firearm ////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
/// D0: Number of Hearts to Use when Activating Subweapon.       ///
/// D1: Time bfore Link can use Subweapon Again.                 ///
/// D2: Type of lweapon to generate.                             ///
/// D3: Amount of Damage that Subweapon Deals to Enemies.        ///
/// D4: Speed that Subweapon Travels across screen; suggest 240. ///
/// D5: Sprite used by Subweapon; select from:                   ///
///            Quest->Graphics->Sprites->WeaponsMisc.            ///   
/// D6: Rate of Fire; Not yet functional.                        ///
/// D7: Counter to use for this weapon.                          ///     
////////////////////////////////////////////////////////////////////

item script Firearm{
void run(int ammo, int nouse, int subweapon, int power, int speed, int SWsprite, int rof, int GunCounter){
if (Game->Counter[GunCounter] >= 1){
Game->Counter[GunCounter] -= ammo;
Link->ItemJinx = nouse;
lweapon subweapon;
Link->Action = LA_ATTACKING;
Game->PlaySound(SFX_GUN);
        subweapon = NextToLink(LW_ARROW, 8);                        //Create in front of Link
        subweapon->UseSprite(SWsprite);                            //Graphics
        subweapon->Damage = power;                                    //Damage
        subweapon->Step = speed;                                    //Speed
		
		for ( int i = 0; i < 30; i++ ){ //For 30 frames
            subweapon->DeadState = WDS_ALIVE; //Keep it alive at all times
            Waitframe();
}
subweapon->DeadState = WDS_ALIVE;}   
   else{
    Game->PlaySound(SFX_ERROR);
    }

}

}


//////////////////
/// Ammo Pickup ////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
/// D0: Set to Counter for Type of Amunition You are Using       ///
/// D1: Amount of Ammo Boxes to Gain                             ///
/// D2: Minimum Aount to Increase CounterMax; suggest 1.         ///  
////////////////////////////////////////////////////////////////////

item script AmmoPickup{
void run(int AmmoCounter, int amount, int increaseAmmoCount){
Game->Counter[AmmoCounter]+=amount;
Game->MCounter[AmmoCounter]+=increaseAmmoCount;
}
}

//////////////////
/// Ammo Pickup ////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
/// D0: Set to Counter for Type of Amunition You are Using       ///
/// D1: Set to Counter for Firearm Being Loaded.                 ///
/// D2: Amount of Rounds to Give player on Loading.              ///
/// D3: Time before Link can use this item again.                ///    
////////////////////////////////////////////////////////////////////

item script AmmoLoad{
void run(int AmmoCounter, int GunCounter, int GunAmount, int nouse){
if (Game->Counter[AmmoCounter] >= 1 && Game->Counter[GunCounter] <= 0){
Game->Counter[AmmoCounter] -= 1;
Game->Counter[GunCounter]+=GunAmount;
Link->ItemJinx = nouse;
Game->PlaySound(SFX_RELOAD);
}
    else{
    Game->PlaySound(SFX_ERROR);
    }
}
}


///////////////////////////////////
///// Counters Reference //////////
///////////////////////////////////
/// CR_SCRIPT1            = 7;  ///
/// CR_SCRIPT2            = 8;  ///
/// CR_SCRIPT3            = 9;  ///
/// CR_SCRIPT4            = 10; ///
/// CR_SCRIPT5            = 11; ///
/// CR_SCRIPT6            = 12; ///
/// CR_SCRIPT7            = 13; ///
/// CR_SCRIPT8            = 14; ///
/// CR_SCRIPT9            = 15; ///
/// CR_SCRIPT10           = 16; ///
/// CR_SCRIPT11           = 17; ///
/// CR_SCRIPT12           = 18; ///
/// CR_SCRIPT13           = 19; ///
/// CR_SCRIPT14           = 20; ///
/// CR_SCRIPT15           = 21; ///
/// CR_SCRIPT16           = 22; ///
/// CR_SCRIPT17           = 23; ///
/// CR_SCRIPT18           = 24; ///
/// CR_SCRIPT19           = 25; ///
/// CR_SCRIPT20           = 26; ///
/// CR_SCRIPT21           = 27; ///
/// CR_SCRIPT22           = 28; ///
/// CR_SCRIPT23           = 29; ///
/// CR_SCRIPT24           = 30; ///
/// CR_SCRIPT25           = 31; ///
///////////////////////////////////

You will need to add counters to your subscreen, and then attach these to items. The AmmoPickup should be set as the Pickup script on all ammunition, and the AmmoUse should be set as the Action script for all ammunition.
 
Once you have counters on a subscreen, you can tie these all to weapons and ammo types. If you need a sample quest, I can put a small test game together for you using these.
 
I'll work on ROF and reload time concerns; I've already been doing something along those lines elsewhere, so I hope that this will work with that.
 
Update: Updated script above, and made test quest. You can try it by downloading it HERE.
 
I didn't use the pickup script in the end, but assigned the pickup attributes in the item editor. The AmmoPickup script is in essence, an extra that I may need to use later to get some of what you want to work the way you desire. It uses the Firearm item and AmmoLoad item Action scripts, with sound effects, in an arena.
 
Update II: Here's a second script that features auto-loading. The load time takes twice as much time as you allocate to ROF.
 

import "std.zh"

/////////////////////////////////////////////////
//Import mandatory script headers and packages.//
/////////////////////////////////////////////////

//import "ffcscript.zh"
//import "string.zh"
//import "ghost.zh"
//import "ghost_legacy.zh"
//import "std_extra.zh"

/////////////////////////////////////////////////////////////////////
// Set up environment, Base Ints, Consts, Floats, Bools, Vars, etc.//
// Set Sounds in Quest->Audio->SFX Data  ////////////////////////////
/////////////////////////////////////////////////////////////////////
const int SFX_ERROR = 61;  //In case you want an error SFX
const int SFX_GUN = 71; //Set to a bang SFX as desired.
const int SFX_RELOAD = 72; //Set to a bang SFX as desired.

/////////////////
/// Firearm /////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
/// D0: Number of Bullets to expend when Activating Subweapon.    ///
/// D1: Time before Link can use Subweapon Again (ROF) in frames. ///
/// D2: Rounds weapon can hold.                                   ///
/// D3: Amount of Damage that Subweapon Deals to Enemies.         ///
/// D4: Speed that Subweapon Travels across screen; suggest 240.  ///
/// D5: Sprite used by Subweapon; select from:                    ///
///            Quest->Graphics->Sprites->WeaponsMisc.             ///   
/// D6: Counter for Amo Boxes for this weapon                     ///
/// D7: Counter to use for this weapon.                           ///     
/////////////////////////////////////////////////////////////////////

item script Firearm{
void run(int ammo, int nouse, int ShotsPerLoad, int power, int speed, int SWsprite, int AmmoToLoad, int GunCounter){
if (Game->Counter[GunCounter] >= 1){
Game->Counter[GunCounter] -= ammo;
Link->ItemJinx = nouse;
lweapon subweapon;
if(subweapon->X >= 1 && subweapon->X <= 254 && subweapon->Y >= 1 && subweapon->Y <= 160)
                        {
                        subweapon->DeadState = WDS_ALIVE;
                        //update sprites when dead state is refreshed
                        subweapon->UseSprite(SWsprite);
                        if(subweapon->Dir == DIR_DOWN)
                            {
                            subweapon->Flip = 2;
                            }
                        if(subweapon->Dir == DIR_RIGHT)
                            {
                            subweapon->Tile += 1;
                            }
                        if(subweapon->Dir == DIR_LEFT)
                            {
                            subweapon->Tile += 1;
                            subweapon->Flip = 1;
                            }
                        }
Link->Action = LA_ATTACKING;
Game->PlaySound(SFX_GUN);
        subweapon = NextToLink(LW_ARROW, 8);                        //Create in front of Link
        subweapon->UseSprite(SWsprite);                            //Graphics
        subweapon->Damage = power;                                    //Damage
        subweapon->Step = speed;                                    //Speed
                {
                //set to alive if within screen boundaries
               
                    
}
subweapon->DeadState = WDS_ALIVE;}  
if (Game->Counter[GunCounter] <=0 && Game->Counter[AmmoToLoad] >=1){
	Game->Counter[AmmoToLoad] -= 1;
	Game->Counter[GunCounter] += ShotsPerLoad;
	Game->PlaySound(SFX_RELOAD);
	Link->ItemJinx = (nouse * 2);
	}
 
   else{
    Game->PlaySound(SFX_ERROR);
    }

}

}


//////////////////
/// Ammo Pickup ////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
/// D0: Set to Counter for Type of Amunition You are Using       ///
/// D1: Amount of Ammo Boxes to Gain                             ///
/// D2: Minimum Aount to Increase CounterMax; suggest 1.         ///  
////////////////////////////////////////////////////////////////////

item script AmmoPickup{
void run(int AmmoCounter, int amount, int increaseAmmoCount){
Game->Counter[AmmoCounter]+=amount;
Game->MCounter[AmmoCounter]+=increaseAmmoCount;
}
}

//////////////////
/// Ammo Pickup ////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
/// D0: Set to Counter for Type of Amunition You are Using       ///
/// D1: Set to Counter for Firearm Being Loaded.                 ///
/// D2: Amount of Rounds to Give player on Loading.              ///
/// D3: Time before Link can use this item again.                ///    
////////////////////////////////////////////////////////////////////

item script AmmoLoad{
void run(int AmmoCounter, int GunCounter, int GunAmount, int nouse){
if (Game->Counter[AmmoCounter] >= 1 && Game->Counter[GunCounter] <= 0){
Game->Counter[AmmoCounter] -= 1;
Game->Counter[GunCounter]+=GunAmount;
Link->ItemJinx = nouse;
Game->PlaySound(SFX_RELOAD);
}
    else{
    Game->PlaySound(SFX_ERROR);
    }
}
}


///////////////////////////////////
///// Counters Reference //////////
///////////////////////////////////
/// CR_SCRIPT1            = 7;  ///
/// CR_SCRIPT2            = 8;  ///
/// CR_SCRIPT3            = 9;  ///
/// CR_SCRIPT4            = 10; ///
/// CR_SCRIPT5            = 11; ///
/// CR_SCRIPT6            = 12; ///
/// CR_SCRIPT7            = 13; ///
/// CR_SCRIPT8            = 14; ///
/// CR_SCRIPT9            = 15; ///
/// CR_SCRIPT10           = 16; ///
/// CR_SCRIPT11           = 17; ///
/// CR_SCRIPT12           = 18; ///
/// CR_SCRIPT13           = 19; ///
/// CR_SCRIPT14           = 20; ///
/// CR_SCRIPT15           = 21; ///
/// CR_SCRIPT16           = 22; ///
/// CR_SCRIPT17           = 23; ///
/// CR_SCRIPT18           = 24; ///
/// CR_SCRIPT19           = 25; ///
/// CR_SCRIPT20           = 26; ///
/// CR_SCRIPT21           = 27; ///
/// CR_SCRIPT22           = 28; ///
/// CR_SCRIPT23           = 29; ///
/// CR_SCRIPT24           = 30; ///
/// CR_SCRIPT25           = 31; ///
///////////////////////////////////

This version ties the ammo boxes to the weapon, so the AmmoLoad items are only necessary if you want to include manual loading on weapons, versus automatically reloading (by pressing the weapon button when empty). You need to specify the number of rounds the firearm holds per load in the script arguments, as well as other information, but I think this is more along the lines of what you wanted.

Update 3: Everything is going over HERE ; I have a pistol, rifle, revolver and sub-machine-gun in the demo, all based on this script. making a shotgun will take additional work and an entirely different script. I also have yet to get bullets to pierce (WDS_ALIVE). 


Edited by ZoriaRPG, 29 July 2013 - 04:18 AM.




Also tagged with one or more of these keywords: Counter, Arrow, Guns, Ammo, Bombs, Ruppee

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users