Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: Myth on June 10, 2010, 09:17:40 pm

Title: [resolved] Creating negative skill costs?
Post by: Myth on June 10, 2010, 09:17:40 pm
So. I have been trying to create skills in XP which, when used, increase the user's SP rather than drain it. The database doesn't allow you to input negative values for SP costs. I can break this with events, but it's extremely tedious and I'm sure it can be done a much simpler way through scripts.
What I've been trying to do is alter the bit in Scene_Battle_4 which says
# Use up SP
   @active_battler.sp -= @skill.sp_cost

by making it this
# Use up SP
     if @skill.id = 13
       @active_battler.sp += @skill.sp_cost
       else
   @active_battler.sp -= @skill.sp_cost
   end

which works for making skills restore SP, except that it has made every skill do this now, not only skill 13.
I'm not a scripter, so there's probably a dumb mistake somewhere in calling the ID, but I can't figure out how else to do it. I've been poring over the modules in the Tons of Add-Ons that involve SP, like the SP Cost Status and Sp Damage, but they alter Game_Battler, and Scene_Battle_4 seems to be the place where the default system handles SP change. Well, there's something in Scene_Skill which does the same, but I think that's for when skills are used from the menu.
...Anyway, help would be very much appreciated by this newbie.
Title: Re: Creating negative skill costs?
Post by: G_G on June 10, 2010, 09:43:20 pm
Here you go. Kinda solved it for you .__.
module RPG
  class Skill
    def cost
      case @id
      # Use this
      # when skill_id then return cost
      when 1 then return -10
      when 2 then return -20
      end
      return @sp_cost
    end
  end
end


This makes it so you can have negative costs for skills you want. Otherwise it'll use the old cost.
Title: Re: Creating negative skill costs?
Post by: Myth on June 10, 2010, 09:49:29 pm
*blink*
And I see exactly how that works, but I could have never been able to come up with that myself. Doh. Thank you so much!
Title: Re: Creating negative skill costs?
Post by: Wizered67 on June 10, 2010, 09:50:45 pm
Just saying that the problem before was that you did
if @skill.id = 13
instead of @skill.id == 13
Title: Re: Creating negative skill costs?
Post by: G_G on June 10, 2010, 09:56:09 pm
Your welcome! Glad I could help :)
Title: Re: Creating negative skill costs?
Post by: Myth on June 10, 2010, 10:16:46 pm
Ahhh...I'm sorry to bug again, but I'm putting it above main and it doesn't seem to work. It's just using the database skill costs. Is it possible that I'm still screwing something up?
Wizered, I added the "==" and it works. Thought that only applied to constants. Ehehe. Thank you; I still don't know what I was doing with the module, though.
Title: Re: [resolved] Creating negative skill costs?
Post by: G_G on June 13, 2010, 10:58:07 am
My bad I renamed the method wrong.
module RPG
  class Skill
    def sp_cost
      case @id
      # Use this
      # when skill_id then return cost
      when 1 then return -10
      when 2 then return -20
      end
      return @sp_cost
    end
  end
end


That will work.