Lantern script in conjunction with a spell
(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:
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)
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 ¤t_sprite variables with a little sun
. It's not like that in the actual scripts though

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?


EDIT: Hmm... For some reason it's replaced all the ¤t_sprite variables with a little sun

You need to set &magic_level = 0 in the use proc. It should be followed by draw_status(). This will reset his magic charge which is probably the cause for the repetition.
The size problem is a matter of brain. Shadow brains cannot be resized AFAIK.
The size problem is a matter of brain. Shadow brains cannot be resized AFAIK.
Thanks for the info... I'm gonna try a couple more things, because I didn't know that about shadow brains...
EDIT: Does anyone know if you can change the frame of a shadow brain? Because if you can, I could make an identical frame, but twice as big, and toggle that on and off instead of resizing.
EDIT: Does anyone know if you can change the frame of a shadow brain? Because if you can, I could make an identical frame, but twice as big, and toggle that on and off instead of resizing.
Yeah it'll work, just use sp_pframe(). I've done something similar recently and it turned fine as far as I can tell.
Ok, I've got the lantern side of things working now, but the magic still repeats itself. I thought &magic_cost was the number some timer had to reach before he could cast it, so surely setting it to 0 would just mean he could cast it whenever. I tried it anyway, and it doesn't work. Is there a variable for whatever the timer is that counts up, so I could reset that?
Oh derr on my part, its &magic_level. That just makes sense
