YesNoOk
avatar

How to code interactive item in stage (Read 60524 times)

Started by copticprincess, July 29, 2022, 12:27:58 pm
Share this topic:
How to code interactive item in stage
#1  July 29, 2022, 12:27:58 pm
  • **
    • USA
Hi everyone, I have an exploding barrel I would like to use on my stage when chars are fighting it gets destroyed. I can't find any tutorials on how to do that though. I came across one article explaining what an attachchar is and how the interactive object is like a character that doesn't fight, but how to do this? Hope someone can help.
Last Edit: July 29, 2022, 05:43:18 pm by copticprincess
Re: How to code interactive item in stage
#2  July 30, 2022, 02:10:53 am
  • **
Had a quick look for you concerning this.  Someone who's actually coded interactions before can give you a more in-dept explanation but as far as I can tell, the attachchar is more or less, an actual complete character itself that you need to code. This character is then called upon by the stage if you place it under the [info] tab of your stage.

To get a better understanding, find some interactive stages and see how they use/code the attachchar with the stage.
Re: How to code interactive item in stage
#3  July 30, 2022, 10:28:12 pm
  • **
  • Don't copy code if you don't understand it.
    • USA
    • a13rown@hotmail.com
Ok, I hope this is what you are talking about....

Not sure how to do it with IKEMEN (I don't use it), but in Mugen you can create a helper when your characters are using the stage.  I used the author's name to detect what stage I was using for my game.  For example, 



Now, for the helper itself. If the character goes into a hitstate within a certain distance of the helper, the helper
changes to the blow up state. So your helper must have the proper collision boxes in its animation.  Next, I had to make sure
projectile based attacks wouldn't hit the helper, so I used a NotHitBy
Sctrl.

Hope this is what you mean.
Re: How to code interactive item in stage
#4  July 30, 2022, 10:49:25 pm
  • **
    • USA
Re: How to code interactive item in stage
#5  July 31, 2022, 12:38:52 am
  • **
  • Don't copy code if you don't understand it.
    • USA
    • a13rown@hotmail.com
I think the way I did it should work for ikemen.  I use Mugen 1.1, so I don't think it would be too buggy.   I will try to show you how I did it.  My method wasn't too complex. This was something I wrote on my own, so it shouldn't be too hard to follow. But basically I have a helper in my StateDef -2 section that is spawned when the characters are on the correct stage:

[STATEDEF -2]

[State -2, Stage Helper]
type = Helper
triggerall = !Numpartner
triggerall = !IsHelper
triggerall = RoundState = 2
triggerall = NumEnemy
triggerall = StageVar(info.author) = "AVPBOY"
trigger1 = NumHelper(10141983) = 0
id = 10141983
name = "FLAME POST HELPER"
StateNo =  10141983
Helpertype = normal
pos = -324,-6
keyctrl = 0
ownpal = 1
ignorehitpause = 1
supermoveTime = 999999
pausemoveTime = 999999
bindTime = -1


Next, I have the helper state,  before anyone collides into it.

;-------------------------------------------------------------------------------------------------------------------
;STAGE DETECTION HELPER START
;-------------------------------------------------------------------------------------------------------------------
[Statedef 10141983]
type    = S
movetype = I
physics = N
ctrl = 0
Anim = 10141983 ; Anim should have proper collision boxes

[State 10141983, NotHitBy] ; Projectile based attacks should not destroy it.
type = NotHitBy
trigger1 = Time >= 0
value = SCA, NP, SP, HP

[State 10141983, Explod]; The post
type = Explod
triggerall = NumExplod(10141)=0
trigger1 = Time = 0
Anim = F10141
ID = 10141
removeTime = -1
removeongethit = 1
bindTime = -1
sprpriority = -10
ownpal = 1
scale  = 1,1.2
ignorehitpause = 1
supermoveTime = 999999
pausemoveTime = 999999
persistent = 1
postype = p1
pos = 0,0

[State 10141983, Explod]; The flame on top of the post
type = Explod
triggerall = NumExplod(10140)=0
trigger1 = Time = 0
Anim = F10140
ID = 10140
removeTime = -1
removeongethit = 1
bindTime = -1
sprpriority = -9
ownpal = 1
scale  = 1.2,1.2
ignorehitpause = 1
supermoveTime = 999999
pausemoveTime = 999999
persistent = 1
postype = p1
pos = 0,0

[State 10141983, AssertSpecial]
type = AssertSpecial
trigger1 = 1
flag = NoShadow
ignorehitpause = 1

;THIS IS WHAT TRIGGERS THE POST TO GO INTO THE DESTROYED STATE.  I HAD TO MAKE THIS WORK IN SIMUL MODE ALSO.
[State 10141983, ChangeState]; ENEMY PLAYER
type = ChangeState
triggerall = Enemynear,MoveType = H || Enemynear,StateNo = [5000,5199]
trigger1 = P2BodyDist X = [-20,20]
trigger1 = P2BodyDist Y = [-20,20]
value = 10141984

[State 10141983, ChangeState]; YOU
type = ChangeState
triggerall = Parent,MoveType = H || Parent,StateNo = [5000,5199]
trigger1 = ParentDist X = [-20,20]
trigger1 = ParentDist Y = [-20,20]
value = 10141984

[State 10141983, ChangeState]; TAG PLAYER
type = ChangeState
triggerall = NumPartner
triggerall = Partner,MoveType = H || Partner,StateNo = [5000,5199]
trigger1 = (Partner,Pos X  - Pos X = [-20,20])
trigger1 = (Partner,Pos Y  - Pos Y = [-20,20])
value = 10141984

;HELPER DESTROYING ITSELF WHEN THE MATCH IS OVER.  DONT PAY ATTENTION TO THE VAR(53), THATS JUST FOR MY GAME.
[State 10141983, DestroySelf]
type = DestroySelf
trigger1 = RoundState > 3
trigger1 = Var(53)
trigger2 = RoundState > 3
trigger2 = Win || Lose
ignorehitpause = 1
persistent = 1
id = 10141983

Here is the destroy state of the post.

;------------------------------------------------------------------------------------------------------------------
[Statedef 10141984]
type = A
movetype = I
physics = N
Anim = 6900

;I CREATED A VARIABLE SO THE PREVIOUS EXPLOD WOULD REMOVE ITSELF
[State 10141984, VarSet]
type = VarSet
trigger1 = Time = 0
v = 1
value = 1

;REMOVING PREVIOUS EXPLODS, THIS IS THE POST
[State 10141984, RemoveExplod]
type = RemoveExplod
triggerall = Var(1)
trigger1 = Time = 0
id = 10141

;REMOVING PREVIOUS EXPLODS, THIS IS THE FLAME
[State 10141984, RemoveExplod]
type = RemoveExplod
triggerall = Var(1)
trigger1 = Time = 0
id = 10140

;NEW EXPLOD FOR DESTROYED POST
[State 10141984, Explod]
type = Explod
trigger1 = Time = 0
Anim = F10142
ID = 10142
removeTime = 30
removeongethit = 1
bindTime = -1
sprpriority = 4
ownpal = 1
supermoveTime = 999999
pausemoveTime = 999999
scale  = 1,1.2
persistent = 0
ignorehitpause = 1
postype = p1
pos = 0,0

;MAKING NEW DESTROYED POST TRANSPARENT
[State 10141984, ModifyExplod]
type = ModifyExplod
trigger1 = NumExplod(10142)
trigger1 = Time >= 25
ID = 10142
trans = addalpha
alpha = 36,256

;EXPLOSION EFFECT
[State 10141984, Explod]
type = Explod
triggerall = NumExplod(2105103)=0
trigger1 = Time = 0
Anim = F210510
ID = 2105103
removeTime = 30
removeongethit = 1
pos = 0,-60
sprpriority = 5
ownpal = 1
supermoveTime = 999999
pausemoveTime = 999999
scale  = .5,.5
persistent = 0
ignorehitpause = 1
postype = p1
pos = 0,0

;EXPLOSION SOUND
[State 10141984, PlaySnd]
type = PlaySnd
trigger1 = Time = 0
value = F5,12
loop = 0
abspan = -1
ignorehitpause = 1
persistent = 0
channel = 19

;EXPLOSION SOUND
[State 10141984, PlaySnd]
type = PlaySnd
trigger1 = Time = 0
value = F5,10
loop = 0
abspan = -1
ignorehitpause = 1
persistent = 0
channel = 15

[State 10141984, VelSet]
type = VelSet
trigger1 = Time = 0
x = 0
y = 0

;THESE VELSETS ARE FOR THE POST TO FLY OFF THE SCREEN
[State 10141984, VelSet]
type = VelSet
trigger1 = Time >= 1
x = -3
y = -7

[State 10141984, VelSet]
type = VelSet
trigger1 = Time >= 3
y = -7

[State 10141984, VelSet]
type = VelSet
trigger1 = Time >= 5
y = -7

[State 10141984, VelSet]
type = VelSet
trigger1 = Time >= 7
y = -5

[State 10141984, VelSet]
type = VelSet
trigger1 = Time >= 9
y = -3

[State 10141984, VelSet]
type = VelSet
trigger1 = Time >= 11
y = -2

[State 10141984, VelSet]
type = VelSet
trigger1 = Time >= 13
y = 0

[State 10141984, VelSet]
type = VelSet
trigger1 = Time >= 15
y = 2

[State 10141984, VelSet]
type = VelSet
trigger1 = Time >= 17
y = 3

[State 10141984, VelSet]
type = VelSet
trigger1 = Time >= 19
y = 5

[State 10141984, VelSet]
type = VelSet
trigger1 = Time >= 21
y = 7

[State 10141984, VelSet]
type = VelSet
trigger1 = Time >= 23
y = 9

[State 10141984, VelSet]
type = VelSet
trigger1 = Time >= 25
y = 10

[State 10141984, VelSet]
type = VelSet
trigger1 = Time >= 27
y = 11

[State 10141984, VelSet]
type = VelSet
trigger1 = Time >= 29
y = 13

;HELPER DESTROYING ITSELF WHEN THE MATCH IS OVER. DONT PAY ATTENTION TO THE VAR(53), THATS JUST FOR MY GAME.
[State 10141984, DestroySelf]
type = DestroySelf
trigger1 = RoundState > 3
trigger1 = Var(53)
trigger2 = RoundState > 3
trigger2 = Win || Lose
ignorehitpause = 1
persistent = 1
id = 10141983

HOPE THIS HELPS.
Last Edit: July 31, 2022, 12:42:25 am by The Jaquio
Re: How to code interactive item in stage
#6  July 31, 2022, 01:19:08 am
  • **
    • USA
Had a quick look for you concerning this.  Someone who's actually coded interactions before can give you a more in-dept explanation but as far as I can tell, the attachchar is more or less, an actual complete character itself that you need to code. This character is then called upon by the stage if you place it under the [info] tab of your stage.

To get a better understanding, find some interactive stages and see how they use/code the attachchar with the stage.

Hi steel. I tried to find some interactive stage similar to what i wanted, but I couldn't find one.
---------------------------------------------------------------------------------------------------------------------

Hi and thanks Jaquio. Ok let me make sure i'm getting this right.

1. Create a basic character, with collision, and use my barrel sprites
2. Analyze your code (to the best of my abilities) and use it in the Barrel .def and stage .def for the destructible barrel to work


If I comprehended it wrong, my apologies. So sleepy. ((
Re: How to code interactive item in stage
#7  July 31, 2022, 08:26:58 am
  • *****
  • Shame on you!
    • USA
vVv Ryuko718 Updated 10/31/22 vVv
Re: How to code interactive item in stage
#8  July 31, 2022, 04:06:06 pm
  • **
To make it simple, and AttachedChar (like a real character) needs all the required files to work.  So in your case, if we use 'Barrel' as the name for this charcter, it should have the following files in it's folder:

Barrel.def      ---> File to define the character
Barrel.cmd    ---> command file
Barrel.cns      ---> States file 
Barrel.sff       ---> Sprite file (can also be the same file as your stage's .sff file if the sprite you want is in that file).
Barrel.air       ---> Animation file (As above)
Barrel.cns      ---> Common states file (use the same file as Barrel.cns since it doesn't need any common states)
Barrel.snd      ---> Sound file  (this is optional)

You would then proceed to make the barrel 'character' as you would with normal characters except in your case, you don't need all the required sprites, get-hit animations and/or states. Since your barrel is an inanimate object, it's just going to sit there until someone smashed into it.  You'll only need sprites/animations for these. 

I do stress that if you haven't made characters before or are not familiar with it, then don't use AttachedChar yet. Save it for another project or come back to update it once you've figured out to code some basic characters.
But in short, @The Jaquio:'s code is what you want once you figure out the basics of coding and can modify his code to fit your needs in Ikemen.
For now, it's more trouble than it's worth.

@Odb718: That thread is only for mugen and is not true stage interaction since most of the coding needs to be in each individual characters .cns file.

 



 
Last Edit: July 31, 2022, 04:18:50 pm by SteelHammers