The Dink Network

Scripting help needed

February 3rd 2007, 08:41 AM
pq_skull.gif
dinkme
Peasant He/Him India
 
So as usual, I have encountered another major snag which is prohibiting the quick development of my Dmod.

There is a unique bomb, only one of its kind that is available in the whole map. This bomb has to be used on a certain location, nowhere else. For example, say it has to be used on a certain map "450". I can make sure that it can't be used in another map by adding to the use procedure of the bomb script:

if (&player_map > 450)
{
say("Something",1);
}

if (&player_map < 450)
{
say("Something",1);
}
if (&player_map = 450)
{
//now the bomb can be used
//etc
}

The problem with this is that I am only able to check that this bomb can only be used in that particular map but as this bomb has to destroy a wall, a player can easily waste it by blowing it somewhere else on the same screen. Is there any way by which I can make sure that this bomb can only be used to blow that wall?

Help someone!
February 3rd 2007, 08:49 AM
spike.gif
Propably the easiest way would be to have Dink use the bomb by a cutscene... But there is also a command for this, inside_box(); It's used in original dink for feeding the pigs. (item-pig.c)
February 3rd 2007, 10:48 PM
boncag.gif
Znex
Peasant He/Him Australia
Oh hey. 
Maybe if you use sp_x and sp_y?
February 4th 2007, 01:51 AM
pq_skull.gif
dinkme
Peasant He/Him India
 
That won't work. I would be nearly impossible for the player to use the bomb on that particular x and y co-ordinate.
February 4th 2007, 03:23 AM
peasantmb.gif
Lunacre
Peasant He/Him Finland
 
That won't work. I would be nearly impossible for the player to use the bomb on that particular x and y co-ordinate.
But what about if you do something like this:

int &x = sp_x(1, -1);
int &y = sp_y(1, -1);

if (&x < 300)
{
end:
say("I shouldn't use this here...", 1);
return;
}

if (&x > 370)
goto end:

if (&y < 200)
goto end:

if (&y > 270)
goto end;


But using the inside_box(); command would be much easier than this, I think
February 4th 2007, 10:23 AM
spike.gif
Yeah, it does the same thing, but with fewer lines...

But really, I would just have Dink use the bomb with a cutscene. Having him walk to the wall and blow it up when you use the bomb on that screen would be less annoying than having him tell you he can't use it here until you go to exactly the right spot.
February 4th 2007, 04:31 PM
slayer.gif
rabidwolf9
Peasant He/Him United States
twitch.tv/rabidwolf9 
Here's basically how you would use inside_box(); for your bomb item. If you are really determined to use your method, you could at least have a script attached to the screen or something making Dink say something like "I could use that bomb on that object." or something along those lines. Just try these lines right at the beginning of your use procedure. Just replace the left, right, top, bottom variables with the coordinates you need to use.

//check for correct screen
if (&player_map != 450)
{
//Dink isn't on the correct screen
say("Not here!", 1);
return();
}

//check if dink is in the correct area to place bomb
int &dink_x = sp_x(1, -1);
int &dink_y = sp_y(1, -1);

int &in_box = inside_box(&dink_x,&dink_y, &left_x, &top_y, &right_x, &bottom_y);

if (&in_box != 1)
{
//Dink isn't in the box
say("I am not close enough!", 1);
return();
}
February 6th 2007, 01:31 AM
boncag.gif
Znex
Peasant He/Him Australia
Oh hey. 
You could always use a bomb spawner to spawn bombs if you don't have one. Plus, you could attach a script to the particular part of wall you want to blow up so it DOES blow up when it is hit by a bomb(look in other D-mods, some of them have good blow up scripts). Hope it helps.
February 6th 2007, 04:38 AM
pq_skull.gif
dinkme
Peasant He/Him India
 
You could always use a bomb spawner to spawn bombs if you don't have one. Plus, you could attach a script to the particular part of wall you want to blow up so it DOES blow up when it is hit by a bomb(look in other D-mods, some of them have good blow up scripts). Hope it helps.

Bomb spawner, what do you mean by that? Yeah, the wall blowing up wasn't a problem when hit by a bomb but the problem was to make sure that the player cannot waste the only bomb he had.

Thanks for the help, you guys. Its working quite nicely now.
February 7th 2007, 03:29 AM
knightg.gif
cypry
Peasant He/Him Romania
Chop your own wood, and it will warm you twice. 
Well, you could use a script on a certain map, to look in your inventory and see if you have the required bomb. If you don't(and you passed the part when you had to gain it(check the &story variable for this)), a bomb will be spawned on that screen.