JavaScript questions that don't deserve their own thread

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,640
First Language
Czech
Primarily Uses
RMMV

Bonkers

Get ready to be Wowed!
Restaff
Joined
May 26, 2013
Messages
2,941
Reaction score
2,897
First Language
English
Primarily Uses
RMMV
Quick question as I am using Yanfly's skill core. I'd like to add this note tag to healing spells, so when the 8th actor casts healing spells on someone to full or over heals they restore 10% mana.

<After Eval>
if (target.hp === mhp){
$gameActors.actorid(8).gainMp(Math.round(.1*(m.mmp)))}
</After Eval>

Unfortunately it didn't work, have I miswritten the command?
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,640
First Language
Czech
Primarily Uses
RMMV
@Bonkers
1. You have target.mp, but only mhp. Whose mhp?
2. Not actorid, but actor
3. What is m.mmp? I know what is mmp, but what is m?
4. It's better to write 0.1 instead of .1, it's more readable.
5. If you want to cover both full heals and overheals, it might be better to use >= instead of ===
 

Bonkers

Get ready to be Wowed!
Restaff
Joined
May 26, 2013
Messages
2,941
Reaction score
2,897
First Language
English
Primarily Uses
RMMV
@Poryg
1. Max hp of the target the healing spell effects.
does this mean that 'target' is only for enemy battlers? I can use actor.hp as well then.
2. Thank you, the master script call list was what I was using to flesh out the statement. I have changed this.
3. Max mp? I'll change that as well.
4. Much appreciated.
5. A very good point. That's much better, thank you.

<After Eval>
if (target.hp >= mhp){
$gameActors.actor(8).gainMp(Math.round(0.1*(mmp)))}
</After Eval>

I've also tried actor.hp, but the effect doesn't occur.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,640
First Language
Czech
Primarily Uses
RMMV
@Bonkers None of these were questions to answer, but pointers to your errors.
Alright, more explicitly.
1. You wrote target.hp, but only mhp. target.hp is ok, but just mhp is not, because you need to specify to whom it belongs to.
3. Same here. The point was not mmp being wrong. It was that you wrote m.mmp, which I suppose neither the computer nor me can recognize what the first m was.
 

Bonkers

Get ready to be Wowed!
Restaff
Joined
May 26, 2013
Messages
2,941
Reaction score
2,897
First Language
English
Primarily Uses
RMMV
@Poryg Understood, and thank you. Those points help immensely and I got it working. =D
I knew the targets but the computer did not, and I just haven't learned that the computer doesn't know what it knows till I tell it so.

<Post-Damage Eval>
if (target.hp >= target.mhp){
$gameActors.actor(8).gainMp(Math.round(0.1*($gameActors.actor(8).mmp)))}
</Post-Damage Eval>
 

Sword of Spirit

Veteran
Veteran
Joined
Nov 3, 2017
Messages
114
Reaction score
14
First Language
English
Primarily Uses
RMMV
<Deleted>

Nevermind, I just found what I did wrong--I had a letter uncapitalized.
 

Dama

Veteran
Veteran
Joined
Jun 20, 2013
Messages
61
Reaction score
70
Primarily Uses
Is there any way to be able to use "Comment : tool_position : move_to_target" of chrono engine in its abs mode? or script command? using script command to move to target gives "cannot read property '_x' of undefined" error
 

Sword of Spirit

Veteran
Veteran
Joined
Nov 3, 2017
Messages
114
Reaction score
14
First Language
English
Primarily Uses
RMMV
What's the command to unequip an actor's weapon/weapons based on weapon type ID?
(I can't do it with events, because I need to run it with a plugin at an odd time in processing.)
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
So you want to check if the weapon equipped is of a certain weapon type and if yes, unequip it?
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Do you have dual wield in your game, or all actors can only have 1 weapon equipped at a time?
 

Sword of Spirit

Veteran
Veteran
Joined
Nov 3, 2017
Messages
114
Reaction score
14
First Language
English
Primarily Uses
RMMV
Yes, there are a couple of States that allow Dual Wield, and they are some of the ones relevant to this. If it's a problem though, I think I can just worry about the first weapon slot, although it may be more forward compatible to handle both.
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
569
Reaction score
153
First Language
Serbian
Primarily Uses
N/A
JavaScript code that lets you unequip all weapons of a certain weapon type ID seems to be:
Code:
var actor = $gameActors.actor(1);
actor.equips().forEach(function(equip) {
    if (equip && equip.wtypeId && equip.wtypeId === 2) {
        actor.discardEquip(equip);
    }
});
Where 1 is the actor ID and 2 is the weapon type ID.
I don't know with what plugin are you trying to do it and at what time, so I can't assist further than that (also, I've been away for quite long from RPG Maker MV).
 

Sword of Spirit

Veteran
Veteran
Joined
Nov 3, 2017
Messages
114
Reaction score
14
First Language
English
Primarily Uses
RMMV
That's it! I'm using Yanfly Skill Core to use it with a skill before the rest of the skill's effects start. The skill puts the character into a state that I made that (through Yanfly Equip Requirements) doesn't allow certain weapon types to be equipped when in that state. Unfortunately, if the character had one of those weapon types equipped when they activated the skill before, it would unequip all of their equipment (armor, etc)--not just the offending weapon. So I needed this to remove the weapons first so that adding the state wouldn't cause the character to disrobe. Works great, thanks!
 

Sword of Spirit

Veteran
Veteran
Joined
Nov 3, 2017
Messages
114
Reaction score
14
First Language
English
Primarily Uses
RMMV
Could anyone tell me how to determine if a particular actor is in a particular slot in the battle party, for purposes of an if statement? For some reason I can find a lot of different things that look like they would work, but none of them actually seem to.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,640
First Language
Czech
Primarily Uses
RMMV
There are two possibilities.
Code:
if ($gameParty.members()[0].actorId() == 1) {}

if ($gameActors.actor(1) == $gameParty.members()[0]) {}
 

KockaAdmiralac

Cube-shaped garbage can
Veteran
Joined
Jun 15, 2015
Messages
569
Reaction score
153
First Language
Serbian
Primarily Uses
N/A
In addition to what Poryg said, $gameParty.members() returns all members if outside the battle, if you want specifically battle members you can use $gameParty.battleMembers() instead.
 

Users Who Are Viewing This Thread (Users: 2, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,015
Messages
1,018,351
Members
137,801
Latest member
topsan
Top