Is that possible to make two animals fighting themselves? Do the game engine and scripts allow it?
Forum
Stranded II Scripts AI vs AI fighting?AI vs AI fighting?
3 replies 1
Is that possible to make two animals fighting themselves? Do the game engine and scripts allow it?
McLeaf had it implemented in his modified sourcecode: https://www.youtube.com/watch?v=agjZlkJ5kXA
this should only be started if they are within a certain range of each other ( inrange) and possibly have a free line of sight ( viewline) so that e.g. 2 lions dont run across the whole map and scrape along trees or something as they try to find the direct way to each other.
use a local timer within each unit (not a global one) to check periodically (e.g. 1 second) whether they are in a radius that allows them to attack each other (for lions that would be very close but e.g. natives with bows can have a bigger radius).
after that I think animate can be used to play the attack animation. you might have to look up the exact start and end frames though from the definition files in the sys folder.
[edit: just noticed that I forgot to mention here that you'll still need to use projectile next to simulate the attack, as Mephisto_ said.]
if you want to make the fights more dynamical instead of just the units walking up to each other and hitting each other until one falls over, you should add an on:hit event that uses ai_mode again to make the hit unit run away from the one that hit it for a while. the attacker unit will then follow until the other one turns around again and possibly get hit itself so that the fight takes up a bit more space with the attacks going back and forth.
(if on:hit does not work you should set off a custom event within the unit that has been hit.)
and as always: if the description text of a command reference has not been translated from german to english, put the URL of the page into google translate instead. it's usually enough to let you understand what you have to know.
s2script is pretty powerful in terms of what it lets you do with the game.
edited 2×, last 21.11.15 06:58:57 pm
1