YesNoOk
avatar

Code to make character untouchable (Read 1569 times)

Started by Boxuu, March 20, 2021, 02:43:11 PM
Share this topic:
Code to make character untouchable
#1  March 20, 2021, 02:43:11 PM
    • New Zealand
I am currently making a character within Fighter Factory Studio and it's looking really good so far. Various animations are already completed and he plays well. However, I've hit a wall and I've searched a bunch of sites and videos in hopes to find an answer to my problem but to no avail.

To put it simply, what I am looking for is code to make my character basically untouchable. When he stands, when he runs, when he attacks, etc.
For example, If Kung Fu Man (Or any other character) were to attack and/or threw a projectile at my character, Kung Fu Man would get put in a hurt state while my character is unharmed and there is no change in my character's animations and he can still move and attack and etc..
That is what I'm looking for.

If someone can help me out by giving me the codes to put in my cns file or just directing me to what to use in Fighter Factory Studio, that'd be neato.
That's all I ask.
Boop
Re: Code to make character untouchable
#2  March 25, 2021, 06:06:46 AM
  • *****
  • Shame on you!
    • USA
You're looking for super armor. There should be some examples in Code Library or Tips, Tricks, Tutorials
vVv Mauru Mauru Released vVv
Re: Code to make character untouchable
#3  March 27, 2021, 10:27:33 AM
    • New Zealand
Okay, thanks for suggesting super armor. I am using a HitOverride to achieve that and it works for the most part but for some reason, my character disappears when he gets hit and I am unable to control anything afterwards.

Here is what I have created.

;----------------; Opponent Attacks P1 while P1 is standing
;
[State 0, HitOverride]
type = HitOverride
trigger1 = anim = 0
attr = SCA,AA,AT,NT,ST,HT,NA,SA,HA,NP,SP,HP
stateno = 20000
time = -1

[State 0, Reflect Effect]
type = Explod
trigger1 = GethitVar(damage)>0
anim = 2000
sprPriority=3
posType = P1
pos = 10,-65
vel = 0,0
scale = 0.3,0.3
removetime = 20

;---------------- ; P2 gets knocked back after attacking P1 while standing
;
[Statedef 20000]
type    = A
movetype= A
physics = N
juggle  = 0
poweradd = 5
velset = 0,0
ctrl = 0
anim = 20000
sprpriority = 0

;[State 20000]
;type = PlaySnd
;trigger1 = Time = 2
;value = 0, 4

[State 20000]
type = HitDef
trigger1 = time = 0
attr = S, NA
animtype  = back
damage    = 30
guardflag = MA
pausetime = 12,12
sparkno = s2000
sparkxy = -10,-70
hitsound   = 5,2
guardsound = 6,0
ground.type = High
ground.slidetime = 12
ground.hittime  = 16
ground.velocity = -5.5
air.velocity = -2.5,-4
forcenofall = 1

[State 0]
type = AssertSpecial
trigger1 = 1
flag = invisible

[State 20000]
type = DestroySelf
trigger1 = time = 1

;===========

Help?
Boop
Re: Code to make character untouchable
#4  March 27, 2021, 06:17:34 PM
  • avatar
  • **
    • USA
My method uses a helper, in state -2 have a helper spawn. This is just an example, change numbers and triggers to your needs etc

Code:
;This is the actual helper armor
[State -2]
type = Helper
trigger1 = NumHelper(10000) = 0 ;<---this is the id of my helper, use whatever number youd like
trigger1 = !lose
ID = 10000
name = "Armor"
pos = 0,0
postype = p1
stateno = 10000
helpertype = normal
keyctrl = 0
ownpal = 1

Then I put this statedef it refers to under it in the -2 section

Code:
[Statedef 10000]
type    = U
movetype= I
physics = N
poweradd= 0
ctrl = 0
anim = 0
sprpriority = 0

;they shouldnt see the helper
[State Armor]
type = AssertSpecial
trigger1 = 1
flag = invisible

;when hit go to state10001 below
[State Damage]
type = HitOverride
trigger1 = ishelper
attr = SCA,AA,AT,AP
time = -1
stateno = 10001

bind to player
[State Armor]
type = BindToRoot
trigger1 = 1
time = -1
facing = 1
pos = 0, 0

[State Armor]
type = NotHitBy
trigger1 = roundstate != 2
trigger2 = root,alive = 0
value = SCA,AA,AT,AP

;even if invisible, it has to change animation to your root (your character) so the hit boxes line up
[State Armor]
type = changeanim
trigger1 = 1
value = root,anim
elem = root,animelemno(0)

;this is so your helper doesn't "die"
[State Armor]
type = LifeAdd
trigger1 = 1
value = 10000
absolute = 1

[State Armor]
type = Turn
trigger1 = root,facing != facing

[State -2]
type = playerpush
trigger1 = 1
value = 1

[state -2]
type = DestroySelf
trigger1 = root,!alive

Then this is when they (the helper) gets hit state10001 right below it:

Code:
[Statedef 10001]
type    = U
movetype= H
physics = N
poweradd= 0
ctrl = 0
anim = 0
sprpriority = 0

[State Armor]
type = AssertSpecial
trigger1 = 1
flag = invisible

[State Damage]
type = HitOverride
trigger1 = ishelper
attr = SCA,AA,AT,AP
time = -1
stateno = 10001

[State Armor]
type = BindToRoot
trigger1 = 1
time = -1
facing = 1
pos = 0, 0

[State Armor]
type = NotHitBy
trigger1 = roundstate != 2
trigger2 = root,alive = 0
trigger3 = 1
value = SCA,AA,AT,AP

[State Armor]
type = changeanim
trigger1 = 1
value = root,anim
elem = root,animelemno(0)

[State Armor]
type = LifeAdd
trigger1 = 1
value = 10000
absolute = 1

[State Armor]
type = Turn
trigger1 = root,facing != facing

;this is to calculate damage!!!
[State Damage]
type = parentvarset
trigger1 = 1
var(2) = gethitvar(damage) ;<--------Change variable number to whatever you want that is free, this var saves the damage being done

[State to10000]
type = changestate
trigger1 = time >= 1
value = 10000

[State -2]
type = playerpush
trigger1 = 1
value = 1

[state -2]
type = DestroySelf
trigger1 = root,!alive

Then we actually have to redirect that damage value to the root, we do that with a var and put these two in -2 state

Code:
[state -2]
type = lifeadd
trigger1 = 1
value = ceil(var(2) * -1) <---gets the damage value from helper to apply to character, var(2) saves the damage amount
ignorehitpause = 1

;you WANT the var that saves damage to always reset to 0 so damage is only applied to 1 frame
[state -2]
type = varset
trigger1 = 1
var(2) = 0
ignorehitpause = 1




Re: Code to make character untouchable
#5  March 29, 2021, 06:36:53 AM
    • New Zealand
Code:
[state -2]
type = DestroySelf
trigger1 = root !alive ;<---- This causes an error
Boop
Last Edit: March 29, 2021, 06:37:35 AM by Boxuu
Re: Code to make character untouchable
#6  March 29, 2021, 07:00:20 AM
  • avatar
  • **
    • USA
Re: Code to make character untouchable
#7  March 29, 2021, 07:58:16 AM
    • New Zealand
Boop
Re: Code to make character untouchable
#8  March 29, 2021, 10:54:04 AM
  • avatar
  • ***
    • https://sites.google.com/site/mgmurrow/
Try this
Trigger1=(root,alive=0)
Or
Trigger1=!(root,alive)

Hope this helps

MGMURROW

Re: Code to make character untouchable
#9  March 29, 2021, 05:57:49 PM
  • avatar
  • **
    • USA