How does P1 add as much life as he/she take from a successful attack on P2?

Started by Saturno, June 05, 2009, 02:43:27 PM

Previous topic - Next topic

Saturno

Hi.
I want to ask something a bit complicated. I want my char to add the same life that he takes from player2.
For example, when P1 attacks and causes a damage of 50 on P2, I want P1 to add 50 also, but ONLY IF the Hit is SUCCESSFUL.

I hope someone can help me, if this is possible to do in mugen...

Thanks a lot guys.

[S]witch K'

[State 0, LifeAdd]
type = LifeAdd
trigger1 = Movehit
value = 50

(Thats the SIMPLE version without taking into account all the damage dampening and stuff)

Byakko

type = LifeAdd
trigger1 = Movehit
trigger1 = numtarget ; necessary to avoid a debug flood, even if you used movehit before
value = target,gethitvar(damage)
But that might be buggy in team mode if a move hits more than one enemy with the same hit.

And you definitely don't need a big green font to ask a question -_-
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.

Saturno

Quote from: Byakko on June 05, 2009, 03:07:26 PM
type = LifeAdd
trigger1 = Movehit
trigger1 = numtarget ; necessary to avoid a debug flood, even if you used movehit before
value = target,gethitvar(damage)
But that might be buggy in team mode if a move hits more than one enemy with the same hit.

And you definitely don't need a big green font to ask a question -_-

Thank you byakko ;) I'll try this. Sorry about the big green font. It's just that I like the green colour. Thanks again.

Quote from: -         SWTCH on June 05, 2009, 02:49:47 PM
[State 0, LifeAdd]
type = LifeAdd
trigger1 = Movehit
value = 50

(Thats the SIMPLE version without taking into account all the damage dampening and stuff)

Thank you SWTCH  too.


Cyanide

movehit = trigger while move is hitting, that's through the hitpause and for the entire hit.time of the hitdef. If it lasts 10 ticks you gain 200 life.

If you're not using state -2 for this but just adding it into each state, make sure you add

persistent = 0

to the lifeadd.


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.

Saturno

Quote from: Byakko on June 05, 2009, 03:07:26 PM
type = LifeAdd
trigger1 = Movehit
trigger1 = numtarget ; necessary to avoid a debug flood, even if you used movehit before
value = target,gethitvar(damage)
But that might be buggy in team mode if a move hits more than one enemy with the same hit.

Hi Byakko, I wanna tell you that this didn't work for me.
the problem was this line: value = target,gethitvar


Quote from: Cyanide on June 07, 2009, 01:17:59 AM
movehit = trigger while move is hitting, that's through the hitpause and for the entire hit.time of the hitdef. If it lasts 10 ticks you gain 200 life.

If you're not using state -2 for this but just adding it into each state, make sure you add

persistent = 0

to the lifeadd.

Thanks Cyanide, I'll try what you told me. Thanks, man.

Byakko

Quote from: ubaldo_saul on June 07, 2009, 01:46:54 AM
the problem was this line: value = target,gethitvar
"target, gethitvar(damage)" (check for "trigger redirection" in the first link)
And what was "the problem" ? Did it tell you something ? what was the message ?
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.

Cyanide

I'd be interested too, target, gethitvar(damage) should have functioned perfectly. Target doesn't need an ID specified, so there's no reason for that not to work.


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.

Saturno

Hi friends.
I'll post an example of what I have in my char. He adds life all the time he executes this state. But, as I said before, I only want him to add life if the hit is successful.
I hope you guys can help me. Thanks.


;---------------------------------------------------------------------------
; Standing Medium Punch
; CNS difficulty: easy
[StateDef 210]
type = S
movetype= A
physics = S
juggle  = 1
velset = 0,0
ctrl = 0
anim = 210
poweradd = 20
sprpriority = 2

[State 210, 1]
type = HitDef
trigger1 = AnimElem = 2
attr = S, NA
damage = 100
animtype = Light
guardflag = MA
hitflag = MAF
priority = 3, Hit
pausetime = 10, 10
sparkno = 0
sparkxy = -10, -76
hitsound = 5, 0
guardsound = 6, 0
ground.type = High
ground.slidetime = 5
ground.hittime  = 12
ground.velocity = -4
airguard.velocity = -1.9,-.8
air.type = High
air.velocity = -1.4,-3
air.hittime = 12




[State 210, LifeAdd]
type = LifeAdd
trigger1 =  AnimElem = 4
value = 10
kill = 1
absolute = 0
;ignorehitpause =
;persistent =




[State 210, end]
type = ChangeState
trigger1 = AnimTime = 0
value = 0
ctrl = 1

MikeDaBike

Change the trigger of the LifeAdd controller to
trigger1 = movehit=1
Latest Creation: SSBB Assist Trophies

Saturno

Quote from: MikeDaBike on June 11, 2009, 07:39:57 PM
Change the trigger of the LifeAdd controller to
trigger1 = movehit=1

Thank you very much ;) I'll try this.

Saturno

Quote from: ubaldo_saul on June 12, 2009, 05:58:35 PM
Quote from: MikeDaBike on June 11, 2009, 07:39:57 PM
Change the trigger of the LifeAdd controller to
trigger1 = movehit=1

Thank you very much ;) I'll try this.

This woked very well. Thank you.

By the way:
I want to make my char add life instead of being damaged by the enemy's projectiles. That is to say, if the enemy throws a projectile, I want him to add life if he is touched by the projectile (as if he makes himself stronger when being attacked by projectiles) Does anyone know how can I do that? I would really appreciate your help. Thank you.

Bastard Mami

use the lifeadd controller in state 5000, use the gethitvar as a trigger.

Saturno

Quote from: Frederika Bernkastel~ on June 16, 2009, 06:21:19 PM
use the lifeadd controller in state 5000, use the gethitvar as a trigger.
Thank you very much Frederika ;) I'll try this.

Saturno

Quote from: ubaldo_saul on June 16, 2009, 06:30:47 PM
Quote from: Frederika Bernkastel~ on June 16, 2009, 06:21:19 PM
use the lifeadd controller in state 5000, use the gethitvar as a trigger.
Thank you very much Frederika ;) I'll try this.

Hi Frederika Bernkastel. I wanna tell you that I've been trying to use the lifeadd controller in state 5000 and the gethitvar as a trigger as you told me to do so. However I must have done something wrong, because I can't make my char add life instead of being damaged by the enemy's projectiles. What I have done is adding life all the time the enemy hits my char, but that's not what I tried to do.   
"I want to make my char add life instead of being damaged by the enemy's projectiles. That is to say, if the enemy throws a projectile, I want him to add life if he is touched by the projectile (as if he makes himself stronger when being attacked by projectiles) but I don't want my char to add ife if the enemy attacks him with a punch or a kick, or any other kind of attack which is not a projectile.

Is it here that I've got to add the coding?


;---------------------------------------------------------------------------
; HITG_SHAKE
[Statedef 5000]
type    = S
movetype= H
physics = N
velset = 0,0

[State 5000, 1] ;Anim for HIT_LIGHT to HIT_HARD
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) != [3,5]
value = ifelse((GetHitVar(groundtype) = 1),5000,5010) + GetHitVar(animtype)

[State 5000, 2] ;Anim for HIT_BACK
type = ChangeAnim
trigger1 = Time = 0
trigger1 = GetHitVar(animtype) = [3,5]
value = 5030

[State 5000, 3] ;Anim for HIT_UP/HIT_DIAGUP (only if it exists)
type = ChangeAnim
trigger1 = Time = 0
trigger1 = (GetHitVar(animtype) = [4,5]) && (SelfAnimExist(5047 + GetHitVar(animtype)))
value = 5047 + GetHitVar(animtype) ;5051 - 4 + type

[State 5000, 4] ;Freeze anim
type = ChangeAnim
trigger1 = Time > 0
value = anim

[State 5000, 5] ;State type gets set to aerial if getting hit up
type = StateTypeSet
trigger1 = Time = 0
trigger1 = GetHitVar(yvel) != 0 || GetHitVar(fall)
trigger2 = Pos Y != 0
statetype = a

[State 5000, 6]
type = ChangeState
trigger1 = HitShakeOver
trigger1 = GetHitVar(yvel) = 0 && !GetHitVar(fall)
value = 5001 ;HITG_SLIDE

[State 5000, 7]
type = ChangeState
trigger1 = HitShakeOver
value = 5030

[State 5000, FFB Light]
type = ForceFeedback
trigger1 = anim = 5000
trigger2 = anim = 5010
persistent = 0
time = 6
waveform = square

[State 5000, FFB Medium]
type = ForceFeedback
trigger1 = anim = 5001
trigger2 = anim = 5011
persistent = 0
time = 8
waveform = sinesquare
ampl = 110,-1,-.3

[State 5000, FFB Hard]
type = ForceFeedback
trigger1 = anim = 5012
trigger2 = anim = 5002
trigger3 = anim = 5030
persistent = 0
time = 15
waveform = sinesquare
ampl = 140

Byakko

... It's nearly impossible to tell if you were hit by a punch or a fireball once you have been hit. What might be possible is add a HitOverride that can override projectiles (P in the attr parameter) and send you to a special gethit state, copied from the original one, that adds life. Also, restore your gethit states to normal (remove them from your file, they're in the common1.cns already, you don't need to override them by having them in your files if you don't modify them)

the difference with this and the gethitvar method is that gethitvar can't look up the attr parameter of the attacker's hitdef.
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.

Saturno

Quote from: Byakko on July 08, 2009, 10:56:23 PM
... It's nearly impossible to tell if you were hit by a punch or a fireball once you have been hit. What might be possible is add a HitOverride that can override projectiles (P in the attr parameter) and send you to a special gethit state, copied from the original one, that adds life. Also, restore your gethit states to normal (remove them from your file, they're in the common1.cns already, you don't need to override them by having them in your files if you don't modify them)

the difference with this and the gethitvar method is that gethitvar can't look up the attr parameter of the attacker's hitdef.

Thank you Byakko. Your explanation is very clear.  ;)

Saturno

Quote from: ubaldo_saul on July 09, 2009, 07:24:19 PM
Quote from: Byakko on July 08, 2009, 10:56:23 PM
... It's nearly impossible to tell if you were hit by a punch or a fireball once you have been hit. What might be possible is add a HitOverride that can override projectiles (P in the attr parameter) and send you to a special gethit state, copied from the original one, that adds life. Also, restore your gethit states to normal (remove them from your file, they're in the common1.cns already, you don't need to override them by having them in your files if you don't modify them)

the difference with this and the gethitvar method is that gethitvar can't look up the attr parameter of the attacker's hitdef.

HI Byakko I've been trying this but I can't do it. Could you give me an example of how to do it? What do I have to write in trigger1=......... ? I've seen some things like: ProjContac (*,***); ProjContactTime; ProjHit (*,***) and ProjHitTime.   Could they be useful for what I want to do? If so, how are they used?
Thanks for helping.

Byakko

The hitoverride is used to override the regular gethit behavior as long as it is activated.
What you want is have a HitOverride active constantly (put it in statedef -2) that will work on projectiles - put a P in the attr parameter of your hitoverride.
So with that, you will have a hitoverride that will be active when you get hit by a projectile. You want it to send you to a specific gethit state, which should be a copy of the regular gethit states (the 5000+ states in common1.cns) that's something you do by setting the parameters of the hitoverride correctly. Just look at the docs for that.
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.