Results 1 to 14 of 14
  1. #1

    Default Help - How to make a landmine using UnrealScript

    Like the title says, I need help with making land mines. If anyone has a tutorial or something that can help, please share it. Really need help ASAP. Thanks!

  2. #2
    Redeemer
    Join Date
    Jul 2011
    Location
    London, UK
    Posts
    1,749

    Default

    I guess you could just place a mesh with a trigger near it, when your pawn reaches this trigger, you just reduce it's damage, also make sure to "play" an explosion effect, something along those lines,

  3. #3
    Iron Guard
    Join Date
    Aug 2010
    Location
    stoke.u.k
    Posts
    617
    Gamer IDs

    Gamertag: gaz661

    Default

    i dont remember who posted this code(sorry) and couldnt find it in a search,but this the code i use for landmines.



    Code:
    class boombarrel extends DynamicSMActor
        placeable;
       
    /** Should go boom when shot. */
    var()	bool	bDestroyOnDamage;
    
    /** Should go boom when a player walks over it. */
    var()	bool	bDestroyOnPlayerTouch;
    
    /** Should go boom when a vehicle drives over it. */
    var()	bool	bDestroyOnVehicleTouch;
    
    /** Mesh to switch to when destroyed. */
    var()	StaticMesh				MeshOnDestroy;
    
    /** Sound to play when destroyed. */
    var()	SoundCue				SoundOnDestroy;
    
    /** Particles to play when destroyed. */
    var()	ParticleSystem			ParticlesOnDestroy;
    
    /** Static mesh to spawn as physics object when destroyed. */
    var()	StaticMesh				SpawnPhysMesh;
    
    /** How long the spawned physics object should last. */
    var()	float					SpawnPhysMeshLifeSpan;
    
    /** Initial linear velocity for spawned physics object. */
    var()	vector					SpawnPhysMeshLinearVel;
    
    /** initial angular velocity for spawned physics object. */
    var()	vector					SpawnPhysMeshAngularVel;
    
    /** Time between being destroyed and respawning. */
    var()	float					RespawnTime;
    
    /** Used to remember what mesh to set us back to when respawned. */
    var		StaticMesh				RespawnStaticMesh;
    
    /** Whether we are currently in the destroyed state. */
    var		bool					bDestroyed;
    
    /** Time before we are going to respawn. */
    var		float					TimeToRespawn;
    
    /** Used to shut down actor on the server to reduce overhead. */
    simulated function PostBeginPlay()
    {
    	Super.PostBeginPlay();
    
    	// Remember what mesh we
    	RespawnStaticMesh = StaticMeshComponent.StaticMesh;
    
    	// If this is on dedicated server 
    	if(WorldInfo.NetMode == NM_DedicatedServer)
    	{
    		SetCollision(FALSE, FALSE);
    		DetachComponent(StaticMeshComponent);
    		BeginState('IgnoreItAll');
    	}
    }
    
    
    /** Do actual explosion. */
    simulated function GoBoom()
    {
    	local UTSD_SpawnedKActor PhysMesh;
    
        HurtRadius(50.0, 250.0, class'UTDamageType', 500.0, Location,,, True);
    
    	// Swap/hide the mesh
    	if(MeshOnDestroy != None)
    	{
    		StaticMeshComponent.SetStaticMesh(MeshOnDestroy); 
    	}
    	else
    	{
    		StaticMeshComponent.SetStaticMesh(None);
    		DetachComponent(StaticMeshComponent);
    	}
    
    	// Fire particles
    	if(ParticlesOnDestroy != None)
    	{
    		WorldInfo.MyEmitterPool.SpawnEmitter(ParticlesOnDestroy, Location, Rotation);
    	}
    
    	// Play sound
    	if(SoundOnDestroy != None)
    	{
    		PlaySound(SoundOnDestroy, TRUE);
    	}
    
    	// Spawn physics mesh
    	if(SpawnPhysMesh != None)
    	{
    		PhysMesh = spawn(class'UTSD_SpawnedKActor',,,Location, Rotation);
    		PhysMesh.StaticMeshComponent.SetStaticMesh(SpawnPhysMesh);
    		PhysMesh.StaticMeshComponent.SetRBLinearVelocity(SpawnPhysMeshLinearVel, FALSE);
    		PhysMesh.StaticMeshComponent.SetRBAngularVelocity(SpawnPhysMeshAngularVel, FALSE);
    		PhysMesh.StaticMeshComponent.WakeRigidBody();
    
    		// Have it collide with the world but thats it (ie not vehicles or players)
    		PhysMesh.SetCollision(FALSE, FALSE);
    		PhysMesh.StaticMeshComponent.SetRBChannel(RBCC_Default);
    		PhysMesh.StaticMeshComponent.SetRBCollidesWithChannel(RBCC_Default, TRUE);
    
    		// Set lifespan
    		PhysMesh.LifeSpan = SpawnPhysMeshLifeSpan;   
    
    	
    	}
    
    	bDestroyed = TRUE;
    	TimeToRespawn = RespawnTime;
    	SetTimer(1.0, TRUE, 'CheckRespawn');
    }
    
    /** Put destructible back into pre-destroyed state. */
    simulated function RespawnDestructible()
    {
    	// Reset static mesh and re-attach component.
    	StaticMeshComponent.SetStaticMesh(RespawnStaticMesh);
    	if(!StaticMeshComponent.bAttached)
    	{
    		AttachComponent(StaticMeshComponent);
    	}
    
    	bDestroyed = FALSE;
    }
    
    /** Called when shot. */
    simulated function TakeDamage(int DamageAmount, Controller EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser)
    {
    	if(!bDestroyed && bDestroyOnDamage)
    	{
    		GoBoom();
            
    	}
    }
    
    /** Called when overlapped by car/player */
    simulated function Touch(Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal)
    {
    	// Ignore if destroyed.
    	if(bDestroyed)
    	{
    		return;
    	}
    
    	if( Vehicle(Other) != None )
    	{
    		if(bDestroyOnVehicleTouch)
    		{
    			GoBoom();
    		}
    	}
    	else
    	{
    		if(bDestroyOnPlayerTouch)
    		{
    			GoBoom();
    		}
          
    	}
    }
    
    /** Used to countdown to respawn. */
    simulated event CheckRespawn()
    {
    	// If destroyed, countdown to respawn.
    	if(bDestroyed)
    	{
    		TimeToRespawn -= 1.0;
    
    		if(TimeToRespawn < 0.f && (StaticMeshComponent.LastRenderTime < WorldInfo.TimeSeconds - 1.0f))
    		{
    			RespawnDestructible();
    			ClearTimer('CheckRespawn');
    		}
    	}
    }
    
    /** State used to stop anything from happening on dedicated server. */
    state IgnoreItAll
    {
    	ignores Touch, TakeDamage, Tick;
    }
    
    
    
    defaultproperties
    {
    	bCollideActors=TRUE
    	bProjTarget=TRUE
    	bPathColliding=FALSE
    	bNoDelete=TRUE
        
        Begin Object Name=MyLightEnvironment
    		bEnabled=TRUE
    		bDynamic=FALSE
    	End Object
    
    	Begin Object Name=StaticMeshComponent0
            StaticMesh=StaticMesh'goodies.Mesh.explobar'
    	End Object
    
    	ParticlesOnDestroy[0]=ParticleSystem'goodies.Effects.expbarl'
    	
    	SoundOnDestroy=SoundCue'A_Vehicle_Manta.SoundCues.A_Vehicle_Manta_Explode'
    
    
    	RespawnTime=1000.0
    
    	SpawnPhysMeshLifeSpan=500.0
    	bDestroyOnDamage=TRUE
    	bDestroyOnPlayerTouch=TRUE
    	bDestroyOnVehicleTouch=TRUE
    }

  4. #4
    Redeemer
    Join Date
    May 2012
    Location
    Barcelona
    Posts
    1,559

    Default

    extend it from trigger , everything else would be eas with the touch event

  5. #5
    MSgt. Shooter Person
    Join Date
    Jan 2008
    Posts
    188

    Default

    Hi Guys,
    I tried the Landmine code but it does not appear to effect my player in the editor (i.e. no damage is scored on the player when he steps on the mine). Any ideas why that isn't working? BTW, I am using July 2012 UDK beta.

  6. #6
    MSgt. Shooter Person
    Join Date
    Jan 2008
    Posts
    188

    Default

    Could it be the HurtRadius clause in the GoBoom routine?
    Last edited by DemoMan2; 08-11-2012 at 10:35 AM.

  7. #7

    Default

    Quote Originally Posted by gaz661 View Post
    i dont remember who posted this code(sorry) and couldnt find it in a search,but this the code i use for landmines.
    Thanks! Currently doesn't affect health but working on fixing that. Thank you so much for the help!

  8. #8

    Default

    Nevermind, it does modify health.

  9. #9
    MSgt. Shooter Person
    Join Date
    Jan 2008
    Posts
    188

    Default

    Your right BlackJacket! Today I am getting damage to my health. Not sure what I did different today but it seems to work!

  10. #10
    MSgt. Shooter Person
    Join Date
    Jan 2008
    Posts
    188

    Default

    Well now this is really weird. Sometimes it works and sometimes it doesn't. That's very strange indeed.

  11. #11
    MSgt. Shooter Person
    Join Date
    Jan 2008
    Posts
    188

    Default

    From what I've been able to determine the Hurtradius function only applies damage to players that DO NOT initiate the objects destruction. So for a landmine we need an additional line of code to apply the damage back to the player and/or vehicle. Anyone care to supply that line of code?

  12. #12
    Iron Guard
    Join Date
    Jun 2008
    Posts
    818
    Gamer IDs

    Gamertag: Black Fang666

    Default

    Just change it so that it doesn't exclude the instigator.
    Want to collaborate? Want to chat UDK? Message me on Skype, Craig Delancy. Check out my UDK Youtube channel: http://www.youtube.com/user/xblBlack...ew=0&flow=grid

  13. #13
    MSgt. Shooter Person
    Join Date
    Jan 2008
    Posts
    188

    Default

    Quote Originally Posted by skwisdemon666 View Post
    Just change it so that it doesn't exclude the instigator.
    So how do you do that?

  14. #14
    Iron Guard
    Join Date
    Aug 2010
    Location
    stoke.u.k
    Posts
    617
    Gamer IDs

    Gamertag: gaz661

    Default

    just found the origional post(actually kel'tar did) by Gmax5.just mentioning it to give proper credit.http://forums.epicgames.com/threads/...loding-barrels


 

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.