News:

MFG's Character of the Month: October 2026 Nominations

Main Menu

random explod position

Started by Dendog90, April 29, 2016, 08:16:03 PM

Previous topic - Next topic

Dendog90

Hello, Im trying to make an explode or helper that randomly spawns multiple times around player 1 and all of em goes to his hand, basically its like Goku's Spirit bomb when hes charging it and little balls goes to that specific area, how can code this? please and thank you

Odb718

Spoiler: Make the helper (click to show)
[State 7500, Helper]
type = Helper
trigger1 = time = 9
;helpertype = normal ;player
name = "Particel"
ID = 2220
stateno = 7522
pos = 0,0
postype = p1    ;p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 1

Spoiler:  Helper State (click to show)

;Energy Ball
[Statedef 7522]
type    = S
movetype= I
physics = S
juggle  = 0
velset = 0,0
ctrl = 0
anim = 7223
poweradd = 0
sprpriority = 2

[State 7522, BindToRoot]
type = BindToRoot
trigger1 = IfElse(power >= 1500,(time%3),(time%6))
time = 1
pos = Ceil(-60+random%120),floor(-130+random%130)

[State 7522, Explod]
type = Explod
trigger1 = IfElse(power >= 1500,(!(time%3)),(!(time%6)))
anim = 7223
ID = 7223
pos = 0,0
postype = p1  ;p2,front,back,left,right
facing = 1
vfacing = 1
bindtime = 1
vel = (rootdist x -2)/15,(rootdist Y-20)/15;IfElse(rootdist Y <= 0 && vel y <= 0,0,(((rootdist Y)-60)/14))
removetime = 15
scale = 0.5,0.5
sprpriority = Ifelse(random < 800,2,-2);([-2,2])
ontop = 1
shadow = 0,0,0
ownpal = 1
removeongethit = 0

[State 7522, DestroySelf]
type = DestroySelf
trigger1 = (root, stateno != 7500)
;trigger1 = (root, movetype = H)

Bind to root, and the explod velocity is probably what you want to play around with.

Also, anim 7223 is the energy ball animation.
vVv Gouken718 vVv SabreTooth718 vVv


Cyanide

You really really should explain what all of that does and why it will do what he wants.

You've even left some stuff in there commented out. That's just confusing. An explanation of why you are using an explod that uses the same animation as the state would also be worth adding.

If the above copy paste does not make enough sense the code you desire is within the code library with each point laid out.


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.

Dendog90

I went another way but I will try this out

altoiddealer

I would think it would be simpler to just use something like:

[State -2,0]
type = Explod
trigger1 = Time%5 = 0
anim = 9999
pos = -10+random%20 , -10+random%20

This would trigger an Explod every 5 ticks, in a random x/y position relative to the player, in a range of 20px x 20px.

To have them randomly appear by his hand, set the pos of his hand and attach the random code

pos = 24+(-10+random%20) , -63+(-10+random%20)


Cyanide

He's talking about piccolos scatter shot effect. They all converge on a point. Not just random explod placement.


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.

Noctis

#6
The charge effect to CVS characters does this if you wanna look at that since no one's explaining it. You can just visually see what it does through the coding itself.
In fact, here's the code. I know it's similar to what odb posted, but it's kinda less cluttered and simpler.
I never fully understood how it worked myself nor did I ever take the time to figure out the math, but I explained the important bits.
The only thing I didn't explain is the random / 3.125 portion. Messing with that screws up everything.
Also, I didn't really change anything. I copied it and pasted it here.
;---------------------------------------------------------------------------
; Particles
[StateDef 8601]
type = A
physics = N
movetype = I
anim = 9999
ctrl = 0
velset = 0,0

[State 8331, BindToRoot] ;This is to randomize the starting position, but with the explod's vel coding below, it will always go to the same place it was meant to go no matter where this code puts it.
type = BindToRoot
trigger1 = !(Time % 8)
pos = ceil(-151 + (Random / 3.125)), ceil(98 - (Random / 3.125))

[State 8331, Particle]
type = Explod
trigger1 = (Time % 8) = 1
anim = 8602
id = 8602
sprpriority = ifElse(Random < 750, 5, -1)
postype = p1
vel = ((RootDist x - 6) / 32.0), ((RootDist y - 55) / 32.0) ;The 32.0 is the velocity divided by the position you want it to go to. The RootDist x - 6 and RootDist y - 55 is where it will go to and what the velocity is divided by. You want the animation length to be the same as the velocity. So if the velocity is 32.0, then you'll want the animation to be 32 ticks long. If the animation is only say 16 ticks, it'll disappear too soon. If it's say 48 ticks, it'll disappear way too late and just pass through your character.
;Anywho, if you set the rootdist x to say + 20 and rootdist y to say + 20, then that's where it'll go.
scale = ifElse(Random < 500, 0.5, -0.5), ifElse(Random < 500, 0.5, -0.5)
pausemovetime = -1
supermovetime = -1
ownpal = 1

[State 8331, RemoveExplod]
type = RemoveExplod
trigger1 = Root, StateNo != 750
id = 8602

[State 8331, End]
type = DestroySelf
trigger1 = Root, StateNo != 750

(Youtube) (WIP) (Mediafire) (New Anime Shop) My Manga Reviews! Personal favorite Patreon! Check her out!

"There is nothing either good or bad, but thinking makes it so."

Odb718

Noctis, you dont have to worry about the timing in the velocity if the animation is standard or loops. If it fades out or does an end animation, yeah you'd want to time it. But you can just use RemoveTime = X.
Another effect using RemoveTime would to kind of create an aura. You could have the removetime earlier than the central point. This would be good for a growing orb or something similar.
vVv Gouken718 vVv SabreTooth718 vVv


Noctis

True. I hadn't thought of it at the time. Just use removetime instead of worrying about the time of the animation divided by the velocity. Or just edit it accordingly so it never confuses you down the road. Animation = 20 ticks? Edit the numbers to 20 instead of 32.

Also, still haven't bothered to figure out what the rest of it does. :)

Get what you need, Dendog?

(Youtube) (WIP) (Mediafire) (New Anime Shop) My Manga Reviews! Personal favorite Patreon! Check her out!

"There is nothing either good or bad, but thinking makes it so."