Tripwire Interactive Forums

Go Back   Tripwire Interactive Forums > Killing Floor Forums > Killing Floor Modifications > Coding

Reply
 
Thread Tools Display Modes
  #1  
Old 11-14-2010, 07:36 PM
-=Ivan=- -=Ivan=- is offline
Senior Member
 
Join Date: Oct 2009
Posts: 172
Default Extend KFPawn & KFGUI with Mutator

As nearly everyone knows Jack and Me are working on a weaponpack. Now nearly everything is finished expect some script bug.
Ok to solve the problem with the dual pricing of the mk23 i have to add some code to the KFPawn and to the KFBuyMenuSaleList and KFBuyMenuInvList script. Also i have to modify the veteran scripts. But I don’t know how to that without touching the source code. Can i just extent the classes and add to the functions my code? But how do i let the engine know that this code got extended? So who to make this with a mutator.
So here is a example of the KFPawn Script, the orange part should be added somehow to it: I would be very happy if some could help me

Quote:
//================================================== ===========================
// KFPawn
//================================================== ===========================
class KFPawn extends xPawn
dependsOn(xPawnGibGroup);
...


...
function ServerBuyWeapon( Class<Weapon> WClass )
{
local Inventory I, J;
local float Price;

if( !CanBuyNow() || Class<KFWeapon>(WClass)==None || Class<KFWeaponPickup>(WClass.Default.PickupClass)= =None )
{
Return;
}

Price = class<KFWeaponPickup>(WClass.Default.PickupClass). Default.Cost;

if ( KFPlayerReplicationInfo(PlayerReplicationInfo).Cli entVeteranSkill != none )
{
Price *= KFPlayerReplicationInfo(PlayerReplicationInfo).Cli entVeteranSkill.static.GetCostScaling(KFPlayerRepl icationInfo(PlayerReplicationInfo), WClass.Default.PickupClass);
}

for ( I=Inventory; I!=None; I=I.Inventory )
{
if( I.Class==WClass )
{
Return; // Already has weapon.
}
}

if ( WClass == class'DualDeagle' )
{
for ( J = Inventory; J != None; J = J.Inventory )
{
if ( J.class == class'Deagle' )
{
Price = Price / 10;
bHasDeagle = true;

break;
}
}
}

if ( !bHasDeagle && !CanCarry(Class<KFWeapon>(WClass).Default.Weight) )
{
bHasDeagle = false;
Return;
}

if ( PlayerReplicationInfo.Score < Price )
{
bHasDeagle = false;
Return; // Not enough CASH.
}

I = Spawn(WClass);

if ( I != none )
{
KFWeapon(I).UpdateMagCapacity(PlayerReplicationInf o);
KFWeapon(I).FillToInitialAmmo();
KFWeapon(I).SellValue = Price * 0.75;
I.GiveTo(self);
PlayerReplicationInfo.Score -= Price;

ClientForceChangeWeapon(I);
}

bHasDeagle = false;

SetTraderUpdate();



if( !CanBuyNow() || Class<KFWeapon>(WClass)==None || Class<KFWeaponPickup>(WClass.Default.PickupClass)= =None )
{
Return;
}

Price = class<KFWeaponPickup>(WClass.Default.PickupClass). Default.Cost;

if ( KFPlayerReplicationInfo(PlayerReplicationInfo).Cli entVeteranSkill != none )
{
Price *= KFPlayerReplicationInfo(PlayerReplicationInfo).Cli entVeteranSkill.static.GetCostScaling(KFPlayerRepl icationInfo(PlayerReplicationInfo), WClass.Default.PickupClass);
}

for ( I=Inventory; I!=None; I=I.Inventory )
{
if( I.Class==WClass )
{
Return; // Already has weapon.
}
}

if ( WClass == class'DualMK23' )
{
for ( J = Inventory; J != None; J = J.Inventory )
{
if ( J.class == class'MK23' )
{
Price = Price / 2;
bHasMK23 = true;

break;
}
}
}

if ( !bHasMK23 && !CanCarry(Class<KFWeapon>(WClass).Default.Weight) )
{
bHasMK23 = false;
Return;
}

if ( PlayerReplicationInfo.Score < Price )
{
bHasMK23 = false;
Return; // Not enough CASH.
}

I = Spawn(WClass);

if ( I != none )
{
KFWeapon(I).UpdateMagCapacity(PlayerReplicationInf o);
KFWeapon(I).FillToInitialAmmo();
KFWeapon(I).SellValue = Price * 0.75;
I.GiveTo(self);
PlayerReplicationInfo.Score -= Price;

ClientForceChangeWeapon(I);
}

bHasMK23 = false;

SetTraderUpdate();
}


function ServerSellWeapon( Class<Weapon> WClass )
{
local Inventory I;
local Single NewSingle;
local Deagle NewDeagle;
local MK23 NewMK23;
local float Price;

if ( !CanBuyNow() || Class<KFWeapon>(WClass) == none || Class<KFWeaponPickup>(WClass.Default.PickupClass) == none )
{
SetTraderUpdate();
Return;
}

for ( I = Inventory; I != none; I = I.Inventory )
{
if ( I.Class == WClass )
{
if ( KFWeapon(I) != none && KFWeapon(I).SellValue != -1 )
{
Price = KFWeapon(I).SellValue;
}
else
{
Price = int(class<KFWeaponPickup>(WClass.default.PickupCla ss).default.Cost * 0.75);

if ( KFPlayerReplicationInfo(PlayerReplicationInfo).Cli entVeteranSkill != none )
{
Price *= KFPlayerReplicationInfo(PlayerReplicationInfo).Cli entVeteranSkill.static.GetCostScaling(KFPlayerRepl icationInfo(PlayerReplicationInfo), WClass.Default.PickupClass);
}
}

if ( Dualies(I) != none && DualDeagle(I) == none )
{
NewSingle = Spawn(class'Single');
NewSingle.GiveTo(self);
}

if ( DualDeagle(I) != none )
{
NewDeagle = Spawn(class'Deagle');
NewDeagle.GiveTo(self);
Price = Price / 5;
}

if ( DualMK23(I) != none )
{
NewMK23 = Spawn(class'MK23');
NewMK23.GiveTo(self);
Price = Price / 2;
}


if ( I == Weapon || I == PendingWeapon )
{
ClientCurrentWeaponSold();
}

PlayerReplicationInfo.Score += Price;

I.Destroyed();
I.Destroy();

SetTraderUpdate();

return;
}
}
}
Reply With Quote
  #2  
Old 11-14-2010, 09:00 PM
YoYoBatty's Avatar
YoYoBatty YoYoBatty is offline
Senior Member
 
Join Date: Dec 2009
Location: Canada
Posts: 3,319
Default

It's a very complicated process to replace KFHumanPawn with your new pawn the has the new code. The engine automatically knows to use that new code. You don't put any of this into a mutator btw. My suggestion is to ask marco for help with the dualmk23 bug.
__________________
Reply With Quote
  #3  
Old 11-15-2010, 06:23 AM
-=Ivan=- -=Ivan=- is offline
Senior Member
 
Join Date: Oct 2009
Posts: 172
Default

and how is it about the Gui Files and the verteran perk script?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:59 PM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright ©2005 - 2013, Tripwire Interactive, LLC