# MegaMan Zero help: Shield Boomerang (Read 966 times)

Started by RedDragonCats17, December 30, 2018, 12:02:30 am

#### RedDragonCats17

##### MegaMan Zero help: Shield Boomerang
#1  December 30, 2018, 12:02:30 am
Odb said that it's alright to make as many help threads as I want, so here I go with another help thread.

Recently, me and my teacher, Ryon, were working on Zero's Shield Boomerang. While it does work, it does need some adjustments.

Here's what it looks like right now: https://streamable.com/nkldr

See the helper doesn't destroy itself when it makes contact with Zero himself. Another thing is that it doesn't follow Zero when it comes back towards him. Me and Ryon kinda had a hard time getting that to work.

Here's the code for the helper as of now:

Spoiler, click to toggle visibilty

Spoiler, click to toggle visibilty

How do I make the Shield Boomerang follow Zero when it's on it's way back, and how can I make it destroy itself when it makes contact with Zero.

Spoiler, click to toggle visibilty
Last Edit: December 31, 2018, 11:46:31 pm by RedDragonCats17

#### ink

##### Re: MegaMan Zero help: Shield Boomerang
#2  December 30, 2018, 05:05:50 am
• inktrebuchet

• Online
I think you can do that with these formulas.

Code:
Vel = Distance / time
Time = Distance / vel

I don’t want to just post the code here for you but I think if you play with something like this you’ll get it.
Code:
Y = distance / (Distance / vel)

If you end up struggling with it just let me know and I’ll try to help more.
Last Edit: December 30, 2018, 05:34:30 am by ink

#### RedDragonCats17

##### Re: MegaMan Zero help: Shield Boomerang
#3  December 30, 2018, 06:41:20 am
I'm already having a hard time figuring this out. First of all idk what the distance is about, because I used time for when the Shield Boomerang turns around.

#### ink

##### Re: MegaMan Zero help: Shield Boomerang
#4  December 30, 2018, 06:55:25 am
• inktrebuchet

• Online
Well you already have parentdist x in your code, that is the distance...

The Y velocity will need to change on its own in order for it to always reach the character. That’s why a formula like this is needed.

#### RedDragonCats17

##### Re: MegaMan Zero help: Shield Boomerang
#5  December 30, 2018, 10:48:31 pm
Code:
[State 0, VelSet]
type = VelSet
trigger1 = parent, pos Y < 0
y = parentdist x / (parentdist x / -1.7)

Like this?

#### ink

##### Re: MegaMan Zero help: Shield Boomerang
#6  December 31, 2018, 01:41:17 am
• inktrebuchet

• Online
You tell me, did that work? Lol

I was thinking something like this. You’ll still have to decide if y is positive or negative.
Code:
Type = VelSet
Trigger = time > 30
Y = parentdist y / (parentdist x / abs(vel x))

I haven’t tried this code so let me know if it has weird results. Also Please don’t just copy and paste this without understanding how it works. If you have questions ask or you’ll never learn anything.

Exactly like the formulas I shared before:
(parentdist x / abs(vel x)) = “time”, the amount of time it will take the shield to reach the parent.
Parentdist y / “time” = the y velocity it must travel at in order to connect with the parent.
Last Edit: December 31, 2018, 02:19:37 am by ink

#### RedDragonCats17

##### Re: MegaMan Zero help: Shield Boomerang
#7  December 31, 2018, 06:42:20 am
It didn't work. The Shield Boomerang didn't even turn around, and when I jump, it goes down.

Code:
[State 0, VelSet]
type = VelSet
trigger1 = time > 30
y = parentdist y / (parentdist x / abs(vel x))

#### ink

##### Re: MegaMan Zero help: Shield Boomerang
#8  December 31, 2018, 02:47:00 pm
• inktrebuchet

• Online
I’m not sure why you’re sharing that with us. If the shield didn’t come back it’s because you removed the velset that controls x vel, just add it back in. This code only controls y (as it is).

As I said before, you’ll need to figure out if/when y is positive or negative, which is what makes it move up or down. It’s pretty much already in your original code.

Those two things are simple enough, I think you’ll be able to figure them out on your own.

If you run into problems with it come back with questions, not “It didn’t work.”, We can help but noone is here to write the code for you.

Last Edit: December 31, 2018, 04:56:10 pm by ink

#### RedDragonCats17

##### Re: MegaMan Zero help: Shield Boomerang
#9  December 31, 2018, 10:47:02 pm
I added the velset I had originally back in, and this is strange. When I throw the Shield Boomerang, as long as I'm standing, it shoots upwards, but when I jump, it drops down.

Look at this: https://streamable.com/v5z0y

#### ink

##### Re: MegaMan Zero help: Shield Boomerang
#10  December 31, 2018, 10:50:59 pm
• inktrebuchet

• Online
That is weird! Can you post your code again?

#### RedDragonCats17

##### Re: MegaMan Zero help: Shield Boomerang
#11  December 31, 2018, 10:54:14 pm
New code:

Spoiler, click to toggle visibilty

Old code (just in case):

Spoiler, click to toggle visibilty

#### ink

##### Re: MegaMan Zero help: Shield Boomerang
#12  December 31, 2018, 11:02:22 pm
• inktrebuchet

• Online
You didn’t make a positive and negative for y... that’s what I posted about last time.

Go ahead and give this a try. Be sure to read through it too, it might need a doublecheck or adjustments.
Code:
;-----------------------------------------------------------------
;Shield Boomerang
[Statedef 2700]
movetype = A
anim = 2700
sprpriority = 3

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

[State 0, VelSet]
type = VelSet
trigger1 = time = 0
x = 5

[State 0, VelSet]
type = VelSet
trigger1 = time = 30
x = -vel X

[State 0, VelSet]
type = VelSet
trigger1 = time > 30
Trigger1 = parent, pos y < pos y
y = parentdist y / (parentdist x / abs(vel x))

[State 0, VelSet]
type = VelSet
trigger1 = time > 30
Trigger1 = parent, pos y > pos y
y = -(parentdist y / (parentdist x / abs(vel x)))

[State 0, HitDef]
type = HitDef
trigger1 = time = 0
attr = SCA,SP        ;SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT
hitflag = MAF        ;HLAFD+-
guardflag = MA         ;HLA
animtype = medium          ;light,medium,hard,back,up,diagup
damage = 30,0
pausetime = 0 ,0
;sparkno = S3000
;guard.sparkno = S3100
;sparkxy = 0,0
hitsound = S5,0
guardsound = S6,0
ground.type = High      ;Low,Trip,None
air.type = High
ground.slidetime = 15
ground.hittime = 15
air.hittime = 15
ground.velocity = -5,0
air.velocity = -5,0

[State 1005, 3]
type = changestate
trigger1 = parentdist X = [-10,10]
value = 2701

-Edit-
You may have to use abs(parentdist y) instead of parentdist y.
Last Edit: December 31, 2018, 11:10:45 pm by ink

#### RedDragonCats17

##### Re: MegaMan Zero help: Shield Boomerang
#13  December 31, 2018, 11:20:36 pm
Okay, I've tried your code, and while it no long goes up, it slowly goes down. However, when I jump, it still drops like a stone.

Here: https://streamable.com/c6x2e

And here's the code just in case:

Spoiler, click to toggle visibilty

#### ink

##### Re: MegaMan Zero help: Shield Boomerang
#14  December 31, 2018, 11:23:51 pm
• inktrebuchet

• Online
You probably missed that edit to my last post... give this a try.

Code:
;-----------------------------------------------------------------
;Shield Boomerang
[Statedef 2700]
movetype = A
anim = 2700
sprpriority = 3

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

[State 0, VelSet]
type = VelSet
trigger1 = time = 0
x = 5

[State 0, VelSet]
type = VelSet
trigger1 = time = 30
x = -vel X

[State 0, VelSet]
type = VelSet
trigger1 = time > 30
Trigger1 = parent, pos y > pos y
y = abs(parentdist y) / (parentdist x / abs(vel x))

[State 0, VelSet]
type = VelSet
trigger1 = time > 30
Trigger1 = parent, pos y < pos y
y = -(abs(parentdist y) / (parentdist x / abs(vel x)))

[State 0, HitDef]
type = HitDef
trigger1 = time = 0
attr = SCA,SP        ;SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT
hitflag = MAF        ;HLAFD+-
guardflag = MA         ;HLA
animtype = medium          ;light,medium,hard,back,up,diagup
damage = 30,0
pausetime = 0 ,0
;sparkno = S3000
;guard.sparkno = S3100
;sparkxy = 0,0
hitsound = S5,0
guardsound = S6,0
ground.type = High      ;Low,Trip,None
air.type = High
ground.slidetime = 15
ground.hittime = 15
air.hittime = 15
ground.velocity = -5,0
air.velocity = -5,0

[State 1005, 3]
type = changestate
trigger1 = parentdist X = [-10,10]
value = 2701
Last Edit: December 31, 2018, 11:30:11 pm by ink

#### RedDragonCats17

##### Re: MegaMan Zero help: Shield Boomerang
#15  December 31, 2018, 11:31:07 pm
It follows Zero now. The only issue now is that it's still going down a little bit. How can I make it go straight?

#### ink

##### Re: MegaMan Zero help: Shield Boomerang
#16  December 31, 2018, 11:41:01 pm
• inktrebuchet

• Online
I’m guessing that’s because the y axis of the shield is on the shield, not the floor. If that’s true the the triggers parent,pos y < pos y will always trigger.

To fix this you just need to subtract the amount of pixels the shield is off the floor from the parent pos and dist.

Like this:
(20 is just my guess, you should know how far off the floor it is.)

Parent, pos y - 20 > pos y
And
Abs(parentdist y - 20)
Last Edit: December 31, 2018, 11:45:36 pm by ink

#### RedDragonCats17

##### Re: MegaMan Zero help: Shield Boomerang
#17  December 31, 2018, 11:46:18 pm
It goes straight now. Thanks.

I am planning on making another MegaMan Zero help thread, this time it's about a selectable weapons system. The Shield Boomerang is set on B as a test, now I want to use B to allow Zero to switch weapons.

#### ink

##### Re: MegaMan Zero help: Shield Boomerang
#18  December 31, 2018, 11:49:21 pm
• inktrebuchet

• Online
Any easier stuff you could work on first? Lol

Make sure you give it a solid try on your own first.

Sounds like a cool project, good luck!
Last Edit: December 31, 2018, 11:59:22 pm by ink

#### RedDragonCats17

##### Re: MegaMan Zero help: Shield Boomerang
#19  January 01, 2019, 12:06:13 am
Zero is almost done, really. A lot of the stuff I'm planning on adding to him is really complicated.

#### ink

##### Re: MegaMan Zero help: Shield Boomerang
#20  January 01, 2019, 12:12:11 am
• inktrebuchet

• Online
You may want to add these to those velsets we worked on.

For the top one:
Trigger1 = Vel y < 5.1

For the bottom one:
Trigger1 = vel y > -5.1

These will keep the shield from moving oddly fast if you try to do something like jump over it.You might want to experiment with that anyways.

You would need more changes to your code if you decide to do that though! Both the velset for x and the changestate would need edited.
Last Edit: January 01, 2019, 12:16:37 am by ink