adding mp cost to weapon use

CWells

Storyteller/Artist
Veteran
Joined
Apr 22, 2013
Messages
731
Reaction score
40
First Language
English
Primarily Uses
I have certain weapons that when equipped, should cost a little mp.

I have scripts that allow me to input damage formulas for my weapons but it lacks a feature for mp cost.

I have scripts that allow me to specify normal attack for the Actor, but doing this goes beyond what I need

and will only make it so that the actor, not the weapon uses a certain skill[iD].

Is there anything that I can use where I just plug in something like:

<mp> 3 </mp>

in a weapons tag?
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
What does it mean to use a weapon?
 

CWells

Storyteller/Artist
Veteran
Joined
Apr 22, 2013
Messages
731
Reaction score
40
First Language
English
Primarily Uses
I simply mean to equip it and attack with it. I should have worded that differently. i can see why one might confuse using with consuming as if it were an item.
 

ShadowLurk

Tanoshii~
Veteran
Joined
Feb 14, 2014
Messages
226
Reaction score
53
Primarily Uses
You can find any weapon attack replace script and change the related weapon's attack with a skill similar to the normal attack, but with MP cost.
 

CWells

Storyteller/Artist
Veteran
Joined
Apr 22, 2013
Messages
731
Reaction score
40
First Language
English
Primarily Uses
You can find any weapon attack replace script and change the related weapon's attack with a skill similar to the normal attack, but with MP cost.
I had two scripts for this. But both gave me some sort of issue. The one I have now works the best, but it doesn't allow for mp cost.

Yanfly's made my loaded games crash because of how it is designed.
 

ShadowLurk

Tanoshii~
Veteran
Joined
Feb 14, 2014
Messages
226
Reaction score
53
Primarily Uses
Use this.

Code:
module SHD  module REGEXP    ATTACK_ID = /<attack skill id: (\d+)>/i    ATTACK_ID_PRIO = /<attack skill id: (\d+), (\d+)>/i  endendclass RPG::BaseItem    def attack_id    load_notetags_define_attack_feat if @attack_id.nil?    @attack_id  end    def attack_id_priority    load_notetags_define_attack_feat if @attack_id_priority.nil?    @attack_id_priority  end    def load_notetags_define_attack_feat    @attack_id = 1    @attack_id_priority = 0    self.note.split(/[\r\n]+/).each do |line|      case line      when SHD::REGEXP::ATTACK_ID        @attack_id = $1.to_i        @attack_id_priority = 1      when SHD::REGEXP::ATTACK_ID_PRIO        @attack_id = $1.to_i        @attack_id_priority = $2.to_i      end    end  end  endclass Game_BattlerBase    alias :asiex_ft :attack_skill_id  def attack_skill_id    feature_objects.inject([asiex_ft, 0]) { |r, o|      o.attack_id_priority > r[1] ? [o.attack_id, o.attack_id_priority] : r    }[0]  end  end
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
max_by priority would probably be cleaner.
 
Last edited by a moderator:

ShadowLurk

Tanoshii~
Veteran
Joined
Feb 14, 2014
Messages
226
Reaction score
53
Primarily Uses
So, collect, add the default, and max_by?

Code:
module SHD  module REGEXP    ATTACK_ID = /<attack skill id: (\d+)>/i    ATTACK_ID_PRIO = /<attack skill id: (\d+), (\d+)>/i  endendclass RPG::BaseItem    def attack_id    load_notetags_define_attack_feat if @attack_id.nil?    @attack_id  end    def load_notetags_define_attack_feat    @attack_id = [1, 0]    self.note.split(/[\r\n]+/).each do |line|      case line      when SHD::REGEXP::ATTACK_ID        @attack_id[0] = $1.to_i        @attack_id[1] = 1      when SHD::REGEXP::ATTACK_ID_PRIO        @attack_id[0] = $1.to_i        @attack_id[1] = $2.to_i      end    end  end  endclass Game_BattlerBase    alias :asiex_ft :attack_skill_id  def attack_skill_id    (feature_objects.collect{|o| o.attack_id} << [asiex_ft, 0]).max_by{|e| e[1]}[0]  end  end
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
I was thinking just get the one with highest priority, and then figure out whether you want to return that, or the default attack skill.

Code:
alias :asiex_ft :attack_skill_iddef attack_skill_id  obj = feature_objects.max_by{|obj|obj.attack_id[1]}  obj.attack_id[1] > 0 ? asiex_ft[0] : obj.attack_id[0]end
But that's cause I typically find inject or fold operations in general to be kind of difficult to read since I don't use them very often.
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
@CWells - then just make sure to use a new game first instead of loading? if the game is still in development I don't really see any problems... plus there's the object reinitializer script that can help you with starting a loaded game just after you put yanfly's script
 

CWells

Storyteller/Artist
Veteran
Joined
Apr 22, 2013
Messages
731
Reaction score
40
First Language
English
Primarily Uses
I will try the patch and reinstall Yanfly script first.

Nevermind that fix. It is bugged and removes armor upon load.

then just make sure to use a new game first instead of loading?
This isn't a short game. At some point a player will have to save. The game being incomplete now isn't the issue at all.

I think I have an idea. Maybe an ammo script will be of good use.
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
This isn't a short game. At some point a player will have to save. The game being incomplete now isn't the issue at all.
I am using that script and if the save file was created when the script is already there it doesn't error anymore... It only errors when you load a save that was created before the script was added... That is the normal behavior of most scripts that only write the data during object initialization... Which most of Yanfly's scripts does


That should be the way it works, unless it's actually a compatibility problem with another script...
 
Last edited by a moderator:

CWells

Storyteller/Artist
Veteran
Joined
Apr 22, 2013
Messages
731
Reaction score
40
First Language
English
Primarily Uses
I managed to work my way around it, thanks for the suggestions. I've decided on something I'm happy with and is consistent with my designing plan.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,867
Messages
1,017,061
Members
137,575
Latest member
akekaphol101
Top