I am trying to modify the LoTrap mod (Valve portal gun for UT3) so that it will not work if it hits an unvalid wall. I have created a new type of Volume called LoTrapVolume and I have an edited version of the Weap_LoTrap gun that will clean up the portals if it hits an invalid wall.
Essentially I do not know the syntax to be able to reference:
If the object that is colliding with my LoTrapVolume is a LoTrap projectile
Access and change a variable within another script ( from LoTrapVolume01.uc I need to change 'bValidWall' boolean, located in Weap_LoTrap_Edit01.uc, to false )
I am new to unreal script, so saying - just look up documentation, does not help me.
Following is my edited version of the Weap_LoTrap gun
Here is my attempt to create the LoTrapVolumeCode:class Weap_LoTrap_Edit extends Weap_LoTrap; // Is the wall valid to create a portal on? var bool bValidWall; var int whichPortalToCleanUp; // check whether Portal has hit a valid wall or not (based on hitting a LotrapVolume). function bool HitValidPortalWall( vector HitLocation, vector HitNormal ) { if (bValidWall) { return true; } else { return false; } } /* original CleanUpPortals function // Cleans up any existing portals simulated function CleanUpPortals() { if( m_Teleporters[0] != none ) { m_Teleporters[0].BeginClose(); } if( m_Teleporters[1] != none ) { m_Teleporters[1].BeginClose(); } // Even if the teleporters are destroyed, they aren't garbage collected unless we clean up references to them as well m_Teleporters[0] = none; m_Teleporters[1] = none; } */ simulated function ProcessPortalHit( byte FiringMode, vector HitLocation, vector HitNormal ) { local byte OtherMode; // Server side code only if( Role != ROLE_Authority ) { return; } // We are allowed to fire again now. m_MyProjectile = none; // Only continue if we hit a wall that is big enough for our portal if( HitValidPortalWall( HitLocation, HitNormal ) ) { OtherMode = (FiringMode == 1 ) ? 0 : 1; if( m_Teleporters[FiringMode] == none ) { if( FiringMode == 0 ) { m_Teleporters[FiringMode] = Spawn( class'LoTrap_Teleporter_Blue',,,HitLocation, rotator(HitNormal),,true ); } else { m_Teleporters[FiringMode] = Spawn( class'LoTrap_Teleporter_Red',,,HitLocation, rotator(HitNormal),,true ); } } else { m_Teleporters[FiringMode].SetLocation( HitLocation); m_Teleporters[FiringMode].SetRotation( rotator(HitNormal) ); } // Begins the scaling of the portal m_Teleporters[FiringMode].BeginOpen(); // Update both the portals m_Teleporters[FiringMode].SetTargetTeleporter( m_Teleporters[OtherMode] ); if( m_Teleporters[OtherMode] != none ) { m_Teleporters[OtherMode].SetTargetTeleporter( m_Teleporters[FiringMode] ); } m_Teleporters[FiringMode].UpdateRenderTarget(); if( m_Teleporters[OtherMode] != none ) { m_Teleporters[OtherMode].UpdateRenderTarget(); } } else { // I may need to split up this function to know whether it was the blue or orange portal which hit so the CleanUpPortals function does not destroy valid portals CleanUpPortals(); // clean up validity check bValidWall = true; } }
Code:/** * Copyright 2012 Dale, Alison. All Rights Reserved. * Desctiption: Custom volume which stops Lotrap portals from occuring */ class LotrapVolume01 extends Volume native placeable; var bool bNotValidWall; var bool bBounceHitObject; // On Touch with a LoTrap projectile will set the HitValidPortalWall return value to false. (HitValidPortalWall function is found in Weap_LoTrap.uc) event Touch( Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal ) { // ? super.Touch( Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal ); // Check whether the actor touching the volume is one of the LoTrap projectiles (there is a different projectile whether you click with the left or right mouse button) AssociatedActor.Touch(Other, OtherComp, HitLocation, HitNormal); /* I'm not sure on the syntax with check if it is a Lotrap projectile */ If (Pawn(Other) != None && Pawn(Other) = /*REFERENCE LOTRAP Projectile*/ ) { // Change the 'bValidWall' boolean in Weap_LoTrap_Edit.uc to false /* Again, I need to learn how to reference and edit variables in other scripts */ // I may need to split up this function to know whether it was the blue or orange portal which hit so the CleanUpPortals function does not destroy valid portals } } event UnTouch(Actor Other) { super.UnTouch(Other); if (Pawn(Other) != none && Pawn(Other) = /* REFERENCE LOTRAP PROJECTILE*/) { // TODO: Change the 'bValidWall' boolean in Weap_LoTrap_Edit.uc to True - NOT SURE HOW } } simulated event PostBeginPlay() { Super.PostBeginPlay(); // match bProjTarget to weapons (zero extent) collision setting if (BrushComponent != None) { bProjTarget = BrushComponent.BlockZeroExtent; } } simulated function bool StopsProjectile(Projectile P) { return false; } defaultproperties { BrushColor=(B=200,G=177,R=72,A=255) bColored=True Begin Object Class=BrushComponent Name=BrushComponent0 ObjName=BrushComponent0 Archetype=BrushComponent'Engine.Default__Volume:BrushComponent0' ObjectArchetype=BrushComponent'Engine.Default__Volume:BrushComponent0' End Object BrushComponent=BrushComponent0 Components(0)=BrushComponent0 bProjTarget=True CollisionComponent=BrushComponent0 SupportedEvents(1)=Class'Engine.SeqEvent_TakeDamage' Name="Default__LoTrapVolume" ObjectArchetype=Volume'Engine.Default__Volume' }
Here is the original Weap_Lotrap code, if it helps
Thankyou for whatever help you can give me on this.Code://----------------------------------------------------------- // //----------------------------------------------------------- class Weap_LoTrap extends UTWeapon; /* List of teleporters that we have currently in existence */ var LoTrap_Teleporter m_Teleporters[2]; /* The pretty particle system for this weapon */ var UTParticleSystemComponent m_ParticleSwirly; var UTParticleSystemComponent m_ParticleLeftBlue; var UTParticleSystemComponent m_ParticleRightOrange; /* Keeps track of the current projectile, to make sure we only have one in the air at a time */ var LoTrap_Proj m_MyProjectile; simulated state Active { simulated function BeginState( name PreviousStateName ) { Super.BeginState( PreviousStateName ); // Attach the system to the 1st person mesh. if( SkeletalMeshComponent( Mesh ) != none ) { SkeletalMeshComponent( Mesh ).AttachComponentToSocket( m_ParticleSwirly, 'FX_Socket' ); SkeletalMeshComponent( Mesh ).AttachComponentToSocket( m_ParticleLeftBlue, 'Left' ); SkeletalMeshComponent( Mesh ).AttachComponentToSocket( m_ParticleRightOrange, 'Right' ); m_ParticleLeftBlue.SetDepthPriorityGroup(SDPG_Foreground); m_ParticleLeftBlue.SetFOV(UTSkeletalMeshComponent(Mesh).FOV); m_ParticleRightOrange.SetDepthPriorityGroup(SDPG_Foreground); m_ParticleRightOrange.SetFOV(UTSkeletalMeshComponent(Mesh).FOV); // Activate it. m_ParticleLeftBlue.ActivateSystem(); m_ParticleRightOrange.ActivateSystem(); m_ParticleSwirly.ActivateSystem(); } } } simulated function Projectile ProjectileFire() { // Already have one in the air, destroy it. if( m_MyProjectile != none ) { m_MyProjectile.Destroy(); } m_MyProjectile = LoTrap_Proj(Super.ProjectileFire()); if (m_MyProjectile != None ) { m_MyProjectile.m_MyWeapon = self; } return m_MyProjectile; } function bool HitValidPortalWall( vector HitLocation, vector HitNormal ) { // make sure that the four corners from the hit location will be big enough to support our mesh. return true; } /** * When destroyed, make sure we clean up any portals that are still around */ simulated event Destroyed() { super.Destroyed(); CleanUpPortals(); } /** * A notification call when this weapon is removed from the Inventory of a pawn * @see Inventory::ItemRemovedFromInvManager */ function ItemRemovedFromInvManager() { Super.ItemRemovedFromInvManager( ); CleanUpPortals(); } // Cleans up any existing portals simulated function CleanUpPortals() { if( m_Teleporters[0] != none ) { m_Teleporters[0].BeginClose(); } if( m_Teleporters[1] != none ) { m_Teleporters[1].BeginClose(); } // Even if the teleporters are destroyed, they aren't garbage collected unless we clean up references to them as well m_Teleporters[0] = none; m_Teleporters[1] = none; } simulated function ProcessPortalHit( byte FiringMode, vector HitLocation, vector HitNormal ) { local byte OtherMode; // Server side code only if( Role != ROLE_Authority ) { return; } // We are allowed to fire again now. m_MyProjectile = none; // Only continue if we hit a wall that is big enough for our portal if( HitValidPortalWall( HitLocation, HitNormal ) ) { OtherMode = (FiringMode == 1 ) ? 0 : 1; if( m_Teleporters[FiringMode] == none ) { if( FiringMode == 0 ) { m_Teleporters[FiringMode] = Spawn( class'LoTrap_Teleporter_Blue',,,HitLocation, rotator(HitNormal),,true ); } else { m_Teleporters[FiringMode] = Spawn( class'LoTrap_Teleporter_Red',,,HitLocation, rotator(HitNormal),,true ); } } else { m_Teleporters[FiringMode].SetLocation( HitLocation); m_Teleporters[FiringMode].SetRotation( rotator(HitNormal) ); } // Begins the scaling of the portal m_Teleporters[FiringMode].BeginOpen(); // Update both the portals m_Teleporters[FiringMode].SetTargetTeleporter( m_Teleporters[OtherMode] ); if( m_Teleporters[OtherMode] != none ) { m_Teleporters[OtherMode].SetTargetTeleporter( m_Teleporters[FiringMode] ); } m_Teleporters[FiringMode].UpdateRenderTarget(); if( m_Teleporters[OtherMode] != none ) { m_Teleporters[OtherMode].UpdateRenderTarget(); } } } simulated function String GetHumanReadableName() { return "LoTrap Gun"; } defaultproperties { Begin Object Class=UTParticleSystemComponent Name=Particle_Swirly ObjName=Particle_Swirly Archetype=UTParticleSystemComponent'UTGame.Default__UTParticleSystemComponent' Template=ParticleSystem'WP_LoTrap.FX.FX_LoTrapSwirly' SecondsBeforeInactive=0.000000 Name="Particle_Swirly" ObjectArchetype=UTParticleSystemComponent'UTGame.Default__UTParticleSystemComponent' End Object m_ParticleSwirly=Particle_Swirly Begin Object Class=UTParticleSystemComponent Name=Particle_LeftBlue ObjName=Particle_LeftBlue Archetype=UTParticleSystemComponent'UTGame.Default__UTParticleSystemComponent' Template=ParticleSystem'WP_LoTrap.FX.FX_LeftBlue' SecondsBeforeInactive=0.000000 Name="Particle_LeftBlue" ObjectArchetype=UTParticleSystemComponent'UTGame.Default__UTParticleSystemComponent' End Object m_ParticleLeftBlue=Particle_LeftBlue Begin Object Class=UTParticleSystemComponent Name=Particle_RightOrange ObjName=Particle_RightOrange Archetype=UTParticleSystemComponent'UTGame.Default__UTParticleSystemComponent' Template=ParticleSystem'WP_LoTrap.FX.FX_RightOrange' SecondsBeforeInactive=0.000000 Name="Particle_RightOrange" ObjectArchetype=UTParticleSystemComponent'UTGame.Default__UTParticleSystemComponent' End Object m_ParticleRightOrange=Particle_RightOrange ShotCost(0)=0 ShotCost(1)=0 InventoryGroup=1 AttachmentClass=Class'LoTrap.Attachment_LoTrap' GroupWeight=0.700000 ArmsAnimSet=AnimSet'WP_FlakCannon.Anims.K_WP_FlakCannon_1P_Arms' WeaponFireSnd(0)=SoundCue'A_Weapon_FlakCannon.Weapons.A_FlakCannon_FireAltCue' WeaponFireSnd(1)=SoundCue'A_Weapon_FlakCannon.Weapons.A_FlakCannon_FireAltCue' WeaponPutDownSnd=SoundCue'A_Weapon_Link.Cue.A_Weapon_Link_LowerCue' WeaponEquipSnd=SoundCue'A_Weapon_Link.Cue.A_Weapon_Link_RaiseCue' MuzzleFlashSocket="MuzzleFlash" MuzzleFlashPSCTemplate=ParticleSystem'WP_ShockRifle.Particles.P_ShockRifle_MF_Alt' WeaponFireTypes(0)=EWFT_Projectile WeaponFireTypes(1)=EWFT_Projectile WeaponProjectiles(0)=Class'LoTrap.LoTrap_Proj_Primary' WeaponProjectiles(1)=Class'LoTrap.LoTrap_Proj_Alt' Begin Object Class=UTSkeletalMeshComponent Name=FirstPersonMesh ObjName=FirstPersonMesh Archetype=UTSkeletalMeshComponent'UTGame.Default__UTWeapon:FirstPersonMesh' FOV=60.000000 SkeletalMesh=SkeletalMesh'WP_LoTrap.Meshes.SK_WP_LoTrap' Animations=UTAnimNodeSequence'LoTrap.Default__Attachment_LoTrap:SkeletalMeshComponent0.MeshSequenceA' AnimSets(0)=AnimSet'WP_Translocator.Anims.K_WP_Translocator_1P_Base' Translation=(X=-6.000000,Y=0.000000,Z=-4.000000) ObjectArchetype=UTSkeletalMeshComponent'UTGame.Default__UTWeapon:FirstPersonMesh' End Object Mesh=FirstPersonMesh Begin Object Class=SkeletalMeshComponent Name=PickupMesh ObjName=PickupMesh Archetype=SkeletalMeshComponent'UTGame.Default__UTWeapon:PickupMesh' SkeletalMesh=SkeletalMesh'WP_LoTrap.Meshes.SK_WP_LoTrap_MID' ObjectArchetype=SkeletalMeshComponent'UTGame.Default__UTWeapon:PickupMesh' End Object DroppedPickupMesh=PickupMesh PickupFactoryMesh=PickupMesh Name="Default__Weap_LoTrap" ObjectArchetype=UTWeapon'UTGame.Default__UTWeapon' }



Reply With Quote

Bookmarks