I created a new state for the Weaken Weapon state. From what I have been seeing it is possible weaken a damage type the weapon is doing also to check if the player the state is on has that weapon type equipped.
So what I want to do is weaken the damage type of a weapon if they have that weapon equipped. For example Weaken Swords would cause Slashing damage to be reduced to 75% if the player is equipped with a sword.
Here's what I got.
<JS Post-Apply>
//weapon ids 26-44 are all swords
if(target.equips[1].id>=26 && target.equips[1].id<=44)
{
//element 1 is slashing
target.element[1]=75%;
}
</JS Post-Apply>
Game crashes as soon as battle starts with an enemy that has an attack with the status.
I'm thinking the target.element[] is wrong, but not sure what would be correct in its place.
0.75
although I'm not sure about accessing the element directly.
if that's a weapon attribute, you have to pull the battler first, then the weapon, then the lot of attributes and THEN the one element.
I think one of the VisuStella MZ core plugins has a tag like <JS Pre-Damage as User> that can be used on states, with a value variable representing the actual damage/heal to apply? In that case maybe consider something like this:
<JS Pre-Damage as User>
if (
this.isPhysical() &&
value > 0 &&
user.weapons?.().some(w => 26 <= w.id && w.id <= 44)
) {
value = Math.floor(value * 0.75);
}
</JS Pre-Damage as User>
I.e. "if it's a physical hit, does damage, and the user has at least one relevant weapon equipped, multiply the damage output by 0.75". I haven't tested this...you might need different syntax.
So you're saying something like this but it still the same crash
I think target. works with someone that has a status effect. Maybe not though. If .target is the problem how do I do it without an individual if statement for every playable character that exists. with the actor(x) tag.
"if that's a weapon attribute, you have to pull the battler first, then the weapon, then the lot of attributes and THEN the one element."
I'm not sure what you mean here. Elements are the damage types in the system. I know you can assign element on a weapon and on any damaging skill. Maybe this is just something that can't be accessed as I haven't found anyone else even trying to do this and I'm just assuming .element[x] is how you'd access the element. There is no code in the Script calls for elements.
If this needs a plugin does anyone know one that may work? Below is my 2nd try and .element can't be used on .equips either. Even if that did work I think it would permanently change the value and I need it to go away when the status goes away.
<JS Post-Apply>
//weapon ids 26-44 are all swords
if(target.equips[1].id>=26 && target.equips[1].id<=44)
{
//element 1 is slashing
target.equips[1].element[1]=0.75;
}
</JS Post-Apply>
The other way to do this could be to check the weapon as I did then in the if check if attacking and what type of damage the weapon does. If it does slashing damage reduce the damage by 25%. Not sure how to code that also and still would have to check the element in that case.
caethyril
I don't fully understand this line
user.weapons?.().some(w => 26 <= w.id && w.id <= 44
user.weapons makes sense not sure if the ? is code or if I need to fill something in there and there's a . before the () and after the (). () usually is the end of a function to pass parameters the dot before it confuses me what you mean or if that is how it should be coded. some? I don't know of a some function or am I supposed to replace that. I'm assuming all the w's should have .id on them and w just is you abbreviating for weapon. As written it doesn't work that's why I'm trying to understand this line to fix it. And yes I do use the VisuStella core & battler.
SyntaxError
Malformed arrow function parameter list
Shows up when I boot up the game.
So odd the error is
evTools failed to load SourceMap: Could not load content for chrome-extension://njgcanhfjdabfmnlmpmdedalocpafnhl/js/libs/pixi.js.map: System error: net::ERR_FILE_NOT_FOUND
But if I remove the code there is no error. Not sure what this is even about. Not sure what pixi.js.map is but I have pixi.js in my libs folder.
Ok your code is working for some reason my troop slot 2 is crashing the game no matter what enemies I put in that space. It crashes when I encounter them. Slots 1 and 3 are working fine moving the test monster there fixed it.
Try deleting troop 2 and recreating it - if you made the troop then deleted enemies it references, that could cause crashing.
My guess about the error would be that it's trying to reference an enemy with no image assigned. That could be for various reasons, e.g. maybe the enemy has no image in the database (or was deleted), or a plugin is replacing its image with undefined (maybe due to a mistake in a notetag somewhere).
Since it only happens for troop 2, my only suggestion is to double-check everything (troop events, enemy notetags, plugin parameters, etc) that might apply to that troop to see what might be wrong. In the meantime, I guess you can just avoid using that troop.
Also, I'd suggest turning off the first ----- plugin in your list, because it's blocking any potential warning messages from plugins below it.