Forum

> > Stranded II > Scripts > AI vs AI fighting?
Forums overviewStranded II overview Scripts overviewLog in to reply

English AI vs AI fighting?

3 replies
To the start Previous 1 Next To the start

old AI vs AI fighting?

Warbringer
User Off Offline

Quote
Hello!

Is that possible to make two animals fighting themselves? Do the game engine and scripts allow it?

old Re: AI vs AI fighting?

Hurri04
Super User Off Offline

Quote
as user Mephisto_ said, using s2 cmd ai_mode probably works to let the units find each other.

this should only be started if they are within a certain range of each other (s2 cmd inrange) and possibly have a free line of sight (s2 cmd 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 s2 cmd 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 s2 cmd 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 s2 cmd projectile next to simulate the attack, as user 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 s2 cmd on:hit event that uses s2 cmd 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 s2 cmd on:hit does not work you should set off a custom s2 cmd 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
To the start Previous 1 Next To the start
Log in to reply Scripts overviewStranded II overviewForums overview