Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation
previous class next class | frames no frames

# tmod.tmodWeaponBlaster

00001 00002 00003 00004 00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197

    class tmodWeaponBlaster extends EquipmentClasses.WeaponBlaster config(tribesmodSettings);

    var config float spread;
    //var() int numberOfBullets;
    var config float energyUsage;
    var config float roundsPerSecond;
    var config float projectileVelocity;
    var config float projectileInheritedVelFactor;

    var Shader plasmaShader;
    var ControllableTexturePanner plasmaTexPanner;
    var() int plasmaMaterialIndex;

    var Shader dialShader;
    var ControllableTexturePanner dialTexPanner;
    var() int dialMaterialIndex;

    var bool bControllableSkinSet;

    var float baseScale;
    var float nextFireTime;
    var float timeCounter;
    var bool bPostFire;

    simulated function buildControllableSkins()
    {
        local Combiner dialCombiner;

        // Build a controllable texture panner for the plasma shader
        plasmaShader = Shader(ShallowCopyMaterial(GetMaterial(plasmaMaterialIndex), self));

        if (plasmaShader != None)
        {
            plasmaTexPanner = new class'ControllableTexturePanner';
            plasmaTexPanner.PanDirection = Vector(TexPanner(plasmaShader.SelfIllumination).PanDirection);
            plasmaTexPanner.Material = TexPanner(plasmaShader.SelfIllumination).Material;

            plasmaShader.Diffuse = plasmaTexPanner;
            plasmaShader.SelfIllumination = plasmaTexPanner;
            plasmaShader.SelfIlluminationMask = plasmaTexPanner;
        }

        // Build a controllable texture panner for the dial shader
        dialShader = Shader(ShallowCopyMaterial(GetMaterial(dialMaterialIndex), self));

        if (dialShader != None)
        {
            dialCombiner = Combiner(ShallowCopyMaterial(dialShader.SelfIllumination, self));

            if (dialCombiner != None)
            {
                dialTexPanner = new class'ControllableTexturePanner';
                dialTexPanner.PanDirection = Vector(TexPanner(dialCombiner.Material2).PanDirection);
                dialTexPanner.Material = TexPanner(dialCombiner.Material2).Material;

                dialCombiner.Material2 = dialTexPanner;
                dialCombiner.Mask = dialTexPanner;

                dialShader.SelfIllumination = dialCombiner;
            }
        }

        // If both succeeded set the shaders as the skins for the weapon
        if (plasmaTexPanner != None && dialTexPanner != None)
            setControllableSkins();
    }

    simulated protected function FireWeapon()
    {
        Super.FireWeapon();

        baseScale = 0.5;
        bPostFire = true;
        timeCounter = 0.0;
        nextFireTime = 1 / roundsPerSecond;
    }

    simulated function Tick(float DeltaTime)
    {
        Super.Tick(DeltaTime);

        if (useAlternateMesh())
            return;

        if (PlayerCharacter(Owner) != None)
        {
            if (bControllableSkinSet)
            {
                dialTexPanner.Scale = FMax(0.0, Character(rookOwner).energy / Character(rookOwner).energyMaximum - 0.09);

                if (bPostFire)
                {
                    timeCounter += DeltaTime;

                    plasmaTexPanner.Scale = FMax(0.0, 0.5 - ((timeCounter / nextFireTime) * 0.5));

                    bPostFire = timeCounter <= nextFireTime;

                    if (!bPostFire)
                        baseScale = 0.0;
                }
                else
                {
                    plasmaTexPanner.Scale = baseScale;
                }
            }
            else
                buildControllableSkins();
        }
    }

    simulated function setControllableSkins()
    {
        local int maxNeedIndex;
        local int i;

        maxNeedIndex = Max(plasmaMaterialIndex, dialMaterialIndex);

        if (Skins.Length <= maxNeedIndex)
            Skins.Length = maxNeedIndex + 1;

        for (i = 0; i < maxNeedIndex; ++i)
        {
            Skins[i] = None;
        }

        Skins[plasmaMaterialIndex] = plasmaShader;
        Skins[dialMaterialIndex] = dialShader;

        bControllableSkinSet = true;
    }

    simulated function setHasAmmoSkins()
    {
        // Always has ammo
    }

    function useAmmo()
    {
        Character(rookOwner).weaponUseEnergy(energyUsage);
    }

    simulated function bool hasAmmo()
    {
        return true;
    }

    simulated function bool canFire()
    {
        return (rookOwner != None) && (Character(rookOwner).energy > (energyUsage * numberOfBullets));
    }

    // makeProjectile
    // not simulated, server only
    protected function Projectile makeProjectile(Rotator fireRot, Vector fireLoc)
    {
        local Rotator r;
        local float spreadInRotUnits;
        local int i;

        spreadInRotUnits = spread * 65536 / 360;

        for (i = 0; i < numberOfBullets; i++)
        {
            r.Yaw = spreadInRotUnits * (2.0f * FRand() - 1);
            r.Pitch = spreadInRotUnits * (2.0f * FRand() - 1);

            Super.makeProjectile( fireRot + r, fireLoc );
        }

        return None; // Warning: return None for this weapons projectile
    }

    defaultproperties
    {
        Spread=2.200000
        numberOfBullets=6
        energyUsage=1.500000
        plasmaMaterialIndex=3
        dialMaterialIndex=4
        ammoUsage=0
        roundsPerSecond=1.200000
        projectileClass=Class'tmodProjectileBlaster'
        projectileVelocity=18000.000000
        projectileInheritedVelFactor=0.000000
        aimClass=Class'AimProjectileWeapons'
        bGenerateMissSpeechEvents=False
        firstPersonMesh=SkeletalMesh'weapons.Blaster'
        firstPersonOffset=(X=-33.000000,Y=22.000000,Z=-15.000000)
        animPrefix="Blaster"
        animClass=Class'CharacterEquippableAnimator'
        inventoryIcon=Texture'GUITribes.InvButtonBlaster'
        hudIcon=Texture'HUD.Tabs'
        hudIconCoords=(V=472.000000)
        hudRefireIcon=Texture'HUD.Tabs'
        hudRefireIconCoords=(V=421.000000)
    }

Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation
previous class next class | frames no frames

Class file time: po 8.1.2018 22:01:56.000 - Creation time: st 23.5.2018 00:10:47.932 - Created with UnCodeX