The Dink Network

projectile script

October 29th 2005, 01:23 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
can someone make me a script for a projectile that sticks to whatever it hits and blows up (causing damage)when you press the button again, preferably modifying the one sequence axe script...
October 29th 2005, 02:34 PM
fairy.gif
Glennglenn
Peasant He/Him Norway
GlennGlenn doesn't want a custom title. 
Have you tried TheProphets "Guided Projectile"?
October 29th 2005, 03:13 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
when i said stick, i didn't mean like a homing missile, i meant like literally sticking, like an arrow when shot at something with a hardness
October 29th 2005, 04:21 PM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
That'd be very difficult to make, and I think that anyone who's capable of making such a script would prefer to use it for his own purposes.

Anyway, I'm not going to do it now, too much work. I'd suggest looking at the possibilities of using brain 15...
October 30th 2005, 12:45 PM
spike.gif
kikki
Peasant He/Him United Kingdom
This place has changed :) 
I'm sure using the original arrows scripts would help..
October 30th 2005, 01:17 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
i was thinking that i could modify the boomerang script from that bangerang by joshriot for the remote explosion, but my head hurts and i'm just confusing myself...and as for the sticking part, i'm pretty sure i could modify the dam-a1 script, but i can't do anything like this...darn headaches....

add: could someone please help out, it isn't for a personal dmod, it is going to be part of a dev file for a ninja...
October 30th 2005, 03:49 PM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
I don't think it would really make a difference that it is for a dev-file or for a DMOD...

But I might look into it... It kinda depends... I have got some tests for school tomorrow, but after that I might have some spare time...

EDIT: Looking a few posts up I suddenly remembered how inconstant I am...
October 30th 2005, 05:40 PM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
I have some ideas for a script, but they work only if you want it as an item (not-magic) and you're also in bad luck if you want to let it stick to moving things, but maybe you can use a shadow brain for that. Dummy code:

void main( void )
{
//This is the missile
sp_strength(&current_sprite, 0);
}

void damage( void )
{
//hooray, we hit something.
sp_speed(&current_sprite, 0);
sp_brain(&current_sprite, 0);
//I don't know if it works, but you might want to set this brain to a shadow brain, with a brain parm of the missile target.
loop:
wait(10);
wait_for_button();
if (&result == &whatever_key_the_ctrl_is)
{
//explosion code, probably copied from a bomb script
}
goto loop;
}

LATE ADDITION: You can copy the fireball script (item script, not missile script) for this, but you must fix it so that it remembers if there's already a missile out there. Probably by &sticky = create_sprite(#missile parms); and making &sticky a global. Then maybe using the sp_gold trick to determine on other screens if there's a missile of the sticky type in there. Anyway, I'm out, maybe some other author can help you
October 30th 2005, 05:58 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
the projectile (thrown by the player - base hit for throw is 320) is a ninja star(sequence 88). after being thrown by the player, it should stick to whatever it hits (whether it moves or not) and should be detonated by pressing 'ctrl' again. upon detonation, it shall blow up (i was thinking using the fireball explosion) causing damage to the target.

i was thinking the detonation could be used as part of the 'use' command of the item, by changing a variable after it is thrown (sounds simple enough) but a problem comes up when the ninja star goes off the screen, maybe there is a way to switch the variable back when it goes off of the screen... ughhhh, thats all i can think of right now..
November 2nd 2005, 03:52 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
@metatarasal
so, are you gonna do it?
November 3rd 2005, 08:36 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
You push me into it don't you?
November 5th 2005, 09:31 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
Hey, I looked into it, and I just took the flying axe script and modified it. I was suprised how easy it actually is (and how much bugs it gave when I just started it...)

This is the item's script:

void use(void)
{
if (&oldmap != &player_map)
{
&oldmap = &player_map;
goto continue; //This is to make sure Dink can throw his nina star when he enters a screen.
}
if (sp_active(&missl,-1) == 1)
{
int &vari = sp_brain(&missl,-1);
if (&vari != 15)
{
goto end; //If the nina star is still in mid-air ctrl shouldn't do anything...
}
sp_speed(&missl,0);
int &temp = sp_brain_parm(&missl,-1);
sp_brain(&missl,7);
sp_seq(&missl,167);
playsound(6,22050,0,0,0);
sp_hurt(&temp,&strength); //This is the amount of damage done to the enemy, there are other ways to determine the amount of damage too...
goto end;
//The previous part is to blow up the star when ctrl is pressed and the nina star is stuck into a monster.
}
continue:
//Here starts the standard axe throwing procedure: (With 88 being the sequence)
&mydir = sp_dir(1, -1);

if (sp_dir(1, -1) == 1)
sp_dir(1, 4);
if (sp_dir(1, -1) == 3)
sp_dir(1, 6);
if (sp_dir(1, -1) == 7)
sp_dir(1, 4);
if (sp_dir(1, -1) == 9)
sp_dir(1, 6);

playsound(8, 8000,0,0,0);

&basehit = sp_dir(1, -1);
&basehit += 320;

sp_seq(1, &basehit);
sp_frame(1, 1);
sp_kill_wait(1);
sp_nocontrol(1, 1);
&mholdx = sp_x(1, -1);
&mholdy = sp_y(1, -1);
freeze(1);

wait(100);

if (&mydir == 1)
{
&mholdx -= 30;
&missl = create_sprite(&mholdx, &mholdy, 11, 88, 1);
sp_seq(&missl, 88);
sp_mx(&missl, -6);
sp_my(&missl, +2);
}
if (&mydir == 4)
{
&mholdx -= 30;
&missl = create_sprite(&mholdx, &mholdy, 11, 88, 1);
sp_seq(&missl, 88);
sp_dir(&missl, 4);
}
if (&mydir == 6)
{
&mholdx += 30;
&missl = create_sprite(&mholdx, &mholdy, 11, 88, 1);
sp_seq(&missl, 88);
sp_dir(&missl, 6);
}
if (&mydir == 3)
{
&mholdx += 30;
&missl = create_sprite(&mholdx, &mholdy, 11, 88, 1);
sp_seq(&missl, 88);
sp_mx(&missl, +6);
sp_my(&missl, +2);
}
if (&mydir == 2)
{
&missl = create_sprite(&mholdx, &mholdy, 11, 88, 1);
sp_seq(&missl, 88);
sp_dir(&missl, 2);
}
if (&mydir == 7)
{
&mholdx -= 30;
&missl = create_sprite(&mholdx, &mholdy, 11, 88, 1);
sp_seq(&missl, 88);
sp_mx(&missl, -6);
sp_my(&missl, -2);
}
if (&mydir == 8)
{
&missl = create_sprite(&mholdx, &mholdy, 11, 88, 1);
sp_seq(&missl, 88);
sp_dir(&missl, 8);
}
if (&mydir == 9)
{
&mholdx += 30;
&missl = create_sprite(&mholdx, &mholdy, 11, 88, 1);
sp_seq(&missl, 88);
sp_mx(&missl, +6);
sp_my(&missl, -2);
}

sp_timing(&missl, 0);
sp_speed(&missl, 6);

sp_range(&missl, 10);
sp_flying(&missl, 1);
sp_attack_hit_sound(&missl, 48);
sp_attack_hit_sound_speed(&missl, 13000);
&mshadow = create_sprite(&mholdx, &mholdy, 15, 432, 3);
sp_brain_parm(&mshadow,&missl);
sp_que(&mshadow, -500);

sp_brain_parm(&missl, 1);
sp_brain_parm2(&missl, &mshadow);

//I gave the missile a script called "ninastar":
sp_script(&missl,"ninastar");
unfreeze(1);
end:
}
void disarm(void)
{
&hashoot = 0;
debug("nina star no longer armed");
kill_this_task();
}
void arm(void)
{
init("load_sequence_now graphics\dink\walk\ds-w1- 71 43 38 72 -14 -9 14 9");
init("load_sequence_now graphics\dink\walk\ds-w2- 72 43 37 69 -13 -9 13 9");
init("load_sequence_now graphics\dink\walk\ds-w3- 73 43 38 72 -14 -9 14 9");
init("load_sequence_now graphics\dink\walk\ds-w4- 74 43 38 72 -12 -9 12 9");

init("load_sequence_now graphics\dink\walk\ds-w6- 76 43 38 72 -13 -9 13 9");
init("load_sequence_now graphics\dink\walk\ds-w7- 77 43 38 72 -12 -10 12 10");
init("load_sequence_now graphics\dink\walk\ds-w8- 78 43 37 69 -13 -9 13 9");
init("load_sequence_now graphics\dink\walk\ds-w9- 79 43 38 72 -14 -9 14 9");

init("load_sequence_now graphics\dink\idle\ds-i2- 12 250 33 70 -12 -9 12 9");
init("load_sequence_now graphics\dink\idle\ds-i4- 14 250 30 71 -11 -9 11 9");
init("load_sequence_now graphics\dink\idle\ds-i6- 16 250 36 70 -11 -9 11 9");
init("load_sequence_now graphics\dink\idle\ds-i8- 18 250 32 68 -12 -9 12 9");

init("load_sequence_now graphics\dink\hit\normal\ds-h2- 102 75 60 72 -19 -9 19 9");
init("load_sequence_now graphics\dink\hit\normal\ds-h4- 104 75 61 73 -19 -10 19 10");
init("load_sequence_now graphics\dink\hit\normal\ds-h6- 106 75 58 71 -18 -10 18 10");
init("load_sequence_now graphics\dink\hit\normal\ds-h8- 108 75 61 71 -19 -10 19 10");
debug("nina star armed");
//The variables needed in the script (No globals necessary )
int &missl
int &basehit;
int &status = 0;
int &oldmap = &player_map;
int &mholdx;
int &mholdy;
int &mydir;
int &mshadow;
}
void pickup(void)
{
debug("nina star now owned by player");
kill_this_task();
}
void drop(void)
{
debug("nina star dropped");
kill_this_task();
}

Then the script ninastar is:

void damage(void)
{
sp_brain(¤t_sprite,15);
sp_brain_parm(¤t_sprite,&missile_target);
}

I really wonder why I put my time into this, but this is the script. (not neccessarily bug-free)
November 5th 2005, 11:40 AM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
its ummm...not sticking....
November 5th 2005, 01:52 PM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
Are you sure you got the script "ninastar" is attached to the missile correctly? That's what would cause it not to stick properly...

(remember that the script "ninastar" is a different procedure from the script of the item itself...)
November 5th 2005, 03:12 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
yes, i am...did you test it to make sure it worked?
November 6th 2005, 01:59 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
Yep, it worked perfectly fine with me... (exept I don't have a seq 88 so the item is invisible, but it sticks...)

Can't see what could go wrong... Or haven't you replaced ¤t_sprite with & current_sprite? (without the spacebar)

EDIT: Perhaps you should also remove my comments.
November 6th 2005, 02:48 PM
old.gif
I tried it, it's sticking. But not on moving creatures and it doesn't explode when I press CTRL

Edit: I forgot to put & in front of current_sprite It works for me now
November 12th 2005, 02:38 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
So rabidwolf9, got it to work too?
November 12th 2005, 11:52 AM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
haha, i'll try again. i've been grounded
November 12th 2005, 12:00 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
tested on pillbug and tree...it sticks, still spinning though. didn't do any damage to the pillbug. sticks above the pillbug....
November 12th 2005, 03:11 PM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
Yeah you're right, it doesn't do any damage. Some way or another I replaced hurt(&temp,&strength); with sp_hurt(&temp,&strength); which causes this problem.

And if you don't want it to spin when it hits something just add sp_seq(&current_sprite,0); in the script ninastar. (I haven't tested this though...)
November 17th 2005, 10:39 AM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
okay, it stopped spinning, but still no damage...
November 17th 2005, 06:30 PM
burntree.gif
Striker
Noble She/Her United States
Daniel, there are clowns. 
I believe I can fix this problem. The projectile isn't doing any damage because the wrong command is being used.

sp_hurt(&temp, &strength) won't work because you're telling the game to injure the returned brain parameter. Notice

int &temp = sp_brain_parm(&missl,-1);

Oops.

But even with that mistake, sp_hurt() will not work. What you want is much, much simpler...

Just under
sp_timing(&missl, 0);
sp_speed(&missl, 6);

merely add
sp_strength(&missl, &strength);
Because the ninja star has a missle brain, anything it touches will be dealt that damage once it hits when you use that command.
November 18th 2005, 01:38 AM
slimeg.gif
metatarasal
Bard He/Him Netherlands
I object 
Hmm... It worked with me... But I only tested it on one particular screen, (could be just a coincidence it worked). So yeah, your fix is probably better.
November 18th 2005, 07:48 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
it damages the target, when it connects, but not when it explodes, which was the whole point of the weapon
November 19th 2005, 12:39 AM
burntree.gif
Striker
Noble She/Her United States
Daniel, there are clowns. 
Just create an explosion sprite in the same spot as the old one when you push the button. And be sure to give it something like sp_strength(&example, &explodestrength) as well as brain 17, so that sprite will kill itself when the explosion is finished.
November 19th 2005, 10:11 AM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
okay, i got it working now
November 21st 2005, 07:34 AM
dinkdead.gif
millimeter
Peasant He/Him Canada
Millimeter is Wee-Lamm, Recording Artist. :-) 
Just a comment,

At continue: you redirect diagonal throws but you still check for them after freeze(1);

mm
November 21st 2005, 10:39 AM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
oh well, it works so i'm done screwing with it
November 21st 2005, 12:35 PM
dinkdead.gif
millimeter
Peasant He/Him Canada
Millimeter is Wee-Lamm, Recording Artist. :-) 
Perhaps, but what about performance issues?
November 21st 2005, 12:40 PM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
It's indeed true that some parts of the script will never be executed.. but on the other hand, it only has to check values of a four integers.. the performance increase by removing then is very very minimal (aka not noticable). On the other hand, yes; strictly you'd need to remove them as it would increase the readability of the script(most important thing) and filesize but that's less of an issue.

Edit: now that I think of it, it could cause a bug because it uses the value of this line:

&mydir = sp_dir(1, -1);

to do the code depending on Dink's direction yet his actual direction changes that:

if (sp_dir(1, -1) == 1)
sp_dir(1, 4);
if (sp_dir(1, -1) == 3)
sp_dir(1, 6);
if (sp_dir(1, -1) == 7)
sp_dir(1, 4);
if (sp_dir(1, -1) == 9)
sp_dir(1, 6);

Of course, it could be that you can get away with it, I haven't checked the script in detail for all if-statements

Edit II: it doesn't.