Help coding - Throw attack problem :/

Started by ZackTheRiolu, July 27, 2015, 08:43:58 PM

Previous topic - Next topic

ZackTheRiolu

These days i'm trying to finish a throw attack where involve 2 opponents.
I'm actually stuck cause i don't know how to "release them".

For example, at the 4° frame i want the first opponent being thrown away and the second opponent in the 10° frame..
From now i'm like arrived to a point where or i release them togheter or i can't separatley cause i don't know as to select them separately..

Question: How can i decide to release them separatley? What is the coding correct if exist?

Sorry and thanks in advance (I don't show pictures about cause someone could get offended ^^; )

GT

#1
Use the Target State state controller on the 4th frame to put P2 into a state where they can be released and go back to their own states.


;Thrown by Kung Fu Throw - thrown into the air
[Statedef 821]
type    = A
movetype= H
physics = N
velset = 2.8,-7
poweradd = 40

[State 821, 1] ;Gravity
type = VelAdd
Trigger1 = 1
y = .4

[State 821, 2] ; Recover near ground (use ChangeState)
type = ChangeState
triggerall = Vel Y > 0
triggerall = Pos Y >= -20
triggerall = alive
triggerall = CanRecover
trigger1 = Command = "recovery"
value = 5200 ;HITFALL_RECOVER

[State 821, 3] ; Recover in mid air (use SelfState)
type = SelfState
triggerall = Vel Y > 0
triggerall = alive
triggerall = CanRecover
trigger1 = Command = "recovery"
value = 5210 ;HITFALL_AIRRECOVER

[State 821, 4] ;Hit ground
type = SelfState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= 0
value = 5100 ;Hit ground


ZackTheRiolu

#2
And what about the second opponent? If i try as you said both the enemys gonna be released togheter, i actually need something that permit me to release them in different moments. Thanks aniway for the answer

GT

If you can find a way to assign the targets differently, you can release the targets at different times.

[state 0]
type = targetstate
trigger1 = animelem = 4
value = 5040
id = 2000
persistent = 0
[state 0]
type = targetstate
trigger1 = animelem = 10
value = 5040
id = 2001
persistent = 0

Felkazz

You may try something using TargetDrop...
Supose your throw state is 1000 and the enemies are in state 1001, then, create the state 1002 to release the enemies


[StateDef 1002]
Type = S
MoveType = H

[State 1002, End]
Type = SelfState
Trigger1 = Time = 1 ;Using Time = 1 so the character has time to release one enemy
Value = 5040 ;Just releasing the enemy, if you want the enemy to go to another state, put it here, if the enemy is suposed to go another custom state, use ChangeState instead of SelfState
Ctrl = 0


Now, on your state 1000, lets drop the characters on the right time, you should also create the state 1003 to send the second enemy, in this state, you should code the enemy being thrown from AnimElem 4 to 10, like you would do in state 1001


[State 1000, Release one]
Type = TargetState
Trigger1 = AnimElem = 4, = 0
Value = 1002

[State 1000, Drop one]
Type = TargetDrop
Trigger1 = AnimElem = 4, = 0
KeepOne = 1

[State 1000, Keep the other enemy]
Type = TargetState
Trigger1 = AnimElem = 4, = 0
Value = 1003

[State 1000, Release the other one]
Type = TargetState
Trigger1 = AnimElem = 10, = 0
Value = 1002 ;You may use state 1002 to release the other enemy, or you can create the state 1004 if he will be released in a different way


I don't know if this code will work, can't test it right now, but I hope it helps you ^^

ZackTheRiolu

[GT .Howlerr] I already know this and its what i want understand.. U__U
[Thunderbert] I'll gonna try it soon and late i tell you ^_^

altoiddealer

#6
Do you put your opponents into 2 separate states?  Or do they both go into the same one?

Assuming they each go into a different state

If you add this parameter to the throw's HitDef (assuming you are NOT including the parameter "fall.envshake.time")...

fall.envshake.ampl = ID

...you can then easily redirect triggers back to your player, from the opponent's custom states.

Example:

[State 1002, End]
Type = SelfState
trigger1 = PlayerIDExist(gethitvar(fall.envshake.ampl)) ;This trigger isn't really necessary here, but still good practice.
Trigger1 = PlayerID(gethitvar(fall.envshake.ampl)),animelem = 10
trigger2 = !PlayerIDExist(gethitvar(fall.envshake.ampl)) ;fallback code
Trigger2 = enemynear,animelem = 10 ;fallback code
Value = 5040
Ctrl = 0


kudos to Alexei for teaching me this technique!

You can condense the triggers a bit if you are familiar with the "Cond" trigger


[State 1002, End]
Type = SelfState
trigger1 = Cond(PlayerIDExist(gethitvar(fall.envshake.ampl)),PlayerID(gethitvar(fall.envshake.ampl)),animelem = 10,enemynear,animelem = 10)
Value = 5040
Ctrl = 0



If they both go into the same custom state

You could do the same thing as above, except including numtarget.  I'm pretty sure that each player will need to get a unique targetID from the hit!


[State 1002, End]
Type = SelfState
trigger1 = PlayerIDExist(gethitvar(fall.envshake.ampl)) ;This trigger isn't really necessary here, but still good practice.
Trigger1 = PlayerID(gethitvar(fall.envshake.ampl)),numtarget(1111)
Trigger1 = PlayerID(gethitvar(fall.envshake.ampl)),animelem = 4
trigger2 = !PlayerIDExist(gethitvar(fall.envshake.ampl)) ;fallback code
Trigger2 = enemynear,numtarget(1111) ;fallback code
Trigger2 = enemynear,animelem = 4 ;fallback code
trigger3 = PlayerIDExist(gethitvar(fall.envshake.ampl)) ;This trigger isn't really necessary here, but still good practice.
Trigger3 = PlayerID(gethitvar(fall.envshake.ampl)),numtarget(2222)
Trigger3 = PlayerID(gethitvar(fall.envshake.ampl)),animelem = 10
trigger4 = !PlayerIDExist(gethitvar(fall.envshake.ampl)) ;fallback code
Trigger4 = enemynear,numtarget(2222) ;fallback code
Trigger4 = enemynear,animelem = 10 ;fallback code
Value = 5040
Ctrl = 0



or "simplified"


[State 1002, End]
Type = SelfState
trigger1 = Cond(PlayerIDExist(gethitvar(fall.envshake.ampl)),PlayerID(gethitvar(fall.envshake.ampl)),numtarget(1111),enemynear,numtarget(1111))
trigger1 = Cond(PlayerIDExist(gethitvar(fall.envshake.ampl)),PlayerID(gethitvar(fall.envshake.ampl)),animelem = 4,enemynear,animelem = 4)
trigger2 = Cond(PlayerIDExist(gethitvar(fall.envshake.ampl)),PlayerID(gethitvar(fall.envshake.ampl)),numtarget(2222),enemynear,numtarget(2222))
trigger2 = Cond(PlayerIDExist(gethitvar(fall.envshake.ampl)),PlayerID(gethitvar(fall.envshake.ampl)),animelem = 10,enemynear,animelem = 10)
Value = 5040
Ctrl = 0


ZackTheRiolu

Quote from: altoiddealer on July 28, 2015, 04:08:18 PM
Do you put your opponents into 2 separate states?  Or do they both go into the same one?

Assuming they each go into a different state

If you add this parameter to the throw's HitDef (assuming you are NOT including the parameter "fall.envshake.time")...

fall.envshake.ampl = ID

...you can then easily redirect triggers back to your player, from the opponent's custom states.

Example:

[State 1002, End]
Type = SelfState
trigger1 = PlayerIDExist(gethitvar(fall.envshake.ampl)) ;This trigger isn't really necessary here, but still good practice.
Trigger1 = PlayerID(gethitvar(fall.envshake.ampl)),animelem = 10
trigger2 = !PlayerIDExist(gethitvar(fall.envshake.ampl)) ;fallback code
Trigger2 = enemynear,animelem = 10 ;fallback code
Value = 5040
Ctrl = 0


kudos to Alexei for teaching me this technique!

You can condense the triggers a bit if you are familiar with the "Cond" trigger


[State 1002, End]
Type = SelfState
trigger1 = Cond(PlayerIDExist(gethitvar(fall.envshake.ampl)),PlayerID(gethitvar(fall.envshake.ampl)),animelem = 10,enemynear,animelem = 10)
Value = 5040
Ctrl = 0



If they both go into the same custom state

You could do the same thing as above, except including numtarget.  I'm pretty sure that each player will need to get a unique targetID from the hit!


[State 1002, End]
Type = SelfState
trigger1 = PlayerIDExist(gethitvar(fall.envshake.ampl)) ;This trigger isn't really necessary here, but still good practice.
Trigger1 = PlayerID(gethitvar(fall.envshake.ampl)),numtarget(1111)
Trigger1 = PlayerID(gethitvar(fall.envshake.ampl)),animelem = 4
trigger2 = !PlayerIDExist(gethitvar(fall.envshake.ampl)) ;fallback code
Trigger2 = enemynear,numtarget(1111) ;fallback code
Trigger2 = enemynear,animelem = 4 ;fallback code
trigger3 = PlayerIDExist(gethitvar(fall.envshake.ampl)) ;This trigger isn't really necessary here, but still good practice.
Trigger3 = PlayerID(gethitvar(fall.envshake.ampl)),numtarget(2222)
Trigger3 = PlayerID(gethitvar(fall.envshake.ampl)),animelem = 10
trigger4 = !PlayerIDExist(gethitvar(fall.envshake.ampl)) ;fallback code
Trigger4 = enemynear,numtarget(2222) ;fallback code
Trigger4 = enemynear,animelem = 10 ;fallback code
Value = 5040
Ctrl = 0



or "simplified"


[State 1002, End]
Type = SelfState
trigger1 = Cond(PlayerIDExist(gethitvar(fall.envshake.ampl)),PlayerID(gethitvar(fall.envshake.ampl)),numtarget(1111),enemynear,numtarget(1111))
trigger1 = Cond(PlayerIDExist(gethitvar(fall.envshake.ampl)),PlayerID(gethitvar(fall.envshake.ampl)),animelem = 4,enemynear,animelem = 4)
trigger2 = Cond(PlayerIDExist(gethitvar(fall.envshake.ampl)),PlayerID(gethitvar(fall.envshake.ampl)),numtarget(2222),enemynear,numtarget(2222))
trigger2 = Cond(PlayerIDExist(gethitvar(fall.envshake.ampl)),PlayerID(gethitvar(fall.envshake.ampl)),animelem = 10,enemynear,animelem = 10)
Value = 5040
Ctrl = 0


Thank you but i'm not still so good to understand all you wrote now, so i don't even know as to adapt it fine to the character coding, sorry..
[I'm actually trying aniway but for now i comes more closer with Thunderbert suggestion. I said closer cause the second enemy, seem to be released but remaining invisible when happened. I put that during the threw the opponent not suppose to be saw until when have to being released]

altoiddealer

Quote from: Thunderbert on July 28, 2015, 04:57:57 AM

[State 1000, Release one]
Type = TargetState
Trigger1 = AnimElem = 4, = 0
Value = 1002

[State 1000, Drop one]
Type = TargetDrop
Trigger1 = AnimElem = 4, = 0
KeepOne = 1

[State 1000, Keep the other enemy]
Type = TargetState
Trigger1 = AnimElem = 4, = 0
Value = 1003

[State 1000, Release the other one]
Type = TargetState
Trigger1 = AnimElem = 10, = 0
Value = 1002 ;You may use state 1002 to release the other enemy, or you can create the state 1004 if he will be released in a different way


I'm not sure about his third controller.  I think you should also specify the ID.

Try this instead:


[State 1000, Release one]
Type = TargetState
Trigger1 = AnimElem = 4, = 0
Value = 1002
id = 1111 ;The ID you specified in the hitdef

[State 1000, Drop one]
Type = TargetDrop
Trigger1 = AnimElem = 4, = 0
KeepOne = 1
id = 1111 ;The ID you specified in the hitdef

[State 1000, Release the other one]
Type = TargetState
Trigger1 = AnimElem = 10, = 0
Value = 1002
id = 1111 ;The ID you specified in the hitdef



ZackTheRiolu

#9
Quote from: altoiddealer on July 28, 2015, 09:33:23 PM
Quote from: Thunderbert on July 28, 2015, 04:57:57 AM

[State 1000, Release one]
Type = TargetState
Trigger1 = AnimElem = 4, = 0
Value = 1002

[State 1000, Drop one]
Type = TargetDrop
Trigger1 = AnimElem = 4, = 0
KeepOne = 1

[State 1000, Keep the other enemy]
Type = TargetState
Trigger1 = AnimElem = 4, = 0
Value = 1003

[State 1000, Release the other one]
Type = TargetState
Trigger1 = AnimElem = 10, = 0
Value = 1002 ;You may use state 1002 to release the other enemy, or you can create the state 1004 if he will be released in a different way


I'm not sure about his third controller.  I think you should also specify the ID.

Try this instead:


[State 1000, Release one]
Type = TargetState
Trigger1 = AnimElem = 4, = 0
Value = 1002
id = 1111 ;The ID you specified in the hitdef

[State 1000, Drop one]
Type = TargetDrop
Trigger1 = AnimElem = 4, = 0
KeepOne = 1
id = 1111 ;The ID you specified in the hitdef

[State 1000, Release the other one]
Type = TargetState
Trigger1 = AnimElem = 10, = 0
Value = 1002
id = 1111 ;The ID you specified in the hitdef



If i don't wrong i think to have tried something like.. but maybe i missed something, i'll gonna try it soon as i keep my other computer and i will let you know


UPDATE: Targetdrop not accept ID

Felkazz

So, with my code, the first opponent is dropped correctly and the other one isn't?
Can you show the custom states and how you implemented my code?

ZackTheRiolu

Sure.. here we go...

(This the release statedef)
[Statedef 1410]
type = S
movetype = A
physics = S
ctrl = 0
velset = 0,0
anim = 1325

[State 1410, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = timerfreeze

[State 1410, Release one]
Type = TargetState
Trigger1 = AnimElem = 6, = 0
Value = 1305
ID = 1300
     
[State 1000, Drop one]
Type = TargetDrop
Trigger1 = AnimElem = 6, = 0
KeepOne = 1
;(Inserting the ID not works)
     
[State 1000, Release the other one]
Type = TargetState
Trigger1 = AnimElem = 10, = 0
Value = 1002
id = 1400 ;The ID you specified in the hitdef

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

--------------------------------------------------------------
(This when, as i said, they supposed to be invisible)
[Statedef 1302]
type = A
movetype = H
physics = N
ctrl = 0
velset = 0,0
sprpriority = 2

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

[state 0, AssertSpecial]
type = AssertSpecial
trigger1 = 1 = 1
flag = noshadow

;----------------------------------------------
(The statedef about how the enemy suppose to be released like..)
[Statedef 1305]
type = A
movetype= H
physics = N
velset = -5,-10
poweradd = 40
sprpriority = 2

[State 1305, 1] ;Gravity
type = VelAdd
Trigger1 = 1
y = 1

[State 1305, 1]
type = ChangeAnim2
Trigger1 = time = 0
value = 822

[State 1305, 4] ;Hit ground
type = SelfState
trigger1 = Vel Y > 0
trigger1 = Pos Y >= -20;0
value = 5100 ;Hit ground
ctrl = 0
______________________________________________

As i said before, i still need to learn a lot about coding, from now consider my problems to understand all the parts in english, i'm more trying and experimenting the code. Some i copied and try to adapt them on the character so.. If you notice errors stupid is normal i mean... ^^;

Repeat, the first enemy works fine, being released, appear when have to and the gets up and continue the battle, the second one not.. seem like being released for as much i can't hear any sound but remain invisible and not make a move. Only when attacking where suppose to be released later get hurts, appear and the battle continue.

     Posted: July 30, 2015, 02:00:22 AM
Problem solved ^__^
In the coding i've put a new release code for both the opponents and edits/trying some codes and i solved the problem..

(The statedef about how the enemy suppose to be released like..)
[Statedef 1315]
type = A
movetype= H
physics = N
velset = -5,-10
sprpriority = 7

[State 1305, 1] ;Gravity
type = VelAdd
Trigger1 = 1
y = 1

[State 1305, 1]
type = ChangeAnim2
Trigger1 = animtime = 0
value = 822

[State 1305, 4] ;Hit ground
type = SelfState
trigger1 = Vel Y > 0
trigger1 = Pos Y > 0
value = 5100 ;Hit ground
ctrl = 0
--------------------------------------------

(This the release statedef)
[Statedef 1410]
type = S
movetype = A
physics = S
ctrl = 0
velset = 0,0
anim = 1325

[State 1410, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = timerfreeze

[State 1410, Release one]
Type = TargetState
Trigger1 = AnimElem = 6, = 0
Value = 1315
id = 1300

[State 1410, Release one]
Type = TargetState
Trigger1 = AnimElem = 14, = 0
Value = 1315
id = 1400
     
[state 1315, bind1]
type = targetbind
trigger1 = animelem = 6, = 0
id = 1300
pos = floor(105*(const(size.xscale))),ceil(-33*(const(size.yscale)))

[state 1315, bind1]
type = targetbind
trigger1 = animelem = 14, = 0
id = 1400
pos = floor(105*(const(size.xscale))),ceil(-33*(const(size.yscale)))

[state 1315, end]
type = changestate
trigger1 = animtime = 0
value = 0
ctrl = 1
----------------------------------------------------------------------------

With these now it actually works fine, i played with the targetbind and state using the ID for both.
Thank you very much for the help guys ^__^