(05-22-2018, 04:10 PM)seikosantana Wrote: How do I set the opponent?
Technically, by using some sort of condition. First, you'll have to know a bit about how the game is structured, though. There are 400 object slots in total that can be occupied by either characters, weapons, projectiles, or criminals. There are never more than 400 objects on the bg at any time. If you try to spawn something when all slots are taken, the object will most likely not spawn at all. Now, because this is a rather rigid limit, there is a function that lets you loop through individual objects which can be easily placed in a loop:
AI-Code:
for (int i = 0; i < 400; i++) {
loadTarget(i);
}
|
Now, this code isn't really spectacular because it wouldn't do much. However, you'll have to know how
loadTarget()
behaves: essentially, it takes the slot number as a parameter (the ominous "i") and saves the data into the variable "target" which you can then access.
target.team == self.team
would return true if both objects are on the same team and false otherwise.
There are a ton more things you could check for such as hp, position, id, ...
You can read up on them in this thread:
https://www.lf-empire.de/forum/showthread.php?tid=7946
If you want to set your target only once (i.e. only reset it once the original target is dead/deleted), you'll have to use additional variables. It's been too long since I worked with this kind of stuff so you'd be best off reading about it yourself or hope that somebody else will respond.
(05-22-2018, 04:10 PM)seikosantana Wrote: And is it possible to prevent the character to pick up weapons?
Yes. You'll have to use
id()
in lieu of
ego()
. Note that this requires you to code everything for your character because he won't do any kind of basic action (go for an opponent, chase milk, use attacks, ...).