Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: Shining Riku on July 24, 2010, 06:27:18 pm

Title: [RESOLVED] [XP] Item Activated skills
Post by: Shining Riku on July 24, 2010, 06:27:18 pm
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?
Title: Re: [XP] Item Activated skills
Post by: G_G on July 24, 2010, 06:53:45 pm
Script isnt needed. Items were setup differently in rm2k/3
Where XP all you gotta do is this.
Spoiler: ShowHide
(http://i678.photobucket.com/albums/vv143/GameGuysProjects/fire.png)


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.
Title: Re: [XP] Item Activated skills
Post by: Shining Riku on July 24, 2010, 07:31:24 pm
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
Title: Re: [XP] Item Activated skills
Post by: G_G on July 24, 2010, 07:47:53 pm
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.
Title: Re: [XP] Item Activated skills
Post by: Shining Riku on July 24, 2010, 08:21:00 pm
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...
Title: Re: [XP] Item Activated skills
Post by: ForeverZer0 on July 24, 2010, 08:23:03 pm
It says "def def". Remove one of them.
Title: Re: [XP] Item Activated skills
Post by: Shining Riku on July 24, 2010, 08:41:58 pm
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.
Title: Re: [XP] Item Activated skills
Post by: G_G on July 24, 2010, 09:04:35 pm
Updated post above.
Try again.
Title: Re: [XP] Item Activated skills
Post by: Shining Riku on July 24, 2010, 09:38:34 pm
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 :(
Title: Re: [XP] Item Activated skills
Post by: G_G on July 24, 2010, 09:42:37 pm
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
Title: Re: [XP] Item Activated skills
Post by: Shining Riku on July 24, 2010, 11:02:44 pm
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.
Title: Re: [XP] Item Activated skills
Post by: G_G on July 24, 2010, 11:18:48 pm
Are you using a different battle system? It worked fine for me, might wanna make sure its configured right.
Title: Re: [XP] Item Activated skills
Post by: Shining Riku on July 25, 2010, 12:06:32 am
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 ^_^
Title: Re: [XP] Item Activated skills
Post by: G_G on July 25, 2010, 12:25:41 am
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
Title: Re: [XP] Item Activated skills
Post by: Shining Riku on July 25, 2010, 11:22:32 am
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
Title: Re: [XP] Item Activated skills
Post by: G_G on July 25, 2010, 11:32:40 am
You're probably placing it above a script thats overwriting the method item_effect.
Title: Re: [XP] Item Activated skills
Post by: Shining Riku on July 25, 2010, 11:36:10 am
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
Title: Re: [XP] Item Activated skills
Post by: G_G on July 25, 2010, 11:48:02 am
Thanks no problem!