MV Making A new skill for my game

(speaking in player terms)
New ability, is a passive skill that would do the following: when actorX uses fire there is a probability that he will cast a different element spell.


(speaking as a developer)
I tried using a formula that was apparently a disaster. I will give you an example:
i put this into a <Pre-Eval Damage> because I didn't know where to put it. I'm questioning putting it in a 'Z' state


var reload = Math.floor(Math.random()*3);
if(reload==2){
var fireIce= Math.floor(Math.random()*3);
}

inside the <action sequence> I put this:

if reload==2 && fireIce==1
add state (x): user
end

if reload==3 && fireIce==2
add state (y): user
end

This was my big attempt, but I couldn't do it. somebody could help me?
At least states X and Y cause the player to cast the ability using a <Custom Apply Effect>
this is working.

On the Fire skill, set a variable to the actorID (maybe create a section of variables just for battle calculations and put it there), then execute a Common Event.
In the Common Event, test for state in actor with ID as Variable, then test for random, then Force an Action (Ice spell). Because you have to choose a Target in the Force Action, you might need to save the enemy troop Id if there are multiple. If the Ice follows instead of overriting the Fire, then 'Last Target' works fine.
To be clear, you want a passive state that affects your casting? So if you have this state than casting fire could potentially cast another spell in its place?
To be clear, you want a passive state that affects your casting? So if you have this state than casting fire could potentially cast another spell in its place?
Cast fire could make after it hits, Actor cast Ice or Elect

On the Fire skill, set a variable to the actorID (maybe create a section of variables just for battle calculations and put it there), then execute a Common Event.
In the Common Event, test for state in actor with ID as Variable, then test for random, then Force an Action (Ice spell). Because you have to choose a Target in the Force Action, you might need to save the enemy troop Id if there are multiple. If the Ice follows instead of overriting the Fire, then 'Last Target' works fine.

I will keep that in mind it sounds useful, as soon as I return home I will try, for now I will show you what new I did, it is not perfect yet.
Spoiler: CODE
<Before Eval>
user._reload = Math.floor(Math.random()*2);//Activate
user._elements = Math.floor(Math.random()*2);//ElementsChase
</Before Eval>

<target action>
immortal target: false
action animation: target
wait: 30
action effect: target
wait for animation
wait for effect

if (user._reload === 1 && user._elements === 0)//cast ice
se: P2_Action_07
wait: 60
force element: 3
animation 71: target
wait for animation
action effect: target
wait for effect

else if (user._reload === 1 && user._elements === 1)//cast elect
se: P2_Action_07
wait: 60
force element: 4
animation 175: target
wait for animation
action effect: target
wait for effect
end
</target action>

But he continues to have problems as he sometimes casts Fire + Ice or Fire + Elect
but there is a case where he casts Fire + Ice + Elect just in this order and the latter should not happen ... I think
If you're using yanfly plugins already, there is one called Weapon Unleash that you can use to give skills a % chance to cast other skills instead of the base skill.

Original thread: https://forums.rpgmakerweb.com/threads/making-a-new-skill-for-my-game.128703/