Chaingun with heat based projectile spread - CODE
I was messing around today coding a heat based spread for the tribes2 chaingun, like the new game legions has for its chaingun. The spread starts off at 1.0, and increases. after a bit the chaingun will cool off after not firing it.. the max spread is the same as the classic mod 7.0, and starts off at 1.0, makes for hitting enemys easyer when cool.
To use this code copy and past it to the bottom of the chaingun.cs in the classic mod or your mod, enjoy..
[code]function ChaingunImage::onMount(%this,%obj,%slot)
{
Parent::onMount(%this, %obj, %slot);
if(!%obj.coolingChaingun)
schedule(5000, %obj, "CoolOffChaingun", %obj);
%obj.coolingChaingun = true;
}
function ChaingunImage::onFire(%data,%obj,%slot)
{
%obj.heatLevel += (1 + mFloor(5 * getRandom()));
if(%obj.heatLevel >= 1 && %obj.heatLevel < 15){
%Spread = 1.0 / 1000.0;
bottomPrint(%obj.client, "\nChaingun Temperature ||" SPC %obj.heatLevel @ "\%", 1, 3);
}
if(%obj.heatLevel >= 16 && %obj.heatLevel < 30){
%Spread = 1.50 / 1000.0;
bottomPrint(%obj.client, "\nChaingun Temperature ||||" SPC %obj.heatLevel @ "\%", 1, 3);
}
if(%obj.heatLevel >= 31 && %obj.heatLevel < 45){
%Spread = 2.50 / 1000.0;
bottomPrint(%obj.client, "\nChaingun Temperature ||||||||" SPC %obj.heatLevel @ "\%", 1, 3);
}
if(%obj.heatLevel >= 46 && %obj.heatLevel < 60){
%Spread = 3.50 / 1000.0;
bottomPrint(%obj.client, "\nChaingun Temperature ||||||||||||" SPC %obj.heatLevel @ "\%", 1, 3);
}
if(%obj.heatLevel >= 61 && %obj.heatLevel < 75){
%Spread = 4.50 / 1000.0;
bottomPrint(%obj.client, "\nChaingun Temperature ||||||||||||||||" SPC %obj.heatLevel @ "\%", 1, 3);
}
if(%obj.heatLevel >= 76 && %obj.heatLevel < 500){
%Spread = 7.0 / 1000.0;
bottomPrint(%obj.client, "\nChaingun Temperature ||||||||||||||||||||" SPC %obj.heatLevel @ "\%", 1, 3);
}
%vector = %obj.getMuzzleVector(%slot);
%x = (getRandom() - 0.5) * 2 * 3.1415926 * %Spread;
%y = (getRandom() - 0.5) * 2 * 3.1415926 * %Spread;
%z = (getRandom() - 0.5) * 2 * 3.1415926 * %Spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%vector = MatrixMulVector(%mat, %vector);
%p = new TracerProjectile() {
dataBlock = "ChaingunBullet";
initialDirection = %vector;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
};
%obj.lastProjectile = %p;
MissionCleanup.add(%p);
%obj.decInventory(%data.ammo,1);
if(%obj.client)
%obj.client.projectile = %p;
}
function CoolOffChaingun(%obj)
{
%oldheat = %obj.heatLevel;
%obj.heatLevel = (%obj.heatLevel > 4) ? %obj.heatLevel - 5 : 0;
if(%obj.getMountedImage($WeaponSlot) != 0)
%img = %obj.getMountedImage($WeaponSlot).getName();
else
%img = "";
if(%obj.heatLevel >= 40 && %img $= "ChaingunImage")
{
if(%oldheat >= 50 && %oldheat
To use this code copy and past it to the bottom of the chaingun.cs in the classic mod or your mod, enjoy..
[code]function ChaingunImage::onMount(%this,%obj,%slot)
{
Parent::onMount(%this, %obj, %slot);
if(!%obj.coolingChaingun)
schedule(5000, %obj, "CoolOffChaingun", %obj);
%obj.coolingChaingun = true;
}
function ChaingunImage::onFire(%data,%obj,%slot)
{
%obj.heatLevel += (1 + mFloor(5 * getRandom()));
if(%obj.heatLevel >= 1 && %obj.heatLevel < 15){
%Spread = 1.0 / 1000.0;
bottomPrint(%obj.client, "\nChaingun Temperature ||" SPC %obj.heatLevel @ "\%", 1, 3);
}
if(%obj.heatLevel >= 16 && %obj.heatLevel < 30){
%Spread = 1.50 / 1000.0;
bottomPrint(%obj.client, "\nChaingun Temperature ||||" SPC %obj.heatLevel @ "\%", 1, 3);
}
if(%obj.heatLevel >= 31 && %obj.heatLevel < 45){
%Spread = 2.50 / 1000.0;
bottomPrint(%obj.client, "\nChaingun Temperature ||||||||" SPC %obj.heatLevel @ "\%", 1, 3);
}
if(%obj.heatLevel >= 46 && %obj.heatLevel < 60){
%Spread = 3.50 / 1000.0;
bottomPrint(%obj.client, "\nChaingun Temperature ||||||||||||" SPC %obj.heatLevel @ "\%", 1, 3);
}
if(%obj.heatLevel >= 61 && %obj.heatLevel < 75){
%Spread = 4.50 / 1000.0;
bottomPrint(%obj.client, "\nChaingun Temperature ||||||||||||||||" SPC %obj.heatLevel @ "\%", 1, 3);
}
if(%obj.heatLevel >= 76 && %obj.heatLevel < 500){
%Spread = 7.0 / 1000.0;
bottomPrint(%obj.client, "\nChaingun Temperature ||||||||||||||||||||" SPC %obj.heatLevel @ "\%", 1, 3);
}
%vector = %obj.getMuzzleVector(%slot);
%x = (getRandom() - 0.5) * 2 * 3.1415926 * %Spread;
%y = (getRandom() - 0.5) * 2 * 3.1415926 * %Spread;
%z = (getRandom() - 0.5) * 2 * 3.1415926 * %Spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%vector = MatrixMulVector(%mat, %vector);
%p = new TracerProjectile() {
dataBlock = "ChaingunBullet";
initialDirection = %vector;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
};
%obj.lastProjectile = %p;
MissionCleanup.add(%p);
%obj.decInventory(%data.ammo,1);
if(%obj.client)
%obj.client.projectile = %p;
}
function CoolOffChaingun(%obj)
{
%oldheat = %obj.heatLevel;
%obj.heatLevel = (%obj.heatLevel > 4) ? %obj.heatLevel - 5 : 0;
if(%obj.getMountedImage($WeaponSlot) != 0)
%img = %obj.getMountedImage($WeaponSlot).getName();
else
%img = "";
if(%obj.heatLevel >= 40 && %img $= "ChaingunImage")
{
if(%oldheat >= 50 && %oldheat
Comments
I don't know if this is suggestive, since it would mostly benefit the chasers and perhaps make them overpowered but as your code is now, it isn't the same as in Legions. (I can't really read codes, so I might be wrong and you added this already )
Legions also has a visual indicator for that sort of thing doesn't it?
[code]function ChaingunImage::onMount(%this,%obj,%slot)
{
Parent::onMount(%this, %obj, %slot);
if(!%obj.coolingChaingun)
schedule(5000, %obj, "CoolOffChaingun", %obj);
%obj.coolingChaingun = true;
}
function ChaingunImage::onFire(%data,%obj,%slot)
{
%obj.heatLevel += (1 + mFloor(5 * getRandom()));
if(%obj.heatLevel >= 1 && %obj.heatLevel < 15){
%Spread = 1.0 / 1000.0;
//bottomPrint(%obj.client, "\nChaingun Temperature ||" SPC %obj.heatLevel @ "\%", 1, 3);
}
if(%obj.heatLevel >= 16 && %obj.heatLevel < 30){
%Spread = 1.50 / 1000.0;
//bottomPrint(%obj.client, "\nChaingun Temperature ||||" SPC %obj.heatLevel @ "\%", 1, 3);
}
if(%obj.heatLevel >= 31 && %obj.heatLevel < 45){
%Spread = 2.50 / 1000.0;
//bottomPrint(%obj.client, "\nChaingun Temperature ||||||||" SPC %obj.heatLevel @ "\%", 1, 3);
}
if(%obj.heatLevel >= 46 && %obj.heatLevel < 60){
%Spread = 3.50 / 1000.0;
//bottomPrint(%obj.client, "\nChaingun Temperature ||||||||||||" SPC %obj.heatLevel @ "\%", 1, 3);
}
if(%obj.heatLevel >= 61 && %obj.heatLevel < 75){
%Spread = 4.50 / 1000.0;
//bottomPrint(%obj.client, "\nChaingun Temperature ||||||||||||||||" SPC %obj.heatLevel @ "\%", 1, 3);
}
if(%obj.heatLevel >= 76 && %obj.heatLevel < 500){
%Spread = 7.0 / 1000.0;
//bottomPrint(%obj.client, "\nChaingun Temperature ||||||||||||||||||||" SPC %obj.heatLevel @ "\%", 1, 3);
}
%vector = %obj.getMuzzleVector(%slot);
%x = (getRandom() - 0.5) * 2 * 3.1415926 * %Spread;
%y = (getRandom() - 0.5) * 2 * 3.1415926 * %Spread;
%z = (getRandom() - 0.5) * 2 * 3.1415926 * %Spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%vector = MatrixMulVector(%mat, %vector);
%p = new TracerProjectile() {
dataBlock = "ChaingunBullet";
initialDirection = %vector;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
};
%obj.lastProjectile = %p;
MissionCleanup.add(%p);
%obj.decInventory(%data.ammo,1);
if(%obj.client)
%obj.client.projectile = %p;
}
function CoolOffChaingun(%obj)
{
%oldheat = %obj.heatLevel;
%vel = %obj.getVelocity();
%speed = VectorLen(%vel);
if(%speed > 15)
{
%obj.heatLevel = (%obj.heatLevel > 4) ? %obj.heatLevel - 15 : 0;
}
else
{
%obj.heatLevel = (%obj.heatLevel > 4) ? %obj.heatLevel - 5 : 0;
}
if(%obj.getMountedImage($WeaponSlot) != 0)
%img = %obj.getMountedImage($WeaponSlot).getName();
else
%img = "";
if(%obj.heatLevel >= 40 && %img $= "ChaingunImage")
{
if(%oldheat >= 50 && %oldheat
Tribes:Vengeance
Could also have been named:
Tribes:Tournament
Unreal:Vengeance
T:V is based on the sucky UT3 engine, and (shudders) D3D....
Great art, mediocre game