Jump to content

Photo

My kind of Boomerang...


  • Please log in to reply
13 replies to this topic

#1 Koh

Koh

    Tamer Koh

  • Members
  • Real Name:Dominic
  • Location:Monsbaiya, Virginia

Posted 23 May 2011 - 11:53 AM

Just wondering, is this possible to do in ZC via scripts?

No, I'm not asking for someone to do it for me, I'm just asking the general question of ZC being able to pull off:
-A rotational boomerang path, similar to OoT.
-A "ghost" Effect of the boomerang to imitate extreme speed.

#2 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 23 May 2011 - 11:56 AM

I think it would be possible. The ghost image is definitely doable and fairly simple I would think. The motion would probably require some fun fancy math that I'm unfamiliar with but definitely doable. :3

#3 Radien

Radien

    Courage

  • Members
  • Real Name:Steve
  • Location:Oregon

Posted 23 May 2011 - 02:41 PM

Oooh, a realistic boomerang path... (well, minus the part about homing in on you) This would be a cool thing to see.

One thing I want to mention, though: it curves the wrong direction for being thrown with the left hand. A left-handed boomerang would actually curve to the right (clockwise).

#4 Koh

Koh

    Tamer Koh

  • Members
  • Real Name:Dominic
  • Location:Monsbaiya, Virginia

Posted 23 May 2011 - 03:28 PM

Lol, I fixed it XD. Well I haven't tried scripting since it was first released, so I might give it a whirl, but I'd have to learn the ropes first. Sure, I'm positive it's the exact same as any other programming language I've used, just with syntax differences, but that's just it; it's hard converting from name.variable to name->variable icon_razz.gif!

#5 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 23 May 2011 - 04:40 PM

I wouldn't mind converting the movement formula into ZScript. :3 The rest wouldn't be too hard to make; a global script to control the movement and stuff and the item script to trigger it. I imagine that if we use the boomerang LWeapon, we wouldn't need to set-up any sort of collision to stun enemies appropriately.

#6 Koh

Koh

    Tamer Koh

  • Members
  • Real Name:Dominic
  • Location:Monsbaiya, Virginia

Posted 23 May 2011 - 05:12 PM

Well as you know, I use Game Maker, and it has a built in direction variable, which ranges from 0-360. If you go "over" it just goes to it's <360 counterpart. Likewise for "under." That said, here's the code. Also, the directional wheel in GM is counterclockwise, meaning 0/360 is right, 90 is up, 180 is left, and 270 is down.
CODE

if timer{timer-=1;}
else{
    if degreesleft{degreesleft-=7.5;direction-=7.5;}
    else{
        direction=point_direction(x,y,objLink.x,objLink.y);
        if place_meeting(x,y,objLink) && objLink.z>=-8 && !objLink.fall{
            instance_destroy();
        }
    }
}

NOTES
-Timer is there, because the boomerang travels in a straight line during it's count. Once it hit's 0, the boomerang performs it's 180 and returns to Link.
-degreesleft starts at 180, and is used to make the boomerang do a 180, THEN return to Link.
-It should be noted that should the Boomerang come in contact with anything that it can hit, timer should be set to 0, and most likely degreesleft too.
-point_direction is a built in function that gets the direction from one point (x1,y1) to the other point (x2,y2) in degrees (0-360).
-The Boomerang's speed was 6, meaning it travels at 6 pixels per step.
-Link's Z is used for jumping. He should only catch the boomerang if he's close to the ground. Fall is whether or not he's falling in a hole. He can't catch it if he's plummeting.

#7 lucas92

lucas92

    Defender

  • Members

Posted 23 May 2011 - 05:20 PM

In Zelda Classic, the y axis is inversed, so 90 degrees is down and 270 degrees is up.

#8 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 23 May 2011 - 05:43 PM

I've got a fair bit of GML knowledge, so this shouldn't be too bad. Got a good idea on what most of the built-in functions do. icon_smile.gif

A fair bit in so far. I've got the skeleton laid out for what I plan to do. It may be a little messy when I finish it, but I can always go back and clean it up to make it better. :3 Though having almost all the code basically done and just adapting it into another language is obviously easier than writing it from the ground up. icon_razz.gif

#9 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 23 May 2011 - 07:01 PM

CODE

if timer{timer-=1;}
else{
    if degreesleft{degreesleft-=7.5;direction-=7.5;}
    else{
        direction=point_direction(x,y,objLink.x,objLink.y);
        if place_meeting(x,y,objLink) && objLink.z>=-8 && !objLink.fall{
            instance_destroy();
        }
    }
}


Let's run it through the gmtozc convertatron 4000 and see what it says. icon_razz.gif

CODE

if(timer>0)timer--;
else{
    if (degreesleft) {degreesleft-=7.5;direction-=7.5;} //define this
    else{
        direction=Arctan(ffc->x,ffc->y,Link->x,Link->y);
        if (Distance(x,y,Link->X,Link->Y) && !Link->Jump())
            is_alive=false;
        }
    }
}


Eh.. more or less...

Actually, now that I think about it, I'm pretty sure C-Dawg made a fairly decent boomerang script way back when. Don't know if there's still code for it though.


QUOTE(lucas92 @ May 23 2011, 03:20 PM) View Post

In Zelda Classic, the y axis is inversed, so 90 degrees is down and 270 degrees is up.


Actually GM is backwards. If you have positive y going upward then 90 degrees would be going down in GM (obviously wrong). //rant,.<>




#10 Koh

Koh

    Tamer Koh

  • Members
  • Real Name:Dominic
  • Location:Monsbaiya, Virginia

Posted 23 May 2011 - 08:45 PM

QUOTE(Gleeok @ May 23 2011, 08:01 PM) View Post

Let's run it through the gmtozc convertatron 4000 and see what it says. icon_razz.gif
LOL!
CODE

if(timer>0)timer--;
else{
    if (degreesleft) {degreesleft-=7.5;direction-=7.5;} //define this
    else{
        direction=Arctan(ffc->x,ffc->y,Link->x,Link->y);
        if (Distance(x,y,Link->X,Link->Y) && !Link->Jump())
            is_alive=false;
        }
    }
}


I did define that:
QUOTE(Koh @ May 23 2011, 06:12 PM) View Post

NOTES
-Timer is there, because the boomerang travels in a straight line during it's count. Once it hit's 0, the boomerang performs it's 180 and returns to Link.
-degreesleft starts at 180, and is used to make the boomerang do a 180, THEN return to Link.
-It should be noted that should the Boomerang come in contact with anything that it can hit, timer should be set to 0, and most likely degreesleft too.
-point_direction is a built in function that gets the direction from one point (x1,y1) to the other point (x2,y2) in degrees (0-360).
-The Boomerang's speed was 6, meaning it travels at 6 pixels per step.
-Link's Z is used for jumping. He should only catch the boomerang if he's close to the ground. Fall is whether or not he's falling in a hole. He can't catch it if he's plummeting.

Of course, instead of subtraction, you'll probably have to do addition, due to the inverted directional plane.

#11 Orithan

Orithan

    Studying Scientist - Commission from Silvixen

  • Members
  • Location:Australia

Posted 24 May 2011 - 02:24 AM

QUOTE(SpacemanDan @ May 24 2011, 07:40 AM) View Post
I wouldn't mind converting the movement formula into ZScript. :3 The rest wouldn't be too hard to make; a global script to control the movement and stuff and the item script to trigger it. I imagine that if we use the boomerang LWeapon, we wouldn't need to set-up any sort of collision to stun enemies appropriately.


Had to nitpick ya here; ZScript for some reason doesn't support Boomerang LWeapons, I presume to be because they have a set alograthim that makes them too clunky for ZScript. The Sword, Hammer, Hookshot and Wand LWeapons also don't work when created by ZScript. Your best bet is to use a Script# LWeapon instead icon_razz.gif.

@Koh: Deifantley doable. I've haven't played far enough into ZCG yet, but I've heard that Hero of Fire implemented the same type of Boomerang you mentioned and one that curves in the Z-axis (ala SMB3) into it too. Gleeok has his code going along nicley. Also, from fiddling with scripts, 0 degrees is up and 180 is down (or so I believe).



#12 SpacemanDan

SpacemanDan

  • Members
  • Location:Ontario, Canada

Posted 24 May 2011 - 09:00 AM

Wait, we don't have boomerang LWeapons? Dang, that kind of sucks; I always thought we did. XD Ah well, it's not a big deal. Making a scripted boomerang isn't hard to do either I imagine. Just a little collision detection and some changing of stun values. :3

#13 lucas92

lucas92

    Defender

  • Members

Posted 24 May 2011 - 03:01 PM

The graphics can all be done in the item editor. The only thing that needs scripting is the boomerang trajectory.

CODE
bool trown                 = false;
float angle             = 0;
float angle_counter     = 0;
float boomerang_speed     = 2;
float origin_x            = Link->X;
float origin_y            = Link->Y;
int clockwise = 1;

//this boolean to true would trow the boomerang
bool item_active;
ffc ghosted = Screen->CreateFFC();
while(true)
{
    if(item_active)
    {
        if(!trown)
        {
            angle_counter = 0;
            origin_x = Link->X;
            origin_y = Link->Y;
            
            if(Link->Dir == DIR_UP)
            {
                angle = 270;
                clockwise = Choose(0,1);
            }
            if(Link->Dir == DIR_LEFTUP)
            {
                angle = 235;
                clockwise = 0;
            }
            if(Link->Dir == DIR_RIGHTUP)
            {
                angle = 315;
                clockwise = 1;
            }
            if(Link->Dir == DIR_LEFT)
            {
                angle = 180;
                clockwise = Choose(0,1);
            }
            if(Link->Dir == DIR_RIGHT)
            {
                angle = 0;
                clockwise = Choose(0,1);
            }
            if(Link->Dir == DIR_DOWN)
            {
                angle = 90;
                clockwise = Choose(0,1);
            }
            if(Link->Dir == DIR_LEFTDOWN)
            {
                angle = 135;
                clockwise = 1;
            }
            if(Link->Dir == DIR_RIGHTDOWN)
            {
                angle = 45;
                clockwise = 0;
            }
            trown = true;
        }
        if(clockwise)
            angle_counter++;
        else
            angle_counter--;
        if(Abs(angle_counter) > 180)
        {
            ghosted->X += boomerang_speed * Cos(Angle(ghosted->X,ghosted->Y,Link->X,Link->Y));
            ghosted->Y += boomerang_speed * -Sin(Angle(ghosted->X,ghosted->Y,Link->X,Link->Y));
            if(LinkCollision(ghosted))
            {
                item_active = false;
                trown = false;
            }
                
        }
        else
        {
            ghosted->X += boomerang_speed * Cos(angle + angle_counter) + origin_x;
            ghosted->Y += boomerang_speed * -Sin(angle + angle_counter) + origin_y;
        }
    }
    
    Waitframe();
}


This code put in a global script with the lweapon copying the coordinates of the ghosted ffc would do it...


#14 Gleeok

Gleeok

    It's dangerous to dough alone, bake this.

  • Members
  • Real Name:Pillsbury
  • Location:Magical Land of Dough

Posted 24 May 2011 - 04:28 PM

Isn't there a function in std.zh that converts angles to directions and vice-versa?

..hmm. There indeed is an AngleDir8(float), but not a Dir to angle function.. If someone wants to write one I'll go ahead and add it.

edit: I just noticed that either WrapDegrees() should probably be in the range -180 - 180 also. I don't know if that will break any scripts or not.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users