For direct access use https://forums.oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com

Rechargeable Flashlight?

Ask UnrealEd 1 mapping related questions, or give hints, tips and tricks
Post Reply
William(Rainman)
OldUnreal Member
Posts: 991
Joined: Mon Jul 25, 2011 3:20 am

Rechargeable Flashlight?

Post by William(Rainman) »

Anyone know how to make a Rechargeable Flashlight?

for a more futuristic feel.
Last edited by William(Rainman) on Sat Jul 14, 2012 10:14 pm, edited 1 time in total.
User avatar
SFJake
OldUnreal Member
Posts: 252
Joined: Sun Aug 15, 2010 4:31 pm

Re: Rechargeable Flashlight?

Post by SFJake »

Part of my mod actually has unused items of various kinds including rechargeable items.



I'll share exactly what my code is, I really don't think its the cleanest in any way but it works.

Code: Select all

//=============================================================================
// RechargeableFlashlight.
//=============================================================================
class RechargeableFlashlight expands Flashlight;

var() int bRechargeAmount; //Amount to recharge every bRechargeTimer.
var() float bRechargeTimer;
var() bool bDestroySimilar; //If TRUE, destroys similar objects in the inventory that are useless when having a rechargeable version.
var() int bTimeBeforeRecharge; //This is actually counted by the amount of time it goes in the TIMER. So if bRechargeTimer is at 1.5 and this is at 3, then it will take 3 time 1.5, so 4.5 seconds.

var int bRechargeTime;

state Activated
{
      function endstate()
      {
            bRechargeTime = bTimeBeforeRecharge;
                  s.Destroy();
            bActive = false;
      }

      function Tick( float DeltaTime )
      {
            TimeChange += DeltaTime*10;
            if (TimeChange > 1)
            {
                  if ( s == None )
                  {
                        UsedUp();
                        return;
                  }
                  Charge -= int(TimeChange);
                  TimeChange = TimeChange - int(TimeChange);
            }

            if (s == None) Return;

            if ( Pawn(Owner) == None )
            {
                  s.Destroy();
                  UsedUp();
                  return;
            }
            if (Charge<-0)
            {
                  s.Destroy();
                  Activate();
                  return;
            }

            if (Charge<1) s.LightBrightness=byte(Charge*0.6+10);

            GetAxes(Pawn(Owner).ViewRotation,X,Y,Z);
            EndTrace = Pawn(Owner).Location + 10000* Vector(Pawn(Owner).ViewRotation);
            Trace(HitLocation,HitNormal,EndTrace,Pawn(Owner).Location, True);
            s.SetLocation(HitLocation-vector(Pawn(Owner).ViewRotation)*64);
//            s.LightRadius = fmin(Vsize(HitLocation-Pawn(Owner).Location)/200,14) + 2.0;
      }

      function BeginState()
      {
            bActive = true;
            TimeChange = 0;
            Owner.PlaySound(ActivateSound);
            GetAxes(Pawn(Owner).ViewRotation,X,Y,Z);
            EndTrace = Pawn(Owner).Location + 10000* Vector(Pawn(Owner).ViewRotation);
            Trace(HitLocation,HitNormal,EndTrace,Pawn(Owner).Location+Y*17);
            s = Spawn(class'FlashLightBeam',Owner, '', HitLocation+HitNormal*40);
            s.LightHue = LightHue;
            s.LightRadius = LightRadius;
            if (Charge<1) s.LightBrightness=byte(Charge*0.6+10);
            if (s==None) GoToState('DeActivated');
      }

Begin:
}


state DeActivated
{
      function Timer()
      {
      local inventory I;

      if ( bDestroySimilar )
      {
      for ( I = Owner.Inventory; I != None; I = I.Inventory )
            if ( I.IsA('RechargeableFlashlight') )
            {
            }
            else if ( I.IsA('SearchLight') )
            {
            }
            else if ( I.IsA('Flashlight') )
                  I.Destroy();
      }

            if( Charge<Default.Charge && bRechargeTime <= 0 )
                  Charge+=bRechargeAmount;
            else if ( bRechargeTime >= 1 )
                  bRechargeTime--;
      }
Begin:
      bActive = False;
      SetTimer(bRechargeTimer,true);
      Owner.PlaySound(DeActivateSound);
}

defaultproperties
{
      bRechargeAmount=40
      bRechargeTimer=0.500000
      bDestroySimilar=True
      bTimeBeforeRecharge=2
      PickupMessage="You picked up the rechargeable flashlight"
      Charge=2000
}



Most of it is easy to configure. You can have a delay before it starts recharging, you can edit the recharging speed, you can make it delete redundant, normal Flashlights from your inventory (will keep SearchLights).



Do with this as you wish.
SFJake Center -
Unreal Nightmare - http://sfjake.byethost7.com/unrealnmproject.html
William(Rainman)
OldUnreal Member
Posts: 991
Joined: Mon Jul 25, 2011 3:20 am

Re: Rechargeable Flashlight?

Post by William(Rainman) »

Part of my mod actually has unused items of various kinds including rechargeable items.



I'll share exactly what my code is, I really don't think its the cleanest in any way but it works.







Most of it is easy to configure. You can have a delay before it starts recharging, you can edit the recharging speed, you can make it delete redundant, normal Flashlights from your inventory (will keep SearchLights).



Do with this as you wish.


You should make it into a Mod, Anyway thank you.

Post Reply

Return to “UnrealEd, the editor for Unreal up to version  226”