The Dink Network

Odd problems...

August 1st 2003, 06:41 AM
custom_odd.gif
Couldn't sleep so decided to work on a new spell I thought of trying to sleep. Go me.

I ran into some bizarre problems, tho. The most bizarre being that I cannot create a brain 6 sprite. I don't know what the deal is. I use normal, easy code:

create_sprite(250,250,6,98,1);

and it creates the write sprite, in the write place... but.. it does not loop the seq. I placed the same sprite in the editor, and it loops the seq. I used a var to check the brain of the sprite I created, and it turned up 6.

I strained myself forever on this, and I know it's something simple, because I know I've done this before. It's just weird. I don't know, tell me how stupid I am or whatever now.

And on another note entirely, is there any way to use stop_entire_game or whatever that command is in any way other than to stick it before a choice menu and have it stop again after the choice menu? Because that doesn't help me too much, really. I want to be able to stop the game, not have any choices, and tell it when to start again. Any suggestions?
August 1st 2003, 06:43 AM
spike.gif
Maybe you forgot to give the sprite some speed.
August 1st 2003, 06:45 AM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
I'm pretty sure you have to use sp_seq to make it loop, like this:

int &temp = create_sprite(250,250,6,98,1);
sp_seq(&temp,98);
August 1st 2003, 06:46 AM
spike.gif
Oh yeah, what redink1 said. That should solve it.
August 1st 2003, 11:38 AM
wizardg.gif
Paul
Peasant He/Him United States
 
Right, the seq, apperently it's taken care of automatically if you place it in the editor, but not if you create it.
August 1st 2003, 01:03 PM
custom_odd.gif
Righto, fixed it, thanks. Odd little quirk there..

Another question, I'm trying to make a way to select between all the enemies on the screen, using the brain as a base for which sprites, but the problem is, there's no way to select the next sprite with a certain brain.. only the first, or a random.. So has anyone developed a way to cycle through all sprites of a certain brain or brains? And I still have no idea how I'm going to freeze the game without a choice selection...

Should I just wait for those kind of features to be added to the engine?
August 1st 2003, 01:18 PM
peasantmb.gif
If I didn't misunderstand your question, it might be with a:
if(get_sprite_with_this_brain(9, &sprite) == 0)
or something like this?

Freeze the entire game without choice command?
Ummmm... I haven't idea on how either.
August 1st 2003, 02:34 PM
custom_simon.gif
SimonK
Peasant He/Him Australia
 
Ted Shutes wrote a little sub-routine which lets you count brains... it's in the dinkc.txt revised version. Basically it finds all the sprites with a certain brain, replaces them with another brain (non functional number like 99) until you've located all brains on the screen with the certain brain, then replaces all brain 99 with the certain brain number again. It doesn't use any wait() commands so it is pretty fast. I used a modified version of this code in PQ, both to count firewood trees that had been put out, and to detect brain 9 creatures when using certain magic and with Skard in attack mode.
August 1st 2003, 09:18 PM
custom_odd.gif
Ah, sweet, thanks simonk, I'll look into it.

And just out of curiosity, in PQ, when you hit 'S', does it freeze the game or do anything like that?

Have you released graphics or source on PQ yet? I'd really like to look at some of it.
August 1st 2003, 11:06 PM
custom_odd.gif
Great, thanks to everyone who helped me, I got this script working real smooth very quickly. What it does:

You cast the spell, it freezes you and all sprites of brain 9 and 10

EDIT: just added brain 16, won't bother with 3 and 4

An arrow appears above the first one. When you hit right or up, it goes to the next, and left or down goes to the previous. It cycles between all the enemies, and waits for you to hit shift or space to cancel (unfreezes all enemies and you, but does not cost mana) or hit ctrl to view it's stats. A choice selector comes up with all the enemy stats (hp, str, def, touch damage etc) in the title, and when you hit ctrl it goes on, unfreezes everyone and drains one mana.

It all works, except one minor thing. When I put this in:

&sp-touch = sp_touch_damage(&sprite, -1);

It always returns -1. All other stats turn up right, but touch damage is -1. Can anyone think of a good reason? I'll throw up the script for you guys to evaluate, too.

//magic scan

void use( void )
{

if (&mana_current < 1)
{
say("Not enough mana.", 1);
return;
}

int &count9 = 100;
int &count10 = 200;
int &count16 = 300;
int &total9;
int &total10;
int &total16;
int &sprite;
int &x;
int &y;
int &arrow;

&total9 = get_sprite_with_this_brain(9, 0);
if (&total9 == 0)
{
&total10 = get_sprite_with_this_brain(10, 0);
if (&total10 == 0)
{
&total16 = get_sprite_with_this_brain(16, 0);
if (&total16 == 0)goto none;
}
}
freeze(1);

loop9:
&total9 = get_sprite_with_this_brain(9, 0);
if (&total9 > 0)
{
&count9 += 1;
sp_brain(&total9, &count9);
freeze(&total9);
goto loop9;
}

loop10:
&total10 = get_sprite_with_this_brain(10, 0);
if (&total10 > 0)
{
&count10 += 1;
sp_brain(&total10, &count10);
freeze(&total10);
goto loop10;
}

loop16:
&total16 = get_sprite_with_this_brain(16, 0);
if (&total16 > 0)
{
&count16 += 1;
sp_brain(&total16, &count16);
freeze(&total16);
goto loop10;
}

&total9 = &count9;
&total10 = &count10;
&total16 = &count16;
//creating arrow off screen
&arrow = create_sprite(-100, -100, 6, 98, 1);
sp_que(&arrow, 20000);
sp_nohit(&arrow, 1);
sp_seq(&arrow, 98);

checkloop:
if (&count9 > 100)
{
&sprite = get_sprite_with_this_brain(&count9, 0);
&x = sp_x(&sprite, -1);
&y = sp_y(&sprite, -1);
&y -= 60;
&x += 5;
sp_x(&arrow, &x);
sp_y(&arrow, &y);
goto cont1;
}

if (&count10 > 200)
{
&sprite = get_sprite_with_this_brain(&count10, 0);
&x = sp_x(&sprite, -1);
&y = sp_y(&sprite, -1);
&y -= 60;
&x += 5;
sp_x(&arrow, &x);
sp_y(&arrow, &y);
goto cont1;
}

if (&count16 > 300)
{
&sprite = get_sprite_with_this_brain(&count16, 0);
&x = sp_x(&sprite, -1);
&y = sp_y(&sprite, -1);
&y -= 60;
&x += 5;
sp_x(&arrow, &x);
sp_y(&arrow, &y);
goto cont1;
}
cont1:

wait_for_button();
//1 = ctrl
//2 = space
//3 = shift
//12 = down
//14 = left
//16 = right
//18 = up

if (&result == 1) goto select;
if (&result == 2) goto select;
if (&result == 3) goto cancel;

if (&result == 12) goto previous;
if (&result == 14) goto previous;
if (&result == 16) goto next;
if (&result == 18) goto next;

next:
if (&count9 > 100)
{
&count9 -= 1;
if (&count9 == 100)
{
if (&total10 == 200)
{
if (&total16 == 300)
{
&count9 = &total9;
goto checkloop;
}
}
}
goto checkloop;
}
if (&count10 > 200)
{
&count10 -= 1;
if (&count10 == 200)
{
if (&total9 == 100)
{
if (&total16 == 300)
{
&count10 = &total10;
goto checkloop;
}
}
}
goto checkloop;
}

if (&count16 > 301)
{
&count16 -= 1;
if (&count16 == 300)
{
if (&total9 == 100)
{
if (&total10 == 200)
{
&count16 = &total16;
goto checkloop;
}
}
}
goto checkloop;
}
//all 0
&count9 = &total9;
&count10 = &total10;
&count16 = &total16;
goto checkloop;

previous:
if (&count16 < &total16)
{
&count16 += 1;
goto checkloop;
}
if (&count10 < &total10)
{
&count10 += 1;
goto checkloop;
}
if (&count9 < &total9)
{
&count9 += 1;
goto checkloop;
}
//all max - first check for any 16's...set to 301 if so. If not, check if there's any 10's, set to 201. if so, otherwise set 9's to 101
if (&total16 > 300)
{
&count16 = 301;
&count9 = 100;
&count10 = 200;
goto checkloop;
}

if(&total10 > 200)
{
&count9 = 100;
&count10 = 201;
goto checkloop;
}
&count9 = 101;
goto checkloop;


select:

int &sp-hp = sp_hitpoints(&sprite, -1);
int &sp-def = sp_defense(&sprite, -1);
int &sp-strength = sp_strength(&sprite, -1);
int &sp-touch = sp_touch_damage(&sprite, -1);
choice_start()
set_y 240
title_start();
Enemy Statistics:
Hitpoints = &sp-hp
Defense = &sp-def
Strength = &sp-strength
Touch Damage = &sp-touch
title_end();
"Good to know!"
choice_end()
goto end;

end:

&mana_current -= 1;

cancel:

&bleh = 10;
&bleh * &magic;
&magic_cost = &bleh;
&magic_level = 0;
draw_status();

sp_active(&arrow, 0);

&count9 = &total9;
&count10 = &total10;

loopunfreeze:

if (&count9 > 100)
{
&sprite = get_sprite_with_this_brain(&count9, 0);
unfreeze(&sprite);
sp_brain(&sprite, 9);
&count9 -= 1;
goto loopunfreeze;
}
if (&count10 > 200)
{
&sprite = get_sprite_with_this_brain(&count10, 0);
unfreeze(&sprite);
sp_brain(&sprite, 10);
&count10 -= 1;
goto loopunfreeze;
}
if (&count16 > 300)
{
&sprite = get_sprite_with_this_brain(&count16, 0);
unfreeze(&sprite);
sp_brain(&sprite, 16);
&count16 -= 1;
goto loopunfreeze;
}

unfreeze(1);
return;

none:
say("No targets to scan!", 1);
return;
}

void disarm(void)
{
kill_this_task();
}
void arm(void)
{
int &bleh = 10;
&bleh * &magic;
&magic_cost = &bleh;
&magic_level = 0;
}
void pickup(void)
{

}

void drop(void)
{
draw_status();
kill_this_task();
}
August 2nd 2003, 01:24 AM
custom_simon.gif
SimonK
Peasant He/Him Australia
 
I don't think so... it just uses the wait_for_button() command. I was going to freeze stuff, but it didn't work the way I wanted it to for some reason... can't remeber why... might be something to do with creating sprites for the numbers of the stats or something. If I remember right you can still be attacked if you check your stats mid fight. The script's format was create sprites for each number, show them against the background sprite, then the wait_for_button(); command and after that a sp_active to 0 for all sprites which had numbers and I think I gave all of these weird sprites brains of 20 because I discovered that if you had the tornado magic going and hit S sometimes a number would be sucked up by the tornado. Funny at the time, but not something I had planned to have happen.

As for graphics... some have been released as bmps, but not all.

I've not released the source... but just get a decompiler if you are really curious or email me which ones you want and I'll see about sending them to you.
August 2nd 2003, 07:22 AM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
&sp-touch = sp_touch_damage(&sprite, -1);

It always returns -1. All other stats turn up right, but touch damage is -1. Can anyone think of a good reason? I'll throw up the script for you guys to evaluate, too.


My guess is you simply can't retrieve the touch damage from the sprite. sp_touch_damage(&sprite,-1); is a special instance when the sprite can be 'touched' by Dink, and run the touch function. This is a good example of why Seth should have overloaded the DinkC functions, so you could just check the touch damage by sp_touch_damage(&sprite);

There is a nice little run around though. You could set sp_gold(); to the same value as sp_touch_damage(); in your enemy scripts. sp_gold(); doesn't do anything, but it does allow you to retrieve the value with -1.
August 2nd 2003, 11:09 AM
custom_odd.gif
Ok, I'll look into the gold thing.

And I emailed you, simon