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

AcidGun

The section related to UnrealScript and modding. This board is for coders to discuss and exchange experiences or ask questions.
User avatar
mentalhunter
OldUnreal Member
Posts: 814
Joined: Sun Oct 07, 2007 10:31 am

AcidGun

Post by mentalhunter »

I am making this gun, and i want it so that the target will explode as soon as its fatness reaches 255.
How to do that? till now i have the timer etc set, but i just don't know how to make it explode as the target reaches 255 fatness. Till now i got this:

Code: Select all

var bool bLighting;
var float DelayTime;
Var pawn p;

Function PostBeginPlay()
{
Super.postbeginplay(); 
    SetTimer(1.0,True);
    
}
    
/////////////////////////////////////////////////////
auto state Flying
{
      simulated function ProcessTouch( Actor Other, Vector HitLocation )
      {
            local int hitdamage;
            local vector hitDir;
                  
            if (Other != instigator && StingerProjectile(Other) == none)
            {      
                  if ( Role == ROLE_Authority )
                  {                        
                        hitDir = Normal(Velocity);
                        if ( FRand() < 0.2 )
                              hitDir *= 5;
                        Other.TakeDamage(damage, instigator,HitLocation,                                                
                              (MomentumTransfer * hitDir), 'shot');                        
                              
                  }
                  Destroy();                  
            }
      }

      simulated function HitWall( vector HitNormal, actor Wall )
      {
            Super.HitWall(HitNormal, Wall);      
            if (FRand()> RandRot;
            if( Region.zone.bWaterZone )
                  Velocity=0.7*Velocity;
      }
}

///////////////////////////////////////////////////////
simulated function Explode(vector HitLocation, vector HitNormal)
{
}

simulated function AnimEnd()
{
      Destroy();
}

//
Uhm, i couldn't find the code function when i posted this question, can an admin fix this?
Last edited by mentalhunter on Tue Dec 25, 2007 12:41 pm, edited 1 time in total.
User avatar
Pitbull
Administrator
Posts: 1226
Joined: Fri Oct 04, 2002 6:47 pm
Location: Between Venus and Mars

Re: AcidGun

Post by Pitbull »

Fixed your post for you. For inserting code use the button that has the # sign on it.  ;)
Upon this rock I will build my church O:-)

LOADING HATERS..████████████] 99% Complete.
User avatar
mentalhunter
OldUnreal Member
Posts: 814
Joined: Sun Oct 07, 2007 10:31 am

Re: AcidGun

Post by mentalhunter »

Alright, thanks :)
User avatar
Raven
OldUnreal Member
Posts: 311
Joined: Fri Jun 10, 2005 5:10 am

Re: AcidGun

Post by Raven »

I'd wrote smth like this:

Code: Select all

var bool bLighting;
var float DelayTime;
Var pawn p;

Function PostBeginPlay()
{
Super.postbeginplay(); 
    SetTimer(1.0,True);
    
}
    
/////////////////////////////////////////////////////
auto state Flying
{
      simulated function ProcessTouch( Actor Other, Vector HitLocation )
      {
            local int hitdamage;
            local vector hitDir;

            if (Other != instigator && StingerProjectile(Other) == none)
            {
                  if ( Role == ROLE_Authority )
                  {
                        hitDir = Normal(Velocity);
                        if ( FRand() < 0.2 )
                              hitDir *= 5;
                        Other.TakeDamage(damage, instigator,HitLocation, (MomentumTransfer * hitDir), 'shot');
                                if(Pawn(Other) != none)
                                {
                                   SetOwner(Other);
                                   GoToState('Growing');
                                }
                  }
//                  Destroy();
            }
      }

      simulated function HitWall( vector HitNormal, actor Wall )
      {
            Super.HitWall(HitNormal, Wall);      
            if (FRand()> RandRot;
            if( Region.zone.bWaterZone )
                  Velocity=0.7*Velocity;
      }
}

state Growing
{
Begin:
 if(Pawn(Owner) != none)
 {
   Pawn(Owner).Fatness += 20;
   Pawn(Owner).Health -= 2;   //health is integer  - no floats allowed !
   if(Pawn(Owner).Fatness < 255) GoTo('Begin');
   Pawn(Owner).TakeDamage(1000, instigator, Location, vect(0,0,0) , 'shot');
   SetOwner(none);
   Destroy();
 }
}
///////////////////////////////////////////////////////
simulated function Explode(vector HitLocation, vector HitNormal)
{
}

simulated function AnimEnd()
{
      Destroy();
}

//
didn't test it, so it may containt errors.
Image
User avatar
mentalhunter
OldUnreal Member
Posts: 814
Joined: Sun Oct 07, 2007 10:31 am

Re: AcidGun

Post by mentalhunter »

K, thanks alot. I think i can fix those errors who may appear.

EDIT: If the proj hits the pawn, it gives me an error about the growing state:

Code: Select all


Critical: appError called:
Critical: AcidProj Unreal.AcidProj2 (State mod.AcidProj.Growing:0048) Runaway loop detected (over 1000000 iterations)
Critical: Windows GetLastError: De bewerking is voltooid. (0)
Exit: Executing UObject::StaticShutdownAfterError
Exit: UGalaxyAudioSubsystem::ShutdownAfterError
Exit: Executing UWindowsClient::ShutdownAfterError
Log: DirectDraw End Mode
Critical: FFrame::Serialize
Critical: AActor::ProcessState
Critical: Object AcidProj Unreal.AcidProj2, Old State State mod.AcidProj.Growing, New State State mod.AcidProj.Growing
Critical: AActor::Tick
Critical: TickAllActors
Critical: ULevel::Tick
Critical: (NetMode=0)
Critical: TickLevel
Critical: UGameEngine::Tick
Critical: UpdateWorld
Critical: MainLoop
Last edited by mentalhunter on Tue Dec 25, 2007 2:27 pm, edited 1 time in total.
Jâçkrâßßit

Re: AcidGun

Post by Jâçkrâßßit »

don't let that loop runaway  ;D

a For loop might work best with this


EDIT

Code: Select all

state Growing
{
Begin:
 if(Pawn(Owner) != none)
 {
   Pawn(Owner).Fatness += 20;
   Pawn(Owner).Health -= 2;   //health is integer  - no floats allowed !
   if(Pawn(Owner).Fatness < 255) GoTo('Begin');
   Pawn(Owner).TakeDamage(1000, instigator, Location, vect(0,0,0) , 'shot');
   SetOwner(none);
   Destroy();
 }
}
If your shooting this gun at someone else, shouldn't it be Pawn(Other) and not Pawn(Owner)?
Last edited by Jâçkrâßßit on Tue Dec 25, 2007 3:51 pm, edited 1 time in total.
User avatar
mentalhunter
OldUnreal Member
Posts: 814
Joined: Sun Oct 07, 2007 10:31 am

Re: AcidGun

Post by mentalhunter »

Well, i just copyd the code, didnt looked in it he. Now i did, and it doesnt work. those expression errors. I usual don't get any errors when im coding, so i don't really know how to fix most of em.
Last edited by mentalhunter on Tue Dec 25, 2007 5:03 pm, edited 1 time in total.
User avatar
mentalhunter
OldUnreal Member
Posts: 814
Joined: Sun Oct 07, 2007 10:31 am

Re: AcidGun

Post by mentalhunter »

Come on, there must be someone who knows this :)
User avatar
Raven
OldUnreal Member
Posts: 311
Joined: Fri Jun 10, 2005 5:10 am

Re: AcidGun

Post by Raven »

Forget to add one thing - sleep :P

Code: Select all

state Growing
{
Begin:
 if(Pawn(Owner) != none)
 {
   Pawn(Owner).Fatness += 20;
   Pawn(Owner).Health -= 2;   //health is integer  - no floats allowed !
   if(Pawn(Owner).Fatness < 255)
   {
      Sleep(0.01);
      GoTo('Begin');
   }
   Pawn(Owner).TakeDamage(1000, instigator, Location, vect(0,0,0) , 'shot');
   SetOwner(none);
   Destroy();
 }
}
should work fine. Why not Pawn(Other) ? Because in state Growing you don't have variable other which could store reference to pawn we just hit. Of course you can add such var, but why not use 'owner' to store reference to pawn ?
Image
User avatar
mentalhunter
OldUnreal Member
Posts: 814
Joined: Sun Oct 07, 2007 10:31 am

Re: AcidGun

Post by mentalhunter »

Cool, thanks. Ive almost exactly got what i asked for, the only thing thats wrong is that it doesnt explode if the health reaches 0, in fact the health jsut keeps on counting down lol.

I added a Health thing the same way as the Fatness, i dont know how else to do it.
I added the effect:

Code: Select all

state Growing
{
Begin:
 if(Pawn(Owner) != none)
 {
   Pawn(Owner).Fatness += 20;
   Pawn(Owner).Health -= 2;   //health is integer  - no floats allowed !
   PLaySound(Sound 'AGrowing');
   if(Pawn(Owner).Fatness < 255)
   {
      Sleep(0.01);
      GoTo('Begin');
   }
   if(Pawn(Owner).Health< 0
   {
      Sleep(0.01);
      GoTo('Begin');
   }

   Pawn(Owner).TakeDamage(1000, instigator, Location, vect(0,0,0) , 'shot');
   SetOwner(none);
   spawn(class'AcidExplosion');   
   Destroy();
 }
}

Last edited by mentalhunter on Wed Dec 26, 2007 11:37 pm, edited 1 time in total.

Return to “UScript Board”