54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
var entity = getEntity();
|
|
var obstacles = getObstacles()
|
|
|
|
function choiceWeapon() {
|
|
if (isOnSameLine(getCell(getNearestEnemy()), getCell())) {
|
|
setWeapon(WEAPON_SHOTGUN)
|
|
} else {
|
|
setWeapon(WEAPON_PISTOL);
|
|
}
|
|
}
|
|
function shoot(cible) {
|
|
choiceWeapon();
|
|
if(getCellDistance(getCell(cible), getCell()) <= getWeaponMaxRange(getWeapon())) {
|
|
debug("On est a distance de tir")
|
|
if(getWeapon() == WEAPON_PISTOL) {
|
|
debug("On a le pistolet")
|
|
while(getTP() >= 3 && lineOfSight(getCell(), getCell(cible))) {
|
|
useWeapon(cible);
|
|
}
|
|
} else if(getWeapon() == WEAPON_SHOTGUN) {
|
|
debug("On a le shotgun")
|
|
while(getTP() >= 5 && lineOfSight(getCell(), getCell(cible)) && isOnSameLine(getCell(cible), getCell())) {
|
|
useWeapon(cible);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if(getTP() >= 4 && getTurn() > 2 && getLife() > getTotalLife() * 0.7) {
|
|
useChip(CHIP_MOTIVATION, entity)
|
|
}
|
|
|
|
if(getTP() >= 3) {
|
|
useChip(CHIP_PROTEIN, entity)
|
|
useChip(CHIP_HELMET, entity)
|
|
}
|
|
|
|
if(getLife() < getTotalLife() * 0.7 && getTP() > 4) {
|
|
useChip(CHIP_CURE, entity)
|
|
}
|
|
|
|
while(getPathLength(getCell(getNearestEnemy()), getCell(), obstacles) >= getWeaponMaxRange(getWeapon()) && getMP() > 0) {
|
|
moveToward(getNearestEnemy(), 1);
|
|
}
|
|
|
|
if(getCellDistance(getCell(getNearestEnemy()), getCell()) <= 5) {
|
|
useChip(CHIP_PEBBLE, getNearestEnemy())
|
|
}
|
|
|
|
shoot(getNearestEnemy());
|
|
|
|
if(getLife() <= getTotalLife() * 0.6) {
|
|
moveAwayFrom(getNearestEnemy());
|
|
} |