[RESOLVED] [XP] Item Activated skills

Started by Shining Riku, July 24, 2010, 06:27:18 pm

Previous topic - Next topic

Shining Riku

July 24, 2010, 06:27:18 pm Last Edit: July 27, 2010, 04:05:12 pm by Shining Riku
I understand that RM 2003 had something that let you cast magic from item scrolls you could use in battle.

Is there a script like that for RPG maker XP? If so, where can I find it? I figure somebody out there's made the script, i'm just horrible at finding stuff...

and if it isn't made, is there a chance somebody could make it?

G_G

Script isnt needed. Items were setup differently in rm2k/3
Where XP all you gotta do is this.
Spoiler: ShowHide


Now if your looking for something like, use "Allow Fire" then it enables the Fire skill, that'll require a script but its quite easy to do that as well. I'll have to do that later though.

Shining Riku

Yeah, I know, I already have some items like that but I feel it'd be more strategic to have items casting spells. I don't want players being able to do set damage against enemies....it'd be kinda weird the way I have battles set up.

I don't mind waiting for a script....I doubt it'd be hard THEN again I only know how to edit small parts of scripts and have no real knowledge of scripting.

I was under the impression people liked that feature of rm2k/3 *scratches head*

I'd definitely like a script so I can have items use skills instead. If it isn't too much bother that is. I understand you're pretty back up on requests and stuff yeah? Like I said I wouldn't mind the wait, the script isn't needed to make one of my games playable, but it'd definitely be a desired feature and hopefully other people would wanna use it too lol

G_G

July 24, 2010, 07:47:53 pm #3 Last Edit: July 24, 2010, 09:40:11 pm by game_guy
try this
module GGSI
 def self.item_skill(id)
   case id
   #when item_id then return skill_id
   # pretty much
   # when item then return skill it casts
   when 33 then return 4
   end
   return nil
 end
end
class Game_Battler
 alias gg_link_skill_item_eff_lat item_effect
 def item_effect(item, user = nil)
   s = GGSI.item_skill(item.id)
   return gg_link_skill_item_eff_lat(item) if s == nil
   return gg_link_skill_item_eff_lat(item) if user == nil
   return skill_effect($data_skills[s], user)
 end
end
class Scene_Battler
 def make_item_action_result
   # Get item
   @item = $data_items[@active_battler.current_action.item_id]
   # If unable to use due to items running out
   unless $game_party.item_can_use?(@item.id)
     # Shift to step 1
     @phase4_step = 1
     return
   end
   # If consumable
   if @item.consumable
     # Decrease used item by 1
     $game_party.lose_item(@item.id, 1)
   end
   # Display item name on help window
   @help_window.set_text(@item.name, 1)
   # Set animation ID
   @animation1_id = @item.animation1_id
   @animation2_id = @item.animation2_id
   # Set common event ID
   @common_event_id = @item.common_event_id
   # Decide on target
   index = @active_battler.current_action.target_index
   target = $game_party.smooth_target_actor(index)
   # Set targeted battlers
   set_target_battlers(@item.scope)
   # Apply item effect
   for target in @target_battlers
     target.item_effect(@item, @active_battler)
   end
 end
end


This makes it so you use an item called Fire Scroll, it casts the actual skill called fire. This is setup only for the default battle system. I overwrote a method.
Also, you need to set the animations for the item same to the skill.

Note this hasnt been tested.

Shining Riku

I tested it, but I get an error. All the error window says is there's a syntax error in line 14. No specification what exactly is wrong  :O_O: If there were more to the error message i'd post a picture...

ForeverZer0

It says "def def". Remove one of them.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Shining Riku

Spoiler: ShowHide
Script 'Game_Battler 3' line 108: NoMethodError occured

Undefined method 'scope' for nil:NilClass

That's the error I just got....Not even really sure what happened here either XD

I removed the extra 'def' on line 14 like Forever Zer0 suggested.

G_G


Shining Riku

It did the same error. Just for the record I have a legal version of RPG Maker XP @_@

Tried it by removing scripts I didn't know if they were conflicting or not.

It changed nothing. I'm sorry if i'm not being too helpful :(

G_G

Should work now.
module GGSI
  def self.item_skill(id)
    case id
    #when item_id then return skill_id
    # pretty much
    # when item then return skill it casts
    when 33 then return 7
    end
    return nil
  end
end
class Game_Battler
  alias gg_link_skill_item_eff_lat item_effect
  def item_effect(item, user = nil)
    s = GGSI.item_skill(item.id)
    return gg_link_skill_item_eff_lat(item) if s == nil
    return gg_link_skill_item_eff_lat(item) if user == nil
    return skill_effect(user, $data_skills[s])
  end
end
class Scene_Battler
  def make_item_action_result
    # Get item
    @item = $data_items[@active_battler.current_action.item_id]
    # If unable to use due to items running out
    unless $game_party.item_can_use?(@item.id)
      # Shift to step 1
      @phase4_step = 1
      return
    end
    # If consumable
    if @item.consumable
      # Decrease used item by 1
      $game_party.lose_item(@item.id, 1)
    end
    # Display item name on help window
    @help_window.set_text(@item.name, 1)
    # Set animation ID
    @animation1_id = @item.animation1_id
    @animation2_id = @item.animation2_id
    # Set common event ID
    @common_event_id = @item.common_event_id
    # Decide on target
    index = @active_battler.current_action.target_index
    target = $game_party.smooth_target_actor(index)
    # Set targeted battlers
    set_target_battlers(@item.scope)
    # Apply item effect
    for target in @target_battlers
      target.item_effect(@item, @active_battler)
    end
  end
end

Shining Riku

Okie dokie, this time it didn't give any errors but the item didn't activate the skill. It just showed the animation and then that was all that happened.

G_G

Are you using a different battle system? It worked fine for me, might wanna make sure its configured right.

Shining Riku

Yeah....i had it all set up right and everything. I must be horrible at testing scripts XD

I'll play with it more tomorrow, I really appreciate the help and work so far ^_^

G_G

July 25, 2010, 12:25:41 am #13 Last Edit: July 25, 2010, 12:28:13 am by game_guy
Nevermind it doesnt work. I gotta fix it, I dunno why it isnt working O_O but I'll look at it

EDIT: Fixed. Just had a small type in it :S
module GGSI
  def self.item_skill(id)
    case id
    #when item_id then return skill_id
    # pretty much
    # when item then return skill it casts
    when 33 then return 7 # Fire Scroll uses Fire
    end
    return nil
  end
end
class Game_Battler
  alias gg_link_skill_item_eff_lat item_effect
  def item_effect(item, user = nil)
    s = GGSI.item_skill(item.id)
    return gg_link_skill_item_eff_lat(item) if s == nil || user == nil
    return skill_effect(user, $data_skills[s])
  end
end
class Scene_Battle
  def make_item_action_result
    # Get item
    @item = $data_items[@active_battler.current_action.item_id]
    # If unable to use due to items running out
    unless $game_party.item_can_use?(@item.id)
      # Shift to step 1
      @phase4_step = 1
      return
    end
    # If consumable
    if @item.consumable
      # Decrease used item by 1
      $game_party.lose_item(@item.id, 1)
    end
    # Display item name on help window
    @help_window.set_text(@item.name, 1)
    # Set animation ID
    @animation1_id = @item.animation1_id
    @animation2_id = @item.animation2_id
    # Set common event ID
    @common_event_id = @item.common_event_id
    # Decide on target
    index = @active_battler.current_action.target_index
    target = $game_party.smooth_target_actor(index)
    # Set targeted battlers
    set_target_battlers(@item.scope)
    # Apply item effect
    for target in @target_battlers
      target.item_effect(@item, @active_battler)
    end
  end
end


Tested and its working for sure this time ;D

Shining Riku

July 25, 2010, 11:22:32 am #14 Last Edit: July 25, 2010, 11:32:01 am by Shining Riku
It gave me another error but i'm not sure what it means.

Spoiler: ShowHide
Script 'Item Skills' line 49 ArgumentError occurred.

wrong number of arguments(2 for 1)


I'm gonna test it again in a different project to see if it's cuz of conflicting scripts or something.

EDIT: Alright it indeed works. I'm not quite sure why but it's got a few script conflicts, but it works! :D
Thanks so much, Game_Guy! ^_^

Just in case if you're interested, apparently it has a negative reaction with Blizz's Zombie state script o_o

G_G

You're probably placing it above a script thats overwriting the method item_effect.

Shining Riku

Yeah, I posted it below all of my scripts, and it worked!

Thanks again, Game_guy, I really REALLY appreciate your help. Good work on the script!  :D

G_G