The Dink Network

Reply to Idea: Creating scripts that are extremely versatile

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 12th 2003, 09:18 AM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
I've been doing some thinking, and maybe this is common sense... but I've thought of a way to make one single script behave appropriately in innumerable situations.

Ok, that's a kinda crappy summary. Here is a simple example:

Imagine that you have a basic pillbug script that you've made (or copied from the original game). So you place a few weak pillbugs around the start of the game, and everything is good.

Now imagine you want to build some super-pillbugs, (that are more challenging). Now, the normal way to do this would be to edit your original pillbug script, make some changes, and then save the script as something like en-pill5.c or whatever.

That works fine. But imagine you want to have like 20 different pillbug strengths. Or 50. Or 100. It just doesn't make sense to create 100 different pillbug scripts, wasting space and all.

So... this is what I suggest. In DE or WDE, decide that one of the sprite properties will represent, say, the Pillbug's level (where Level 0 is easy, Level 100 is hard). I'll use Speed as an example. Then give it a script like this:

//Multi-Level Pillbug
//en-pill.c

void main(void)
{
int &my_level = sp_speed(&current_sprite,-1);
int &my_temp = 0;

//Negative values are bad
if (&my_level < 0)
{
&my_level = 0;
}

//Set the non-changing attributes
sp_speed(&current_sprite,1);
sp_brain(&current_sprite,9);
sp_base_walk(&current_sprite,130);
sp_base_death(&current_sprite,140);

//Set the level-dependent attributes
//The hitpoints = 3*LVL + 8
&my_temp = &my_level;
&my_temp * 3;
&my_temp + 8;
sp_hitpoints(&current_sprite, &my_temp);

//The touch damage = LVL + 1
&my_temp = &my_level;
&my_temp += 1;
sp_touch_damage(&current_sprite, &my_temp);

//The experience = LVL * 5
&my_temp = &my_level;
&my_temp * 5;
sp_exp(&current_sprite, &my_temp);
}

//Blah, other procedures here

And that's all there is to it. Just give a pillbug a Speed of 45 in WDE or DE, and its a super-pillbug with 143 HP, 46 Damage (probably a bit much, hehe), and 225 Experience.

This technique could also be used for non-enemy sprites, but things that are similar and used a lot that need a script. Like Blocker scripts (that Dink runs into but can't pass). Just decide that the Speed is the direction the blocker script should move Dink, and say the Hitpoints is the x/y value Dink should be moved to, and you've made one super-functional script that can be used as many times as you want, without creating a brand new script each time.

Like I said in the beginning, this could be common sense and could be in use for decades, but I just realized the potential.