Grapple

Started by Nnaajj, January 14, 2010, 03:08:12 AM

Previous topic - Next topic

Nnaajj

So I was trying to make my character have a throw which makes the character grappled in there hand. They can still move while grappling and jump which have there own seperate anims.
I'm using statedef 810 and have made the targetbinds. Now here's the problem: When the throw ends I want it to switch to the grapple stance and still be grappling the character but, how can I do that.

I've already coded the grapple stance and walk but, I need to make someway of switching the throw (statedef 810) to my grapple stance (statedef 830) WHILE still holding the character. When I test my code my character raises the enemy up but, when it's supposed to switch to the grapple stance it lets go and the enemy is stuck there in the get thrown state.

Here's my code for more help:

;---------------------------------------------------------------------------
; Throwing the opponent

[Statedef 810]
type    = S
movetype= A
physics = N
anim = 810
poweradd = 60

[State 810, Bind 1]
type = TargetBind
trigger1 = AnimElemTime(1)
pos = 23, -63

[State 810, Bind 2]
type = TargetBind
trigger1 = AnimElemTime(2)
pos = 25, -80

[State 810, Bind 5]
type = TargetBind
trigger1 = AnimElemTime(3)
pos = 16, -99

[State 810, Bind 6]
type = TargetBind
trigger1 = AnimElemTime(4)
pos = 41, -60

[State 810, State End]
type = ChangeState
trigger1 = AnimTime = 0
value = 830
ctrl = 1

;---------------------------------------------------------------------------
; Grab Stand
[Statedef 830]
type    = S
movetype= A
physics = N
anim = 830
poweradd = 60

[State 830, Bind 1]
type = TargetBind
trigger1 = AnimElemTime(1)
pos = 41, -60

[State 830, ChangeState]
type = ChangeState
trigger1 = command = "fwd"
value = 831
ctrl = 1

[State 0, ChangeState]
type = ChangeState
trigger1 = command = "back"
value = 832
ctrl = 1

[State 830, ChangeState]
type = ChangeState
trigger1 = command = "down"
value = 830
ctrl = 1

;---------------------------------------------------------------------------
;  GrabWalk
; ---- Forward
[Statedef 831]
type    = S
physics = S
anim = 831

[State 831, Bind 1]
type = TargetBind
trigger1 = AnimElemTime(1)
pos = 44, -106

[State 831, Bind 2]
type = TargetBind
trigger1 = AnimElemTime(2)
pos = 36, -108

[State 831, Bind 3]
type = TargetBind
trigger1 = AnimElemTime(3)
pos = 33, -107

[State 831, Bind 4]
type = TargetBind
trigger1 = AnimElemTime(4)
pos = 38, -104

[State 831, Bind 5]
type = TargetBind
trigger1 = AnimElemTime(5)
pos = 42, -105

[State 831, Bind 6]
type = TargetBind
trigger1 = AnimElemTime(6)
pos = 37, -107

[State 831, Bind 7]
type = TargetBind
trigger1 = AnimElemTime(7)
pos = 33, -106

[State 831, Bind 8]
type = TargetBind
trigger1 = AnimElemTime(8)
pos = 36, -104

[State 831, 1]
type = VelSet
trigger1 = command = "holdfwd"
x = const(velocity.walk.fwd.x)

[State 831, 4]
type = ChangeAnim
triggerall = vel x < 0
trigger1 = Anim != 21 && Anim != 5
trigger2 = Anim = 5 && AnimTime = 0
value = 832

[State 831, ChangeState]
type = ChangeState
trigger1 = vel x = 0
value = 830
ctrl = 1
Quote from: Luis Alejandro on July 27, 2010, 07:46:45 PM
Quote from: RaiN on July 27, 2010, 07:44:57 PM
Kinda strange but I woke up today and her hand was on my ass cheek
I won't suspect anything though I'll take it she was sleeping and didn't notice
you should have flipped over slowly

Byakko

QuoteWhen the throw ends
Quotestill be grappling the character
=> the throw does not end, you don't release the opponent, you must make sure you keep him as a target.

Aren't you missing a TargetState ?
Spoiler: if you didn't add that (click to show)
First thing, you don't just need a targetbind, you need a targetstate if you don't want the opponent to be able to move. Use type = TargetState when your throw succeeds and give a state number ; now, create that state in your own file, and the opponent will be sent to your state in your file instead of the normal gethit states.
When you have control over the opponent, you can make him display the regular gethit sprites (create an animation that only uses the required sprites) and you can keep him held as much as you want - he can't move, he doesn't have control, he can't be punched out of that state etc.

Other thing : you need movetype = A to have a target. You do have it in state 830, but you don't specify any movetype in the grab walk state, IINM the default value is I (so drop all targets). So you don't have any target, so you can't use targetbind, of course.
If I struggled to the end of my determination, to the end of my way of life with my followers, if the result is ruin, then this ruin is inevitable. Grieve. Shed tears. But you cannot regret.

Nnaajj

#2
Ok, I think it'll work now Thanks.

EDIT:
Now the only problem I'm having is that I can't change into the grapple walk when I'm in the stance.
It's like no commands will work when I'm in the stance. And if anyone thinks I haven't added ctrl1 to the change state when it switches to the stance, I have.

Here's my code:
;---------------------------------------------------------------------------
; Grab Stand
[Statedef 830]
type    = S
movetype= A
physics = N
anim = 830

[State 0, 2]
type = VelSet
trigger1 = Time = 0
y = 0

[State 0, TargetState]
type = TargetState
trigger1 = AnimElem = 1
value = 811

[State 830, Bind 1]
type = TargetBind
trigger1 = AnimElem = 1
pos = 41, -60

[State 0, ChangeState]
type = ChangeState
trigger1 = command = "holdfwd"
value = 831
ctrl = 1


[State 0, ChangeState]
type = ChangeState
trigger1 = command = "back"
value = 832
ctrl = 1

[State 830, ChangeState]
type = ChangeState
trigger1 = command = "down"
value = 830
ctrl = 1

;---------------------------------------------------------------------------
;  GrabWalk
; ---- Forward
[Statedef 831]
type    = S
movetype = A
physics = N
anim = 831

[State 0, TargetState]
type = TargetState
trigger1 = AnimElem = 1
value = 811

[State 831, Bind 1]
type = TargetBind
trigger1 = AnimElem = 1
pos = 44, -106

[State 831, Bind 2]
type = TargetBind
trigger1 = AnimElem = 2
pos = 36, -108

[State 831, Bind 3]
type = TargetBind
trigger1 = AnimElem = 3
pos = 33, -107

[State 831, Bind 4]
type = TargetBind
trigger1 = AnimElem = 4
pos = 38, -104

[State 831, Bind 5]
type = TargetBind
trigger1 = AnimElem = 5
pos = 42, -105

[State 831, Bind 6]
type = TargetBind
trigger1 = AnimElem = 6
pos = 37, -107

[State 831, Bind 7]
type = TargetBind
trigger1 = AnimElem = 7
pos = 33, -106

[State 831, Bind 8]
type = TargetBind
trigger1 = AnimElem = 8
pos = 36, -104

[State 831, 1]
type = VelSet
trigger1 = command = "holdfwd"
x = const(velocity.walk.fwd.x)

[State 831, ChangeState]
type = ChangeState
trigger1 = vel x = 0
value = 830
ctrl = 1
Quote from: Luis Alejandro on July 27, 2010, 07:46:45 PM
Quote from: RaiN on July 27, 2010, 07:44:57 PM
Kinda strange but I woke up today and her hand was on my ass cheek
I won't suspect anything though I'll take it she was sleeping and didn't notice
you should have flipped over slowly

Byakko

#3
Quote[State 0, ChangeState]
type = ChangeState
trigger1 = command = "holdfwd"
value = 831
ctrl = 1
Actually you need to remove ctrl = 1. Unless you want to be able to normally input any of your special moves and basic moves and so, but the target will be stuck in the gethit state. If I get it right, you only want to be able to walk forward / back / jump and maybe crouch. You're sending your character to a special state for that (831), so you don't need control.
Ctrl is a simple flag/switch that you set to on or off, nothing else. Simply, most of your commands and basic movements check if that flag is on or off. So if it's on, you can go to the normal walk, jump, light punch states etc. You don't want that when you're doing what you're doing, because you want the states you're designing specifically for that grab stance.

... Aside from the control bit, I'm not really seeing anything really wrong at first glance. What happens exactly if you hold forward, you go to the normal walk state I presume ?
For other random points I can see : the changestate from 831 to 830, I'd rather see the trigger command != "holdfwd" than checking the velocity. Technically checking the velocity should be fine, but you really want to stop when you stop holding fwd, basically. Also, after your velset (and before your changestate), you can add a second velset triggered by command != "holdfwd" setting the velocity to 0, just for safety (in this case you didn't set vel to 0 when entering state 830, so if it worked, you would hold fwd, start walking, release fwd, go to state 830, but still have the same velocity)
Also, just to be sure, you may want to post your state 811.
As a general rule, enable the debug display (hit ctrl+D while in game), and keep an eye on the line that gives the stateno, that's always a start.
If I struggled to the end of my determination, to the end of my way of life with my followers, if the result is ruin, then this ruin is inevitable. Grieve. Shed tears. But you cannot regret.

Nnaajj

Thanks for the help now I just need to figure out why the enemy won't bind with him  :) And yes, when I press forward it goes to the normal walk. At the moment I have no debug flood which is good.

Here's my new code and the state 811 code:
New code:
; Grappling the enemy
[Statedef 810]
type    = S
movetype= A
physics = S
anim = 810
poweradd = 60
ctrl = 0

[State 0, TargetState]
type = TargetState
trigger1 = AnimElem = 1
value = 811

[State 810, Bind 1]
type = TargetBind
trigger1 = AnimElem = 1
pos = 22, -71

[State 810, Bind 2]
type = TargetBind
trigger1 = AnimElem = 2
pos = 25, -93

[State 810, Bind 3]
type = TargetBind
trigger1 = AnimElem = 3
pos = 22, -101

[State 810, Bind 4]
type = TargetBind
trigger1 = AnimElem = 4
pos = 32, -104

[State 0, ChangeState]
type = ChangeState
trigger1 = AnimElem = 4
value = 830
ctrl = 1

;------------------------------------------------------------------------
;Grapple Stance
[Statedef 830]
type = S
physics = S
movetype = A
anim = 830

[State 0, TargetState]
type = TargetState
trigger1 = AnimElem = 1
value = 811

[State 810, Bind 4]
type = TargetBind
trigger1 = AnimElem = 1
pos = 32, -104

[State 0, 2]
type = VelSet
trigger1 = Time = 0
y = 0

[State 0, ChangeState]
type = Changestate
trigger1 = command = "holdfwd"
trigger2 = stateno = 831
value = 831

[State 0, ChangeState]
type = ChangeState
trigger1 = command = "back"
value = 832
ctrl = 1

[State 830, ChangeState]     ;You can't use crouch in the grapple stance
type = ChangeState
trigger1 = command = "down"
value = 830
ctrl = 1

;---------------------------------------------------------------------------
;  GrabWalk
; ---- Forward
[Statedef 831]
type    = S
movetype = A
physics = S
anim = 831

[State 0, TargetState]
type = TargetState
trigger1 = AnimElem = 1
value = 811

[State 831, Bind 1]
type = TargetBind
trigger1 = AnimElem = 1
pos = 44, -106

[State 831, Bind 2]
type = TargetBind
trigger1 = AnimElem = 2
pos = 36, -108

[State 831, Bind 3]
type = TargetBind
trigger1 = AnimElem = 3
pos = 33, -107

[State 831, Bind 4]
type = TargetBind
trigger1 = AnimElem = 4
pos = 38, -104

[State 831, Bind 5]
type = TargetBind
trigger1 = AnimElem = 5
pos = 42, -105

[State 831, Bind 6]
type = TargetBind
trigger1 = AnimElem = 6
pos = 37, -107

[State 831, Bind 7]
type = TargetBind
trigger1 = AnimElem = 7
pos = 33, -106

[State 831, Bind 8]
type = TargetBind
trigger1 = AnimElem = 8
pos = 36, -104

[State 831, 1]
type = VelSet
trigger1 = command = "holdfwd"
trigger2 = stateno = 830
x = const(velocity.walk.fwd.x)

[State 0, VelSet]
type = VelSet
trigger1 = command != "holdfwd"
trigger2 = stateno = 830
x = 0

[State 831, ChangeState]
type = ChangeState
trigger1 = vel x = 0
value = 830
ctrl = 1


State 811:
;---------------------------------------------------------------------------
; Opponent Thrown
; (a custom gethit state)
; Description: This is the state that the opponent changes to after being
;     hit by the throw HitDef. The important thing here is to use a
;     ChangeAnim2 controller. The difference between ChangeAnim2 and
;     ChangeAnim is that ChangeAnim2 changes the player's animation to
;     an action in the AIR file of the attacker (in this case, kfm.air),
;     whereas ChangeAnim always changes the player to an action in his
;     own AIR file. Look at Action 820 in kfm.air for some extra
;     comments.
[Statedef 811]
type    = A
movetype= H
physics = N
velset = 0,0

[State 811, 1]
type = ChangeAnim2
Trigger1 = Time = 0
value = 820
Quote from: Luis Alejandro on July 27, 2010, 07:46:45 PM
Quote from: RaiN on July 27, 2010, 07:44:57 PM
Kinda strange but I woke up today and her hand was on my ass cheek
I won't suspect anything though I'll take it she was sleeping and didn't notice
you should have flipped over slowly

Byakko

Quotetrigger1 = AnimElem = 1
For the record, that's only true on the *first* tick of animation element 1.

Quote[State 0, ChangeState]
type = ChangeState
trigger1 = AnimElem = 4
value = 830
ctrl = 1
Out.

Quote[State 831, ChangeState]
type = ChangeState
trigger1 = vel x = 0
value = 830
ctrl = 1
Out.
If I struggled to the end of my determination, to the end of my way of life with my followers, if the result is ruin, then this ruin is inevitable. Grieve. Shed tears. But you cannot regret.

Nnaajj

Never saw that, thanks for correcting.
It now works like a charm and I couldn't of done it with out ur help. Thankyou very much Byakko  ;D
Quote from: Luis Alejandro on July 27, 2010, 07:46:45 PM
Quote from: RaiN on July 27, 2010, 07:44:57 PM
Kinda strange but I woke up today and her hand was on my ass cheek
I won't suspect anything though I'll take it she was sleeping and didn't notice
you should have flipped over slowly