Reply to Re: Why Can't I Quit You, DinkC?
If you don't have an account, just leave the password field blank.
Note that this specific code only works if the enemy is the only object with it's brain during the setup. It also requires &jug to be initialized or to be replaced with a local variable. It is probably possible to improve the code to make it less dependent on specific brains and to allow multiple enemies but I haven't gotten it to work that way yet.
The "head" (boss1a.c):
The "body" (boss1b.c):
Hopefully I got that all down right, let me know if you have any issues or need help trying to do something specific with it.
The "head" (boss1a.c):
void main( void ) { int &body; //now set brain, touch damage, speed, timing, etc. sp_brain(¤t_sprite, [brain]); sp_speed(¤t_sprite, [speed]); sp_timing(¤t_sprite, [timing]); sp_touch_damage(¤t_sprite, [touch damage]); sp_base_walk(¤t_sprite, [base_walk]); sp_target(¤t_sprite, 1); //nohit so that arrows/fireballs and stuff don't hit him instead of the body. sp_nohit(¤t_sprite, 1); //replace coordinates and sprite with the correct values //even though the body is invisible it still must use the same graphic so that //collisions can happen properly (unless you want to use a different collision sprite) &body = create_sprite([100],[100],[16],[100],[0]); sp_script(&body, "boss1b"); //if you need to do anything with the body from here on out, you have the &body variable }
The "body" (boss1b.c):
void main( void ) { int &head; //first set the stats //sp_hitpoints and such goes here //be careful to set the brain to a different brain than the "head" sp_brain(¤t_sprite, [9 or 10]); sp_hitpoints(¤t_sprite, [hp]); sp_defense(¤t_sprite, [defense]); sp_base_walk(¤t_sprite, [same as head]); //set nodraw so that the body can't be seen sp_nodraw(¤t_sprite, 1); //then we must find the head and put it in a variable &head = get_sprite_with_this_brain([brainofhead], ¤t_sprite); mainloop: //get same x as head &jug = sp_x(&head, -1); sp_x(¤t_sprite, &jug); //get same y as head &jug = sp_y(&head, -1); sp_y(¤t_sprite, &jug); //get same facing as head (for collisions sake) &jug = sp_dir(&head, -1); sp_dir(¤t_sprite, &jug); //wait(0) will wait the minimum amount of time and update the position precisely wait(0); goto mainloop; } void hit( void ) { //then if you need a hit procedure (more than likely you do) //do whatever hit procedure should do, then at the end, return to mainloop like so goto mainloop; }
Hopefully I got that all down right, let me know if you have any issues or need help trying to do something specific with it.