Announcement

Collapse

The Infinity Blade Forums Have Moved

We've launched brand new Infinity Blade forums with improved features and revamped layout. We've also included a complete archive of the previous posts. Come check out the new Infinity Blade forums.
See more
See less

Modifying DunDef Code in UT3

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

  • Modifying DunDef Code in UT3

    Hello,

    I am currently having a problem modifying the staff from Dungeon Defense in UT3. I'm trying to make it so that the gun fires different projectiles depending on if it is charged or not. I currently have a system that nearly works. At the moment, I can rapid click to fire LinkPlasma or Hold-Click for 1.5seconds (or longer) then release for ShockBall. However, if I don't fire anything for 1.5 seconds, it also fires a ShockBall instead of LinkPlasma.

    The part of the code where I think the problem is is here:
    Code:
    	event Tick(float DeltaTime)
    	{
    		super.Tick(DeltaTime);
    
    		if(PendingFire(0) && `TimeSince(LastReleasedTime) > FireInterval[0])
    				SendToFiringState(0);
    	}
    Currently, I've had to // out the "if(PendingFire(0) && `TimeSince(LastReleasedTime) > FireInterval[0])" as I get and error that says:

    Code:
    Warning/Error Summary
    ---------------------
    c:\program files (x86)\steam\steamapps\common\unreal tournament 3\UTGame\Src\MPHMutator\MPHWeap_BasicGun.uc(54) : Error, Unknown macro 'TimeSince'.
    
    Failure - 1 error(s), 0 warning(s)
    
    Execution of commandlet took:  1.76 seconds
    Any Help?

    Thanks,
    Kieran

    PS. Here is the full code for the weapon, Please ignore the sloppyness. Once I get the gun functioning, then I'll do some tidying!:
    Code:
    class MPHWeap_BasicGun extends UTWeapon;
    
    var float FullChargeTime;
    var transient float StoredChargePercent;
    var transient float LastReleasedTime;
    
    simulated function BeginFire(Byte FireModeNum)
    {
    	//start charge here
    	super.BeginFire(FireModeNum);
    }
    simulated function EndFire(Byte FireModeNum)
    {
    	//stop charge here
    	GotoState('Active');
    	super.EndFire(FireModeNum);
    }
    
    simulated state Active
    {
    	/** Initialize the weapon as being active and ready to go. */
    	simulated event BeginState(Name PreviousStateName)
    	{
    		// Cache a reference to the AI controller
    //		if (Role == ROLE_Authority)
    //		{
    //			CacheAIController();
    //		}
    		// Check to see if we need to go down
       		if( bWeaponPutDown )
    		{
    			PutDownWeapon();
    		}
    		else if ( !HasAnyAmmo() )
    		{
    			WeaponEmpty();
    		}
    		//removed automatic firing upon entering active state
    	}
    
    	/** Override BeginFire so that it will enter the firing state right away. */
    	simulated function BeginFire(byte FireModeNum)
    	{
    		if( !bDeleteMe && Instigator != None )
    		{
    			Global.BeginFire(FireModeNum);
    		}
    	}
    
    	event Tick(float DeltaTime)
    	{
    		super.Tick(DeltaTime);
    
    /** WuhTuhFuh!		if(PendingFire(0) && `TimeSince(LastReleasedTime) > FireInterval[0]) */
    				SendToFiringState(0);
    	}
    }
    
    /** Magic Staff's in this state while holding down the Fire button, charges up until release */
    simulated state WeaponFiring
    {
    	simulated event BeginState( Name PreviousStateName )
    	{
    		//`log("Begin Weapon Firing State!");
    		TimeWeaponFiring( CurrentFireMode );
    		
    		//initialize our charge effects
    		StoredChargePercent=0;
    /**		ChargeEffect.SetScale(MinChargeEffectScale);
    		ChargeEffect.ActivateSystem();
    		ChargeLight.SetLightProperties(0);
    		ChargeLight.SetEnabled(true);
    		MyAudioComponent1.FadeIn(1,1);
    */	}
    
    	simulated function RefireCheckTimer()
    	{
    		// if switching to another weapon, abort firing and put down right away
    		if( bWeaponPutDown )
    		{
    			PutDownWeapon();
    			return;
    		}
    
    		return;
    	}
    
    	event Tick(float DeltaTime)
    	{
    		super.Tick(DeltaTime);
    
    		//increment our charge value and effects every frame while holding down the fire button
    		if(StoredChargePercent < 1)
    		{
    			StoredChargePercent = FMin(StoredChargePercent + (DeltaTime/FullChargeTime),1);
    //			ChargeEffect.SetScale(MinChargeEffectScale + (MaxChargeEffectScale-MinChargeEffectScale)*StoredChargePercent);
    //			ChargeLight.SetLightProperties(ChargeLightOriginalBrightness*StoredChargePercent);
    
    //			if(StoredChargePercent > 0.1 && !DunDefPlayer(Instigator).IsPlayingCustomAnim(DunDefPlayer(Instigator).MinStaffChargeAnimation))
    //				DunDefPlayer(Instigator).PlayCustomAnimUpperBody(DunDefPlayer(Instigator).MinStaffChargeAnimation,0.3,true);
    
    //			if(StoredChargePercent == 1)
    //				ReachedFullCharge();
    		}
    	}
    
    	/** Activates full-charge effects */
    /**	function ReachedFullCharge()
    	{
    		MyAudioComponent2.FadeIn(1,1);
    		MyAudioComponent1.FadeOut(1,0);
    		FullyChargedEffect.ActivateSystem();
    		DunDefPlayer(Instigator).PlayCustomAnimUpperBody(DunDefPlayer(Instigator).MaxStaffChargeAnimation,0.33,true);
    		DunDefPlayer(Instigator).StopCustomAnim(0.9,DunDefPlayer(Instigator).MinStaffChargeAnimation);
    	}
    */ 
    simulated function class<Projectile> GetProjectileClass()
    {
              if (StoredChargePercent == 1)
              {
                 return WeaponProjectiles[1];
              }
              else
              {
                  return WeaponProjectiles[0];
              }
    }
    
    	/** Released weapon fire */
    	simulated event EndState( Name NextStateName )
    	{        //shoot it!
                    GetProjectileClass();
    		FireAmmunition();
    		//Reset Properties
    		StoredChargePercent=0;
    		LastReleasedTime=WorldInfo.TimeSeconds;
    
    		//stop all the charge effects
    //		if(MyAudioComponent1.IsPlaying())
    //			MyAudioComponent1.FadeOut(0.5,0);
    //
    //		if(MyAudioComponent2.IsPlaying())
    //			MyAudioComponent2.FadeOut(0.5,0);
    //
    //		ChargeEffect.DeactivateSystem();
    //		ChargeLight.SetEnabled(false);
    //		FullyChargedEffect.DeactivateSystem();
    //		DunDefPlayer(Instigator).StopCustomAnim(0.2,DunDefPlayer(Instigator).MinStaffChargeAnimation);
    //		DunDefPlayer(Instigator).StopCustomAnim(0.2,DunDefPlayer(Instigator).MaxStaffChargeAnimation);
    
    		super.EndState(NextStateName);
    	}
    }
    simulated function bool ShouldRefire()
    {
    	return false;
    }
    
    
    defaultproperties
    {
    	WeaponColor=(R=255,G=255,B=0,A=255)
    	FireInterval(0)=+0.25
    	FireInterval(1)=+0.75
    	PlayerViewOffset=(X=16.0,Y=-18,Z=-18.0)
    
    	Begin Object class=AnimNodeSequence Name=MeshSequenceA
    		bCauseActorAnimEnd=true
    	End Object
    
    	// Weapon SkeletalMesh
    	Begin Object Name=FirstPersonMesh
    		SkeletalMesh=SkeletalMesh'WP_LinkGun.Mesh.SK_WP_Linkgun_1P'
    		AnimSets(0)=AnimSet'WP_LinkGun.Anims.K_WP_LinkGun_1P_Base'
    		Animations=MeshSequenceA
    		Scale=0.9
    		FOV=60.0
    	End Object
    
    	AttachmentClass=class'UTAttachment_Linkgun'
    
    	// Pickup staticmesh
    	Begin Object Name=PickupMesh
    		SkeletalMesh=SkeletalMesh'WP_LinkGun.Mesh.SK_WP_LinkGun_3P'
    	End Object
    
    	FireOffset=(X=12,Y=10,Z=-10)
    
    	WeaponFireTypes(0)=EWFT_Projectile
    	WeaponProjectiles(0)=class'UTProj_LinkPlasma' // UTProj_LinkPowerPlasma if linked (see GetProjectileClass() )
    	WeaponFireTypes(1)=EWFT_Projectile
    	WeaponProjectiles(1)=class'UTProj_ShockBall' // UTProj_LinkPowerPlasma if linked (see GetProjectileClass() )
    
    	WeaponEquipSnd=SoundCue'A_Weapon_Link.Cue.A_Weapon_Link_RaiseCue'
    	WeaponPutDownSnd=SoundCue'A_Weapon_Link.Cue.A_Weapon_Link_LowerCue'
    	WeaponFireSnd(0)=SoundCue'A_Weapon_Link.Cue.A_Weapon_Link_FireCue'
    	WeaponFireSnd(1)=SoundCue'A_Weapon_Link.Cue.A_Weapon_Link_FireCue'
    
    	MaxDesireability=0.7
    	AIRating=+0.71
    	CurrentRating=+0.71
    	bFastRepeater=true
    	bInstantHit=false
    	bSplashJump=false
    	bRecommendSplashDamage=false
    	bSniping=false
    	ShouldFireOnRelease(0)=0
    	ShouldFireOnRelease(1)=0
    	InventoryGroup=5
    	GroupWeight=0.5
    
    	WeaponRange=900
    
    	PickupSound=SoundCue'A_Pickups.Weapons.Cue.A_Pickup_Weapons_Link_Cue'
    
    	AmmoCount=50
    	LockerAmmoCount=100
    	MaxAmmoCount=220
    
    	EffectSockets(0)=MuzzleFlashSocket
    	EffectSockets(1)=MuzzleFlashSocket
    
    	MuzzleFlashSocket=MuzzleFlashSocket
    	MuzzleFlashPSCTemplate=ParticleSystem'WP_LinkGun.Effects.P_FX_LinkGun_MF_Primary'
    	MuzzleFlashAltPSCTemplate=ParticleSystem'WP_LinkGun.Effects.P_FX_LinkGun_MF_Primary'
    	bMuzzleFlashPSCLoops=true
    	MuzzleFlashLightClass=class'UTGame.UTLinkGunMuzzleFlashLight'
    
    	bShowAltMuzzlePSCWhenWeaponHidden=TRUE
    
    	MuzzleFlashColor=(R=120,G=255,B=120,A=255)
    	MuzzleFlashDuration=0.33;
    
    	IconX=412
    	IconY=82
    	IconWidth=40
    	IconHeight=36
    
    	CrossHairCoordinates=(U=384,V=0,UL=64,VL=64)
    
    	LockerRotation=(pitch=0,yaw=0,roll=-16384)
    	IconCoordinates=(U=453,V=467,UL=147,VL=41)
    
    	QuickPickGroup=5
    	QuickPickWeight=0.8
    	
    	FullChargeTime=1.5
    }

  • #2
    In UT3? The source code is meant for UDK, not UT3.

    Comment


    • #3
      Originally posted by Graylord View Post
      In UT3? The source code is meant for UDK, not UT3.
      Indeed it is, but I've got everything working apart from this one bit. I'm wondering where the "TimeSince" macro comes from. Does it come from UDK or can be found in DunDef Source?

      Comment


      • #4
        I can't find any such macro in UDK myself, so it might be in the DunDef codes.

        (Though I am relying on a automated search, so it may not be accurate.)

        Comment


        • #5
          Originally posted by Graylord View Post
          I can't find any such macro in UDK myself, so it might be in the DunDef codes.
          Ok, any ideas where macros are usually saved? Are they inside .uc files, if so, would they be in a parent class, or can they be gotten from elsewhere? If I know where about to find it, I should be able to implement it. I haven't worked with macros in UScript before.

          Thanks,
          Kieran

          Comment


          • #6
            DunDef have indeed used their own Macro. They essentially used their own timers based on DeltaTime; it's the time since the button was last released. You can work it out yourself, you don't need to copy and paste the macro.

            Comment


            • #7
              Originally posted by ambershee View Post
              DunDef have indeed used their own Macro. They essentially used their own timers based on DeltaTime; it's the time since the button was last released. You can work it out yourself, you don't need to copy and paste the macro.
              Ok, Thanks! Now I just need to check UDN on how to actually write macros in UScript!

              Comment

              Working...
              X