Custom Attributes v1.31

Hey Adik,

How do I access available attribute points when increasing the attribute? I already have the value in a global variable, but I don't know how to integrate it (still learning :\ )

I did this..

Spoiler
 #Text shown on actor window
  def actor_text(actor)
    return actor.name + "" + actor.nickname + " - Attribute Points: " + $game_variables[50].to_s#actor.get_custom_attribute_points.to_s
  end
 
  #Edit this to do custom things when an attribute is increased
  def on_custom_attribute_increase(actor,index)
    case index
    when 0
        actor.add_param(0,10)
        use_attr_point
    end
  end
 
  def use_attr_point
    $game_variables[50] -= 1
  end
 
but now I need to make it so I can use the points on the attribute 0. Game variable 50 is my variable for attribute points, and it displays fine.
You don't need to do that subtracting on a variable if you just want to display how many points the player has.

The thing you commented out in the 'def actor_text(actor)' definition does that exactly.

To add attribute points to your actors use the script call:

actor_object.add_custom_attribute_points(value)Replace 'actor_object' with any actor reference, like $game_actors[1] or $game_party.battle_members[3], etc.Replace 'value' with the amount of attribute points you want to give for the actor.

If you want to give automated attribute points on level up, you can try this snippet I made (but I don't know how level up works in that ABS system you are using, so this might not work with that, still, never hurts to test it, right? 😛 ):

Spoiler
#===============================================================================# New script call:## global_attribute_gain(value)# # This will give attribute points for all party members without the need to make # a separate line for every actors in your party.# Replace 'value' with the amount of attribute points you want to give for your # actors.#===============================================================================module Attribute_LevelUp # Amount of attribute points earned on level up. Att_Points_LvlUp = 2 endclass Game_Actor < Game_Battler #-------------------------------------------------------------------------- # alias method: level_up #-------------------------------------------------------------------------- alias sixth_add_att_points112 level_up def level_up sixth_add_att_points112 self.add_custom_attribute_points(Attribute_LevelUp::Att_Points_LvlUp) endendclass Game_Interpreter #-------------------------------------------------------------------------- # new method: Global Attribute Gain #-------------------------------------------------------------------------- def global_attribute_gain(value) $game_party.members.each do |i| if i != nil i.add_custom_attribute_points(value) end end endend
It also includes a script call for making all of your party members gain a specified amount of attribute points. You know, when there are lotsa party members, it can get quite tedious and space consuming to add a script call line for each of them. 😛
No, Sixth, the question is how to add attribute points in the game when you're playing, like in the window, lol

nvmd got it, you were right.

Edit 2:

I edited this script a bit to display the current stat rather than 0. The bolded part is my change. My change works perfectly except I'm having a refresh issue.

    if ADIK::ATTRIBUTES::SHOW_MAX
      draw_text(rect,@actor.param(index+2).to_s + " / " + ADIK::ATTRIBUTES::MAX[index].to_s,alignment)
    else

So I replaced "custom_attribute(index)" with actor.param so it would display the current value, rather than 0.

However, I am getting some refresh issues as shown in this video - As you will see in the video at :08, when I add the first point, nothing visually changes.

https://www.youtube.com/watch?v=EbmTJwVs46k&feature=youtu.be

As you can see, when I add the first point, it isn't refreshing until after I added the second point. The values are adding correctly, it's just drawing the value before adding it. How can I fix this, i.e., draw the value after adding it?
You could add a refresh call after your edit.

Take note that since ur showing the value of an actor param rather than the custom attribute, that will include bonuses from items and from the stat curves. The default check for checking if the attribute is already max in this case won't work as it will only check the attribute not the param. So you might want to edit that too.

PS: I might make an update (if I get the time) that allows increasing an attribute via equipments (you could do that in tandem with my equip extension already but that means that if an equipment makes you go above the limit while the actual points you spent is still below limit, then you cannot add points anymore unless you remove the equipment first then re-quip once you increase the stats)
Yes, I was aware of that when I made the change. Editing the script with that one line would have taken you maybe 5 seconds, took me about an hour to figure out. I'm still quite new at scripting and decided that since I have so many questions, I might as well start learning. One more question, how could I add that refresh call? I would need to know the exact name of it and where to put it, if you don't mind.

Thanks Sixth! The answer was @attribute_window.refresh
You could have simply added refresh right after your edit. That would have worked the same I think
I did the refresh call in the scene right after the 'on_custom_attribute_increase(args)' method, not in the window, that's why I told him '@attribute_window.refresh'.


In the 'def increase_custom_attribute' definition, you called refresh before the increase happens instead of calling it after. Was there any reason I am not aware of doing this?


I mean, it makes more sense to me to call the refresh after everything happens and not before or in the middle to see the changes immediately in every window.


I changed the placement of the refresh call there to be after the mentioned method, and it works flawlessly.
@attribute_window.actor.add_custom_attribute(@attribute_window.get_index,1)@attribute_window.refresh
you called refresh before the increase happens instead of calling it after. Was there any reason I am not aware of doing this?
False

If you look at it, the refresh is right after I modify the attributes, it was just before the on_custom_attribute_increase which by default does nothing because I didn't think that people would be trying to show params that they increase using that method instead of the custom attribute. If you only use the window to show the custom attributes like what it was intended to do, it works fine.

So if you only use the window to show the thing that it was intended to show (which was attributes), that works fine.

Anyway, I'd add it to the update for the benefit of those who likes modifying the windows.

EDIT: Uploaded the updated script. Now have bonuses that is not counted towards the limit so you can have items that can add attributes which can go past the limit (still needs another script like my Equip Extension to utilize)
Yeah, you are right, it doesn't matter if nothing has been modified in the windows.


I started to edit the scene right after I got this awesome script, so I forgot how it works by default. 😀


Nice update, that will come in handy for sure! *-*
I do hope so. I also made the bonus have two possible show methods, one is it's added directly to the current points (and it doesn't make the text use the max color even if the total is over the limit if the actual points spent is still below the limit), another is it is shown before the current points.
After further testing, everything works with the new bonus attributes, except one thing...
They don't do anything when they increase or decrease. 😀

I used the script call ('$game_actors[1].add_custom_attribute_bonus(4,3)')to increase the bonus value only, and when I went to see the changes, I realized that it didn't get any effect after the increase.
Is there something else I should do to make the effects valid or it's bugged?

My scene shows the right value for the current bonus, current bonus points and current level of the attribute, but nothing changes, no matter how high or low the attribute bonus.

Here are a few example screenshots:
1. First one, no points allocated, 3 bonus points added to the "Intelligence" attribute.
The actor's Intelligence should be exactly 28.

http://www.mediafire.com/view/a1oq0v2rdpg35f9/ex1.PNG

2. Second, 4 points allocated on the "Intelligence" attribute, no further bonus points added.
The actor's Intelligence should be exactly 32.

http://www.mediafire.com/view/i9ob0kyg91tmijr/ex2.PNG

3. Third, added another 3 bonus points to the "Intelligence" attribute, no further points allocated.
The actor's Intelligence should be exactly 35.
https://www.mediafire.com/view/t33n1dnj7c6cr6b/ex3.PNG

So, yeah, unfortunately they don't seem to work. 🙁

They add up fine in numbers, but their effect is missing.

And while I am here, you could dispose the background bitmap and sprite on scene terminating. I just noticed this.
Yeah, the bonus as of now doesn't trigger the on increase custom method. I made it that way since you're already using script calls to add the bonuses anyways, so I thought you should just add the things on the script calls too. As of now, the only thing they do is add to the value returned by the custom_attribute method.

I'll try to make it run the method too when I get time. And also maybe add a parameter to the method to determine if it was increase or decrease, or just have two separate methods
I see.


I made an 'on_custom_attribute_bonus_increase(index,value)' method directly in Game_Actor and called it in the add_custom_attribute_bonus definition. Works like a charm, and once it is set up, it's fully automated. 🙂


The only downside of it is that I have to setup the effects again there. >.>


I am thinking of moving your default 'on_custom_attribute' method into Game_Actor itself, so I can spare a lot of space with the settings.


Did the above, works perfectly now! 🙂
That was actually the same thing that I did on the update that I was yet to post... XD
I'd probably update this sometime (depending on how busy I'll be) so that it will support setting a specific method to run for each attribute when increased aside from the current global one... 
edit: sorted out my initial problems, like i said i'm not too experienced with scripting but if i bang my head against my keyboard long enough i can sometimes figure things out. I am having a couple new problems though.

Changing params was easy enough, but when I try to change xparams like this:

if index == 8
      self.add_xparam(2,0.05)
      end

i get this error:

Script 'Adiktuzmiko Cust Att' line 287: NoMethodError occurred.

undefined method 'add_xparam' for #<Game_Actor:0x7151628>

i'm assuming i'm just using the wrong wording for the xparam? but i'm not sure what the proper term would be. also, i originally thought my attribute points were going into a shared pool, long story short actually it just looked that way because i added the attribute command to my individual skill windows and the result is that even when i'm on the second, third, or fourth actor's skill screen, by default the attribute window opens to the first actors attributes. i'm using lots of yanfly's window scripts, soi was wondering if there was a way to change this in your script or if i'll have to hunt around in his scripts for what I need to change. thanks again, great script and i can't wait til i get it ironed out so i can use it.
You can either use if/elsif checks like this:

if index == 0  self.add_param(0,10)elsif index == 1  self.add_param(1,10)endAdd as many elsif conditions before the end line as you want.

Or you could use case statements like this:

case indexwhen 0  self.add_param(0,10)when 1  self.add_param(1,10)endAdd as many case parts as you want before the end line.
thank you sixth, that's good to know. i ended up solving that issue in a much more clumsy way than you said, but it's working for me at least. my real issue now is with the xparams, i'm sure it's just something simple that my noobishness is stopping me from doing. maybe set another def for the xparams?  i imagine i'm just going to have to tweak my yanfly skill menu script for the window issue.
What do you want to do with the xparams? 

You want to add xparams to actors upon attribute increase?

That can't be done without other custom scripts, if I remember right.

I did it with Shaz's script, Dynamic Featues. 

Also can be done with Dekita's Stat control script, if I remember right, and that will add you the bonus of adding direct percentages instead of cumulative ones.

Regardless of what script you choose to use for it, it requires some scripting knowledge.

And what window issue?
sorry, i had edited my first post but because it was my first post i had to wait for moderator approval before it posted. i think it went up one minute after your

first response lol. but yeah, i'm trying to add to a base xparam, specifically crit% and evade%. i'll look into the scripts you mentioned. the window issue is a little tough to explain, i'll do my best. instead of opening adik's attribute menu from my main window, i edited yanfly's skill menu so that if i go to actor 1's skill menu for example, it lists his skills etc then has the attribute button there which opens adik's menu. my issue is that actor 0 is the default menu it opens to, even if i go into actor 3's skill menu for example it opens to actor 0's attribute window. obviously i can use page up/page down to scroll through them, but it would be better if i could open to the actor whose skill menu i start from. (hope that makes sense.) eithe way i'm thinking it's something in yanfly's skill menu i'll have to edit, but i could be wrong.

edit: dekita's stat control worked like a charm for the xparams. thanks

Original thread: https://forums.rpgmakerweb.com/threads/custom-attributes-v1-31.32767/