dracount

Villager
Member
Joined
May 23, 2022
Messages
5
Reaction score
4
First Language
English
Primarily Uses
RMMZ
Hi, I am new to RPG Maker but have coding experience.

I am trying to add a new weapon to my existing character, but I am not having much success.

JavaScript:
$gameParty.members()[0].equips.push(6);

Basically something like this, but I am missing something?

Any help would be most appreciated.

Thanks
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,672
Reaction score
2,760
First Language
EN
Primarily Uses
RMMZ
Since you use push, I'm guessing you're trying to add a new weapon equip slot? But I wonder if instead you're trying to replace the current weapon, or add a new Equip Weapon trait to a character. In case it helps to clarify, by default:
  1. Trait lists are static, sourced from all trait-bearing objects present "on" a battler. If you want to add persistent traits to an actor mid-playthrough, a non-plugin option may be to use a Change Class command. (All states get removed on death, so a state is probably insufficient.)

    Alternatively you could check out the SimplePassiveSkillMZ.js plugin that ships with RMMZ; on the Steam version it's found in the install folder under dlc/BasicResources/plugins/launch.

  2. Equip slots are an array of equipment type IDs. These determine the number of slots available for equipment and the type allowed in each slot. To modify these you could look into writing an override for Game_Actor#equipSlots (rmmz_objects.js). Note that overrides should be written and loaded as separate .js files (i.e. plugins) through the Plugin Manager, for ease of tracking and debugging as well as to avoid loss of data if/when the project's core scripts are updated.

    Note that if you add multiple slots with the same equip ID then that may break the .

  3. Equip data is stored as Game_Item instances. There exist various methods (rmmz_objects.js) for interfacing with this, e.g.
    • Game_Actor#changeEquipById(equipTypeId, itemId);
    • Game_Actor#forceChangeEquip(slotId, itemId).
    More details on usage can be found in the script call list here:
Hope that helps! :kaohi:
 

dracount

Villager
Member
Joined
May 23, 2022
Messages
5
Reaction score
4
First Language
English
Primarily Uses
RMMZ
Since you use push, I'm guessing you're trying to add a new weapon equip slot? But I wonder if instead you're trying to replace the current weapon, or add a new Equip Weapon trait to a character. In case it helps to clarify, by default:
  1. Trait lists are static, sourced from all trait-bearing objects present "on" a battler. If you want to add persistent traits to an actor mid-playthrough, a non-plugin option may be to use a Change Class command. (All states get removed on death, so a state is probably insufficient.)

    Alternatively you could check out the SimplePassiveSkillMZ.js plugin that ships with RMMZ; on the Steam version it's found in the install folder under dlc/BasicResources/plugins/launch.

  2. Equip slots are an array of equipment type IDs. These determine the number of slots available for equipment and the type allowed in each slot. To modify these you could look into writing an override for Game_Actor#equipSlots (rmmz_objects.js). Note that overrides should be written and loaded as separate .js files (i.e. plugins) through the Plugin Manager, for ease of tracking and debugging as well as to avoid loss of data if/when the project's core scripts are updated.

    Note that if you add multiple slots with the same equip ID then that may break the .

  3. Equip data is stored as Game_Item instances. There exist various methods (rmmz_objects.js) for interfacing with this, e.g.
    • Game_Actor#changeEquipById(equipTypeId, itemId);
    • Game_Actor#forceChangeEquip(slotId, itemId).
    More details on usage can be found in the script call list here:
Hope that helps! :kaohi:
Thank you! I am looking at the SimplePassiveSkillMZ and this is what I am looking for :)

I currently have 3 party members, a swordsman, thief and a mage. What I am trying to do is go to a trainer to learn a new weapon e.g. Spear. I want my swordsman and thief to be able to learn this skill but not my Mage. How do I allow the PC to select which character to learn and not give them the option of the Mage to learn?

I am thinking to store variables of classes and names of characters and use those somehow in a show choices. But I dont know if this is possible or if there is a better way to do this?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,526
Reaction score
2,890
First Language
English
Primarily Uses
RMMV
I want my swordsman and thief to be able to learn this skill but not my Mage. How do I allow the PC to select which character to learn and not give them the option of the Mage to learn?

I am thinking to store variables of classes and names of characters and use those somehow in a show choices. But I dont know if this is possible or if there is a better way to do this?
It depends on how your game is set up - as you typed it, it's very straightforward. The Show Choices event command only shows what you choose to type into it. So you'd do, for example,
Code:
Show Choices
1 MySwordsman'sName
2 MyThief'sName

Then the event has code blocks underneath where you do the appropriate things to the appropriate actor, depending on the choice the player input. It doesn't have any kind of automatic listing option that you need to try to restrict.

The only reason this wouldn't work perfectly for you is if you were using a class change system, so the specific actor which is a mage could change. Then you'd need to look at one of the dynamic choices plugins.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,672
Reaction score
2,760
First Language
EN
Primarily Uses
RMMZ
Also, Show Choices supports text codes like \n[1] (name of actor ID 1), \p[1] (name of party member 1, a.k.a. the leader), etc.

If you want to hide ineligible actors (e.g. if they're not in the party, or if they're the wrong class) rather than checking eligibility after selection, you could try one of these approaches:
  1. Branch to different Show Choices commands for different combinations/permutations. This may not be practical depending on the exact situation (e.g. number of actors).

  2. Get creative with the Select Item command, e.g.

    • Add items of an unused Hidden Item type (A or B) for each eligible choice;
    • Get the player to pick one of those items via Select Item;
    • Remove all such items;
    • Check player input, i.e. the value of the input variable.
    This approach also happens to bypass the arbitrary 6-choice editor limit for Show Choices, but does require a "spare" Hidden Item type.

  3. Like ATT_Turan mentions, find a plugin to conditionally hide/show choices, e.g.
 

dracount

Villager
Member
Joined
May 23, 2022
Messages
5
Reaction score
4
First Language
English
Primarily Uses
RMMZ
Thank you for the replies. That was an example, as I plan on allowing the player to choose their own classes, so it could be 2 sorcerers and 1 swordsman or 3 thieves etc.

I think also that trying to apply this for 3 different character classes separately is going to give me headaches. I have been reading about swapping party leaders e.g.

Code:
$gameParty.swapOrder(0, 1);

and only deal with 1 party member at a time within the event. I could then check which class the leader is and present them with the possible options. However I would need to be able to do a choice selection in the script. Is this possible?

Code:
$gameMessage.setChoices();

If I can figure out how to use it correctly...

And then I would need to be able to quickly allow the player to switch the leader maybe through a HUD or something.

Am I complicating this unnecessarily?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,526
Reaction score
2,890
First Language
English
Primarily Uses
RMMV
Am I complicating this unnecessarily?
Yes. I see - both as a programmer, and as a player of the game - no reason that talking to an NPC about my class should rearrange my party members.

Just use one of the methods previously mentioned to control the player's choice, then the rest of the event is unaffected.

As a bit of unasked-for advice...consider slowing down. It sounds like you could benefit from doing more RPG Maker tutorials to learn how its systems and the event commands work before you dive into making your goal, dream game.

If you're knowledgeable in coding, read through some of the base engine's code in the js folder, or look up plugins related to what you want to do and read through those before you try to cram an isolated, random function into what you're doing (like I see no reason that swapOrder() would have come up in this thread :wink: ).
 

dracount

Villager
Member
Joined
May 23, 2022
Messages
5
Reaction score
4
First Language
English
Primarily Uses
RMMZ
Yes. I see - both as a programmer, and as a player of the game - no reason that talking to an NPC about my class should rearrange my party members.

Just use one of the methods previously mentioned to control the player's choice, then the rest of the event is unaffected.

As a bit of unasked-for advice...consider slowing down. It sounds like you could benefit from doing more RPG Maker tutorials to learn how its systems and the event commands work before you dive into making your goal, dream game.

If you're knowledgeable in coding, read through some of the base engine's code in the js folder, or look up plugins related to what you want to do and read through those before you try to cram an isolated, random function into what you're doing (like I see no reason that swapOrder() would have come up in this thread :wink: ).
Thanks, I appreciate the tips. I'll have a look again over the responses.

I would like to have the party consist of 4 different party members, and trying to buy 1 skill e.g. spear for all party members at the same time seemed a bit complicated so I was thinking to use the swopOrder so I only have to worry about 1 actor at a time (the one who initiated the event).

When I want to learn I usually decide to try do something and work out how to do it. Maybe if it's too complicated I'll leave it for a bit, create a 1 player game.

But thanks again I appreciate the advice
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,526
Reaction score
2,890
First Language
English
Primarily Uses
RMMV
I would like to have the party consist of 4 different party members, and trying to buy 1 skill e.g. spear for all party members at the same time seemed a bit complicated so I was thinking to use the swopOrder so I only have to worry about 1 actor at a time (the one who initiated the event).
Your reasoning is splitting it between "only buy it for the party leader" and "buy it for all party members at the same time." (incidentally, I'm not sure why the latter would be complicated at all. It takes one event command for each party member)

It's skipping the kind of reasonable (and very doable) options of "buy it for the actor you select of the appropriate class" (which is using the variable choices we've discussed) or "buy it for all party members who are the appropriate class" (which would require no plugins and is easily doable with regular event commands).

I think you need to firm up your concept, decide how you want this skill buying to work, then ask if you can't figure out how to implement it.
 

dracount

Villager
Member
Joined
May 23, 2022
Messages
5
Reaction score
4
First Language
English
Primarily Uses
RMMZ
Your reasoning is splitting it between "only buy it for the party leader" and "buy it for all party members at the same time." (incidentally, I'm not sure why the latter would be complicated at all. It takes one event command for each party member)

It's skipping the kind of reasonable (and very doable) options of "buy it for the actor you select of the appropriate class" (which is using the variable choices we've discussed) or "buy it for all party members who are the appropriate class" (which would require no plugins and is easily doable with regular event commands).

I think you need to firm up your concept, decide how you want this skill buying to work, then ask if you can't figure out how to implement it.
Thank you for making that clear to me. I have had another look at the variable choices you mentioned and I think this will work!
 

Latest Threads

Latest Profile Posts

The main game of my trilo/saga 50%OFF on Steam..... its now or never more
I swap between Ace and MZ so I can stay fresh but - what do you mean you can use subfolders in the plugin's folder for easier organization!?
Did some new music again, praise be. To the next song!
Watch Studio Blue play Numina by starlit in our latest RPG Maker Games Critique stream starting NOW!

Forum statistics

Threads
123,140
Messages
1,154,268
Members
161,475
Latest member
guihguih27
Top