• 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 Trying to make a Bullpup mod, but compile gets a bunch of wee errors.

tha MediC

Grizzled Veteran
May 18, 2009
105
2
Here's what ucc said

Code:
---------------------------SRMods - Release---------------------------
Analyzing...
Parsing BullpupSwitchMessage
Parsing BullpupAttachment
Parsing DamTypeBullpup
Parsing BullpupAmmo
Parsing BullpupAmmoDM
Parsing Bullpup
Parsing BullpupDM
Parsing BullpupSP
Parsing BullpupAmmoPickup
Parsing BullpupSuperAmmoPickup
Parsing BullpupPickup
Parsing BullpupMuzzFlash
Parsing BullpupBurstFire
C:\Program Files\Steam\steamapps\common\killingfloor\SRMods\Classes\BullpupBurst
Fire.uc(3) : Error, SRMods.BullpupBurstFire's superclass must be KFMod.BullpupFi
re, not SRMods.BullpupFire
Compile aborted due to errors.
Failure - 1 error(s), 0 warning(s)


Basically, i wanted to create a new, better bullpup mod for me and a few mates, i only changed like 4 files which had the locations of damage in, and the reflex sights texture.

I basically got the same error and i thought hey ok ill add all the files and go in them and change KFmod to SRMods.

Any help would be appreciated guys.

Edit: Just tried making it into a simple mutator, which replaces the eotech sight texture and that's it. it shown up in game but didn't replace the texture.
 
Last edited:
I can't say for certain without seeing the code (or at least, each of the first line class declarations), but it looks like either a goofed up subclass (say, (your) BullpupBurstFire extends (your) BullpupBurstFire) or the compiler being grumpy and not "understanding" two classes with identical names.

It probably won't work, but try renaming the files / adjusting the class declarations accordingly. For instance, rename your Bullpup to BullpupMod, BullpupFire to BullpupFireMod, etc. That should clear things up if it's "just" the compiler going "Ok, this extends BullpupFire... wait, which one?"
 
Upvote 0
ITT coder's asking a non-coder some code related questions ;..;'

Here is a code snippet of the default Bullpup file, and then my modded version.

Code:
//=============================================================================
// L85 Inventory class
//=============================================================================
class Bullpup extends KFWeapon
	config(user);

#exec OBJ LOAD FILE=KillingFloorWeapons.utx
#exec OBJ LOAD FILE=KillingFloorHUD.utx
#exec OBJ LOAD FILE=Inf_Weapons_Foley.uax

replication
{
	reliable if(Role < ROLE_Authority)
		ServerChangeFireMode;
}

// Use alt fire to switch fire modes
simulated function AltFire(float F)
{
    if(ReadyToFire(0))
    {
        DoToggle();
    }
}

// Toggle semi/auto fire
simulated function DoToggle ()
{
	local PlayerController Player;

	Player = Level.GetLocalPlayerController();
	if ( Player!=None )
	{
		//PlayOwnedSound(sound'Inf_Weapons_Foley.stg44_firemodeswitch01',SLOT_None,2.0,,,,false);
		FireMode[0].bWaitForRelease = !FireMode[0].bWaitForRelease;
		if ( FireMode[0].bWaitForRelease )
			Player.ReceiveLocalizedMessage(class'KFmod.BullpupSwitchMessage',0);
		else Player.ReceiveLocalizedMessage(class'KFmod.BullpupSwitchMessage',1);
	}
	Super.DoToggle();

	ServerChangeFireMode(FireMode[0].bWaitForRelease);
}

// Set the new fire mode on the server
function ServerChangeFireMode(bool bNewWaitForRelease)
{
    FireMode[0].bWaitForRelease = bNewWaitForRelease;
}

function bool RecommendRangedAttack()
{
	return true;
}

//TODO: LONG ranged?
function bool RecommendLongRangedAttack()
{
	return true;
}

function float SuggestAttackStyle()
{
	return -1.0;
}

exec function SwitchModes()
{
	DoToggle();
}

function float GetAIRating()
{
	local Bot B;

	B = Bot(Instigator.Controller);
	if ( (B == None) || (B.Enemy == None) )
		return AIRating;

	return AIRating;
}

function byte BestMode()
{
	return 0;
}

simulated function SetZoomBlendColor(Canvas c)
{
	local Byte    val;
	local Color   clr;
	local Color   fog;

	clr.R = 255;
	clr.G = 255;
	clr.B = 255;
	clr.A = 255;

	if( Instigator.Region.Zone.bDistanceFog )
	{
		fog = Instigator.Region.Zone.DistanceFogColor;
		val = 0;
		val = Max( val, fog.R);
		val = Max( val, fog.G);
		val = Max( val, fog.B);
		if( val > 128 )
		{
			val -= 128;
			clr.R -= val;
			clr.G -= val;
			clr.B -= val;
		}
	}
	c.DrawColor = clr;
}

simulated function bool CanZoomNow()
{
	Return (!FireMode[0].bIsFiring && Instigator!=None && Instigator.Physics!=PHYS_Falling);
}


defaultproperties
{
	skins(0)=Combiner'KF_Weapons_Trip_T.Rifles.bullpup_cmb'
	skins(1)=Shader'KF_Weapons_Trip_T.Rifles.reflex_sight_A_unlit'
    SleeveNum=2

    WeaponReloadAnim=Reload_BullPup
    IdleAimAnim=Idle_Iron

    CustomCrosshair=11
    CustomCrossHairTextureName="Crosshairs.HUD.Crosshair_Cross5"
    MagCapacity=40
    ReloadRate=1.966667
    ReloadAnim="Reload"
    ReloadAnimRate=1.000000

    Weight=6.000000
    bModeZeroCanDryFire=True
    FireModeClass(0)=Class'KFMod.BullpupFire'
    FireModeClass(1)=Class'KFMod.NoFire'
    PutDownAnim="PutDown"
    SelectSound=Sound'KF_BullpupSnd.Bullpup_Select'
    SelectForce="SwitchToAssaultRifle"
    bShowChargingBar=True
    Description="A military grade automatic rifle. Can be fired in semi-auto or full auto firemodes and comes equipped with a scope for increased accuracy."
    EffectOffset=(X=100.000000,Y=25.000000,Z=-10.000000)
    Priority=4
    InventoryGroup=3
    GroupOffset=2
    PickupClass=Class'KFMod.BullpupPickup'
    PlayerViewOffset=(X=20.000000,Y=21.500000,Z=-9.000000)
    //PlayerViewPivot=(Pitch=400)
    BobDamping=6.000000
    AttachmentClass=Class'KFMod.BullpupAttachment'
    IconCoords=(X1=245,Y1=39,X2=329,Y2=79)
    ItemName="Bullpup"
    Mesh=SkeletalMesh'KF_Weapons_Trip.Bullpup_Trip'
    DrawScale=1.00000
    TransientSoundVolume=1.250000
    AmbientGlow=0

    AIRating=0.55
    CurrentRating=0.55

    DisplayFOV=70.000000
    StandardDisplayFOV=70.0
    PlayerIronSightFOV=65
    ZoomTime=0.25
    FastZoomOutTime=0.2
    ZoomInRotation=(Pitch=-910,Yaw=0,Roll=2910)
    bHasAimingMode=true
    ZoomedDisplayFOV=40

	HudImage=texture'KillingFloorHUD.WeaponSelect.Bullpup_unselected'
	SelectedHudImage=texture'KillingFloorHUD.WeaponSelect.Bullpup'
	TraderInfoTexture=texture'KillingFloorHud.Trader_Weapon_Images.Trader_Bullpup'
}

My version.
Code:
//=============================================================================
// L85 Inventory class
//=============================================================================
class Bullpup extends KFWeapon
	config(user);

#exec OBJ LOAD FILE=KillingFloorWeapons.utx
#exec OBJ LOAD FILE=KillingFloorHUD.utx
#exec OBJ LOAD FILE=Inf_Weapons_Foley.uax

replication
{
	reliable if(Role < ROLE_Authority)
		ServerChangeFireMode;
}

// Use alt fire to switch fire modes
simulated function AltFire(float F)
{
    if(ReadyToFire(0))
    {
        DoToggle();
    }
}

// Toggle semi/auto fire
simulated function DoToggle ()
{
	local PlayerController Player;

	Player = Level.GetLocalPlayerController();
	if ( Player!=None )
	{
		//PlayOwnedSound(sound'Inf_Weapons_Foley.stg44_firemodeswitch01',SLOT_None,2.0,,,,false);
		FireMode[0].bWaitForRelease = !FireMode[0].bWaitForRelease;
		if ( FireMode[0].bWaitForRelease )
			Player.ReceiveLocalizedMessage(class'KFmod.BullpupSwitchMessage',0);
		else Player.ReceiveLocalizedMessage(class'KFmod.BullpupSwitchMessage',1);
	}
	Super.DoToggle();

	ServerChangeFireMode(FireMode[0].bWaitForRelease);
}

// Set the new fire mode on the server
function ServerChangeFireMode(bool bNewWaitForRelease)
{
    FireMode[0].bWaitForRelease = bNewWaitForRelease;
}

function bool RecommendRangedAttack()
{
	return true;
}

//TODO: LONG ranged?
function bool RecommendLongRangedAttack()
{
	return true;
}

function float SuggestAttackStyle()
{
	return -1.0;
}

exec function SwitchModes()
{
	DoToggle();
}

function float GetAIRating()
{
	local Bot B;

	B = Bot(Instigator.Controller);
	if ( (B == None) || (B.Enemy == None) )
		return AIRating;

	return AIRating;
}

function byte BestMode()
{
	return 0;
}

simulated function SetZoomBlendColor(Canvas c)
{
	local Byte    val;
	local Color   clr;
	local Color   fog;

	clr.R = 255;
	clr.G = 255;
	clr.B = 255;
	clr.A = 255;

	if( Instigator.Region.Zone.bDistanceFog )
	{
		fog = Instigator.Region.Zone.DistanceFogColor;
		val = 0;
		val = Max( val, fog.R);
		val = Max( val, fog.G);
		val = Max( val, fog.B);
		if( val > 128 )
		{
			val -= 128;
			clr.R -= val;
			clr.G -= val;
			clr.B -= val;
		}
	}
	c.DrawColor = clr;
}

simulated function bool CanZoomNow()
{
	Return (!FireMode[0].bIsFiring && Instigator!=None && Instigator.Physics!=PHYS_Falling);
}


defaultproperties
{
	skins(0)=Combiner'KF_Weapons_Trip_T.Rifles.bullpup_cmb'
	skins(1)=Shader'SRMods.Rifles.reflex_sight_A_unlit'
    SleeveNum=2

    WeaponReloadAnim=Reload_BullPup
    IdleAimAnim=Idle_Iron

    CustomCrosshair=11
    CustomCrossHairTextureName="Crosshairs.HUD.Crosshair_Cross5"
    MagCapacity=40
    ReloadRate=1.966667
    ReloadAnim="Reload"
    ReloadAnimRate=1.000000

    Weight=6.000000
    bModeZeroCanDryFire=True
    FireModeClass(0)=Class'KFMod.BullpupFire'
    FireModeClass(1)=Class'KFMod.NoFire'
    PutDownAnim="PutDown"
    SelectSound=Sound'KF_BullpupSnd.Bullpup_Select'
    SelectForce="SwitchToAssaultRifle"
    bShowChargingBar=True
    Description="A military grade automatic rifle. Can be fired in semi-auto or full auto firemodes and comes equipped with a scope for increased accuracy."
    EffectOffset=(X=100.000000,Y=25.000000,Z=-10.000000)
    Priority=4
    InventoryGroup=3
    GroupOffset=2
    PickupClass=Class'KFMod.BullpupPickup'
    PlayerViewOffset=(X=20.000000,Y=21.500000,Z=-9.000000)
    //PlayerViewPivot=(Pitch=400)
    BobDamping=6.000000
    AttachmentClass=Class'KFMod.BullpupAttachment'
    IconCoords=(X1=245,Y1=39,X2=329,Y2=79)
    ItemName="Bullpup"
    Mesh=SkeletalMesh'KF_Weapons_Trip.Bullpup_Trip'
    DrawScale=1.00000
    TransientSoundVolume=1.250000
    AmbientGlow=0

    AIRating=0.55
    CurrentRating=0.55

    DisplayFOV=70.000000
    StandardDisplayFOV=70.0
    PlayerIronSightFOV=65
    ZoomTime=0.25
    FastZoomOutTime=0.2
    ZoomInRotation=(Pitch=-910,Yaw=0,Roll=2910)
    bHasAimingMode=true
    ZoomedDisplayFOV=40

	HudImage=texture'KillingFloorHUD.WeaponSelect.Bullpup_unselected'
	SelectedHudImage=texture'KillingFloorHUD.WeaponSelect.Bullpup'
	TraderInfoTexture=texture'KillingFloorHud.Trader_Weapon_Images.Trader_Bullpup'
}

Same code, but i had the same error even with this change. the file had SR added to the end, then i replaced all the KFMod related parts with SRMods and ze same error again.

But i've given up on it. No point in me faffing around just to replace the texture with a mutator or whatever when i can't get online with it.
 
Last edited:
Upvote 0
I haven't used this sdk yet, but some standard trouble shooting techniques can be tried after you've tried all of the more specific suggestions. These apply to most coding type problems.
1) Verify the build environment:
Rebuild everything with NO changes. Sometimes file perms, dates or other meta data can be hosed. And, since this is windoze, there is always the possibility that it stomped on something important. If you can't make a pristine system work, then you probably can't make your hacks work either. ;)
2) Verify that your changes are actually being incorporated into the system. Find the simplest noticable change you can make. If possible, change a simple string: "BullPup" --> ">>BullPup<<" There may not always be an obvious or convenient thing like this. But it should be possible to write to the console some way: (made up syntax, but you get the idea) console.printf("Eh-oh, console.");
If your build seems to work and you don't get the message, then you'll need to do some API/SDK specific troubleshooting that I amn't familiar with. This could include things like dir permissions, environment vars, config parameters and the ever present chance that windoze is hozed or has hozed something. Reboot, reset, reinstall, sacrifice a chicken. You've already sacrificed $ and time. :mad:
But you'll know something is wrong with the system somewhere... this does not mean your code isn't b0rked, too. But you'll need to fix the former before you can check the latter.
3) Someone else mentioned this, but it bears repeating: pick the class that is closest to what you want. Modify BullPup rather than something farther up the family tree.
(I haven't seen the hierarchy yet, but it could be something like this.
this is off the top of my head. flames > /dev/null)
Code:
Actor
 ... a bunch of stuff
gun
 +--- pistol
 +--- rifle
         +--- Bolt action
         +--- Automatic
                  +--- SMG/AR, etc
                           +--- AK
                           +--- BullPup
                           |       +--- My bp sub-class <<<-- yes
                           +--- My foolish new smg sub-class        <<<-- NO!
                                   +--- My way-too-much-work-pup <<<-- NO!
Given this, and your problem, BullPup makes the most sense.
This means that your class only needs to implement the differences from BP. You can do the NO line, but don't. You'll get cooties and lockjaw. And CTS. Coders (the good ones) are lazy and want to minimize changes. This also happens to be very, very good programming practice as well. Fewer changes, fewer places bugs can be added. Program by differences.
Tim Sweeney worked hard designing a beautiful game coding system, which includes at the least his own C-like OOPL with async and parallel features. And a deep, well thought out and designed object hierarchy. Don't kick him in the nuts :eek: by not using it!

4) Implement your changes incrementally. This way you only need to worry about one change at a time, and if things break, it can only be in the new code just added. If you make N changes, it can more like N^2 harder since changes can interact.

5) Comment your changes. It'll help you when you sober up and could be useful to others who steal your code.

6) Take a break. Relax. Breathe. In thru the nose, out thru the mouth.
And then:

YouTube - Man destroys computer

Advanced:
Experienced programmers recognize the futility of it all and go straight to a therapist by way of step 6.

Nothing is too simple to do wrong.
When all else fails, check the plug.
Growing a pony-tail can increase your coding skills by up to 40%.
Beards work, too:
ktdr.jpg


This does not help:
bill-gates-1983.jpg
 
Upvote 0