Announcement

Collapse
No announcement yet.

Weapon lock on.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Weapon lock on.

    I'm trying to figure out what a weapon needs to be able to lock on and fire homing projectiles.

    I've been looking at the weapon files for the longbow and rocket launcher. I can't seem to find where it handles the locking. Like how long it takes for it to lock, and if it can lock onto vehicles or people. I can find the lock on time in the default properties, but not where it is used. What functions do I need to get a homing projectile up and running?

    Thanks

    #2
    I think is it a different projectile, because Rocket Launcher has two kinds of projectiles, Rockets and seeking rockets.

    Comment


      #3
      I looked at both, and there didn't seem to be much difference, and I couldn't find anything relating to homing. I think they are different mostly because of damage, etc.

      Comment


        #4
        Seeking rocket is what your looking for I believe, don't quote me on that though, I don't have anything to hand to check.

        Comment


          #5
          I fooled around with this for a long time and I eventually did find a way to create an (almost) completely custom auto lock-on projectile based off of the old UT2k4 space fighter missile code. It's really buggy, though.

          Comment


            #6
            look in UTWeap_RocketLauncher
            and look at line 197 which is Target Locking then look at 211 and 212

            i would sudgest using notepad++ you can get it here
            http://sourceforge.net/projects/notepad-plus/files/

            Comment


              #7
              Thanks Unrealloco,
              I saw that before, but I don't know how to view it in the game. It would help a lot with all kinds of scripting if I could find out how to get it to work.

              Comment


                #8
                If it's any help, here are all of the functions, etc I have in my weapon script, regarding locking:

                Code:
                /**
                 * The function checks to see if we are locked on a target
                 */
                native function CheckTargetLock();
                
                native function UpdateLockTarget(Actor NewLockTarget);
                
                simulated function GetWeaponDebug( out Array<String> DebugInfo )
                {
                	Super.GetWeaponDebug(DebugInfo);
                
                	DebugInfo[DebugInfo.Length] = "Locked: "@bLockedOnTarget@LockedTarget@LastLockedontime@(WorldInfo.TimeSeconds-LastLockedOnTime);
                	DebugInfo[DebugInfo.Length] = "Pending:"@PendingLockedTarget@PendingLockedTargetTime@WorldInfo.TimeSeconds;
                }
                
                simulated function FireAmmunition()
                {
                	Super.FireAmmunition();
                
                	if ( Role == ROLE_Authority )
                	{
                		AdjustLockTarget( none );
                		LastValidTargetTime = 0;
                		PendingLockedTarget = None;
                		LastLockedOnTime = 0;
                		PendingLockedTargetTime = 0;
                	}
                }
                
                /**
                 *  This function is used to adjust the LockTarget.
                 *  Called by UpdateLockTarget() only when NewLockTarget is different from LockTarget
                 */
                event AdjustLockTarget(actor NewLockTarget)
                {
                	if (NewLockTarget == None)
                	{
                		// Clear the lock
                		if (bLockedOnTarget)
                		{
                			LockedTarget = None;
                
                			bLockedOnTarget = false;
                
                			if (LockLostSound != None && Instigator != None && Instigator.IsHumanControlled() )
                			{
                				PlayerController(Instigator.Controller).ClientPlaySound(LockLostSound);
                			}
                		}
                	}
                	else
                	{
                		// Set the lcok
                		bLockedOnTarget = true;
                		LockedTarget = NewLockTarget;
                		LockedTargetPRI = (Pawn(NewLockTarget) != None) ? Pawn(NewLockTarget).PlayerReplicationInfo : None;
                		if ( LockAcquiredSound != None && Instigator != None  && Instigator.IsHumanControlled() )
                		{
                			PlayerController(Instigator.Controller).ClientPlaySound(LockAcquiredSound);
                		}
                	}
                }
                
                /**
                 * Given an actor (TA) determine if we can lock on to it.  By default only allow locking on
                 * to pawns.  Some weapons may want to be able to lock on to other actors.
                 */
                native function bool CanLockOnTo(Actor TA);
                
                auto simulated state Inactive
                {
                	simulated function BeginState(name PreviousStateName)
                	{
                		Super.BeginState(PreviousStateName);
                
                		if ( Role == ROLE_Authority )
                		{
                			bTargetLockingActive = false;
                			AdjustLockTarget(None);
                		}
                	}
                
                	simulated function EndState(Name NextStateName)
                	{
                		Super.EndState(NextStateName);
                
                		if ( Role == ROLE_Authority )
                		{
                			bTargetLockingActive = true;
                		}
                	}
                }
                
                simulated event Destroyed()
                {
                	AdjustLockTarget(none);
                	super.Destroyed();
                }
                Most of it has very little modification, so it probably isn't something that I screwed up, just left out. I also have the variables defined at the top, and some values in the default properties.

                I can't even seem to find where the code takes the values, say the LockAquireTime, and applies them. I'm totally lost as to where the actual locking happens...

                Comment


                  #9
                  The lock happens in the adjust lock target function:

                  Code:
                  // Set the lcok
                  		bLockedOnTarget = true;
                  		LockedTarget = NewLockTarget;
                  		LockedTargetPRI = (Pawn(NewLockTarget) != None) ? Pawn(NewLockTarget).PlayerReplicationInfo : None;
                  		if ( LockAcquiredSound != None && Instigator != None  && Instigator.IsHumanControlled() )
                  		{
                  			PlayerController(Instigator.Controller).ClientPlaySound(LockAcquiredSound);
                  		}

                  Comment


                    #10
                    Well, I got that, but it isn't working. Are there any flags I need to set for it to start locking?

                    It would be real handy to get that debug info working so I could see how far it is getting, if it is working at all.

                    Comment


                      #11
                      bump

                      Can anyone help with the debug text?

                      Thanks

                      Comment


                        #12
                        OK, I got the weaponDebug working. I just needed to type "showdebug weapon" in the console.

                        When I hover my mouse over the target, I never get a PendingLockedTarget. I can find where pending locked target is defined, but it is never used in the arvil, and used only to set it to none in the rocket launcher.

                        When you put your crosshairs over a target, it needs to check if it can lock onto the target, and then start counting up the locking time until it locks, but I can't find where that is!

                        Comment


                          #13
                          I am also curious to know this. I am working on an avril that targets monsters for Invasion.

                          Comment

                          Working...
                          X