# How do I make an attack have the chance of triggering a State?

#### Jihanger

##### Psychotic Alien
I'm wondering if it's possible to do what I have in mind.

I have the Thunder Weapon from the standard spells apply Thunder Force, which adds elemental thunder damage. I want that while Thunder Force is active, the player has a chance of getting another State called "Hyped Up" when he attacks normally. "Hyped Up" has a 1/3 chance of triggering a second action for the turn, and even a third but at a much lower chance.

Is this possible through solely the database? If not, is there a way to do it without scripts?

#### BrentBAM

##### Veteran
You can try entering this into the damage formula of the skill.

a.add_state(id); a.atk * 4 - b.def * 2

And then enter the number of the state into id.

but I think it adds the state after the attack...

Last edited:

#### BrentBAM

##### Veteran
For the other effects a script might be needed.

#### Binder28

##### Veteran
Create a variable (Lets call it "Hyped Up") that rolls from 1 to 3 everytime the actor uses the skill "atack" and on 1 you put to trigger the "Hyped up" state and on 2 and 3 you put nothing. Now you have a way of doing it...the difficult is triggering this mid battle.

Create a battle event (on troops) with a conditional branc. The conditional branch must be "If charachter has "Thunder Force". Then you put the variable up, with another conditional branch for each random number...it should be something like this:

Conditional Branch: [charachter] is Thunder force aflicted:
---@>Control Variables:[Hyped Up] = Random (1...3)
-----@> Conditional Branch: Variable [ThunderForce] ==1
-----@> Change State [Charachter] + [Hyped Up]
-----@> Control Variables: [Hyped Up] =0 (Trust me...if you don't do this, you can be stuck on a loop)

On Variables 2 and 3 just put "@> Control Variables: [Hyped Up] =0"

And there you go...you got this...but only on one troop...thats where scripting comes into place...I recomend Base troop Events by Yanfly so you just need to put this on the first Troop slot and this will repeat trhough all battles...I hope this is what you wanted...and good night

Edit: Sorry...it just ocurred to me that I forgot to make it trigger by an atack...do all of this on a common event and make a normal atack call the event...you don't need to put this on troops if you do this.

Last edited:

#### Jihanger

##### Psychotic Alien
You can try entering this into the damage formula of the skill.

a.add_state(id); a.atk * 4 - b.def * 2

And then enter the number of the state into id.

but I think it adds the state after the attack...
This will help with somethings else, thank you!

Create a variable (Lets call it "Hyped Up") that rolls from 1 to 3 everytime the actor uses the skill "atack" and on 1 you put to trigger the "Hyped up" state and on 2 and 3 you put nothing. Now you have a way of doing it...the difficult is triggering this mid battle.

Create a battle event (on troops) with a conditional branc. The conditional branch must be "If charachter has "Thunder Force". Then you put the variable up, with another conditional branch for each random number...it should be something like this:

Conditional Branch: [charachter] is Thunder force aflicted:
---@>Control Variables:[Hyped Up] = Random (1...3)
-----@> Conditional Branch: Variable [ThunderForce] ==1
-----@> Change State [Charachter] + [Hyped Up]
-----@> Control Variables: [Hyped Up] =0 (Trust me...if you don't do this, you can be stuck on a loop)

On Variables 2 and 3 just put "@> Control Variables: [Hyped Up] =0"

And there you go...you got this...but only on one troop...thats where scripting comes into place...I recomend Base troop Events by Yanfly so you just need to put this on the first Troop slot and this will repeat trhough all battles...I hope this is what you wanted...and good night

Edit: Sorry...it just ocurred to me that I forgot to make it trigger by an atack...do all of this on a common event and make a normal atack call the event...you don't need to put this on troops if you do this.

Tested it out, instead of making a different If clause for each random number, I put the "Control Variables [Hyped Up] = 0 " on the Else clause, I think this works out, no loops happened, except 1/3 was too much because it triggered up to 4 times in a row (not always). thank you very much!

Edit: just noticed I had Action Times+ on the Thunder force state, that's why it was triggering lots of times in a row.

### Latest Profile Posts

So after completing the Mass Effect Trilogy the first time as a Vanguard, I decided to replay the trilogy as a Soldier. Thus far, I've just finished the Horizon mission in ME2, and I'm already exhausted from ME2's f**k-awful enemy design.
Yeah, now Yes !!!! "boom boom "
"Fire the monsters, guards!!!"

I can't stop buying resource packs I'll never use, or engines for that matter, or free resources as my two terabyte external will attest. I am a digital hoarder I guess. Some people get drunk off the silly juice when they are bored, I just buy shiny digital nonsense I don't need.
Not a bad weekend but anxiety kicking my but. Also wondering about Ms Littlefish. Some people move on. Anyways how is everyone doing?
I did a video review on Psychronic Games' Star Shift Origins, as they did a review on my game.
Check it out!