Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Sp cost to normal attacks - Halo rpg project.

Yeah, I got this awesome idea of making a Halo rpg.

When you enter combat - the "Attack - Skill - Defend - Item" thing
appears. I would need a script that makes the normal attacks cost
SP (which in my game - will be named ammo)

So when Master Chief shoots enemy with his normal gun attack -
his SP (ammo) will decrease by some specific amount. And when
there is no SP left - Normal attack can't be used and
a messenge "You have no ammo left" will pop up when you
try to use a normal attack.

Thank you for any advice!
 
No idea if your still interested in this but this should do most of what you want.
It will use sp when you attack with a weapon that uses ammo (set in the script).
and
Though it doesn't say your out of ammo it will remove your ability to attack
when you have no sp.

1st! Weapons that take sp
In game_battler3
just below class Game_Battler add...

Code:
 

  # Default attack is -1 sp

  Ammo_Weapon_None = {

  #Weapon_ID => -0 sp

          1  => 'none',

          25 => 'none',

  } #DO NOT REMOVE

  Ammo_Weapon_Burst = {

  #Weapon_ID => -5 sp

          5  => 'burst'

  } #DO NOT REMOVE        

 

and below def attack_effect(attacker) [Applying Normal Attack Effects section also in Game_Battler3]
add this...

Code:
 

if Ammo_Weapon_None.has_key?(attacker.weapon_id)

      attacker.sp -= 0

    elsif Ammo_Weapon_Burst.has_key?(attacker.weapon_id)

      attacker.sp -= 5

    else

      attacker.sp -= 1

    end

 

this will allow you to control which weapons use ammo (sp) and how much each uses
[note: There is probably a better/neater way to do this but I'm still new at scripting =P]

Now to disable attack when you have no sp
[note: at the moment the script still removes the attack command when you have 0 sp
even if your weapon doesn't use sp. I may try and fix this later]

In Scene_Battle3 just below @actor_command_window.index = 0 (in the Actor Command Window Setup section)
add this...
Code:
 

if @active_battler.sp == 0

      @actor_command_window.disable_item(0) 

    else

      @actor_command_window.refresh 

    end

 

and in the [Frame Update (actor command phase : basic command) section] just below when 0 # attack
add this...
Code:
 

        if @active_battler.sp == 0

          $game_system.se_play($data_system.equip_se)

          return

        end

 
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top