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

Comments

  • The faster you ski in Legions, the less your chaingun will overheat and thus the less spread your chaingun will have.
    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 :D)
  • ^ did not know that :o
    Legions also has a visual indicator for that sort of thing doesn't it?
  • The chaingun in this version will cool off much faster, when a player is moving at a Velocity of 15 or more. I am sure Keen, can code a much more realistic over heat function for 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
  • The faster you ski in Legions, the less your chaingun will overheat and thus the less spread your chaingun will have.
    Just pointing this out, it was this way in T:V.
  • The faster you ski in Legions, the less your chaingun will overheat and thus the less spread your chaingun will have.
    Just pointing this out, it was this way in T:V.
    what the hell is T:V
  • edited June 2009
    T":V?
    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
  • T":V?
    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
    I'm pretty sure he was being sarcastic
  • jus makin sure
Sign In or Register to comment.