[RMMV] COMPLEX DAMAGE FORMULA / SCRIPT
Posts
Pages:
1
Hello,
I've been stuck for hours on a formula embedded in a script using a plugin from Yanfly
I'm not familiar with scripts and I'm having a hard time configuring it the way I want, even if I think I'm close.
This is a tips & tricks (Chain Lightning), used so that an attack on a single target can reverberate on another target with reduced damage.
Here I want to use it for an equivalent in care.
My problem: the reverb should only hit one of my 4 heroes, but I'm using another plugin that allows me to summon creatures. Those creatures are therefore "friendly targets" but I don't want to include them.
The part of the formula that interests me seems to be this:
var members = allies.aliveMembers();
I would like to be able to specify that the allies who can be targeted are the members of groups 1, 2, 3 and 4.
Is it possible ?
Thanks to those who will help me.
(Translation made via google, please ask me to rephrase if necessary).
I've been stuck for hours on a formula embedded in a script using a plugin from Yanfly
I'm not familiar with scripts and I'm having a hard time configuring it the way I want, even if I think I'm close.
This is a tips & tricks (Chain Lightning), used so that an attack on a single target can reverberate on another target with reduced damage.
Here I want to use it for an equivalent in care.
My problem: the reverb should only hit one of my 4 heroes, but I'm using another plugin that allows me to summon creatures. Those creatures are therefore "friendly targets" but I don't want to include them.
The part of the formula that interests me seems to be this:
var members = allies.aliveMembers();
I would like to be able to specify that the allies who can be targeted are the members of groups 1, 2, 3 and 4.
Is it possible ?
Thanks to those who will help me.
(Translation made via google, please ask me to rephrase if necessary).
I might have to look into the precise code, but, off the top of my head, it could be something like...
...this, if we're talking purely about the `$gameParty` object? I'm not exactly sure how many summon-able members the player would be able to add to their party in-battle. However, I felt inclined to use the modulus function, as it returns the remainder portion of a division function. Hence, the `partyID` variable should be between 0 and 3. Which, in turn, would end up translating to the party members (surviving or not) in positions 1 through 4.
Don't ask me how to keep track of who's already been targeted with a Chain Lightning, though!
function randomMember() { val = Math.randInt($gameParty.members().length - 1); partyID = val % 4; return $gameParty.members()[partyID]; };
...this, if we're talking purely about the `$gameParty` object? I'm not exactly sure how many summon-able members the player would be able to add to their party in-battle. However, I felt inclined to use the modulus function, as it returns the remainder portion of a division function. Hence, the `partyID` variable should be between 0 and 3. Which, in turn, would end up translating to the party members (surviving or not) in positions 1 through 4.
Don't ask me how to keep track of who's already been targeted with a Chain Lightning, though!
Hello,
Thanks for your answer, but I don't quite understand what you mean. I should have said that I don't really know scripts.
Here is what I put inside the capacity:
I understand that the part I'm interested in is:
var members = allies.aliveMembers();
But I don't know what I should replace.
Something that uses the ID is actors? Or the position of the band members?
Thanks for your answer, but I don't quite understand what you mean. I should have said that I don't really know scripts.
Here is what I put inside the capacity:
<Custom Target Eval> // Adds the selected target to the target list. targets.push(target); // Grab the group of alive foes as candidates. var members = allies.aliveMembers(); // Remove the target from the group of candidates. members.splice(members.indexOf(target), 1); // This is the number of extra targets to select with Chain Lightning. var extraTargets = 2; // Loop the extra targets. while (extraTargets--) { // Grab a random Allies from the alive foes. var member = members[Math.floor(Math.random() * members.length)]; // Check to see if the member exists. if (member) { // Add the member to the group of targets. targets.push(member); // Remove the member as a viable candidate. members.splice(members.indexOf(member), 1); } } </Custom Target Eval>
I understand that the part I'm interested in is:
var members = allies.aliveMembers();
But I don't know what I should replace.
Something that uses the ID is actors? Or the position of the band members?
That code looks like you could be using one of Yanfly's scripts for MV? I'm not sure what gave me the idea you were using something else, but, whatever. Either way, I edited your post to include the code tag to make things more visible.
In any case, the line you're looking at...
...would return an array that contains the living members of a battle party. However, the variable/object `allies` could be either `$gameParty` or `$gameTroop`, depending on what the user of the skill would be. If the user is a player-controlled party member, then, `allies` would be, or refer to, `$gameParty`. If the user of the skill is an enemy the player fights, `allies` would be, or refer to, `$gameTroop`.
The code already removes the initial target, and removes targets that have already been hit by the spell. The missing ingredient, then, is to ensure that the spell can only hit an ally if they are in the first through fourth position in the party. However, to do this, you must first check if `member` is referring to `$gameParty`.
In MZ, there is a keyword of `instanceof` that can be used to check objects, and it probably exists in MV as well. However, since the two arrays could be different, you probably have to loop through `$gameParty` until the data matches.
So, I'm kinda thinking something like...
...this? I can't test this personally, so I apologize if this doesn't work.
In any case, the line you're looking at...
var members = allies.aliveMembers();
...would return an array that contains the living members of a battle party. However, the variable/object `allies` could be either `$gameParty` or `$gameTroop`, depending on what the user of the skill would be. If the user is a player-controlled party member, then, `allies` would be, or refer to, `$gameParty`. If the user of the skill is an enemy the player fights, `allies` would be, or refer to, `$gameTroop`.
The code already removes the initial target, and removes targets that have already been hit by the spell. The missing ingredient, then, is to ensure that the spell can only hit an ally if they are in the first through fourth position in the party. However, to do this, you must first check if `member` is referring to `$gameParty`.
In MZ, there is a keyword of `instanceof` that can be used to check objects, and it probably exists in MV as well. However, since the two arrays could be different, you probably have to loop through `$gameParty` until the data matches.
So, I'm kinda thinking something like...
<Custom Target Eval> // Adds the selected target to the target list. targets.push(target); // Grab the group of alive foes as candidates. var members = allies.aliveMembers(); // Remove the target from the group of candidates. members.splice(members.indexOf(target), 1); // This is the number of extra targets to select with Chain Lightning. while (extraTargets--) { // Grab a random Allies from the alive foes. var member = members[Math.floor(Math.random() * members.length)]; // Check to see if the member exists. if (member) { if (member instanceof Game_Party) { for (i=0; i<3; i++) { if (member === $gameParty.members()[i]) { // Target lies within the first four slots; cannot be targeted. break; }; }; // Target lies outside the first four slots; can be targeted. targets.push(member); // Remove the member as a viable candidate. members.splice(members.indexOf(member), 1); } else { // Add the member to the group of targets. targets.push(member); // Remove the member as a viable candidate. members.splice(members.indexOf(member), 1); } } } </Custom Target Eval>
...this? I can't test this personally, so I apologize if this doesn't work.
Thank you for taking the time to help me. Unfortunately that doesn't work.
The message :
ReferenceError: extraTargets is not defined
message:"extraTargets is not defined"
stack: (...)
get stack: function () { }
set stack: function () { }__proto__: Error
The message :
ReferenceError: extraTargets is not defined
message:"extraTargets is not defined"
stack: (...)
get stack: function () { }
set stack: function () { }__proto__: Error
That's a fairly fixible error, as I forgot to copy that over from before.
The part I'm more leery about is the 'break' function, and if that would work as intended. Like, I'm thinking it would just break out of the if statement...
...rather than the for loop...
...that I want to 'break' from.
<Custom Target Eval> // Adds the selected target to the target list. targets.push(target); // Grab the group of alive foes as candidates. var members = allies.aliveMembers(); // Remove the target from the group of candidates. members.splice(members.indexOf(target), 1); // This is the number of extra targets to select with Chain Lightning. var extraTargets = 2; // Loop the extra targets. while (extraTargets--) { // Grab a random Allies from the alive foes. var member = members[Math.floor(Math.random() * members.length)]; // Check to see if the member exists. if (member) { if (member instanceof Game_Party) { for (i=0; i<3; i++) { if (member === $gameParty.members()[i]) { // Target lies within the first four slots; cannot be targeted. break; }; }; // Target lies outside the first four slots; can be targeted. targets.push(member); // Remove the member as a viable candidate. members.splice(members.indexOf(member), 1); } else { // Add the member to the group of targets. targets.push(member); // Remove the member as a viable candidate. members.splice(members.indexOf(member), 1); } } } </Custom Target Eval>
The part I'm more leery about is the 'break' function, and if that would work as intended. Like, I'm thinking it would just break out of the if statement...
if (member === $gameParty.members()[i])
...rather than the for loop...
for (i=0; i<3; i++)
...that I want to 'break' from.
Pages:
1














