Platforms

Started by XoninX, September 30, 2016, 04:25:14 AM

Previous topic - Next topic

XoninX

I've been wanting to make a One Piece full game for a long time now, with vulnerability & immune values, weaknesses according to the canon, etc. I'm pretty sure I can do these things, but I'm stuck on one feature right now. Platforms. How to make these monstrosities has been on my mind for weeks now, and however much I try, nothing seems to work. I've tried setting a helper and having vars detect how far away the character is from the platform:

State -2:
Spoiler (click to show)
[State -2, Helper]
type = Helper
trigger1 = numhelper(8000) = 0
helpertype = normal ;player
name = "Platform"
ID = 8000
stateno = 8000
pos = 0,-50
postype = back
facing = 1

[State -2, VarSet]
type = VarSet
trigger1 = helper(8000), IsHelper(8000)
trigger1 = 1
fvar(20) = (helper(8000),pos x - (pos x))
ignorehitpause = 1

[State -2, VarSet]
type = VarSet
trigger1 = helper(8000), IsHelper(8000)
trigger1 = 1
fvar(21) = (helper(8000),pos y - (pos y))
ignorehitpause = 1


State 50:
Spoiler (click to show)
[State 50, ChangeState]
type = ChangeState
trigger1 = helper(8000), IsHelper(8000)
trigger1 = Vel Y > 0 && Pos Y >= 0
trigger1 = !(Fvar(20)>-20 || Fvar(20)<20)
value = 52
ctrl = 0

[State 50, ChangeState]
type = ChangeState
trigger1 = helper(8000), IsHelper(8000)
trigger1 = Vel Y > 0 && (fvar(21) < -50 && fvar(21) > -52)
trigger1 = (Fvar(20)>-20 || Fvar(20)<20)
value = 53 ;Custom land state
ctrl = 0

This really is all I can think of, but always ends in the character falling straight through the platform and jumping normally. The point is, I really need someone to tell me 'what' goes 'where' and how to correctly write that 'what', because I feel like I'll spend a loop of eternities if I try to find this out on my own, and I really need to finish this so I can progress with other things. Anyone who has experience with platforms, help please. Thanks

(Running Mugen 1.1)

Cyanide

Gone a bit... odd there. You're redirecting to helper 8000 and then checking if it is helper 8000. Is this a game where 1 player can jump on the platforms, or both, and how much interactivity with said platforms is there? There are a few methods.

You can do absolute position of your player on the stage to define whether they should be on a platform or not. You can set the helpers up as platforms and have them apply variables which cause the root to "land" or you can have the helpers deal a hit to make the root land, all depends on how you want to play it.

Would you be happy to mock up a screenshot of what you want to achieve? Like walking and falling off, or jumping through them in some way, all that stuff. I helped with Bane84's mario stage so this isn't new, it's just what you want to do.


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.

XoninX

Thanks for replying so quickly! I'd like a game where both players are able to land on the platforms.

Something like this:



There should be:
-- Several platforms per stage.

-- Activating the crouch command two times + start should set you off the platform.

-- Platforms should be destroyed once they take enough damage.

That's pretty much the gist of it. Sorry if I overwhelmed you! Once again thanks for replying so quickly.

ESFAndy011

Here's a way I can think of (for the landing on the platform):

In statedef -2:

[State -2, Land on platform]
type = ChangeState
trigger1 = statetype = A
trigger1 = pos y >= helper(8000), pos y  && vel y > 0 ;Basically the same logic you would use with natural ground landing, just look at "helper(8000), pos y" as if it was 0.
value = 53


Next, go to statedef 53 and do this (in case you haven't):

[State 53, Stepping on platform]
type = PosSet
trigger1 = pos y > helper(8000),pos y && pos y < 0 ;Again, treating the platform's position as you would the ground's position, only this time you're making sure your character isn't a few pixels below it.
y = helper(8000), pos y


That should help in getting you started. As for the sinking through them with down,down+start, make a state for that and add stateno != sinkingthroughstate in your "Land on platform" sctrl. Otherwise, they're just gonna change to State 53.

Hope I'm not being too convoluted, if there's something you didn't understand let me know.
Quote from: Millie, &quot;Ozy and Millie&quot;"I think there are really three types of people: "Glass is half-full" sorts of people, "Glass is half-empty" sorts of people,
and people who will spit into the glass until that's fixed."

XoninX

SUCCESS!

I added the "if you're within this amount of x from the platform" argument and also a changestate to go into state 50 once you're out of that range. There was a problem where you'd block when you're near the enemy's platform, so I just made an assert special that stopped you from doing that unless they're actually in an attacking state. The platforms would mirror (One would be P1s and only he could go on it, same for P2), so I overlapped the platforms based on what teamside you're on, and now they can both be on the same platform! I hope everything goes smoothly from here.

Here's my code for people to see:

State -2
Spoiler (click to show)
[State -2, Helper]
type = Helper
trigger1 = numhelper(8000) = 0
helpertype = normal
name = "Platform"
ID = 8000
stateno = 8000
pos = ifelse(teamside=1,0,320),-50
postype = back
facing = 1

[State 0, AssertSpecial]
type = AssertSpecial
trigger1 = pos x > helper(8000), pos x-50 && pos x < helper(8000), pos x+50
trigger1 = enemy,movetype!=A
flag = nostandguard
flag2 = nocrouchguard
flag3 = noairguard

[State -2, Land on platform]
type = ChangeState
trigger1 = pos y <= helper(8000), pos y
trigger1 = !(pos x > helper(8000), pos x-50 && pos x < helper(8000), pos x+50)
trigger1 = stateno!=50
value = 50

[State -2, Land on platform]
type = ChangeState
trigger1 = statetype = A
trigger1 = pos y >= helper(8000), pos y  && vel y > 0
trigger1 = pos x > helper(8000), pos x-50 && pos x < helper(8000), pos x+50
value = 53

State 8000 (Platform Helper)
Spoiler (click to show)
[StateDef 8000]
type = S
movetype = A
physics = S
anim = 8000
sprpriority = -3
ctrl = 0

[State 0, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT
value2 = S,NA
time = -1

[State 0, DestroySelf]
type = DestroySelf
trigger1 = time = -1

State 53 (Custom state to land on the platform)
Spoiler (click to show)
[statedef 53]
type=s
physics=s
anim=53
velset=0,0
ctrl=0

[State 53, Stepping on platform]
type = PosSet
trigger1 = pos y > helper(8000),pos y && pos y < 0
y = helper(8000), pos y

[state 0]
   type=changestate
   trigger1=animtime=0
   value=0
   ctrl=1

Still going to bug test to see if multiple platforms will work okay.
Thanks a ton!

XoninX

Aight. There is a problem. So I'm able to make one platform without any problems, but now I can't make more than one platform at once without the character getting stuck in either the custom landing state, or state 50.

Spoiler (click to show)
[State -2, Land on platform]
type = ChangeState
trigger1 = statetype = A && movetype != H
trigger1 = pos y > helper(8000), pos y - 2 && pos y < helper(8000), pos y + 2  && vel y > 0
trigger1 = pos x > helper(8000), pos x-50 && pos x < helper(8000), pos x+50
trigger2 = statetype = A && movetype != H
trigger2 = pos y > helper(8001), pos y - 2 && pos y < helper(8001), pos y + 2  && vel y > 0
trigger2 = pos x > helper(8001), pos x-50 && pos x < helper(8001), pos x+50
value = 53

Spoiler (click to show)
[State -2, Fall from platform]
type = ChangeState
trigger1 = pos y <= helper(8000), pos y
trigger1 = !(pos x > helper(8000), pos x-50 && pos x < helper(8000), pos x+50)
trigger1 = stateno!=50
trigger1 = stateno!=[170,3051]
trigger1 = stateno!=[5000,5101]
trigger2 = pos y <= helper(8001), pos y
trigger2 = !(pos x > helper(8001), pos x-50 && pos x < helper(8000), pos x+50)
trigger2 = stateno!=50
trigger2 = stateno!=[170,3051]
trigger2 = stateno!=[5000,5101]
value = 50

State 53
Spoiler (click to show)
[State 53, Stepping on platform 8000]
type = PosSet
trigger1 = pos x > helper(8000), pos x-50 && pos x < helper(8000), pos x+50
trigger1 = pos y > helper(8000), pos y - 2 && pos y < helper(8000), pos y + 2  && vel y > 0
y = helper(8000), pos y
[State 53, Stepping on platform 8000]
type = PosSet
trigger1 = pos x > helper(8001), pos x-50 && pos x < helper(8001), pos x+50
trigger1 = pos y > helper(8001), pos y - 2 && pos y < helper(8001), pos y + 2  && vel y > 0
y = helper(8001), pos y

Cyanide

Your triggers match too often. Your helpers are both the same ID. Something is going to be true for one or the other very frequently. Find a way of having the helpers register the parents position and then have the parent change basedo n that.


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.

XoninX

#7
Fixed. I'm currently working on a way to have a projectile set p2 into state 53, since I think the overlapping helpers thing is inefficient (having to set the x distance depending on what team side you're on every time is a pain). I'll keep testing.

Edit: Meh. The stacking helpers thing won't be THAT bad... it's just a bit of positioning anyway.

Here's the code for the platforms. I still have to make the whole breaking platforms thing, but I don't think that'll be THAT bad.  Everything's working well, a big thanks to everyone!

Statedef -2
Spoiler (click to show)
[State -2, Fall from platform]
type = ChangeState
triggerall = pos y < 0
triggerall = stateno!=50
triggerall = stateno!=[170,3051]
triggerall = stateno!=[5020,5071]
trigger1 = (pos y > ((helper(8000), pos y) - 2)) && (pos y < ((helper(8000), pos y) + 2)) && abs(pos x - helper(8000),pos x)>=50
trigger2 = (pos y > ((helper(8001), pos y) - 2)) && (pos y < ((helper(8001), pos y) + 2)) && abs(pos x - helper(8001),pos x)>=50
value = 50
[State -2, Fall from platform getting hit]
type = ChangeState
triggerall = pos y < 0
triggerall = stateno!=50
triggerall = stateno!=[170,3051]
triggerall = stateno=[5020,5071]
triggerall = movetype = H
trigger1 = (pos y > ((helper(8000), pos y) - 2)) && (pos y < ((helper(8000), pos y) + 2)) && abs(pos x - helper(8000),pos x)>=50
trigger2 = (pos y > ((helper(8001), pos y) - 2)) && (pos y < ((helper(8001), pos y) + 2)) && abs(pos x - helper(8001),pos x)>=50
value = 5050
[State -2, Land on platform]
type = ChangeState
triggerall = vel y > 0
triggerall = stateno != [5020,5071]
triggerall = statetype = A && movetype != H
trigger1 = abs(pos y - helper(8000),pos y)<5 && abs(pos x - helper(8000),pos x)<=50
trigger2 = abs(pos y - helper(8001),pos y)<5 && abs(pos x - helper(8001),pos x)<=50
value = 53
[State -2, Land on platform when hurt]
type = ChangeState
triggerall = vel y > 0
triggerall = stateno = [5020,5071]
triggerall = movetype = H
trigger1 = abs(pos y - helper(8000),pos y)<5 && abs(pos x - helper(8000),pos x)<=50
trigger2 = abs(pos y - helper(8001),pos y)<5 && abs(pos x - helper(8001),pos x)<=50
value = 55



;Platform 1 ----------------
[State -2, Helper]
type = Helper
;triggerall = teamside = 1
trigger1 = numhelper(8000) = 0
helpertype = normal ;player
name = "Platform"
ID = 8000
stateno = 8000
pos = ifelse(teamside=1,0,320),-50
postype = back
facing = 1
;---------------------------

;Platform 2 ----------------
[State -2, Helper]
type = Helper
;triggerall = teamside = 1
trigger1 = numhelper(8001) = 0
helpertype = normal ;player
name = "Platform"
ID = 8001
stateno = 8001
pos = ifelse(teamside=1,300,20),-100
postype = back
facing = 1
;---------------------------

Platform 1 & 2 helpers
Spoiler (click to show)
;Platform 1
[StateDef 8000]
type = S
movetype = U
physics = S
anim = 8000
sprpriority = -3
ctrl = 0
[State 0, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT
value2 = S,NA
time = -1
[State 0, DestroySelf]
type = DestroySelf
trigger1 = time = -1

;Platform 2
[StateDef 8001]
type = S
movetype = U
physics = S
anim = 8001
sprpriority = -3
ctrl = 0
[State 0, NotHitBy]
type = NotHitBy
trigger1 = 1
value = SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT
value2 = S,NA
time = -1
[State 0, DestroySelf]
type = DestroySelf
trigger1 = time = -1

Custom land state
Spoiler (click to show)
;===============================
;Land on Platform
[statedef 53]
type=s
physics=s
anim=53
velset=0,0
ctrl=0

[State 53, Stepping on platform 8000]
type = PosSet
trigger1 = abs(pos x - helper(8000),pos x)<50
trigger1 = abs(pos y - helper(8000),pos y)<5
trigger1 = pos y!=helper(8000),pos y
y = helper(8000),pos y
[State 53, Stepping on platform 8001]
type = PosSet
trigger1 = abs(pos x - helper(8001),pos x)<50
trigger1 = abs(pos y - helper(8001),pos y)<5
trigger1 = pos y!=helper(8001),pos y
y = helper(8001),pos y


[state 0]
   type=changestate
   trigger1=animtime=0
   value=0
   ctrl=1

Custom "land on the platform from getting hit in the air" state
Spoiler (click to show)
;Hit Ground on Platform
[statedef 55]
type=l
movetype=h
physics=n
anim = 55

[State 0, PosSet]
type = PosSet
trigger1 = abs(pos y - helper(8000),pos y)<5 && abs(pos x - helper(8000),pos x)<=50
y = helper(8000),pos y
[State 0, PosSet]
type = PosSet
trigger1 = abs(pos y - helper(8001),pos y)<5 && abs(pos x - helper(8001),pos x)<=50
y = helper(8001),pos y

[state 0]
   type=fallenvshake
   trigger1=!time

[state 0] ;; save fall velocity
   type=null;varset
   trigger1=!time
   sysvar(1)=floor(vel y)

[state 0]
   type=velset
   trigger1=!time
   y=0
[state 0]
   type=velmul
   trigger1=!time
   x=0.75
[state 0]
   type=hitfalldamage
   trigger1=time=3

[state 0]
   type=changestate
   trigger1=animtime=0
   value=56

[statedef 56]
type=l
movetype=h
physics=n

[state 0]
   type=changeanim
   triggerall=!time
   trigger1=(anim!=[5101,5109])
   trigger2=!selfanimexist(5160+(anim%10))
   value=5160
[state 0]
   type=changeanim
   triggerall=!time
   trigger1=(anim=[5101,5109])
   trigger1=selfanimexist(5160+(anim%10))
   value=5160+(anim%10)

[state 0]
   type=hitfallvel
   trigger1=!time

; edited

[state 0] ; *new v1.1
   type=posadd
   trigger1=!time
   x=-1
   
;; acceleration
[state 0]
   type=veladd
   trigger1=1
          y=0.2
;---
;; hit ground (edited)
[state 0]
type=changestate
trigger1= pos y >= helper(8000),pos y
trigger2= pos y >= helper(8001),pos y
trigger2= pos y < helper(8000),pos y
value=57

[statedef 57]
type=l
movetype=h
physics=n

[state 0]
   type=fallenvshake
   trigger1=!time

;; for hit up/up-diag type (from state 5081)
[state 0]
   type=changeanim
   trigger1=selfanimexist(5110+(anim%10))
   trigger1=(anim=[5081,5089])
   value=5110+(anim%10)
   persistent=0

;; hit ground anim (normal)
[state 0]
   type=changeanim
   triggerall=!time
   triggerall=(anim!=[5110,5119]) ;;<-not already changed anim
   trigger1=(anim!=[5161,5169])
   trigger2=!selfanimexist(5170+(anim%10))
   value=5170

;; hit ground anim (for hit up)
[state 0]
   type=changeanim
   triggerall=!time
   triggerall=(anim!=[5110,5119]) ;;<-not already changed anim
   trigger1=(anim=[5161,5169])
   trigger1=selfanimexist(5170+(anim%10))
   value=5170+(anim%10)

[state 0]
   type=hitfalldamage
   trigger1=!time
;---
[state 0] ;; *new v11 Get fall velocity
   type=varset
   trigger1=!time && gethitvar(fall.yvel)!=0
   sysvar(1)=floor(vel y)
;---
[state 0]
   type=velset
   trigger1=!time
   y=0

;; for hit up type
[state 0]
   type=changeanim
   triggerall=anim=[5171,5179]
   triggerall=selfanimexist(5110+(anim%10))
   trigger1=animtime=0
   trigger2=sysvar(0) ;;<-sysvar(0)=1 ;;avoids hit ground anim
   value=5110+(anim%10)
   persistent=0

;; for normal
[state 0]
   type=changeanim
   triggerall=anim!=[5111,5119]
   trigger1=animtime=0
   trigger2=sysvar(0) ;;<-sysvar(0)=1 ;;avoids hit ground frame
   value=5110
   persistent=0

;; if just died
[state 0]
   type=changestate
;;old;   triggerall=!alive
   triggerall=!alive && time>0
   trigger1=animtime=0
   trigger2=sysvar(0) ;;<-sysvar(0)=1 ;;avoids hit ground frame
   trigger3=anim=[5110,5119]
   value=5150

[state 0]
   type=varset
;;old;   trigger1=!time && sysvar(0)
   trigger1=time>0 && sysvar(0)
   sysvar(0)=0

;; friction
[state 0]
   type=velmul
   trigger1=1
   x=0.85

;; friction
[state 0]
   type=velset
   trigger1=time>abs(vel x)<const(movement.down.friction.threshold)
;;@   trigger1=time>3
   persistent=0
   x=0

[state 0]
   type=changestate
   trigger1=time>42 ;; normal standing
   value=5120

It'd be amazing if a ton of more people could work on platforming. Flat stages get a tad mundane after a while, and this really spices things up. Once again, thanks to everyone who contributed! I hope this helps people!