Enemy Combat Scripting
Well, I was working on Fate of Destiny today and got up to an area where I want to start testing some enemy scripts. But before I begin, I want to ask if any of you know if its possible to set an enemy to lock onto ANOTHER enemy if said target has a specific variable in place?
At first I'm hoping to get some simple enemies hunting enemies going in screens. Take the well known Grey Bonca from the main game for example. But my main goal in the end will have fully self-contained Battlefields where enemies can slaughter each other until one side remains, with one side being "allied" with Dink and unable to target him unless they get hit 3 times or so.
Anyway, that's it from me. Anyone care to share their insight?
At first I'm hoping to get some simple enemies hunting enemies going in screens. Take the well known Grey Bonca from the main game for example. But my main goal in the end will have fully self-contained Battlefields where enemies can slaughter each other until one side remains, with one side being "allied" with Dink and unable to target him unless they get hit 3 times or so.
Anyway, that's it from me. Anyone care to share their insight?
I've done something like this before. I marked creatures as team 1 and team 2 by setting their sp_gold values to 1 and 2. Then I would have them target a random member of the other team in their main procedure. Here's a bit of code from a member of team 2 I used to do it.
I wasn't quite finished with this so there are still a couple of things that need to be done. A team allied with Dink will of course have to check if they targeted Dink and target something else if they did. A new target has to be picked once the current target is dead. It would also be nice if the creatures were able to target the nearest enemy creature. I haven't quite figured out how to do the last part yet but I think it's possible. I'll play around with it once I have time and let you know what I know once I know it.
int &mtarget; loop: &mtarget = get_rand_sprite_with_this_brain(9, 0); if (&mtarget > 0) { int &team; &team = sp_gold(&mtarget, -1); if (&team == 1) { sp_target(¤t_sprite, &mtarget); } if (&team == 2) { sp_target(¤t_sprite, 0); wait(1); goto loop; } } }
I wasn't quite finished with this so there are still a couple of things that need to be done. A team allied with Dink will of course have to check if they targeted Dink and target something else if they did. A new target has to be picked once the current target is dead. It would also be nice if the creatures were able to target the nearest enemy creature. I haven't quite figured out how to do the last part yet but I think it's possible. I'll play around with it once I have time and let you know what I know once I know it.
