• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code [Help] Zed Gun Beam Projectile

Josko

Grizzled Veteran
Nov 2, 2012
107
0
I have been making a custom version of the ZED Gun (Zed Eradication Device )

Everything works fine except when I fire it, the beam projectile is just blue and you can barely see it, it's nothing like the default gun, where you clearly see the beam and it's blue and sparkley.

I know I'm missing something, but I just can't figure out what.

I always thought if I edited a few things, the rest would be taken from the default files, but this beam projectile won't.

What have I missed? D:
 
This happens because PreloadAssets() isn't called on extended weapons. Take a look on KFPlayerController.ClientWeaponSpawned() - another classic example of pre-school programming level.

There are 2 solutions:
  1. Replace all refs with static links. E.g. "MeshRef" -> "Mesh"
  2. Use ServerPerks + ScrnBalance, which calls PreloadAssets() for custom weapons too
 
Upvote 0
Replace all refs with static links. E.g. "MeshRef" -> "Mesh"

Could you explain a little more? I am new at this so I have no idea what you are talking about D:

I found this in KFPlayercontroller:


case class'ZEDGun':
class'ZEDGun'.static.PreloadAssets(Inv);
class'ZEDGunFire'.static.PreloadAssets(Level);
class'ZEDGunAltFire'.static.PreloadAssets(Level);
class'ZEDGunProjectile'.static.PreloadAssets();
class'ZEDGunAttachment'.static.PreloadAssets();
break;

Don't know if that has anything to do with it.
 
Upvote 0
If you have your own version of ZED gun, let's say class'MyMut.MyZEDGun', then case in KFPlayercontroller doesn't work and weapon's PreloadAssets() isn't called.


I did like this in my own playercontroller:

Code:
simulated function ClientWeaponSpawned(class<Weapon> WClass, Inventory Inv)
{
 switch ( WClass )
 {
  case class'CustomZEDGun':
   class'CustomZEDGun'.static.PreloadAssets(Inv);
   class'CustomZEDGunFire'.static.PreloadAssets(Level);
   class'CustomZEDGunProjectile'.static.PreloadAssets();
   break;
 }
}
simulated function ClientWeaponDestroyed(class<Weapon> WClass)
{
 switch ( WClass )
 {
  case class'CustomZEDGun':
   if ( class'CustomZEDGun'.static.UnloadAssets() )
   {
    class'CustomZEDGunFire'.static.UnloadAssets();
    class'CustomZEDGunProjectile'.static.UnloadAssets();
   }
   break;
 }
}

But it did not work.

I don't know what else to do :/
 
Upvote 0
I don't know what else to do :/

This happens because PreloadAssets() isn't called on extended weapons. Take a look on KFPlayerController.ClientWeaponSpawned() - another classic example of pre-school programming level.

There are 2 solutions:
  1. Replace all refs with static links. E.g. "MeshRef" -> "Mesh"
  2. Use ServerPerks + ScrnBalance, which calls PreloadAssets() for custom weapons too
I'd say option 1 is easiest, depending on your level of customisation.
 
Upvote 0
are you sure your code is being called?
put some log lines, the logs must appear at client side (check the client killingfloor.ini or open the log window - in console type: showlog )


The code has to be called, the gun works, only the projectile beam is not like the default, same with buzzsaw bow and pipebomb ^^

with pipebombs, the bombs turns invisible after they've been deploy'd, only the red dot is visible. Weird.
 
Upvote 0
The code has to be called, the gun works, only the projectile beam is not like the default, same with buzzsaw bow and pipebomb ^^

with pipebombs, the bombs turns invisible after they've been deploy'd, only the red dot is visible. Weird.

Just because the gun works, doesnt mean every function is being called, your gun isnt working as normal so something definitely isnt working. Poosh has explained that the preloading isnt called on custom weapons, thus you missing textures etc.

as for option 2, in you default properties,

ie
StaticMeshRef="ZED_FX_SM.Energy.ZED_FX_Energy_Card"

becomes

StaticMesh=StaticMesh'ZED_FX_SM.Energy.ZED_FX_Energy_Card'
 
Upvote 0
Just because the gun works, doesnt mean every function is being called, your gun isnt working as normal so something definitely isnt working. Poosh has explained that the preloading isnt called on custom weapons, thus you missing textures etc.

as for option 2, in you default properties,

ie
StaticMeshRef="ZED_FX_SM.Energy.ZED_FX_Energy_Card"

becomes

StaticMesh=StaticMesh'ZED_FX_SM.Energy.ZED_FX_Energy_Card'

Okay, thanks I'll try that.


I've also noticed that a custom version of a gun like SCARMK17 together with a default SCARMK17, they both share the same ammo pool and I don't know why and want to stop that, how can I change that?

I've checked the code of the golden versions of AK47 or Benelli since they have separate ammo pools. But I can't get it right, they still share the same ammo pool.

Probably some little detail I've missed...
 
Upvote 0
Okay, thanks I'll try that.


I've also noticed that a custom version of a gun like SCARMK17 together with a default SCARMK17, they both share the same ammo pool and I don't know why and want to stop that, how can I change that?

I've checked the code of the golden versions of AK47 or Benelli since they have separate ammo pools. But I can't get it right, they still share the same ammo pool.

Probably some little detail I've missed...



Look for any Default Property that refer's to Ammo, you'll see in your ones that they list the same class, in the golden versions they list different classes to the originals, you can see this easily when you browse the files since you will see each file has its inventory, fire, attachment, ammo, ammopickup, pickup.
 
Upvote 0
I have like this with my Custom FNFAL:

Code:
class CustomFNFALAmmo extends FNFALAmmo;
defaultproperties
{
  MaxAmmo=500
  AmmoPickupAmount=28
  InitialAmount=250
  PickupClass=Class'SuperSpecimen8_Xmas.CustomFNFALAmmoPickup'
}

and

Code:
class CustomFNFALAmmoPickup extends FNFALAmmoPickup;
defaultproperties
{
     AmmoAmount=28
     InventoryType=Class'SuperSpecimen8_Xmas.CustomFNFALAmmo'
}

It still shares same ammo pool with the Default FNFAL.

What did I do wrong? What am I missing? D:
 
Upvote 0
Your not specifying the new ammo class in your Fire class. So even though your files are there, they are not being used unless specified, think of it as branches on a tree.

My Fire class of my custom FNFAL is:

Code:
class CustomFNFALFire extends FNFALFire;
defaultproperties
{
     DamageType=Class'SuperSpecimen8_Xmas.CustomDamTypeFNFALAssaultRifle'
     AmmoClass=Class'SuperSpecimen8_Xmas.CustomFNFALAmmo'
  DamageMax=115
  RecoilRate=0.001000
     maxVerticalRecoilAngle=75
     maxHorizontalRecoilAngle=50
  Spread=0.000100
}

I don't see anything wrong with it. The AmmoClass is there.
 
Upvote 0
Is your firemodes in the inventory class updated with the new fire class?

is the inventory class updated in the weaponpickup class updated?

It needs to flow through ie WeaponPickup -> Weaponinventory -> weaponfire -> weaponammo

Honestly, I'm not sure. These are all the files I use for my Custom FNFAL:


CustomFNFAL_ACOG_AssaultRifle:

Code:
class CustomFNFAL_ACOG_AssaultRifle extends FNFAL_ACOG_AssaultRifle;
defaultproperties
{
    FireModeClass(0)=Class'SuperSpecimen8_Xmas.CustomFNFALFire'
    Priority=135
    MagCapacity=28
    InventoryGroup=3
    Weight=5.000000
    ItemName="Upgraded FNFAL ACOG"
    PickupClass=Class'SuperSpecimen8_Xmas.CustomFNFAL_ACOGPickup'
}

CustomFNFAL_ACOGPickup:

Code:
class CustomFNFAL_ACOGPickup extends FNFAL_ACOG_Pickup;
defaultproperties
{
     cost=500
     ItemName="Upgraded FNFAL ACOG"
     ItemShortName="Upgraded FNFAL ACOG"
     Weight=5.000000
     PickupMessage="You found the Upgraded FN FAL with ACOG Sight!"
     InventoryType=Class'SuperSpecimen8_Xmas.CustomFNFAL_ACOG_AssaultRifle'
}

CustomFNFALAmmo:

Code:
class CustomFNFALAmmo extends FNFALAmmo;
defaultproperties
{
  MaxAmmo=500
  AmmoPickupAmount=28
  InitialAmount=250
  PickupClass=Class'SuperSpecimen8_Xmas.CustomFNFALAmmoPickup'
}

CustomFNFALAmmoPickup:

Code:
class CustomFNFALAmmoPickup extends FNFALAmmoPickup;
defaultproperties
{
     AmmoAmount=28
     InventoryType=Class'SuperSpecimen8_Xmas.CustomFNFALAmmo'
}

CustomFNFALFire:

Code:
class CustomFNFALFire extends FNFALFire;
defaultproperties
{
     DamageType=Class'SuperSpecimen8_Xmas.CustomDamTypeFNFALAssaultRifle'
     AmmoClass=Class'SuperSpecimen8_Xmas.CustomFNFALAmmo'
     DamageMax=115
     RecoilRate=0.001000
     maxVerticalRecoilAngle=75
     maxHorizontalRecoilAngle=50
     Spread=0.000100
}


I can't see what's the problem o_O
 
Last edited:
Upvote 0