Change Color of Shock Rifle Shot

Discussions about Coding and Scripting

Change Color of Shock Rifle Shot

Postby Vankuss » Tue Jan 31, 2012 6:34 pm

Hi guys.

I need a modified version of the Super Shock Rifle: basically, I just want to make the alternate fire to be blue instead of red.
Is there a way to do this without using custom textures?
User avatar
Vankuss
Experienced
 
Posts: 111
Joined: Wed Jan 25, 2012 6:35 pm

Re: Change Color of Shock Rifle Shot

Postby ASLYE702 » Tue Jan 31, 2012 6:43 pm

User avatar
ASLYE702
Masterful
 
Posts: 513
Joined: Wed Nov 30, 2011 9:33 pm

Re: Change Color of Shock Rifle Shot

Postby Vankuss » Tue Jan 31, 2012 6:48 pm

I searched through the forum and found nothing, lol.
Thanks ;)
User avatar
Vankuss
Experienced
 
Posts: 111
Joined: Wed Jan 25, 2012 6:35 pm

Re: Change Color of Shock Rifle Shot

Postby ASLYE702 » Tue Jan 31, 2012 7:25 pm

Vankuss wrote:I searched through the forum and found nothing, lol.
Thanks ;)


Nope! :D
User avatar
ASLYE702
Masterful
 
Posts: 513
Joined: Wed Nov 30, 2011 9:33 pm

Re: Change Color of Shock Rifle Shot

Postby Dr.Flay » Wed Feb 01, 2012 4:02 pm

If you have a look at "ColourMatch" mutator, you may be able to make the changes you need.
http://utdatabase.99k.org/mutators_standard.html
User avatar
Dr.Flay
Godlike
 
Posts: 1129
Joined: Thu Aug 04, 2011 9:26 pm
Location: Kernow, UK
Personal rank: C= AMIGA freak

Re: Change Color of Shock Rifle Shot

Postby Vankuss » Wed Feb 01, 2012 7:09 pm

Thanks Doctor!
Anyway, I successfully changed the color of the beam (making it blue instead of red), but I can't make it only for the alt firing.

I looked up at the source of both Super and Shock Rifle, found nothing. Does anyone have an idea? Basically it's just changing some words, but I don't know where the "alt fire animation" is stored.
User avatar
Vankuss
Experienced
 
Posts: 111
Joined: Wed Jan 25, 2012 6:35 pm

Re: Change Color of Shock Rifle Shot

Postby Feralidragon » Wed Feb 01, 2012 11:08 pm

So, if I understood right, you just want the altfire red trace/line effect of the super shock rifle to have the regular shockrifle blue color.

This should do it (explanation below):
Code: Select all
class MySuperShockRifle expands SuperShockRifle;

var() class<ShockBeam> ShockBeamClass[2];
enum E_ShotType
{
   ST_Fire,
   ST_AltFire
};
var E_ShotType shotType;


function Fire(float Value)
{
   shotType = ST_Fire;
   Super.Fire(Value);
}

function AltFire(float Value)
{
   shotType = ST_AltFire;
   Super.AltFire(Value);
}

function SpawnEffect(vector HitLocation, vector SmokeLocation)
{
local SuperShockBeam Smoke,shock;
local Vector DVector;
local int NumPoints;
local rotator SmokeRotation;

    DVector = HitLocation - SmokeLocation;
    NumPoints = VSize(DVector)/135.0;
    if ( NumPoints < 1 )
        return;
    SmokeRotation = rotator(DVector);
    SmokeRotation.roll = Rand(65535);
   
    Smoke = Spawn(ShockBeamClass[shotType],,,SmokeLocation,SmokeRotation);
    Smoke.MoveAmount = DVector/NumPoints;
    Smoke.NumPuffs = NumPoints - 1;
}


defaultproperties
{
   ShockBeamClass(0)=Class'SuperShockBeam'
   ShockBeamClass(1)=Class'ShockBeam'
}


Basically the effect is spawned with SpawnEffect, therefore you have to alternate between spawning either ShockBeam (blue version) or SuperShockBeam (red version).

What I did there (so the code would be the most "correct" possible), was to declare ShockBeamClass as the property where you define the beam classes, where the slot 0 is for fire and slot 1 for altfire.
Then I created an enumeration called E_ShotType which is then declared as variable as shotType.

As you can see in SpawnEffect, I used shotType to select which class to spawn from the array.
shotType could have been a byte as well, and assign 0 and 1 in fire and altfire respectively, however legible code is the best thing to do and enumerations in UScript (and some other languages) are the same thing as a byte variables, but with an alias, therefore ST_Fire=0, and ST_AltFire=1 actually, and to keep code legible in what those bytes mean, I used an enum instead (simply good coding practice, that's all).

Btw, I didn't test/compile this code, so if it has any syntax error, sorry.
User avatar
Feralidragon
Site Staff
 
Posts: 3713
Joined: Wed Feb 27, 2008 6:24 pm
Location: Portugal - Lisbon
Personal rank: The Unreal Boy

Re: Change Color of Shock Rifle Shot

Postby EvilGrins » Thu Feb 02, 2012 7:36 am

I've got mutators for that sorta thing... or at the very least weapon packs.
Image Image Image Image Image Image
ut99 needs superheroes & supervillains
http://unreal-games.livejournal.com/
User avatar
EvilGrins
Godlike
 
Posts: 1728
Joined: Thu Jun 30, 2011 8:12 pm
Location: Palo Alto, CA
Personal rank: God of Fudge

Re: Change Color of Shock Rifle Shot

Postby Vankuss » Thu Feb 02, 2012 8:50 am

With some corrections it worked perfectly. Just a stupid thing: the explosion is red instead of blue, but right now I'm trying to correct it.

Little edit: A thing I noticed is that the energy ray (the beam, I don't know how it's called) moves faster than the original. Obviously it is an insta-hit weapon, but as you know in the Shock Rifle and in the Instagib one you can see the energy ray. In my version, the beam is twice faster, lol. Going to correct it too, if I can.

Thank you guys.
User avatar
Vankuss
Experienced
 
Posts: 111
Joined: Wed Jan 25, 2012 6:35 pm


Return to Coding, Scripting

Who is online

Users browsing this forum: Google [Bot] and 0 guests