projectile script
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...
Have you tried TheProphets "Guided Projectile"?
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
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...
Anyway, I'm not going to do it now, too much work. I'd suggest looking at the possibilities of using brain 15...
I'm sure using the original arrows scripts would help..
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...
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...
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...
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...
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(¤t_sprite, 0);
}
void damage( void )
{
//hooray, we hit something.
sp_speed(¤t_sprite, 0);
sp_brain(¤t_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
void main( void )
{
//This is the missile
sp_strength(¤t_sprite, 0);
}
void damage( void )
{
//hooray, we hit something.
sp_speed(¤t_sprite, 0);
sp_brain(¤t_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
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..
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..
@metatarasal
so, are you gonna do it?
so, are you gonna do it?
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)
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)
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...)
(remember that the script "ninastar" is a different procedure from the script of the item itself...)
yes, i am...did you test it to make sure it worked?
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.
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.
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
Edit: I forgot to put & in front of current_sprite It works for me now
haha, i'll try again. i've been grounded
tested on pillbug and tree...it sticks, still spinning though. didn't do any damage to the pillbug. sticks above the pillbug....
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(¤t_sprite,0); in the script ninastar. (I haven't tested this though...)
And if you don't want it to spin when it hits something just add sp_seq(¤t_sprite,0); in the script ninastar. (I haven't tested this though...)
okay, it stopped spinning, but still no damage...
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.
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.
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.
it damages the target, when it connects, but not when it explodes, which was the whole point of the weapon
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.
Just a comment,
At continue: you redirect diagonal throws but you still check for them after freeze(1);
mm
At continue: you redirect diagonal throws but you still check for them after freeze(1);
mm
oh well, it works so i'm done screwing with it
Perhaps, but what about performance issues?
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.
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.