[resolved] Creating negative skill costs?

Started by Myth, June 10, 2010, 09:17:40 pm

Previous topic - Next topic

Myth

June 10, 2010, 09:17:40 pm Last Edit: June 10, 2010, 11:06:53 pm by Myth
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.

G_G

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.

Myth

*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!

Wizered67

Just saying that the problem before was that you did
if @skill.id = 13
instead of @skill.id == 13

G_G


Myth

June 10, 2010, 10:16:46 pm #5 Last Edit: June 10, 2010, 10:55:10 pm by Myth
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.

G_G

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.