Hello, everyone. I have been trying to use script calls to link actor #11's stat parameters to an enemy stat parameters. Here is what I have so far, but it's not working.
newValueATK = $gameActors.actor(11).param[2];
$gameTroop.members(1)[1].param[2] = newValueATK;
I figured that I might be able to just reword some of it and it would work, but it's not, so I'm asking if anyone might know a way to get this to work.
I was trying to directly connect Actor #11's attack parameter to the first enemy in Troops #1 to change the first enemy in Troops #1's attack parameter into the amount that Actor #11 has. I'm trying to use this script call outside of battle, so that the battle is ready just before the player actually has to fight the battle. However, when I try to run the event the will crash and give me this,
TypeError
Cannot read property 'param' of undefined
I'm assuming that it is $gameTroop.members(1)[1].param[2] = newValueATK; However, I'm not sure what to do to get this to work the way that I want it to.
Edit:
I just tried to use the script call during battle and got this message:
TypeError
Cannot read property 'param' of undefined
Instead of using the script call in an event on the map outside of battle I put the script call in the troop section.
I set the conditions to '
turn 0'' and Span 'Battle'
I even tried the Span at 'Turn'
I got the TypeError message both ways.
Edit #2:
I got it working. I ended up having to use the script call during the battle instead of on the map just before the battle. Unfortunationly that means I will have to change my plans for my game just a little, but luckily not by much
The script that I ended up using with script call during a battle is:
a = $gameActors.actor(actorID).param[parameterID];
b = $gameTroop.members()[troopmemberID];
b.addParam(2, a);
With this I managed to link an 1 parameter of 1 enemy with 1 parameter of an actor.
First I change the parameter of the actor that I'm using before the battle and during the battle the enemy(ies) that are linked that actor will have the parameters that they share changed.
Edit #3:
Sorry, I tried it once and it seemed to work, but it only brought the enemy's attack to 0. I couldn't increase it, but I think that I might be onto the right track. I'm just missing something to allow it to link up with an actor's parameters. Not sure how to make it work, but this is what I have so far.
{In a Troop Event}
b = $gameTroop.members()[0];
b.addParam(2, n);
If you exchange the "n" with 20 it will add 20 to the attack parameter of the first enemy of the troop.
If you exchange the "n" with -20 it will subtract 20 from the attack parameter of the first enemy of the troop.
Now I just need to figure out how to replace "n" with the value of actor(11)'s attack parameter.
Edit #4:
I got it to work by using variables.
#1: Make an event
#2: Go to CONTROL VARIABLES and set a variable to GAME DATE, ACTOR, "Pick an actor", "Pick a parameter".
#3: Create a SCRIPT CALL in a TROOP EVENT, in the DATABASE using the following script:
b = $gameTroop.members()[EnemyID];
v = $gameVariables.value(variableID)
b.addParam(ParameID, v);
b.addParam(ParamID, -#);
Change EnemyID with,
0 = First Enemy
1 = Second Enemy
2 = Third Enemy
3 = Fourth Enemy
4 = Fifth Enemy
6 = Seventh Enemy
8 = Eighth Enemy
(Please note that I found out that if, you replace EnemyID with an enemy number that is not in the troop then the game will crash.)
(Example: if the battle troop has only two enemies in it and you replace EnemyID with 2 it will think that you are trying to change the a parameter of the third enemy that does not exist and it will come back with an error.)
Change VariableID with any variable that you have connected to an actor's parameter with.
Change ParamID with,
0 = MaxHP
1 = MaxMP
2 = ATTACK
3 = DEFENSE
4 = MAGIC ATTACK
5 = MAGIC DEFENSE
6 = AGILITY
7 = LUCK
Change -# with the enemies base parameter value for the parameter that you are trying to change.
Due to the "- sign" it will subtract that value that you change the "# sign" into from the enemy's parameter that you are changing.
Just remember to leave the "- sign" just before the number or you will not subtract that number from the enemy's parameter.
Example: If the enemy's attack parameter for example is 1 and you are changing the enemy's attack parameter with the actor's attack parameter then you will change the -# with -1, so that it will subtract 1 for the enemy therefore, making the enemy's attack parameter truly equally the actor's parameter.
#4:
Remember to while on the Troop screen in the Database to set the troop event with this script call to have
Conditions: Turn 0
With this the event will run at the beginning of the battle.
#5: Remember to change the parameter that you want to change of the actor that you have connected to the variable that you're using before the battle or before the script call.
(If you just change the level of the actor that is connected to the variable that you're using it will automatically change the parameters of the actor.)
Thank you everyone for the help. I hope that this helps someone else who was also trying to work out this issue.