[XP] Stat Distribution System

Started by Blizzard, January 09, 2008, 04:18:49 pm

Previous topic - Next topic

Launian

Ok then, apology accepted  :haha: No, seriously, thank you. Can't imagine how many questions and requests like this you get per script, and considering just how many you make...

If I were to leave tonight, would your hand try to reach me?

Blizzard

September 28, 2012, 02:40:26 pm #101 Last Edit: September 29, 2012, 05:45:58 am by Blizzard
People still ask me for advice and scripts. xD

EDIT: I have updated the script and added the feature. You simply assign negative values for X_DP_COST and it will use an inverted exchange rate (e.g. -100 means that 1 DP increases the stat by 100). Why I have gone with this convention instead of using decimal numbers?

Quote from: Script notesThis convention has been added as calculation with decimals (floating point numbers) can cause problems during rounding due to physically limited precision.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Launian

September 29, 2012, 12:46:28 pm #102 Last Edit: September 29, 2012, 12:54:30 pm by Launian
Because you don't like decimals? Lol I have no idea. I guess it was easier than scripting it so it wouldn't draw the numbers as 999.899999997 or something, right? Easier to write something like "if string is negative, @spent = @spent * string)" than making a function for rounding up the result, I guess.

And yes, my example is bad, and I should feel bad. Please refrain from pointing out :P

EDIT: It seems to work great! I just found a little bug: say you have a MaxHP of 500, then add 200 HP to it. Then, you hold the R key and click the left arrow (R+key adds/substracts 1000), and you'd end up with -300 MaxHP and 80 DP more than whatever you started with. Same with the L key. And it is possible to lower your MaxHP with this.

Anyways, thank you for the script! =D

If I were to leave tonight, would your hand try to reach me?

Blizzard

There is a function for rounding, but if you type 2.000000000000000000000001 and 1.999999999999999999999999 in a programming language, you'll most likely end up with 2.0 in both cases. That also means that 1.499999999999999999999999 could end up as 1.5 which would be incorrectly rounded up to 2 instead of being rounded down to 1. Oh, the joys of floating point numbers. :X

I'll check the negative bug later. I think I know what causes it and how I can quickly fix it.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Launian

Soooo... it was easier to do that than to ensure it'd round up properly? xD

And, for now, I deleted this part; not sure if it helps:

 def update
    super
    return unless self.active
    if Input.press?(Input::R)
      if Input.repeat?(Input::RIGHT)
        if add_points(100)
          $game_system.se_play($data_system.cursor_se)
          draw_item(self.index)
        else
          $game_system.se_play($data_system.buzzer_se)
        end
      elsif Input.repeat?(Input::LEFT)
        if remove_points(100)
          $game_system.se_play($data_system.cursor_se)
          draw_item(self.index)
        else
          $game_system.se_play($data_system.buzzer_se)
        end
      end
    elsif Input.press?(Input::L)
      if Input.repeat?(Input::RIGHT)
        if add_points(10)
          $game_system.se_play($data_system.cursor_se)
          draw_item(self.index)
        else
          $game_system.se_play($data_system.buzzer_se)
        end
      elsif Input.repeat?(Input::LEFT)
        if remove_points(10)
          $game_system.se_play($data_system.cursor_se)
          draw_item(self.index)
        else
          $game_system.se_play($data_system.buzzer_se)
        end
      end
    elsif Input.repeat?(Input::RIGHT)
      if add_points(1)
        $game_system.se_play($data_system.cursor_se)
        draw_item(self.index)
      else
        $game_system.se_play($data_system.buzzer_se)
      end
    elsif Input.repeat?(Input::LEFT)
      if remove_points(1)
        $game_system.se_play($data_system.cursor_se)
        draw_item(self.index)
      else
        $game_system.se_play($data_system.buzzer_se)
      end
    end
  end


And left just the add_points(1) parts.

If I were to leave tonight, would your hand try to reach me?

Blizzard

September 29, 2012, 01:16:14 pm #105 Last Edit: September 30, 2012, 04:53:07 am by Blizzard
This will disable the feature to add 10 or 100 points at once. I'll fix this tomorrow properly.

Technically it's simply not possible to make it round up properly. Trust me, working with floating point numbers is not a can of worms that you want to open if you're not a programmer. xD

EDIT: There you go.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Launian

Hadn't had time to check it out. It works great (no surprises there :p) Still, will report any bugs I find.

Again, thanks a lot. For this, and all the other amazing scripts you've made for XP

If I were to leave tonight, would your hand try to reach me?

Kiwa

Ive been trying for the past 2 hours to create a Hotkey to this. Can someone help me to add this feature? or perma add it to the script plz :D

I just cant do it.
I tried using dragos addition to blizzes smart target as a foundation for my "mod"
this is sorta what i was going off of.

Quote
module LiTTleDRAgo

  TARGET_ANIMATION_ID = 104 # 141
  TARGET_CHANGE_KEY   = Input::Key['T']
  AUTO_CHANGE_TARGET  = false


end


#==============================================================================
# BlizzABS::Controls
#==============================================================================

class BlizzABS::Controls
 
  alias update_attack_autotarget_later update_attack
  def update_attack

    if $BlizzABS.autotarget == nil
        targets = $game_map.battlers.find_all {|b| b.valid? && b.in_screen?}
        $BlizzABS.autotarget = targets[0] if targets.size > 0
    elsif Input.repeat?(LiTTleDRAgo::TARGET_CHANGE_KEY) 
      targets = $game_map.battlers.find_all {|b| b.valid? && b.in_screen?}
      index = targets.index($BlizzABS.autotarget)
      $BlizzABS.autotarget = targets[(index + 1) % targets.size] if index != nil
    end
    if $BlizzABS.autotarget != nil && (!$BlizzABS.autotarget.in_screen? ||
        !$BlizzABS.autotarget.valid?)
      $BlizzABS.autotarget = nil
    end
    return update_attack_autotarget_later
  end


I created a module just the same as dragos.


module getkey

  CHANGE_KEY   = Input::Key['N']

end


This is ok.. but the second i try to make it call $scene = Scene_Points.new
it tells me theres an error with the "module getkey"

If anyone can add the option or link some code to add i would greatly appreciate it :D

KK20

You can use a common event. Parallel process with a conditional branch in there. Check if Input.trigger?(Input::Key['T']). Then use a script call $scene = Scene_Points.new

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Kiwa

I'm trying to keep down parallel processes.
the more events i have the more it will lag me down right?

i have 1 main parallel process that slowly restores mana.. i wonder if i can add this in to no effect? but it may delay 60 frames between pressing the button and the menu going up lol.


its a wait 60 frames
then entire party +mp

so i don't think i can add it in cuz of the wait option.

anyway ill check back on it later.. thanks kk20 :D

ThallionDarkshine

April 13, 2013, 03:33:43 pm #110 Last Edit: April 13, 2013, 06:16:50 pm by ThallionDarkshine
Try this:


module PointsHotkey
 KEY = Input::Key['T']
 CALLABLE_SCENES = [Scene_Map, Scene_Menu, Scene_Item, Scene_Status, Scene_Equip]
end

module Input
 class << self
   alias_method :tdks_points_hotkey_updt, :update
 end

 def self.update
   self.tdks_points_hotkey_updt
   if Input.trigger?(PointsHotkey::KEY) and PointsHotkey::CALLABLE_SCENES.include?($scene.class)
     $scene = Scene_Points.new
   end
 end
end

Blizzard

That's not a good fix. It will trigger anywhere, even on the title screen, during battle, etc.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

ThallionDarkshine

April 13, 2013, 03:46:42 pm #112 Last Edit: April 13, 2013, 03:48:15 pm by ThallionDarkshine
Right you are. And fixed.

Blizzard

It should be:

PointsHotkey::CALLABLE_SCENES.include?($scene.class)


xD
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

ThallionDarkshine

Fixed again. I can be so dumb at times.

PhoenixFire

=P So, I'll be using this script in the latest version of TEP as well.. I think it'll work fine for me the way it is though..
Quote from: Subsonic_Noise on July 01, 2011, 02:42:19 amNext off, how to create a first person shooter using microsoft excel.

Quote from: Zeriab on September 09, 2011, 02:58:58 pm<Remember when computers had turbo buttons?

Kiwa

Thank worked great Darkshine!! :D

thanks for the mod!!!!!

TrueCynder

May 07, 2013, 01:19:24 pm #117 Last Edit: May 07, 2013, 03:19:31 pm by TrueCynder
hey sorry if that got asked before but
is there a way for me to give every actor an unique max value for each stat ?

and is there a way how i can use the currency as DP ยด?

sirSLR

November 21, 2013, 11:27:46 am #118 Last Edit: November 21, 2013, 11:40:52 am by sirSLR
Quote from: Launian on September 27, 2012, 06:24:17 pm
Quote from: sirSLR on March 15, 2012, 03:34:58 pm
can i edit something so that 1 dp rises 10 hp or sp instead of 1=1  ?


Find this part:

def apply_new_attributes
    @actor.maxhp += @spent[0] / BlizzCFG::HP_DP_COST
    @actor.maxsp += @spent[1]  / BlizzCFG::SP_DP_COST
    @actor.str += @spent[2] / BlizzCFG::STR_DP_COST
    @actor.dex += @spent[3] / BlizzCFG::DEX_DP_COST
    @actor.agi += @spent[4] / BlizzCFG::AGI_DP_COST
    @actor.int += @spent[5] / BlizzCFG::INT_DP_COST
    @actor.dp -= @spent.sum
    self.actor = @actor
  end


and then change it for this:

def apply_new_attributes
    @actor.maxhp += (@spent[0] * 10) / BlizzCFG::HP_DP_COST
    @actor.maxsp += (@spent[1] * 10) / BlizzCFG::SP_DP_COST
    @actor.str += @spent[2] / BlizzCFG::STR_DP_COST
    @actor.dex += @spent[3] / BlizzCFG::DEX_DP_COST
    @actor.agi += @spent[4] / BlizzCFG::AGI_DP_COST
    @actor.int += @spent[5] / BlizzCFG::INT_DP_COST
    @actor.dp -= @spent.sum
    self.actor = @actor
  end


Sadly, this doesn't change the behaivor of the stat distribution window, wich means that, if you allocate 1 DP to your HP, it'll show 501 instead of 510 until you click on Accept Changes. I can't find out how to make it so the window reflects the fact that it adds 10 HP instead of 1, but leaving alone the Stats (STR, DEX, etc.).




oh well funny thing :D i did what u said than it didnt work i was stuck with hp i haid before so i tried this

def apply_new_attributes
    @actor.maxhp += (BlizzCFG::HP_DP_COST > 0 ?
        @spent[0] / BlizzCFG::HP_DP_COST : @spent[0] * 10 )


worked like a charm :D tough in windiow mode it still shows as if i add 100 hp


EDIT :

after few min of playing i did this

from:
  HP_DP_COST = -100


to:
  HP_DP_COST = -10


all is well that ends well :D

PhoenixFire

Alright, so, here's a question for anyone out there who might know.. I'm using Blizzs' Mouse Controller, and, the Mouse Controller Enhancement Script. They work great together, and this script works as expected too, minus one issue; when leveling up, you can click the distribute points button, but it doesn't allow you to actually distribute the points. Any thoughts on how to get it to work? I don't care if it still requires the left and right arrow keys to increase/decrease the values, but to be honest, I have no clue where I would even start when trying to edit the script(s).

If needed, I can link to a demo of the game so you can see what I mean..
Quote from: Subsonic_Noise on July 01, 2011, 02:42:19 amNext off, how to create a first person shooter using microsoft excel.

Quote from: Zeriab on September 09, 2011, 02:58:58 pm<Remember when computers had turbo buttons?