Показать сообщение отдельно
Старый 21.04.2016, 18:15   #669
LeaderAI
Местный
 
Регистрация: 20.03.2016
Сообщений: 275
По умолчанию

private void updateTurret(Turret turret, int i, float f) {
if (!turret.bIsOperable)
CT.WeaponControl[i + 10] = false;
else if (!turret.bIsAIControlled)
((Aircraft) this.actor).setHumanControlledTurretAngels(turret, tu,
HM, am);
else if (turret.indexA != -1 && turret.indexB != -1) {
am = (ActorHMesh) this.actor;
float f_22_ = 0.0F;
float f_23_ = (float) (turretSkill + 1) * turret.health;
if (W.lengthSquared() > 0.25)
f_23_ *= 1.0F - (float) Math.sqrt(W.length() - 0.5);
if (getOverload() > 1.0F)
f_23_ *= Aircraft.cvt(getOverload(), 1.0F, 5.0F, 1.0F, 0.0F);
else if (getOverload() < 0.0F)
f_23_ *= Aircraft.cvt(getOverload(), -1.5F, 0.0F, 0.0F, 1.0F);
if (turret.target != null && turret.target instanceof Aircraft
&& ((Aircraft) turret.target).FM.isTakenMortalDamage())
turret.target = null;
if (turret.target == null) {
if (turret.tMode != 0) {
turret.tMode = 0;
turret.timeNext = Time.current();
}
} else {
turret.target.pos.getAbs(Pt);
turret.target.getSpeed(Vt);
this.actor.getSpeed(Ve);
Vt.sub(Ve);
HM.setCurChunk(turret.indexA);
ActorHMesh actorhmesh = am;
if (this != null) {
/* empty */
}
actorhmesh.getChunkLocAbs(Actor._tmpLoc);
Vector3d vector3d = Ve;
Point3d point3d = Pt;
if (this != null) {
/* empty */
}
vector3d.sub(point3d, Actor._tmpLoc.getPoint());
f_22_ = (float) Ve.length();
float f_24_
= ((14.0F - 2.25F * f_23_)
* (float) Math.sin((double) ((float) (Time.current()
& 0xffffL)
* 0.003F)));
Vt.scale((double) ((f_22_ + f_24_) * 0.001492537F));
Ve.add(Vt);
Vg.set(Ve);
Or.transformInv(Ve);
turret.Lstart.transformInv(Ve);
Ve.y = -Ve.y;
HM.setCurChunk(turret.indexB);
turret.Lstart.get(Oo);
Oo.setAT0(Ve);
Oo.get(tu);
Or.transformInv(Vt);
turret.Lstart.transformInv(Vt);
Vt.normalize();
shoot = ((Aircraft) this.actor).turretAngles(i, tu);
}
switch (turret.tMode) {


case 0: {
turret.bIsShooting = false;
float[] fs = ((Aircraft) this.actor).getTurretRestOrient(i);
turret.tuLim[0] = fs[0];
turret.tuLim[1] = fs[1];
if (Time.current() > turret.timeNext) {
turret.target = War.GetNearestEnemyAircraft(this.actor, 3619.0F, 9);
if (turret.target == null) {
turret.target = War.GetNearestEnemyAircraft(this.actor, 6822.0F, 9);
if (turret.target == null)
turret.timeNext = (Time.current() + World.Rnd().nextLong(1000L, 10000L));
else if (VisCheck.visCheckTurret(turret, (Aircraft) this.actor, ((Aircraft) turret.target), true)) {
turret.tMode = 1;
turret.timeNext = 0L;
if (((Aircraft) this.actor == World.getPlayerAircraft()) && turret.health > 0.4F)
Voice.speakRearGunEA((Aircraft) this.actor, (Aircraft) turret.target);
} else
turret.timeNext = Time.current() + World.Rnd().nextLong(100L, 3000L);
} else if (VisCheck.visCheckTurret(turret, (Aircraft) this.actor, ((Aircraft) turret.target), true)) {
turret.tMode = 1;
turret.timeNext = 0L;
if ((Aircraft) this.actor == World.getPlayerAircraft() && turret.health > 0.4F)
Voice.speakRearGunEA((Aircraft) this.actor,
(Aircraft) turret.target);
} else
turret.timeNext = Time.current() + World.Rnd().nextLong(100L, 3000L);
}
break;
}


case 1:
turret.bIsShooting = false;
turret.tuLim[0] = tu[0];
turret.tuLim[1] = tu[1];
if (isTick(39, 16)) {
if (!shoot && f_22_ > 550.0F || World.Rnd().nextFloat() < 0.1F) {
turret.tMode = 0;
turret.timeNext = Time.current();
}
if ((float) (World.Rnd().nextInt() & 0xff) < 32.0F * f_23_ || f_22_ < 148.0F + 27.0F * (f_23_ - 1.0F)) {
if (f_22_ < 450.0F + 66.6F * (f_23_ - 1.0F)) {
if (f_23_ - 1.0F <= 0.0F) {
if (Vt.x < -0.9599999785423279) {
switch (World.Rnd().nextInt(1, 3)) {
case 1:
turret.tMode = 5;
turret.timeNext = (Time.current() + World.Rnd().nextLong(500L, 1200L));
break;
case 2:
turret.tuLim[0] += World.Rnd().nextFloat(-15.0F, 15.0F);
turret.tuLim[1] += World.Rnd().nextFloat(-10.0F, 10.0F);
/* fall through */
case 3:
turret.tMode = 3;
turret.timeNext = (Time.current() + World.Rnd().nextLong(500L, 10000L));
break;
}
} else if (Vt.x < -0.33000001311302185) {
turret.tMode = 3;
turret.timeNext = (Time.current() + World.Rnd().nextLong(1000L, 5000L));
}
} else if (f_23_ - 1.0F <= 2.0F) {
if (Vt.x < -0.9100000262260437) {
if (World.Rnd().nextBoolean())
turret.tMode = 3;
else
turret.tMode = 2;
turret.timeNext = (Time.current() + World.Rnd().nextLong(500L, 2200L));
} else {
if (World.Rnd().nextFloat() < 0.5F)
turret.tMode = 2;
else
turret.tMode = 3;
turret.timeNext = (Time.current() + World.Rnd().nextLong(1500L, 7500L));
}
} else {
turret.tMode = 2;
turret.timeNext = (Time.current() + World.Rnd().nextLong(500L, 7500L));
}
} else if (f_22_ < 902.0F + 88.0F * (f_23_ - 1.0F)) {
turret.tMode = 3;
turret.timeNext = Time.current() + World.Rnd().nextLong(300L, 1000L);
}
}
}
break;


case 2:
turret.bIsShooting = true;
turret.tuLim[0] = (tu[0] * World.Rnd().nextFloat(0.76F + 0.06F * f_23_, 1.24F - 0.06F * f_23_) + World.Rnd().nextFloat((-10.0F + 2.5F * f_23_
- rotSpeed * 4.0F), (10.0F - 2.5F * f_23_ + rotSpeed * 4.0F)));
turret.tuLim[1] = (tu[1] * World.Rnd().nextFloat(0.76F + 0.06F * f_23_, 1.24F - 0.06F * f_23_) + World.Rnd().nextFloat((-10.0F + 2.5F * f_23_
- rotSpeed * 4.0F), (10.0F - 2.5F * f_23_ + rotSpeed * 4.0F)));
if (Time.current() > turret.timeNext) {
turret.tMode = 1;
if (f_23_ - 1.0F <= 1.0F) {
turret.tMode = 0;
turret.timeNext = (Time.current() + World.Rnd().nextLong(100L, (long) (f_23_ * 700.0F)));
}
}
break;


case 3:
// default true//
turret.bIsShooting = true;
turret.tuLim[0] = (tu[0] * World.Rnd().nextFloat(0.76F + 0.06F * f_23_, 1.24F - 0.06F * f_23_) + World.Rnd().nextFloat((-10.0F + 2.5F * f_23_
- rotSpeed * 5.0F), (10.0F - 2.5F * f_23_ + rotSpeed * 5.0F)));
turret.tuLim[1] = (tu[1] * World.Rnd().nextFloat(0.76F + 0.06F * f_23_, 1.24F - 0.06F * f_23_) + World.Rnd().nextFloat((-10.0F + 2.5F * f_23_
- rotSpeed * 5.0F), (10.0F - 2.5F * f_23_ + rotSpeed * 5.0F)));
if (Time.current() > turret.timeNext)
turret.tMode = 1;
break;



case 4:
// default true//
turret.bIsShooting = true;
shoot = true;
((Aircraft) this.actor).turretAngles(i, turret.tuLim);
if (isTick(20, 0)) {
turret.tuLim[0] += World.Rnd().nextFloat(-50.0F, 50.0F);
turret.tuLim[1] += World.Rnd().nextFloat(-50.0F, 50.0F);
}
if (Time.current() > turret.timeNext) {
turret.tMode = 5;
turret.timeNext = Time.current() + World.Rnd().nextLong(100L, 1500L);
}
break;



case 5:
turret.bIsShooting = false;
if (Time.current() > turret.timeNext) {
turret.tMode = 0;
turret.timeNext = 0L;
}
break;



}
shoot &= turret.bIsShooting;
if (shoot && isTick(32, 0)) {
shoot
= VisCheck.visCheckTurret(turret, (Aircraft) this.actor,
(Aircraft) turret.target, false);
if (!shoot)
turret.tMode = 0;
}
if (shoot) {
HM.setCurChunk(turret.indexB);
ActorHMesh actorhmesh = am;
if (this != null) {
/* empty */
}
actorhmesh.getChunkLocAbs(Actor._tmpLoc);
Vg.normalize();
Vg.scale(2.0);
Point3d point3d = p;
if (this != null) {
/* empty */
}
point3d.set(Actor._tmpLoc.getPoint());
p.add(Vg);
Vg.normalize();
Vg.scale((double) (f_22_ + 300.0F));
Point3d point3d_25_ = p2;
if (this != null) {
/* empty */
}
point3d_25_.set(Actor._tmpLoc.getPoint());
p2.add(Vg);
clipFilter.setTarget(turret.target);
clipFilter.setOwner(this.actor);
Actor actor = Engine.collideEnv().getLine(p, p2, true,
clipFilter, null);
if (actor != null && actor.getArmy() == this.actor.getArmy()
&& actor != this.actor && actor instanceof Aircraft)
shoot = false;
else {
Vt.set(1.0, 0.0, 0.0);
if (this != null) {
/* empty */
}
Actor._tmpLoc.getOrient().transform(Vt);
double d = Vg.angle(Vt);
if (d > 0.1)
shoot = false;
}
}
if (f_23_ <= 0.0F)
shoot = false;
CT.WeaponControl[i + 10] = shoot;
updateRotation(turret, f);
}
}
Вот всеь метод стрелков
LeaderAI вне форума   Ответить с цитированием