Results 1 to 8 of 8
  1. #1

    Arrow Coding Help: Instahit/Particles team based for Darkwalker replacement.

    I was trying to change the Darkwalkers default "red" 1st seat primary fire into a team based system. Where blue team has a "Blue" primary for the "Recognizer" below. I have found that the Instagib rifle has a team based option for the particle system. I don't have any clue how to fix it though to get it to work. Help if you can.

    Code:
    class UTVehicle_Recognizer extends UTVehicle_DarkWalker_Content;
    
    var array<ParticleSystem> TeamMuzzleFlashes;
    
    simulated function AttachWeaponTo(SkeletalMeshComponent MeshCpnt, optional name SocketName)
    {
    	local int TeamIndex;
    
    	TeamIndex = Instigator.GetTeamNum();
    	if (TeamIndex > TeamMuzzleFlashes.length)
    	{
    		TeamIndex = 0;
    	}
    	MuzzleFlashPSCTemplate = TeamMuzzleFlashes[TeamIndex];
    
    	Super.AttachWeaponTo(MeshCpnt, SocketName);
    }
    defaultproperties
    {
    
    	BeamTemplate=ParticleSystem'VH_DarkWalker.Effects.P_VH_DarkWalker_MainGun_Beam'
    	BeamSockets(0)=MainGun_00
    	BeamSockets(1)=MainGun_01
    	EndPointParamName=LinkBeamEnd
    	
    TeamMuzzleFlashes[0]=ParticleSystem'VH_DarkWalker.Effects.P_VH_DarkWalker_MainGun_Beam'
    TeamMuzzleFlashes[1]=ParticleSystem'VH_Recognizer.Effects.P_VH_Recognizer_Beam_Blue'
    
    }
    I have already got the 2nd seat turret to be blue when on the blue team. You can see the vehicle and the blue turret fire here:
    Last edited by euchreplayer23; 03-25-2012 at 01:22 PM.
    Please support the UT3 community both on the PC and PS3.

  2. #2

    Default

    Here is another sampling of the code where a particle changes in relation to the team your on.
    Hoverboard cable:
    Code:
    simulated event SpawnTowCableEffects()
    {
    	local byte TeamNum;
    	local UTPawn P;
    	TeamNum = GetTeamNum();
    	if (TowBeamEmitter == None)
    	{
    		TowBeamEmitter = new(self) class'UTParticleSystemComponent';
    		TowBeamEmitter.SetTickGroup(TG_PostAsyncWork);
    		TowBeamEmitter.SetTranslation(vect(0.0, 8.0, 0.0));
    		TowBeamEmitter.SecondsBeforeInactive = 1.0;
    		TowBeamEmitter.bDeferredBeamUpdate = true;
    		TowBeamEmitter.SetTemplate((TeamNum == 1) ? TowBeamTeamEmitters[1] : TowBeamTeamEmitters[0]);
    		P = UTPawn(Driver);
    		if (P != None && P.Mesh != None)
    		{
    			P.Mesh.AttachComponentToSocket(TowBeamEmitter, P.WeaponSocket);
    		}
    }
    Here is the part i need inside the Darkwalker code to change.
    Code:
    simulated function AddBeamEmitter()
    {
    	local int i;
    	if (WorldInfo.NetMode != NM_DedicatedServer)
    	{
    		for (i=0;i<2;i++)
    		{
    			if (BeamEmitter[i] == None)
    			{
    				if (BeamTemplate != None)
    				{
    					BeamEmitter[i] = new(Outer) class'UTParticleSystemComponent';
    					BeamEmitter[i].SetTemplate(BeamTemplate);
    					BeamEmitter[i].SecondsBeforeInactive=1.0f;
    					BeamEmitter[i].SetHidden(true);
    					Mesh.AttachComponentToSocket( BeamEmitter[i],BeamSockets[i] );
    				}
    			}
    			else
    			{
    				BeamEmitter[i].ActivateSystem();
    			}
    		}
    	}
    }
    I have tried to ad the team stuff into this code but no luck. Please help.
    Please support the UT3 community both on the PC and PS3.

  3. #3
    MSgt. Shooter Person
    Join Date
    Jun 2009
    Posts
    399

    Default

    I used it somewhere in my codes as well. But i couldn't find it for now. Basically you can solve this by creating a base material with a Vector parameter, used for the team color, and create two MaterialInstance with these teamcolors. You can assign team to be used as material for the specific ParticleSystem. But you can do the same programmatically. You can look at the LinkGun source.

    UTWeap_LinkGun
    Code:
    simulated function PostBeginPlay()
    {
        local color DefaultBeamColor;
    
        [...]
    
        if (WorldInfo.NetMode != NM_DedicatedServer && Mesh != None)
        {
            LinkAttachmentClass.static.GetTeamBeamInfo(255, DefaultBeamColor);
            WeaponMaterialInstance = Mesh.CreateAndSetMaterialInstanceConstant(0);
            WeaponMaterialInstance.SetVectorParameterValue('TeamColor', ColorToLinearColor(DefaultBeamColor));
        }
    }
    The problem with the MainGun Beam Material/ParticleSystem is: There is no parameter.
    You can create an own PSC like this one:
    PICKUPS_2.Deployables.Effects.FX_Deployables_LinkS tation_Discharge

    There is this 'Link_Beam_Color' parameter to control to color of the effect.

    UTLinkGenerator
    Code:
    simulated function AddBeamEmitters()
    {
       [...]
       BeamEmitter[i].SetColorParameter('Link_Beam_Color', LinkBeamColor);
       [...]
    }

  4. #4

    Default

    RattleSN4K3 i don't understand, (PSC=particle system component?). I have a stock red beam and a new blue beam in my vech package.

    This compiled but crashes my PC. I think this is wrong "if (teamNum != 1)" for the blue team. Maybe the else if section is wrong 2.
    Code:
    simulated function AddBeamEmitter()
    {
    	local int i;
    	local byte TeamNum;
    
    	TeamNum = GetTeamNum();
    
    	if (WorldInfo.NetMode != NM_DedicatedServer)
    	{
    		if (teamNum != 1)		
    		{
    			for (i=0;i<2;i++)
    			{
    				if (BeamEmitter[i] == None)
    				{
    					if (BeamTemplate != None)
    					{
    						BeamEmitter[i] = new(Outer) class'UTParticleSystemComponent';
    						BeamEmitter[i].SetTemplate(BlueBeamTemplate);
    						BeamEmitter[i].SecondsBeforeInactive=1.0f;
    						BeamEmitter[i].SetHidden(true);
    						Mesh.AttachComponentToSocket( BeamEmitter[i],BeamSockets[i] );
    					}
    				}
    				else
    				{
    					BeamEmitter[i].ActivateSystem();
    				
    
    				}
    			}
    		}
    	}
    	else if (WorldInfo.NetMode != NM_DedicatedServer)
    	{
    		if (teamNum != 0)
    		{
    			for (i=0;i<2;i++)
    			{
    				if (BeamEmitter[i] == None)
    				{
    					if (BeamTemplate != None)
    					{
    						BeamEmitter[i] = new(Outer) class'UTParticleSystemComponent';
    						BeamEmitter[i].SetTemplate(BeamTemplate);
    						BeamEmitter[i].SecondsBeforeInactive=1.0f;
    						BeamEmitter[i].SetHidden(true);
    						Mesh.AttachComponentToSocket( BeamEmitter[i],BeamSockets[i] );
    					}
    				}
    				else
    				{
    					BeamEmitter[i].ActivateSystem();
    				
    
    				}
    			}
    		}
    
    	}
    }
    Please support the UT3 community both on the PC and PS3.

  5. #5
    MSgt. Shooter Person
    Join Date
    Jun 2009
    Posts
    399

    Default

    Ah okay.

    Regarding your code:
    The 2nd if clause is never called. Try this:
    Code:
    class MyDW extends UTVehicle_DarkWalker_Content;
    
    var ParticleSystem BlueBeamTemplate;
    
    simulated function AddBeamEmitter()
    {
        local int i;
        local ParticleSystem LocalBeamTemplate;
    
        if (GetTeamNum() != 0) {
            LocalBeamTemplate = BeamTemplate;
        } else {
            LocalBeamTemplate = BlueBeamTemplate;
        }
        
        if (WorldInfo.NetMode != NM_DedicatedServer)
        {
            for (i=0;i<2;i++)
            {
                if (BeamEmitter[i] == None)
                {
                    if (LocalBeamTemplate != None)
                    {
                        BeamEmitter[i] = new(Outer) class'UTParticleSystemComponent';
                        BeamEmitter[i].SetTemplate(LocalBeamTemplate);
                        BeamEmitter[i].SecondsBeforeInactive=1.0f;
                        BeamEmitter[i].SetHidden(true);
                        Mesh.AttachComponentToSocket( BeamEmitter[i],BeamSockets[i] );
                    }
                }
                else
                {
                    BeamEmitter[i].ActivateSystem();
                }
            }
        }
    }
    
    DefaultProperties
    {
        BeamTemplate=ParticleSystem'VH_MyDW.Effects.P_VH_MyDW_Beam_Red'
        BlueBeamTemplate=ParticleSystem'VH_MyDW.Effects.P_VH_MyDW_Beam_Blue'
    }

    If you have your own ParticleSystem, you can add a Parameter like "TeamColor". So you can change it programmatically (like the LinkGenerator ParticleSystem mentioned in my previous post).

    Code:
    BeamEmitter[i].SetTemplate(BeamTemplate);
    BeamEmitter[i].SetColorParameter ('TeamColor', GetTeam().TeamColor);

  6. #6

    Default

    I don't have to nessecarily use it. It is just a editor color modified default DW beam. I will look through your LinkGun suggestions, i believe that will atleast not crash UT3.
    Quote Originally Posted by RattleSN4K3 View Post
    If you have your own ParticleSystem, you can add a Parameter like "TeamColor". So you can change it programmatically (like the LinkGenerator ParticleSystem mentioned in my previous post).

    Code:
    BeamEmitter[i].SetTemplate(BeamTemplate);
    BeamEmitter[i].SetColorParameter ('TeamColor', GetTeam().TeamColor);
    This compiles but crashes PC/UT3:
    Quote Originally Posted by RattleSN4K3 View Post
    Code:
    class MyDW extends UTVehicle_DarkWalker_Content;
    
    var ParticleSystem BlueBeamTemplate;
    
    simulated function AddBeamEmitter()
    {
        local int i;
        local ParticleSystem LocalBeamTemplate;
    
        if (GetTeamNum() != 0) {
            LocalBeamTemplate = BeamTemplate;
        } else {
            LocalBeamTemplate = BlueBeamTemplate;
        }
        
        if (WorldInfo.NetMode != NM_DedicatedServer)
        {
            for (i=0;i<2;i++)
            {
                if (BeamEmitter[i] == None)
                {
                    if (LocalBeamTemplate != None)
                    {
                        BeamEmitter[i] = new(Outer) class'UTParticleSystemComponent';
                        BeamEmitter[i].SetTemplate(LocalBeamTemplate);
                        BeamEmitter[i].SecondsBeforeInactive=1.0f;
                        BeamEmitter[i].SetHidden(true);
                        Mesh.AttachComponentToSocket( BeamEmitter[i],BeamSockets[i] );
                    }
                }
                else
                {
                    BeamEmitter[i].ActivateSystem();
                }
            }
        }
    }
    Please support the UT3 community both on the PC and PS3.

  7. #7
    MSgt. Shooter Person
    Join Date
    Jun 2009
    Posts
    399

    Default

    Did you set the defaultproperties? I tested that code and it compiles fine and runs without crashing. But the effect does not get applied as the TeamNum variable is set after the vehicle is fully spawned. The AddEmitter function is called within spawning.

    So the code needs to be changed a bit to apply a team based beam after the vehicle got spawned. The SetTeamNum event works well for this purpose.

    Test mutator
    Code:
    class TBDWBMut extends UTMutator;
    
    function bool CheckReplacement(Actor Other)
    {
        local string vpath;
    
        if (UTVehicleFactory_DarkWalker(Other) !=none) {
            vpath = GetPackageName()$"."$class'BeamDW'.default.Class.name;
            UTVehicleFactory_DarkWalker(Other).VehicleClassPath = vpath;
            UTVehicleFactory_DarkWalker(Other).VehicleClass = class'BeamDW';
            
            return true;
        }
    
        return true;
    }
    
    DefaultProperties
    {
    }
    DW class
    Code:
    class BeamDW extends UTVehicle_DarkWalker_Content;
    
    var ParticleSystem BlueBeamTemplate;
    
    /**
     * Team is changed when vehicle is possessed
     */
    event SetTeamNum(byte T)
    {
        super.SetTeamNum(T);
    
        AdjustBeam(T);
    }
    
    simulated function ParticleSystem GetTeamBasedTemplate(byte T)
    {
        if (T==1) {
            return BlueBeamTemplate;
        } else {
            return BeamTemplate;
        }
    }
    
    simulated function AdjustBeam(byte T)
    {
        local int i;
        local ParticleSystem LocalBeamTemplate;
            
        if (WorldInfo.NetMode != NM_DedicatedServer)
        {
            for (i=0;i<2;i++)
            {
                if (BeamEmitter[i] != None)
                {
                    LocalBeamTemplate=GetTeamBasedTemplate(T);
                    if (LocalBeamTemplate != none) {
                        BeamEmitter[i].SetTemplate(LocalBeamTemplate);
                    }
                }
            }
        }
    }
    
    DefaultProperties
    {
        BeamTemplate=ParticleSystem'WP_LinkGun.Effects.P_WP_Linkgun_Altbeam_Red'
        BlueBeamTemplate=ParticleSystem'WP_LinkGun.Effects.P_WP_Linkgun_Altbeam_Blue'
    }
    Note: Could not work on clients in Netmode.
    Hint: You can check the Raptor code. The Raptor has team based coloured particle system for the projectiles.

  8. #8

    Default


    The below worked great thx. Thanks again.

    Quote Originally Posted by RattleSN4K3 View Post
    Code:
    class BeamDW extends UTVehicle_DarkWalker_Content;
    
    var ParticleSystem BlueBeamTemplate;
    
    /**
     * Team is changed when vehicle is possessed
     */
    event SetTeamNum(byte T)
    {
        super.SetTeamNum(T);
    
        AdjustBeam(T);
    }
    
    simulated function ParticleSystem GetTeamBasedTemplate(byte T)
    {
        if (T==1) {
            return BlueBeamTemplate;
        } else {
            return BeamTemplate;
        }
    }
    
    simulated function AdjustBeam(byte T)
    {
        local int i;
        local ParticleSystem LocalBeamTemplate;
            
        if (WorldInfo.NetMode != NM_DedicatedServer)
        {
            for (i=0;i<2;i++)
            {
                if (BeamEmitter[i] != None)
                {
                    LocalBeamTemplate=GetTeamBasedTemplate(T);
                    if (LocalBeamTemplate != none) {
                        BeamEmitter[i].SetTemplate(LocalBeamTemplate);
                    }
                }
            }
        }
    }
    
    DefaultProperties
    {
        BeamTemplate=ParticleSystem'WP_LinkGun.Effects.P_WP_Linkgun_Altbeam_Red'
        BlueBeamTemplate=ParticleSystem'WP_LinkGun.Effects.P_WP_Linkgun_Altbeam_Blue'
    }
    Last edited by euchreplayer23; 03-28-2012 at 06:02 PM.
    Please support the UT3 community both on the PC and PS3.


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.