The Dink Network

Reply to Custom procedures

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:
 
 
December 20th 2024, 10:52 PM
custom_simon.gif
SimonK
Peasant He/Him Australia
 
Looking at these and getting my head around such things as local variables scope is excluded in custom procedures unless variable is defined in that exact procedure, plus the availability of &arg1 thru to &arg9 as parameters that can be passed to a custom procedure - you can only return a single integer value, right?

And if you use set_callback_random("procedure", xxx, yyyy); on a custom procedure you have to activate its own callback at the end of the procedure code, if you want it called again after the last call.

Although is "void target (void)" as used in the original en-drag.c a custom or a Dink Engine predefined procedure? As this doesn't call on itself at the end.

void main( void )
{
int &fsave_x;
int &kcrap;
int &fsave_y;
int &resist;
int &mcounter;
int &mtarget;
screenlock(1);
sp_brain(&current_sprite, 10);
sp_timing(&current_sprite, 66);
sp_speed(&current_sprite, 1);
sp_nohit(&current_sprite, 0);
sp_exp(&current_sprite, 400);
sp_base_walk(&current_sprite, 200);
sp_base_death(&current_sprite, 210);
sp_touch_damage(&current_sprite, 10);
sp_hitpoints(&current_sprite, 80);
sp_defense(&current_sprite, 8);
preload_seq(202);
preload_seq(204);
preload_seq(206);
preload_seq(208);
preload_Seq(70);
preload_Seq(166);

set_callback_random("target",500,2000);

}

void target( void )
{
    //get new target
&kcrap = random(9, 1);
if (&life < 1)
  &kcrap = 2;

if (&kcrap == 1)
 {
 sp_target(&current_sprite, 1);
 return;
 }

        &mtarget = get_sprite_with_this_brain(16, &current_sprite);
        if (&mtarget > 0)
          {

           &mtarget = get_rand_sprite_with_this_brain(16, &current_sprite);
           sp_target(&current_sprite, &mtarget);
          }

}