News:

MFG's Character of the Month: October 2026 Nominations

Main Menu

Custom state problem

Started by Ichisennen, September 11, 2011, 10:38:09 AM

Previous topic - Next topic

Ichisennen

Okay I've been working my ass off on this and I don't know why I can't root the problem out, i hope you guys could.

Basically, I have a custom state which makes p2 invisible for a while, then repositions him to the middle of the screen in order to be hit by a rave attack behind a hyper BG, which gives an illusion of some sorts. Testing with my character it works against himself just fine, p2 is repositioned smack dab in the middle, but for some characters they go awry.

Oh and he is repositioned to the middle the same time with p1, who does a taunt while he is invisible.

I'll explain the code.

So first, enemy gets sent to the state via Targetstate right? the state is this one:

;----------------------------------------------------------------------------
;Player Invisible
[statedef 3993]
type = A
movetype = H
physics = N
sprpriority = -5

;This repositions the character to the middle of the screen at time=0, behind p1 and his helper, who will do a taunt for about 30 ticks.
[State 0, PosAdd]
type = PosAdd
trigger1 = time= 0
x = (gamewidth*0.5 - screenpos x)*facing
y = (gamewidth*0.5 - screenpos y)

;This repositions the character to the middle of the screen yet again, just to be safe.
[State 0, PosAdd]
type = PosAdd
trigger1 = time > 27
x = (gamewidth*0.5 - screenpos x)*facing
y = (gamewidth*0.5 - screenpos y)

;Keeps p2 afloat the whole time so he doesnt fall.
[State 0, VelSet]
type = VelSet
trigger1 = time < 300
y = -0.01
x = 0

;Makes p2 invisible for a few ticks.
[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = time < 30
flag = invisible

;This selfstates p2 to the falling state, ready to be bashed by an onslaught of attacks.
[State 0, SelfState]
type = SelfState
trigger1 = time > 30
value = 5050
ctrl = 1


I'm probably going about this the wrong way or something, but it works for most characters, but for others it doesn't. The main problem here is that sometimes p2 is repositioned somewhere NOT in the middle of the screen albeit the two posadds there.

I've also triggered clsns on, and turns out even though during the taunt p1 has no clsns, he still pushes p2 away from him. Why?

Am I doing something wrong? Is there a better way to do this?

Cyanide

I would use time = 27 for that second posadd. Not >. Using that in a posadd makes it do so over and over again and is possibly messing stuff up.

Other than that, if there are no clsn's on p1 while he taunts, i cannot see how he'd push.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.

Odb718

I'd do something like

[State 0, PosAdd]
type = PosAdd
triggerall = pos x != 0
triggerall = pos y != (gamewidth*0.5 - screenpos y)
trigger1 = time > 27
x = (gamewidth*0.5 - screenpos x)*facing
y = (gamewidth*0.5 - screenpos y)

This way even if your p1 char pushes the enemy away it'll reset to the center. Not sure if this exact code will work, I havent tested it.
vVv Gouken718 vVv SabreTooth718 vVv


Ichisennen

I did a sort of combination of both your inputs which went like:

[State 0, PosAdd]
type = PosAdd
triggerall = pos x != 0
triggerall = pos y != (gamewidth*0.5 - screenpos y)
trigger1 = time = 27
x = (gamewidth*0.5 - screenpos x)*facing
y = (gamewidth*0.5 - screenpos y)


and also making all state physics N during the attack. I suddenly realized I had physics = A on some states, probably due to me having bad eyes again and laziness.

Thanks for the input Cyanide and Odb718, really helped me fix this one up.

Rajaa Retired

y = (gamewidth*0.5 - screenpos y)

Should be gameheight*0.5. That is your problem. You can go back to using time = 0 as your trigger.

We all overlook things. ;)

Ichisennen

That's why I just love mugen math.  :P

Anyway, I've come across another bump...

So I've only explained the positioning of the enemy. So that's all good; the custom state puts him in the middle, ready for the attack. Now, the problem is my character's positioning is all wrong.

Scenario is p1 appears at middle, helper arrives beside him, they do a taunt, (p2 is invis whole time), then they execute the attack. During this time, p2 now appears in the middle via custom state we've established, not invisible anymore, and goes to fall state (refer to previous code) ready to be attacked. But thing is, for some characters, my code goes awry yet again; sometimes he's too far or sometimes he's too close to p2. Note he still doesn't have clsn's, and it's not supposed to have them, so I have to
manually position the character, no playerpushing.

The taunt part is okay, the p2 state is okay, all that's bugging is the attack start. He just doesn't reposition right.

Im just gonna post the code, if anybody sort of gets what i'm talking about. I've removed explods and unrelated stuff.


;----------------------------------------------------------------------------
;Session Rush Start
[statedef 1201]
type = A
movetype = A
physics = N
anim = 1201
sprpriority = 5
ctrl = 0
facep2= 1

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = nobardisplay
flag = noBG
flag = noFG

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = globalnoshadow
flag = timerfreeze

[State 0, VarRandom]
type = VarRandom
trigger1 = animelem = 4 ||animelem=14||animelem=17
v = 38
range = 1,5

[State 0, VarSet]
type = VarSet
trigger1 = animtime=0
v = 38    ;fv = 10
value = 0

[State 0, PlaySnd]
type = PlaySnd
trigger1 = animelem = 4 || animelem=14||animelem=17
value = S11,var(38)
volume = 100
channel = -1
freqmul = 1.0
loop = 0
pan = 0

[State 0, ScreenBound]
type = ScreenBound
trigger1 = 1
value = 1
movecamera = 0,0

[State 720, HitDef]
type = HitDef
trigger1 = animelem = 4 || animelem =10||animelem=14||animelem=17
attr = S, HA
damage = var(40) := 15, var(41) := 50
givepower=0,0
getpower = 10,10
animtype = hard
guardflag = MAL
pausetime = 0,20
sparkno = 3
sparkxy = 7,-40
hitsound = s1,3
ground.type = High
guardsound =  s100, 2
ground.slidetime = 0
ground.hittime = 13
ground.velocity = 0, 0
air.velocity = 0,0
envshake.time = 16
envshake.freq = 160
envshake.ampl = -4
envshake.phase = 90

[State 0, Helper]
type = Helper
trigger1 = animelem = 6
helpertype = normal ;player
name = "Riku"
ID = 1122
stateno = 1122
pos = 160,0
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 0
supermovetime=999999
pausemovetime=999999

;this would probably be where problem arises
[State 0, VelSet]
type = VelSet
trigger1 = animelem=1
trigger2 = time > 34
y = -0.01
x = 0

;and also this.
[State 0, PosSet]
type = PosSet
trigger1 = animelem = 1
x =(gamewidth*0.5 - screenpos x)*facing -ifelse(facing=1,120,100)
y =(gameheight*0.5 - screenpos y)-170

[State 0, ChangeState]
type = ChangeState
trigger1 = animtime=0
value = 1202
ctrl = 0



Note the posset... it's supposed to put me just beside p2 for attack execution. Originally, I wanted to make it that he appears below p2, then does an upward slash, stops when he hits, then executes the attack. But of course I failed.  -___-

I do have a video reference if it will help...

jailuis

Mmmm.. instead off a posset with that values, maybe using Posadd and p2dist or p2bodydist X and Y.. They would give u a clear point of where P2 is... Im not an expert, but I believe it could do the job.

and about ur code.. I believe this is what is going wrong:

x =(gamewidth*0.5 - screenpos x)*facing -ifelse(facing=1,120,100)

I believe they should be both the same, one negative (-100) and one positive (100).. since u're at the middle of the screen, so depending on ur facing, u should add or reduce... Well, maybe I misunderstood the problem here, but I believe it would help

Ichisennen

Quote from: jailuis on September 14, 2011, 12:44:44 AM
maybe using Posadd

Oh god, didn't see it was Posset instead of posadd. Explains everything **facepalm**

It works now, thank you, and curse my eyes.  --;