The Dink Network

Reply to Lantern script in conjunction with a spell

If you don't have an account, just leave the password field blank.
Username:
Password:
Subject:
Antispam: Enter Dink Smallwood's last name (surname) below.
Formatting: :) :( ;( :P ;) :D >( : :s :O evil cat blood
Bold font Italic font hyperlink Code tags
Message:
 
 
March 14th 2011, 04:12 PM
boncag.gif
JugglingDink
Peasant He/Him United Kingdom
Streetfish 
(Yes, this is another one of my massive and complicated questions again )

So in my DMOD there's one of those bits you get where it's all dark with a small ring of light around the player. I'm using lantern.c from CAST AWAKENING: INITIATION. Now, I'm trying to make a spell which enlarges the circle of light around Dink for a small period of time. I've made two scripts, but I don't seem to be able to get them working.
It uses the global variables &light and &lightlp. The spell's script is this:
//item everlasting flame

//THIS IS THE IMPORTANT BIT
void use( void )
{
playsound(17, 8000, 0, 1, 0);
if (&player_map == 376)
{
dark:
say("This won't do anything if it isn't dark!", 1);
return;
}

if (&player_map == 408)
{
goto dark;
}

//If we're here, the player's in one of the dark areas. So let's light it up a bit more!
if (&light == 1)
{
say("It's already light enough!", 1);
return;
}

&light = 1;
int &random;
&random = random(4, 1);

if (&random == 1)
{
say("Let's shed some light on the situation!", 1);
}

if (&random == 2)
{
say("This place should really lighten up...", 1);
}

if (&random == 3)
{
say("I say, let there be light!", 1);
}

if (&random == 4)
{
say("This is truly solar-powered!", 1);
}

}
//END OF THE IMPORTANT BIT

void disarm(void)
{
&magic_cost = 0;
kill_this_task();
}

void arm(void)
{
Debug("Preloading flame");
&magic_cost = 3000;
}

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

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


I just copy/pasted the fireball script, then edited all the various bits. Next, this is my lantern script (I've edited it a bit as well)

//Lantern

void main(void)
{
int &temp = sp_x(1,-1);
if (&temp >= 620)
{
sp_x(¤t_sprite,20);
goto skipx;
}
if (&temp <= 20)
{
sp_x(¤t_sprite,620);
goto skipx;
}
sp_x(¤t_sprite,&temp);
skipx:

&temp = sp_y(1,-1);
if (&temp >= 400)
{
sp_y(¤t_sprite,0);
goto skipy;
}
if (&temp <= 0)
{
sp_y(¤t_sprite,400);
goto skipy;
}
sp_y(¤t_sprite,&temp);
skipy:

sp_brain(¤t_sprite,15);
sp_pframe(¤t_sprite,1);
sp_brain_parm(¤t_sprite,1);
sp_que(¤t_sprite,500);
sp_nohit(¤t_sprite,1);

//THIS IS THE IMPORTANT BIT
if (&light == 1)
{
loop1:
wait(100);
if (&lightlp == 50)
{
&lightlp = 0;
&light = 0;
goto loop2;
}

&temp = random(15, 200);
sp_size(¤t_sprite, &temp);
&lightlp += 1;
goto loop1;
}

if (&light == 0)
{
loop2:
wait(100);

if (&light == 1)
{
goto loop1;
}

&temp = random(15, 100);
sp_size(¤t_sprite, &temp);
goto loop2;
}

//END OF IMPORTANT BIT
}


As far as I can tell, I'm getting two errors, which are possibly related...
The first issue is that in-game when I press SHIFT, it calls the magic script loads of times (It plays the sound lots of times, and Dink says that the spell is already running).
The other issue is in the lantern script. For some reason it doesn't resize the dark/light graphics. Well, it does, but not properly, because it flickers back and forth between size 100 and size 200, which makes the whole thing look really buggy and just generally suck.

I've rewritten this about 10 times, but I just can't manage to fix either of these bugs/glitches. So... Any ideas? I swear, each time I ask a question it's even more complicated than the last

EDIT: Hmm... For some reason it's replaced all the &current_sprite variables with a little sun . It's not like that in the actual scripts though