The Dink Network

Script Problem?

July 5th 2008, 07:33 AM
boncag.gif
Znex
Peasant Male Australia
Oh hey. 
Hey guys. I've been noticing that one of my scripts doesn't appear to be working. This also seems to be happening with another script as one of the knights I've got can't even attack with its axe and instead I have to run into it. Could someone help? Try this one:

//item fists

void use(void)
{
//disallow diagonal punches

if (sp_dir(1, -1) == 1) sp_dir(1, 2);
if (sp_dir(1, -1) == 3) sp_dir(1, 2);
if (sp_dir(1, -1) == 7) sp_dir(1, 8);
if (sp_dir(1, -1) == 9) sp_dir(1, 8);

&basehit = sp_dir(1, -1);
&basehit += 540; //100 is the 'base' for the hit animations, we just add
//the direction
sp_seq(1, &basehit);
sp_frame(1, 1); //reset seq to 1st frame
sp_kill_wait(1); //make sure dink will punch right away
sp_nocontrol(1, 1); //dink can't move until anim is done!
wait(1);
playsound(15,8000,0,0,0);

}

void disarm(void)
{
debug("Killed fists");

kill_this_task();
}

void arm(void)
{

load_sequence graphics\foes\bonca\attack\f03a2- 544 75 70 65 -21 -11 21 14
load_sequence graphics\foes\bonca\attack\f03a4- 548 75 70 64 -32 -8 32 17
load_sequence graphics\foes\bonca\attack\f03a6- 542 75 65 66 -24 -12 24 16
load_sequence graphics\foes\bonca\attack\f03a8- 546 75 68 65 -21 -11 21 11
int &basehit;

debug("fists armed");
}

int &basehit;
}

void pickup(void)
{
Debug("Player now owns this item.");
kill_this_task();
}

void drop(void)
{
Debug("Item dropped.");
kill_this_task();
}

Hmmm...?
July 5th 2008, 08:45 AM
slimeg.gif
metatarasal
Bard Male Netherlands
I object 
You have 5 opening brackets and 6 closing brackets, so something is wrong there. Remove these lines from the script:
int &basehit;
}

Other than that I can't see anything wrong right now.
July 5th 2008, 06:51 PM
boncag.gif
Znex
Peasant Male Australia
Oh hey. 
It's still not working. In that I mean it's not delivering any damage for some reason. The normal Dink game works, but I can't imagine what's wrong with this...
July 5th 2008, 07:38 PM
spike.gif
scratcher
Bard Male Finland bloop
cigarette bonca 
Why, for the love of DinkC, would you think that part is necessary? If removing those lines doesn't work, try putting the sp_dir(); commands on separate lines.

if (sp_dir(1,-1) == 1)
sp_dir(1,2);
if (sp_dir(1,-1) == 3)
sp_dir(1,2);
if (sp_dir(1,-1) == 7)
sp_dir(1,8);
if (sp_dir(1,-1) == 9)
sp_dir(1,8);

Also remove the load_sequence(); lines, unless you actually have other graphics that you want to replace when this item is armed. (Even then, you should use init(); )
July 5th 2008, 07:50 PM
boncag.gif
Znex
Peasant Male Australia
Oh hey. 
Hey, I just copied this script from another Dmod. Geez. <_<

And besides, how is that supposed to make it do damage. The animations are going just fine, it's just the lack of damage that I'm worried about.
July 5th 2008, 08:08 PM
spike.gif
scratcher
Bard Male Finland bloop
cigarette bonca 
I was replying to your earlier post that you edited out. (Admittedly before I posted, but I couldn't be arsed to change mine )

The set_sprite_info lines might be related to it not doing damage, if you look at dink.ini there are several set_frame_specials after attack sequences- They make the animation able to hit other sprites.

Using set_sprite_info in a script might somehow interfere with this, I've never tried but I always assumed the init(); command served some purpose. In your script though, those lines propably aren't needed at all, so you can just delete them.
July 5th 2008, 09:39 PM
dinkdead.gif
Are you sure it's not something else you've overlooked, like the strength or defense of Dink or the enemies?

Those load_sequence lines probably aren't doing anything, like Scratcher said, you need to use init(). Also, set_sprite_info only works in the ini, even with init()

Edit: I just tested your script, minus what Metatarasal said to take out, and it works. Dink turns into a bonca when hitting (so evidently load_sequence does work without init() ) but he does hit and deal damage.
July 5th 2008, 10:13 PM
boncag.gif
Znex
Peasant Male Australia
Oh hey. 
Hmmm, must have something having to do with either my computer, my Dink or just my Dmod. It(the Dmod) got messed up a while back and I thought it was just the computer itself. I'll probably have to restart the whole map thing again...

EDIT: Sparrowhawk: He's actually supposed to turn into a bonca. It's for my Dmod(see profile ^_^).
July 6th 2008, 02:29 AM
spike.gif
scratcher
Bard Male Finland bloop
cigarette bonca 
Also, set_sprite_info only works in the ini, even with init()

Doh, I seem to have confused load_sequence with set_sprite_info in my second post.

Dink turns into a bonca when hitting (so evidently load_sequence does work without init() )

Doesn't necessarily mean it works, as there is no graphic that gets replaced- 540 is bonca attack by default...

Hmmm, must have something having to do with either my computer, my Dink or just my Dmod. It(the Dmod) got messed up a while back and I thought it was just the computer itself. I'll probably have to restart the whole map thing again...

Perhaps you might have somehow accidentally deleted the lines needed to make the attack hit? In dink.ini, look for

set_frame_special 544 5 1
set_frame_special 548 5 1
set_frame_special 542 5 1
set_frame_special 546 5 1
July 6th 2008, 02:47 AM
boncag.gif
Znex
Peasant Male Australia
Oh hey. 
Hmmm, they're not there. Maybe you're right. And if that's so, I bet none of the other ones are there if the knight couldn't attack with his axe thingy. Hmmm...

EDIT: I was right. I've just replaced them. I'll go try them as soon as I find that tutorial thing having to do with adding new things into the ini.

EDIT2: HAH HAH! All the hardness is back! Thank you so much, Scratcher, for your idea! Whoopee!
July 6th 2008, 04:19 AM
dinkdead.gif
"Doesn't necessarily mean it works, as there is no graphic that gets replaced- 540 is bonca attack by default..."

Oh yeah, I didn't notice the &basehit bit of it