YesNoOk
avatar

ChangeState (SCTRL) (Read 11620 times)

Started by Ricepigeon, September 23, 2015, 05:36:30 pm
Share this topic:
ChangeState (SCTRL)
#1  September 23, 2015, 05:36:30 pm
  • *****
  • Thanks and God bless
    • USA
    • ricepigeon.neocities.org
Changes the state number of the player.

Required parameters:
    value = state_no (int)
        state_no is the number of the state to change to.

Optional parameters:
    ctrl = ctrl_flag (int)
        ctrl_flag is the value to set the player's control flag to. 0 for no control, nonzero for control.
    anim = anim_no (int)
        This is the action number to switch to. If omitted, the player's animation will remain unchanged.

Example:
Code:
; Change to standing state, and give player control
type = ChangeState
value = 0
ctrl = 1

Additional Notes
The state number that the player changes to will be the state number contained in the character files containing the state the player is currently in.
Using the above example, if Player2 is currently within one of his/her own states, the ChangeState SCTRL will change Player2 to Player2's Standing State. However, if Player2 is currently in one of Player1's states, such as through the use of a TargetState SCTRL, then executing the above state controller will send Player2 to Player1's standing state instead. To circumvent this issue, it is recommended to use the SelfState SCTRL within any custom states in order to send the target player back to his or her own states, unless you specifically want Player2 to change to another state within Player1's files, such as another custom state.
Last Edit: September 23, 2015, 08:11:25 pm by Odb718

Bea

Re: ChangeState (SCTRL)
#2  September 23, 2015, 07:17:14 pm
  • *****
  • MUGEN Grandma
    • Brazil
    • www.smeenet.org
It is worth noting that if you use ChangeState to change your current state to the same state, it will process the state with time = 0 at the same tick, which means you can use this to create some crude form of loop processing if needed, but you have to break the loop before 1,000 iterations (used to be 500) or Mugen will crash with an infinite loop error.
Princess Adora: "My friend saw She-Ra take her dress off in the shower. She said she has an 8 pack. She said She-Ra is shredded."

SF2NES is dead. Long live SF2NES.
Re: ChangeState (SCTRL)
#3  September 24, 2015, 04:54:08 pm
  • avatar
  • *****
  • Sr. Black Person
  • Mess with the chuchu you get the pewpew
    • USA
    • Kamekaze.world
That limit is 2500 now as of 1.0, but yeah in a way you can technically implement recursion but why you'd want to do that is beyond me.
Want to feel useful for a useless show? click here
119/150 Chars, I'm not dead yet....the true surprise is in my thread.
Hahahah fuck you photobucket.

Bea

Re: ChangeState (SCTRL)
#4  September 24, 2015, 05:17:25 pm
  • *****
  • MUGEN Grandma
    • Brazil
    • www.smeenet.org
To do stuff like this, of course:

;---------------------------------------------------------------------------
; Generate 8 explosions within a circle
[StateDef 4002]
Type = S
movetype = I
physics = N
ctrl = 0
anim = 4000

[state 4002, Scale]
Type = VarSet
trigger1 = time = 0
fvar(1) = 0.2 + 0.8 * random/1000.0

[State 4002, Generate my angle orientation]
Type = VarSet
trigger1 = !var(0)
fvar(0) = 10.0 + 20.0 * random/1000.0

[State 4002, Generate my angle orientation]
Type = VarSet
trigger1 = var(0) > 0
fvar(0) = 45 + fvar(0)

[State 4002, Convert it to radians]
Type = VarSet
trigger1 = time = 0
fvar(2) = fvar(0) * 0.01745329

[State 4002, Explod]
Type = Explod
trigger1 = time = 0
anim = 7110
pos = 0,0
random = 20, 16
ownpal = 1
id = 4000
sprpriority = 3
ignorehitpause = 1
vel = cos(fvar(2)), -(1.0 - abs(cos(fvar(2)))) * ifelse(var(0) >= 4, -1, 1)
accel = -0.01 * cos(fvar(2)), -0.01 * -(1.0 - abs(cos(fvar(2)))) * ifelse(var(0) >= 4, -1, 1)
scale = fvar(1), fvar(1)
facing = 1

[State 4002, VarAdd]
Type = VarAdd
trigger1 = time = 0
v = 0
value = 1

[State 4002, Loop]
Type = ChangeState
trigger1 = var(0) < 8
value = 4002

[State 4002, DestroySelf]
Type = DestroySelf
trigger1 = var(0) = 8

Princess Adora: "My friend saw She-Ra take her dress off in the shower. She said she has an 8 pack. She said She-Ra is shredded."

SF2NES is dead. Long live SF2NES.
Re: ChangeState (SCTRL)
#5  September 25, 2015, 08:54:14 pm
  • ******
  • [E]
    • Mexico
That limit is 2500 now as of 1.0, but yeah in a way you can technically implement recursion but why you'd want to do that is beyond me.

I use it in tifa to generate 50 different (invisible) projectiles on screen in the same tick, each projectile does slightly different damage folllwing a bell curve, so if youa re too clsoe to tifa or too far you get the less damage, but by sitting in the sweet spot you get twice as much damage (had to do it like that because we don't have hitdefs than apply to specific clsns in mugen).
Re: ChangeState (SCTRL)
#6  September 25, 2015, 09:08:31 pm
  • ****
  • A frame here, a pixel there.
It is worth noting that if you use ChangeState to change your current state to the same state, it will process the state with time = 0 at the same tick, which means you can use this to create some crude form of loop processing if needed, but you have to break the loop before 1,000 iterations (used to be 500) or Mugen will crash with an infinite loop error.
Huh. I wonder if that might come in handy for replicating turbo speed.
Re: ChangeState (SCTRL)
#7  September 25, 2015, 11:52:52 pm
  • avatar
  • *****
  • Sr. Black Person
  • Mess with the chuchu you get the pewpew
    • USA
    • Kamekaze.world
Well I use the same helper with various functions all the time but I don't do anything recursive with it I guess lol I only differentiate behavior with the helper's id
Want to feel useful for a useless show? click here
119/150 Chars, I'm not dead yet....the true surprise is in my thread.
Hahahah fuck you photobucket.
Re: ChangeState (SCTRL)
#8  January 13, 2017, 06:14:04 pm
  • ******
    • www.justnopoint.com/
Notes on differences in using P1StateNo in hitdef or ChangeState

XGargoyle - Today at 10:59 AM
by the way, the damage scaling on FF was not due to the dampening system

JustNoPoint - Today at 11:00 AM
oh?

XGargoyle - Today at 11:00 AM
it was related to the p1stateno in the hitdef
apparently, p1stateno and changestate are triggerd on different timings

JustNoPoint - Today at 11:01 AM
For the clones fix?

XGargoyle - Today at 11:01 AM
yes
I had the same problem with the Atomic Blast

JustNoPoint - Today at 11:01 AM
Is it easy to resolve?

XGargoyle - Today at 11:02 AM
yes, but needs to be checked on individual basis

JustNoPoint - Today at 11:02 AM
That's useful info to add to the MUGEN Class

XGargoyle - Today at 11:02 AM
because sometimes you have to add additional triggering conditions to the targetstate and the changestate
using just movecontact or movehit sometimes is not enough
as they trigger the change state too early or too late

JustNoPoint - Today at 11:03 AM
To clarify you are using MoveHit = 1?

XGargoyle - Today at 11:05 AM
for the final flash, I had to add a special var check, as damage was controlled by a variable
in the case of the Atomic Blast, I had to add an additional removeexplod on the new state, because the changestate was triggered earlier than just the p1state from the hitdef

JustNoPoint - Today at 11:06 AM
That's crazy
Leave it to elecbyte

XGargoyle - Today at 11:06 AM
yeah
mugen does wanky stuff sometimes
I think the p1stateno from the hitdef is actually triggered after the hitpauses
but the changestate can ignore the hitpause
therefore, the movecontact=1 fails triggers earlier

JustNoPoint - Today at 11:09 AM
try with ignorehitpause=0?

XGargoyle - Today at 11:10 AM
if you do that, movehit=1 will not trigger
JustNoPoint - Today at 11:10 AM
ah

XGargoyle - Today at 11:10 AM
crazy stuff