Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Problem accessing $game_actor methods

I am trying to access the methods of game_actor class to change some attributes such as HPs/name/class/etc. In the intro of my game I want to give the game player the option to choose their class and by doing that have the game generate random HPs/SPs/STR/etc. So the only way I can think of doing this is to access the game_actor class and input the fields I want changed. Below is what I wrote as a test:

>Script:$game_actor.setup(9)
with 9 being the id for actor 9
Here is the error I got:
NoMethodError occurred while running script.
undefined Method 'setup' for NilClass

Im confused because there is a class called game_actor and the method does exist.
I would appreciate it if someone could help explain to me why my coding doesnt work.

Thanks,
Pao
 
I need all the attributes of the new character changed. RPG Maker XP has a default 8 Actors. I created a new one with ID of 9. But it has all the characteristics of a warrior. I need to be able to set all the attributes to whatever I want not the default that stored on the database->actors tab. What would be the best way to do this? I just assume calling game_actor.setup method would do it. Any help would be greatly appreciated.

Thanks,
Pao
 
I'm not sure that I understand what you're trying to do here, or why you need a script.

You don't need any kind of scripting to change the maximum number of actors-- "Change Maximum" is a single button push in the Database.

You can then set the characteristics of that character by hand. Or copy-paste another actor, if you'd rather. There isn't any part of this that requires a script that I can see.
 
Unka Josh":mwb3tl65 said:
I'm not sure that I understand what you're trying to do here, or why you need a script.

You don't need any kind of scripting to change the maximum number of actors-- "Change Maximum" is a single button push in the Database.

You can then set the characteristics of that character by hand. Or copy-paste another actor, if you'd rather. There isn't any part of this that requires a script that I can see.
To make more sense, here is what I am doing:
1) Starts out as a dog (I created actor 9, used dog sprite) gave him all the attributes copied from fighter in the database->Actors tab.

2)In the intro, the dog meets an Angel which the angel ask the dog(the person playing) if he/she would like the character to be male or female. Then it asks her what class she wants to be.

3)Based on her choice, this is where I am trying to use the script to give the character NEW attributes(re-initialized all attributes/stats) based on what class they choose. I am trying to access the game_actor class.setup because it looks like thats where it initializes all the variables.

What I really want it to do if POSSIBLE is to overwrite what ever data is for that Actor in the database.

If that is not possible, I want to create all the new attributes/stats for the character and for the game to use the NEW attributes rather than the default ones in the database->Actor tab.

What would be a better way of doing this?
 
Start with the dog. When a character is selected, remove the dog from the party, and add the character (Male Knight, or whatever) to the party. Use Name Input Processing once they've picked a character, or whatever.

Much, much simpler-- if you want a different set of stats for each set of options, what you're really picking is a different actor anyway.
 
Ah.... No, you can't do that with that simple little line of script. You need something much bigger than that to change all of the attribute curves based on class choice. I'm not really sure if you know anything about programming, but you can't just call a method and have things happen.

If I were you, I'd head over to the script requests or support and ask someone for code that will change the stat curves depending on the player's class choice. You're doing something a little more complicated than it seems like you realize... unless I'm just getting an inaccurate read, which is possible. ^_^

EDIT: Ah! Didn't see Unka's post. Yeah, that is simpler than setting it during runtime. Then you can avoid scripting altogether.
 
Yes, you both are correct. I knew it was going to be pretty hard to do. I think I will stick with Unka Josh idea and just have it select one of the existing Actor to replace the dog (Actor 9).

I am assuming this is as easy as:

@>Change Party Member: Remove[]
@>Change Party Member: Add[], Initialized

I hope once the dog is removed, the sprite on the map will change to the correct Actor.

Well I will try it and see how it goes...

Thanks for your help... At least it made my mind focus and grasp it better.
 
I did something similar- creating a new actor during game-play. There are problems with that, like you can't add/remove that actor from the party using events, add weapons, or do anything to it really. I advice you to make several actors in the database instead.
 
Now the problem I have is making sure the character is deleted from the game so my character cant meet up with it. For example if I chose the Fighter, the Fighter that I put in the game should disappear. This is what I used but it doesnt hide them.

For each class ( male ) I used this list of Event Commands:

When [Male]
Text: What class is your character?
Show Choices: Fighter, Lancer, Warrior, Gunner
: When [Fighter]
Change Party Member: Remove[]
Change Party Member: Add[], Initialize
Control Switches: [0003: Fighter Taken]=ON
and so on.........

Then on the Actor Event (Fighter) -This is the Fighter character I placed on one of the map so I can meet them and add them to the group.

1st Event page I checked the switch [0003: Fighter Taken] is ON
@>Erase Event

2nd Event page for it to do other things...

But it doesnt seem to work like I thought. Shouldnt it just disappear?
 
There's a problem with your event. If there are 2 pages- 1 with a certain condition(like a switch being ON), and 2nd with none, the 2nd page is always executed. use a single page with conditional branch: switch 003==ON
 
Better than that, use two pages. First page: The normal, interact-with-this-character page. Second page, blank, page conditions: Fighter Chosen ON.

The single page option will run into problems-- if you have the page set to Autorun, you won't be able to interact with the event. If not, the character won't disappear until you talk to them.
 
Yes. That's why you should do it the way that I said, instead of the way that was described by a previous poster.

First page: Normal.

Second, to be more clear, No graphic. Completely blank page in every way. Page conditions of the fighter being in the group.

Editing to add: This method-- a second blank page with no graphics-- is a method that you'll be using a lot, so try to understand how it works, and how it can be applied to other operations, such as boss fights.
 
AllPaoTeam":38t32032 said:
Not sure what happened but now the character is invisible no matter who I choose. I ran a test by using a different character sprite in the 2nd page with the conditional switch. When I ran the test the new sprite is used rather than the 1 page sprite. Any Idea why?

I guess I wasn't clear enough on the "Page Conditions" part. I'm going to explain with a bit more detail-- the next stage of escalation is a 10-screenshot tutorial that I've got somewhere, but that may not be necessary here.

An event will run the last page where the events are true.

It doesn't matter what you've done with earlier pages. If page 2 has no page conditions, it will run, no matter what page 1 does.

BadExample.jpg


Since there are no page conditions, this is the page that will run. The conditional branch is irrelevant and unimportant.

I'm kind of surprised that you had this problem, because you used page conditions correctly here.
BadExample2.jpg


Page one never had a chance-- Page Two outranked it, since it didn't have any conditions, either.

Now, a warning: You used Erase Event when Brooke joins your party. This is not the way to do it, for this reason: Erase Event is a lie. It only erases the event while you are on the same map. Once you leave and re-enter, the event will be back. You need to use multiple pages and page conditions to make events go away long-term.

BadExample3.jpg
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top