# Have enemies only be damaged by certain skills depending on States to the enemy applied?

#### ALTERED STATE ?

##### They/Them
I am having trouble figuring out how to have enemies only be damaged by certain skills depending on States to the enemy applied, is there a way to do this with events or preexisting scripts?

Such as having an Enemy only be damaged by the skill 'Back Slash' because it has the State 'Front Guard' applied

#### Kes

##### Veteran
Try something like this in the damage formula of your skill 'Back Slash'

[SIZE=10.5pt]if[/SIZE] [SIZE=10.5pt]b[/SIZE][SIZE=10.5pt].[/SIZE][SIZE=10.5pt]state[/SIZE][SIZE=10.5pt]?([/SIZE][SIZE=10.5pt]x[/SIZE][SIZE=10.5pt]);[/SIZE][SIZE=10.5pt] damage formula [/SIZE][SIZE=10.5pt];[/SIZE] [SIZE=10.5pt]else[/SIZE][SIZE=10.5pt];[/SIZE][SIZE=10.5pt] 0[/SIZE][SIZE=10.5pt];[/SIZE] [SIZE=10.5pt]end[/SIZE]

[SIZE=10.5pt]where x is the state id of 'Front Guard'[/SIZE]

[SIZE=10.5pt]What this does is check if state x is present.  If it is, then the damage you define is applied; if not then damage = zero.  Note the semi-colons, they are important.[/SIZE]

[SIZE=10.5pt]A neater way of putting that formula would be[/SIZE]

[SIZE=10.5pt]b.state?(x)? damage formula : 0[/SIZE]

[SIZE=10.5pt]The colon acts as the if/else.  The first is more obvious in its meaning, so if you don't use different formulas very often it is easier to remember what's going on.[/SIZE]

Last edited by a moderator:

#### ALTERED STATE ?

##### They/Them
That isn't exactly what I meant, what I meant was I need to have the skill be able damage enemies with and without the '--- Guard' state but have enemies with the '--- Guard' state only be able to be damaged by skills 'marked' in some way so that the skill will damage otherwise invincible enemies be damaged

I hope I explained it better, I will still experiment with the formula to see if I can get it to work

EDIT: I forgot other bits in your post so this post might be pointless

Last edited by a moderator:

#### estriole

##### Veteran
you need to alter ALL skill damage formula for that. .

it would be easier to use element instead. create the front guard state which immune to all element (including physical) except one element called back stab. then in the skill back stab... use that element.

and enemy without that state can still be damaged with the skill back stab as long as they not immune to back stab element.

but you must careful if you create some state / equipment that reduced element resistance against physical. make it also reduce back stab element too.

Last edited by a moderator:

#### ALTERED STATE ?

##### They/Them
Thank you ksjp and Estriole for the assistance with my problem

### Latest Profile Posts

I'm hoping to get a call October 1. They should be fully open by then.

With this, all demo dungeon graphics are done.
Eventually I need to make animations...send help.
OcRam demo project is now available at https://ocram-codes.net !!!

--- Mushroom ---

F.Knight: We runs out the food!
Hero: Anything could eat in this place?
F.Archer: It's a bunch of Mushroom over there. I wonder it's safe to eat.
F.Knight: No worries,we have to fill our inside no matter what it is.
(Hero & F.Knight Eat The Mushroom,After 10 Seconds They Collapse With Foam)