Yanfly Skill Core | Adding Variable on Skill Use Depending on Weapon

fallenlorelei

Veteran
Veteran
Joined
Jul 8, 2013
Messages
298
Reaction score
346
First Language
English
Primarily Uses
So I hope you guys can help figure this out with me. My plan is to add 1 to a variable every time a skill ("Attack") is used, depending on their weapon. If they have "this weapon," then "add 1" to "variable ID 1." If they have "this other weapon," then "add 1" to "variable ID 2." And so on. There are 4 weapons.


I tried using a simple common event that was called on every time they used "Attack." This didn't do anything.


rpgmaker-variables1.PNG


So then I thought I'd use Yanfly's Lunatic mode. This is the script I came up with for the Attack notetag:


<Custom Execution>
if ($gameActors.actor(1).equips().contains($dataWeapons[1])
{
$gameVariables.setValue(1, $gameVariables.value(1) + 1);
}
else {
}
</Custom Execution>


This is giving me an error. SyntaxError: Unexpected token { {stack: (...), message: "Unexpected token {"}


Any ideas? 
 

Astfgl66

Veteran
Veteran
Joined
Jan 5, 2016
Messages
722
Reaction score
578
First Language
French
Primarily Uses
I didn't try it in game, but by quickly looking at it, you're missing a ")"


<Custom Execution>
if ($gameActors.actor(1).equips().contains($dataWeapons[1]) ) //you didn't close the if () there
{
$gameVariables.setValue(1, $gameVariables.value(1) + 1);
}
else {
}
</Custom Execution>


I don't see anything else, so try it like this and tell me how it goes.
 

fallenlorelei

Veteran
Veteran
Joined
Jul 8, 2013
Messages
298
Reaction score
346
First Language
English
Primarily Uses
I didn't try it in game, but by quickly looking at it, you're missing a ")"



<Custom Execution>
if ($gameActors.actor(1).equips().contains($dataWeapons[1]) ) //you didn't close the if () there
{
$gameVariables.setValue(1, $gameVariables.value(1) + 1);
}
else {
}
</Custom Execution>


I don't see anything else, so try it like this and tell me how it goes.
Haha awesome, thank you. I asked my javascript-knowing buddy if he saw anything wrong with it, and he didn't (pfff). So I thought it was something else.


So this isn't giving me any errors anymore *cheer!* But the variable is not going up whenever I finish a battle. Checking it, it still stays at 0, even after attacking 3 or 4 times. Weapon 1 is equipped, and it is Actor 1. Trying to figure out how to make this work... *chinstroke*


Edit: It works when I don't have "if [this weapon] equipped." If it's simply [add variable] on attack, it's okay. So I've gotta figure out how to make it add only if a certain weapon is on.
 
Last edited by a moderator:

Astfgl66

Veteran
Veteran
Joined
Jan 5, 2016
Messages
722
Reaction score
578
First Language
French
Primarily Uses
Well this will increase the value each time the skill is used if actors 1's weapon is n*1.


If Actor 2 uses attack and actor 1 has that weapon it will increase it too.


Also, no need to make a else statement if you don't use it.


Here is the notetag I use that works in my project (Core engine, battle engine and skill core installed):


<Custom Execution>
if (user.equips().contains($dataWeapons[1])) {
$gameVariables.setValue(7,$gameVariables.value(7)+1)
}
</Custom Execution>


Try it and if it still doesn't work if actor 1 indeed does have weapon 1 equipped, my guess would be that you have a plugin that modifies how equipment is handled.
 

fallenlorelei

Veteran
Veteran
Joined
Jul 8, 2013
Messages
298
Reaction score
346
First Language
English
Primarily Uses
Well this will increase the value each time the skill is used if actors 1's weapon is n*1.


If Actor 2 uses attack and actor 1 has that weapon it will increase it too.


Also, no need to make a else statement if you don't use it.


Here is the notetag I use that works in my project (Core engine, battle engine and skill core installed):



<Custom Execution>
if (user.equips().contains($dataWeapons[1])) {
$gameVariables.setValue(7,$gameVariables.value(7)+1)
}
</Custom Execution>


Try it and if it still doesn't work if actor 1 indeed does have weapon 1 equipped, my guess would be that you have a plugin that modifies how equipment is handled.
Luckily, only one actor in this game.


Just found out after quite a bit of trial and error that it's a plugin. Specifically Dreamx's Random Pre/Suffixes. I assumed the plugin used the base ID for the weapon, but I must be wrong. So I guess the game isn't seeing that the actor has indeed equipped Weapon 1. It sees something determined by the plugin.


Can I ask how to fix that here? Or should I go ahead and post to their page?
 

Astfgl66

Veteran
Veteran
Joined
Jan 5, 2016
Messages
722
Reaction score
578
First Language
French
Primarily Uses
I don't use Dreamx's plugin so I wouldn't know. Ask here if you want, but I think you're more likely to get an answer if you ask the plugin creator himself.


I could think of another solution: if there are only 4 weapons in the game, make them have a different type, and just check for that type.


You can get a weapon type by using equips[0].wtypeId for example.
 
Last edited by a moderator:

fallenlorelei

Veteran
Veteran
Joined
Jul 8, 2013
Messages
298
Reaction score
346
First Language
English
Primarily Uses
I don't use Dreamx's plugin so I wouldn't know. Ask here if you want, but I think you're more likely to get an answer if you ask the plugin creator himself.


I could think of another solution: if there are only 4 weapons in the game, make them have a different type, and just check for that type.


You can get a weapon type by using equips[0].wtypeId for example.
That's brilliant, I'll give it a try! 


Edit: Praise the Light! It works beautiful! I love you @Astfgl66. Let's get married.


This is the code I used:


<Custom Execution>
if ($gameActors.actor(1).isWtypeEquipped(1)) {
$gameVariables.setValue(1,$gameVariables.value(1)+1)
}
</Custom Execution>
<Custom Execution>
if ($gameActors.actor(1).isWtypeEquipped(2)) {
$gameVariables.setValue(2,$gameVariables.value(2)+1)
}
</Custom Execution>
<Custom Execution>
if ($gameActors.actor(1).isWtypeEquipped(3)) {
$gameVariables.setValue(3,$gameVariables.value(3)+1)
}
</Custom Execution>
<Custom Execution>
if ($gameActors.actor(1).isWtypeEquipped(4)) {
$gameVariables.setValue(4,$gameVariables.value(4)+1)
}
</Custom Execution>


And it works for all 4 weapons.


There was probably a more efficient and pretty way to get all that in, but hey. It works. I'm not complaining.
 
Last edited by a moderator:

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

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,049
Messages
1,018,547
Members
137,835
Latest member
yetisteven
Top