Announcement

Collapse
No announcement yet.

Super simple shotgun!

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

    #16
    I think it might be in the projectile class you have a problem as for the Area of Damage the projectile does.
    Look into that, otherwise I don't have a clue what could make it hurt yourself.

    Comment


      #17
      Some improvement that you can do:

      Originally posted by ValleW View Post
      ...
      Code:
      simulated function Projectile ProjectileFire() // Main function from UTWeapon
      {
      	if(bIsShotGun == true) // Make the function check if our weapon actually is a shotgun.
      	{
      	    // This is wrong approach - look in to UT3 how to do that right...
                  for(s=0; s < Shells; s++) // Spawn the wanted amount of projectiles.
                  {
                      super.ProjectileFire();
                  }
              }
              else // If it isn't a shotgun then just do the normal ProjectileFire.
              {
                  super.ProjectileFire(); // Link to normal ProjectileFire(). <= use return super.ProjectileFire();
              }
              return None; // Standard. <= This is not standart - it should return projectile
      }
      ...
      ...with return None; log will be spammed with ReceiveProjectileWarning accessed None

      Comment


        #18
        In theory, if you put a sleep(x) in there, could this be used to make a burst fire weapon?

        Comment


          #19
          The variable s is only used in one function so I recommend making it a local variable and not a global variable, so Global Variables:
          Code:
          var int Shells; // Amount of bullets to be shot!
          var bIsShotgun; // Used as a detector if the weapon should fire as a shotgun or normally.
          And the ProjectileFire function:
          Code:
          simulated function Projectile ProjectileFire() // Main function from UTWeapon
          {
              local int s;
          
              if(bIsShotGun == true) // Make the function check if our weapon actually is a shotgun.
              {
                      for(s=0; s < Shells; s++) // Spawn the wanted amount of projectiles.
                      {
                          super.ProjectileFire();
                      }
                  }
                  else // If it isn't a shotgun then just do the normal ProjectileFire.
                  {
                      super.ProjectileFire(); // Link to normal ProjectileFire().
                  }
                  return None; // Standard.
          }

          Comment


            #20
            if(bIsShotGun == true) // Make the function check if our weapon actually is a shotgun.
            {
            // This is wrong approach - look in to UT3 how to do that right...
            for(s=0; s < Shells; s++) // Spawn the wanted amount of projectiles.
            {
            super.ProjectileFire();
            }
            }
            This is how the flakgun in UT3 does it, if there is another (better) approach feel free to post it. =)

            Comment


              #21
              Originally posted by ValleW View Post
              This is how the flakgun in UT3 does it...
              You're sure..?
              Code:
              // In UTWeap_FlakCannon...
              simulated function Projectile ProjectileFire()
              {
              	local vector		RealStartLoc;
              	local UTProj_FlakShell	SpawnedProjectile;
              
              	// tell remote clients that we fired, to trigger effects
              	IncrementFlashCount();
              
              	if( Role == ROLE_Authority )
              	{
              		// this is the location where the projectile is spawned.
              		RealStartLoc = GetPhysicalFireStartLoc();
              
              		// Spawn projectile
              		SpawnedProjectile = Spawn(class'UTProj_FlakShell',,, RealStartLoc);
              		if( SpawnedProjectile != None && !SpawnedProjectile.bDeleteMe )
              		{
              			SpawnedProjectile.Init( Vector(GetAdjustedAim( RealStartLoc )) );
              		}
              
              		// Return it up the line
              		return SpawnedProjectile;
              	}
              
              	return None;
              }
              
              // In UTProj_FlakShell...
              simulated function Explode(vector HitLocation, vector HitNormal)
              {
              	local vector SpawnPos, BaseChunkDir;
              	local actor HitActor;
              	local rotator rot;
              	local int i;
              	local UTProj_FlakShard NewChunk;
              
              	Super.Explode(HitLocation, HitNormal);
              
              	SpawnPos = Location + 10 * HitNormal;
              
              	HitActor = Trace(HitLocation, HitNormal, SpawnPos, Location, false);
              	if (HitActor != None)
              	{
              		SpawnPos = HitLocation;
              	}
              
              	if ( (Role == ROLE_Authority) && (UTVehicle(ImpactedActor) == None) )
              	{
              		BaseChunkDir = Normal(HitNormal + 0.8 * Normal(Velocity));
              		for (i = 0; i < 5; i++)
              		{
              			rot = rotator(4*BaseChunkDir + VRand());
              			NewChunk = Spawn(class 'UTProj_FlakShard',, '', SpawnPos, rot);
              			if (NewChunk != None)
              			{
              				NewChunk.bCheckShortRangeKill = false;
              				NewChunk.Init(vector(rot));
              			}
              		}
              	}
              }
              ...this is the best way.

              Comment


                #22
                VendorX,
                What you just linked is the secondary fire of the flak gun, which is a projectile that on impact explodes and spawns smaller projectile around the explosion. I am only doing the spawn part of it, and I am doing it only straight forward. =D

                Comment


                  #23
                  ...never mind...

                  Comment


                    #24
                    Thanks for the code. The only problem when using the instant hit shotgun is the fire effects (decal/bullet trace) can only be seen fully by the server, while clients can only see effect from one instantfire.

                    Comment


                      #25
                      I'm actually having a bit of difficulty getting this to work right, though I suspect that's because of how I've got my own game set up, as it's using udk code and not ut. For example, having it return projectile actually won't compile, and there's no actual spread shot; it just shoots one rocket at a time and the accuracy of which varies slightly per shot. Also, altfire does nothing at all.

                      But! I now have a working weapon I can build from, and more importantly, you have introduced me to the concept of a rocket shotgun, which is a rediculously fantastic idea. So you get a bump and my gratitude.

                      Comment


                        #26
                        I'm actually having a bit of difficulty getting this to work right, though I suspect that's because of how I've got my own game set up, as it's using udk code and not ut. For example, having it return projectile actually won't compile, and there's no actual spread shot; it just shoots one rocket at a time and the accuracy of which varies slightly per shot. Also, altfire does nothing at all, and I'm getting a tremendous amount of logspam.

                        But! I now have a working weapon I can build from, and more importantly, you have introduced me to the concept of a rocket shotgun, which is a rediculously fantastic idea. So you get a bump and my gratitude.

                        Comment


                          #27
                          I am having the same problem as SolaceEternal...

                          Comment


                            #28
                            Originally posted by SolaceEternal View Post
                            I'm actually having a bit of difficulty getting this to work right, though I suspect that's because of how I've got my own game set up, as it's using udk code and not ut. For example, having it return projectile actually won't compile, and there's no actual spread shot; it just shoots one rocket at a time and the accuracy of which varies slightly per shot. Also, altfire does nothing at all, and I'm getting a tremendous amount of logspam.

                            But! I now have a working weapon I can build from, and more importantly, you have introduced me to the concept of a rocket shotgun, which is a rediculously fantastic idea. So you get a bump and my gratitude.

                            Glad I could be of help!
                            I believe the problem is because you're deriving from UDK and not UT as most functions used here are from UT classes. However if you post the error log & your code I am more than willing to see if I can help =)

                            Comment


                              #29
                              Originally posted by galerian View Post
                              Thanks for the code. The only problem when using the instant hit shotgun is the fire effects (decal/bullet trace) can only be seen fully by the server, while clients can only see effect from one instantfire.
                              Hmm... It could be a problem with instanthit replication...
                              Could you post the error log and/or script you use? I could take a look at it and see if it's in the actual weapon code =)

                              Comment


                                #30
                                Actually, I think I fixed it. I changed the ProjectileFire() function so that in the for loop, it doesn't return and just calls super.ProjectileFire(), and instead of returning "projectile" at the end of the function, it returns "none". It seems to work now, which is good...

                                Code:
                                simulated function Projectile ProjectileFire()
                                {
                                             local int s;
                                
                                 if(bIsShotGun == true && CurrentFireMode==0)
                                 {
                                            for(s=0; s < Shells; s++)
                                            {
                                                super.ProjectileFire(); //Here I changed it to keep looping instead of returning
                                            }
                                        }
                                        else 
                                        {
                                           return super.ProjectileFire();
                                        }
                                        return None;
                                }

                                Comment

                                Working...
                                X