Classfile 10C28AC4C8A11640 is LocomotiveUSSR.class, which is the full code.
My main change:
- Altered the period in which the headlight gets turned on/off when an enemy gets within a certain distance. Previously this was fixed to the period between certain hours of the day. But the seasonal variation, particularly at middle and sub-Arctic latitudes, is too large for this to be appropriate. I use the actual elevation of the Sun below the horizon. And I dynamically scale the threshold detection distance with the Sun elevation, such that when darker an enemy is sensed only at a nearer distance.
Here's the Java file for LocomotiveUSSR.class:
package com.maddox.il2.objects.trains;
import com.maddox.JGP.Point3d;
import com.maddox.JGP.Vector3d;
import com.maddox.il2.ai.*;
import com.maddox.il2.engine.*;
import com.maddox.il2.objects.air.Aircraft;
import com.maddox.il2.objects.effects.MiscEffects; //NEW
import com.maddox.rts.MsgAction;
import com.maddox.rts.Spawn;
import com.maddox.util.HashMapExt;
import java.util.Map;
// Referenced classes of package com.maddox.il2.objects.trains:
// Wagon, Train, WagonSpawn
public class LocomotiveUSSR extends Wagon
implements MsgCollisionRequestListener, MsgExplosionListener, MsgShotListener
{
public static class SPAWN
implements WagonSpawn
{
public Wagon wagonSpawn(Train train)
{
return new LocomotiveUSSR(train);
}
public SPAWN()
{
}
}
private boolean danger()
{
Point3d point3d = new Point3d();
super.pos.getAbs(point3d);
Vector3d vector3d = new Vector3d();
for(java.util.Map.Entry entry1 = Engine.name2Actor().nextEntry(null); entry1 != null; entry1 = Engine.name2Actor().nextEntry(entry1))
{
Actor actor1 = (Actor)entry1.getValue();
float scaleDist = MiscEffects.cvt(World.Sun().ToSun.z, -0.31F, -0.1F, 0.25F, 1.0F);
// if(Actor.isAlive(actor1) && (actor1 instanceof Aircraft) && actor1.getArmy() != myArmy && actor1.pos.getAbsPoint().distance(point3d) < 1500D)
if(Actor.isAlive(actor1) && (actor1 instanceof Aircraft) && actor1.getArmy() != myArmy && actor1.pos.getAbsPoint().distance(point3d) < 3000F * scaleDist)
return true;
}
return false;
}
protected void explode(Actor actor)
{
new MsgAction(0.0D, this)
{
public void doAction(Object obj)
{
LocomotiveUSSR locomotiveussr = (LocomotiveUSSR)obj;
Eff3DActor.New(locomotiveussr, new HookNamed(locomotiveussr, "Damage"), null, 1.0F, "Effects/Smokes/BoilerBurst.eff", 2.0F); //was 2s; NEW effect by WxTech
Eff3DActor.New(locomotiveussr, new HookNamed(locomotiveussr, "Damage"), null, 1.0F, "Effects/Smokes/LocomotiveFC2.eff", 25F); //was 25s
}
};
// new MsgAction(2D, new Wagon.Pair(this, this, this))
new MsgAction(2D, new Wagon.Pair(this, actor))
{
public void doAction(Object obj)
{
Actor actor1 = getOwner();
if(actor1 != null)
((Train)actor1).wagonDied(((Wagon.Pair)obj).victim, ((Wagon.Pair)obj).initiator);
life = -1F;
ActivateMesh();
}
};
new MsgAction(6.5D, this)
{
public void doAction(Object obj)
{
LocomotiveUSSR locomotiveussr = (LocomotiveUSSR)obj;
Eff3DActor.New(locomotiveussr, new HookNamed(locomotiveussr, "Damage"), null, 1.0F, "Effects/Smokes/LocomotiveFC1.eff", 90F); //was 35s
}
};
}
protected LocomotiveUSSR(Train train, String s, String s1)
{
super(train, s, s1);
// fn = World.getTimeofDay();
super.life = 0.015F;
super.ignoreTNT = 0.84F;
super.killTNT = 3.5F;
super.bodyMaterial = 2;
pipe = Eff3DActor.New(this, new HookNamed(this, "Vapor"), null, 1.0F, "Effects/Smokes/SmokeBlack_Locomotive.eff", -1F);
pipe2 = Eff3DActor.New(this, new HookNamed(this, "Vapor2"), null, 1.0F, "Effects/Smokes/SmokeWhite_Locomotive.eff", -1F);
Light1 = Eff3DActor.New(this, new HookNamed(this, "Light1"), null, 1.0F, "Effects/Smokes/Locomotive_light.eff", -1F);
Light2 = Eff3DActor.New(this, new HookNamed(this, "Light2"), null, 1.0F, "Effects/Smokes/Locomotive_light.eff", -1F);
Light3 = Eff3DActor.New(this, new HookNamed(this, "Light3"), null, 1.0F, "Effects/Smokes/Locomotive_light.eff", -1F);
SteamL = Eff3DActor.New(this, new HookNamed(this, "SteamL"), null, 1.0F, "Effects/Smokes/S_SteamL.eff", -1F);
SteamR = Eff3DActor.New(this, new HookNamed(this, "SteamR"), null, 1.0F, "Effects/Smokes/S_SteamR.eff", -1F);
}
public LocomotiveUSSR(Train train)
{
this(train, getMeshName(0), getMeshName(1));
}
private static String getMeshName(int i)
{
String s;
switch(World.cur().camouflage)
{
case 0: // '\0'
s = "summer";
break;
case 1: // '\001'
s = "winter";
break;
default:
s = "summer";
break;
}
return "3do/Trains/Prvz" + (i != 1 ? "" : "_Dmg") + "/" + s + "/hier.him";
}
void place(Point3d point3d, Point3d point3d1, boolean flag, boolean flag1)
{
super.place(point3d, point3d1, flag, flag1);
if(pipe == null && Light1 == null && Light2 == null && SteamL == null && SteamR == null && pipe2 == null)
return;
float f;
if(!IsDead())
{
f = ((Train)getOwner()).getEngineSmokeKoef();
if(f == 0.0F && ((Train)getOwner()).stoppedForever())
f = -1F;
} else
{
f = -1F;
}
if(f >= 0.0F)
{
pipe._setIntesity(f);
pipe2._setIntesity(f);
Light1._setIntesity(f);
Light2._setIntesity(f);
Light3._setIntesity(f);
SteamL._setIntesity(f);
SteamR._setIntesity(f);
// if((double)fn < 18D && (double)fn >= 6D || danger())
if(World.Sun().ToSun.z > -0.1 || danger())
{
Light1._setIntesity(0.0F);
Light2._setIntesity(0.0F);
Light3._setIntesity(0.0F);
}
} else
{
pipe._finish();
pipe = null;
pipe2._finish();
pipe2 = null;
Light1._finish();
Light1 = null;
Light2._finish();
Light2 = null;
Light3._finish();
Light3 = null;
SteamL._finish();
SteamL = null;
SteamR._finish();
SteamR = null;
}
}
protected void ActivateMesh()
{
if(IsDead() && pipe != null && Light1 != null)
{
pipe._finish();
pipe = null;
pipe2._finish();
pipe2 = null;
Light1._finish();
Light1 = null;
Light2._finish();
Light2 = null;
Light3._finish();
Light3 = null;
SteamL._finish();
SteamL = null;
SteamR._finish();
SteamR = null;
}
super.ActivateMesh();
}
/* public static String getMeshNameForEditor()
{
return getMeshName(0);
}
static Class _mthclass$(String s)
{
return Class.forName(s);
ClassNotFoundException classnotfoundexception;
classnotfoundexception;
throw new NoClassDefFoundError(classnotfoundexception.getMessage());
} */
static Class _mthclass$(String s)
{
try
{
return Class.forName(s);
}
catch(ClassNotFoundException classnotfoundexception)
{
throw new NoClassDefFoundError(classnotfoundexception.getMessage());
}
}
// float fn;
private static Class cls;
protected Eff3DActor pipe;
protected Eff3DActor pipe2;
protected Eff3DActor Light1;
protected Eff3DActor Light2;
protected Eff3DActor Light3;
protected Eff3DActor SteamL;
protected Eff3DActor SteamR;
private int myArmy;
static
{
cls = com.maddox.il2.objects.trains.LocomotiveUSSR.class;
Spawn.add(cls, new SPAWN());
}
}