Not sure this can be done with event scripting options, I haven't been able to figure it out so here's what I'd like to be able to do and my question essentially is, can it be done with events or would this require a script?
What I want to do is assign one or more variables to each actor to measure or track various thinks (i.e. skills, abiilities, etc). For example, say I want to have a "Charming" variable for each actor in the party so I assign a variable to each actor which tracks how "charming" that actor is. Now, in an encounter I want the NPC to choose the most charming actor in the party. So the Event needs to compare the "Charming" variable for each actor (which means 2 or more unique variables) and then determine the highest.
But as I said, I can't figure out how to do this with the availabe Event options. Can this be done with event options alone or would this require a script?
And if you haven't guessed, I'm exploring ways to put more "role play" into the RPGs I'd like to make. So I'm looking for ways I can modify and control the "reaction" of encouters, ways to trigger different scripted behaviors / dialog, etc.
Being able to compare the highest variable, level, stat like strength, or HP and have an NPC (created with an event) react according to who had the highest (or lowest) score would be useful to me. However, right now I'm not ready to take on writing scripts yet, still learning what can and cannot be done with events (I'm kind of methodical that way).
Comparing variable, choose highest / lowest
● ARCHIVED · READ-ONLY
-
-
class Game_Interpreter def get_highest_parameter(x) actor = $game_party.members.max_by { |obj| obj.param(x) } return actor.param(x) endendThis snippet should check all members of your current party and return the highest value of parameter x. But I havn't tested it ingame. Scriptcall get_highest_parameter(x).
If you want to check the maximum of a given set of variables, you could do so via events. Set a dummy variable to actor1's charm. Then make a conditional branch that sets the dummy variable to actor2's charm if actor2's charm is higher than the dummy - repeat for each actor in your party.
But if you want I could writ a short snippet for that, too. Its much easier with scripts. -
This is extremely similar to a question I answered a few days ago - the solution I explained here should also work for what you're asking.
-
Thanks! hadn't expected anyone to come up with a script to do that. Very nice of you. I do get the impression a lot of the more complex stuff I'd like to do would need or be easier with scripts. Hopefully in a couple months or so I can shift focus to start learning the scripting language.
Hadn't thought of doing it that way with condition branches, but I think I get what you mean. The only thing that concerns me is that it doesn't appear to give me a way to compare the variable associated with party member #1 to party member #2 (i.e. just the party members present) and since I have no way of knowing who will be in the party(unless I very carefully structure other game events to control who is in the party when the event happen) then not only would I have to figure out how to get the event to compare the variables, but also which party members were there and... ugh... I'll give it a try and see if I can make a limited form of it work properly, if nothing else just as part of learning. The script clearly is preferable.
Can you give me an example of how to implement the call script in an event to compare four variables (lets assume they are Variable 001, 002, 003, 004 (first four in the list of used variables) which might be Actor 001's "Charm", Actor 002's Charm, etc.). As I said, I'm not good with scripts yet and I know very little about them or using them at this point.
Q: Looking through all the things the condition branch can "test", there doesn't seem to be a way to check things like HP, SP, Level in a class (you can check to see if a class exists, but not the level of that class. Is there any way to check those kinds of things?
For example, say I'm designing an event where the Old Wizard chooses who he will accept as an apprentice. His event checks the max SP of each party member (lets assume they're all Jr Wizards and so they can all use magic) and determines the highest, then returns the result in some way that enables his dialog to proceed and he then bestows new skills or spells on that actor or whatever the event needs to happen to advance the storyline.
I don't see a way to do this with the condition branch alone, so I'm assuming it would also need a script? .oO(Maybe I should move up my schedule on learning RGSS lol) -
Thanks for pointing to that, will read through it an see what I can absorb.This is extremely similar to a question I answered a few days ago - the solution I explained here should also work for what you're asking.
-
If you simply want to add a few parameters to an actor, you could just add attr_accessors to the Game_Actor class:
class Game_Actor < Game_Battler attr_accessor :charmendNow each actor has a charm variable:
msgbox_p($game_actors[1].charm) #=> nil$game_actors[1].charm = 1msgbox_p($game_actors[1].charm) #=> 1$game_actors[1].charm += 3msgbox_p($game_actors[1].charm) #=> 4This is REALLY simple, but as long as you don't want to da anything fancy with those variables, it will do.
EDIT: I had a bug in my previous post, its param(x), not params(x). -
Oh wow, didn't know you could create new parameters for an actor like that. That could be REALLY useful for some things I want to do later.
Q: Can those parameters still be called as variable by event conditions, condition branches, etc? Cause most of what I want to do I'll probably be doing with event scripts (dialog, choices, adding or removing effects, etc.), so its got to work with that. If they do, it would save me having to create a lot of variables manually, though as I'm digging into this that seems less a problem now than initially. Mainly I just need to think ahead as to how many actors I intend to have in a game and how many variables to reserve for them for planned functions.
Either way, being able to have a script compare variables from different actors and choose the highest or lowest would be a big help in itself, I can do quite a lot with just that.
Again, very much appreciate the advice and info. Helping a novice more than you may realize. Will still be awhile before I'm able to do much with it but at least now I'm getting a much clearer idea what is and isn't possible and that will help me in coming up with successful (and workable) concepts in future projects. -
Pencil's being very helpful so I don't want to step on his toes, but basically, when you define an attribute for a character like he has here, you're basically creating a new attribute just like their name or class ID or MP. These new attributes don't have built-in tools to adjust them in the editor but they can be worked with anywhere you see a "Script" option (such as the 'Script' event command or the 'Script' condition in a conditional branch). So if you wanted to increase Actor 5's charm by 1, you could script the following phrase: $game_actors[5].charm += 1 and that would do the trick. You could also write that actor's charm to a variable: $game_variables[17] = $game_actors[5].charm would copy the actor's charm to Variable #17.
This is how I do a lot of my work, and it's how a lot of somewhat-experience scripters do it before they get really fancy with very advanced stuff. But if you've never touched a word of RGSS before, it can be a lot more comfortable to just do everything with the normal variables, and then use a few lines of scripting to compare those variables to each other when the default editor doesn't provide a tool to do so, which is why I linked you to the snippet I wrote for someone a few days ago. -
You are both being very helpful and I very much appreciate it.
I think I get a more of how the scripts create and manipulate things and you answered several of my questions. Part of what I hadn't been clear on was how the script output the result of its process in a form I could use in an event. Now I get it. Going back to the example you linked to earlier, I looked at that again and I understand now what you were doing. The script can process variables, whether they be in game variables, HP, SP, or a new attribute we create for actors and can then out put that to one of the "standard" numbered variables, 21 in your other example or 17 above. Its that output variable that you then use in the event script. That clears up SO much. Between the two of you, you've given me a ton of food for thought here... just being able to create new attributes, compare them, adjust them as you described above... there's so much I could do with just that!
I'm sure once I have time to go look up some of the terms you've used in RGSS I'll understand even better. -
BardicHeart, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.
That's twice in as many days I've said to stop double posting. Please read the forum rules and follow them (whether you think there's "harm" in updating your post or not). If you need to add more information and nobody has posted since you, edit your post. -
@Wavelength: All my scripting is seft taught, calling me a ""somewhat experienced scripter" is more then accurate and in no way stepping on my toes. And my previous example was deliberatly simple, if I'd write a script to add extra stats to actors, I'd probably add annother group of params (like param, xparam and sparam). But thats a little bit too complicated to elaborate here.
@BardicHeart: Some things you could do with such attributes.
$game_party.members is an array with all the actors currently in your party. .max_by { |element| element.something } is a method you can use on arrays to find the element in an array that has the maximum amount of something.
most_charming_actor = $game_party.members.max_by { |actor| actor.charm }$game_variables[1] = most_charming_actor.id$game_variables[2] = most_charming_actor.charmThis script call for example would set v[1] to the id if the most charming actor in your party and v[2] to his charm. Now you can do stuff in events with v[1] and v[2].
($game_party.members.max_by {|a| a.charm}).atk > 15This you could add to a conditional branch script, and it would return true if your most charming actor has an atk value greater than 15. No idea why you want to do something like that, just an example.
http://youtu.be/8gMjdiQInvc?list=PLu_gesZsbQQ50g3Y302dN0sq6DuErvcJy <- this is a playlist of tutorials by DP3, maybe you want to watch the first 5-10 to get a basic understanding what variables, arrays, methids and all that stuff is. -
Again, thank you for the advice. I'll definitely bookmark and watch those videos. Also thanks for the examples, you're right I probably wouldn't combine charm and ATK... but I might want to combine say Stealth and AGL... there are just so many possibilities. It really is giving me lots of ideas the more I think on it.
After reading over your and Wavelength's replies several times I think I'm starting to get a good grasp of the basics, at least of this lil bit of scripting. But as it happens its something I'll probably get a lot of use out of in the future.
Hopefully, I'll have time to take a more serious look at scripting, its clearly something I need to learn. Between work and other projects I often don't have as much time as I would wish.