Page 1 of 1

Coding Problems

PostPosted: Thu Nov 17, 11 9:42 am
by SimonDenton
So I decided to start the code for my mod Summer 101 from scratch. After all, most of it is just extending existing DX classes with just different text, textures and sounds.

Lucky that I am able to know how to code on my own and not make people do it for me, but I need your help and I'd appreciate that :)

PostPosted: Thu Nov 17, 11 1:25 pm
by ~DJ~
Umm, not sure.. but let's take a start; try using this SummerHUD code..
also; request to move at 'Editing Issue'.. amiritee :oops:

Code: Select all
//=============================================================================
// SummerHUD.
//=============================================================================
class SummerHUD extends DeusExHUD;

// ----------------------------------------------------------------------
// InitWindow()
// ----------------------------------------------------------------------

event InitWindow()
{
   root = DeusExRootWindow(GetRootWindow());

   Super.InitWindow();
   cross.Destroy();
   cross = SummerCrosshair(NewChild(Class'SummerCrosshair'));

   //Create the log window
   msgLog.Destroy();
   msgLog = HUDLogDisplay(NewChild(Class'SummerHUDLogDisplay', False));

   bTickEnabled = True;
}

// ----------------------------------------------------------------------
// CreateInfoLinkWindow()
//
// Creates the InfoLink window used to display messages.  If a
// InfoLink window already exists, then return None.  If the Log window
// is visible, it hides it.
// ----------------------------------------------------------------------

function HUDInfoLinkDisplay CreateInfoLinkWindow()
{
   if ( infolink != None )
      return None;

   infolink = SummerHUDInfoLinkDisplay(NewChild(Class'SummerHUDInfoLinkDisplay'));

   // Hide Log window
   if ( msgLog != None )
      msgLog.Hide();

   infolink.AskParentForReconfigure();

   return infolink;
}

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
defaultproperties
{
}

PostPosted: Fri Nov 18, 11 10:53 am
by SimonDenton
Thanks for the contribution but I get:


Error, 'root': Bad command or expression
Failed due to errors.

History: CompileError <- TryCompile <- FScriptCompiler::CompileScript <- (Class SummerCore.SummerHUD, Pass 1, Line 12) <- CompileScripts <- CompileScripts <- CompileScripts <- CompileScripts <- CompileScripts <- DoScripts <- UEditorEngine::MakeScripts <- UMakeCommandlet::Main

Exiting due to error

PostPosted: Fri Nov 18, 11 10:57 am
by ynnaD
did u make sure u hav all ur semicolons m8

PostPosted: Fri Nov 18, 11 11:37 am
by ~DJ~
SimonDenton wrote:Thanks for the contribution but I get:


Ah, right.. my bad, perhaps they'll be more errors but try the below code. Keep in mind that I'm saying that it's a start, I'm not saying it'll probably fix everything.. you'll have to post here and all :$

[spoiler="Code"]
Code: Select all
//=============================================================================
// SummerHUD.
//=============================================================================
class SummerHUD extends DeusExHUD;

var DeusExRootWindow root;

// ----------------------------------------------------------------------
// InitWindow()
// ----------------------------------------------------------------------

event InitWindow()
{
   root = DeusExRootWindow(GetRootWindow());

   Super.InitWindow();
   cross.Destroy();
   cross = SummerCrosshair(NewChild(Class'SummerCrosshair'));

   //Create the log window
   msgLog.Destroy();
   msgLog = HUDLogDisplay(NewChild(Class'SummerHUDLogDisplay', False));

   bTickEnabled = True;
}

// ----------------------------------------------------------------------
// CreateInfoLinkWindow()
//
// Creates the InfoLink window used to display messages.  If a
// InfoLink window already exists, then return None.  If the Log window
// is visible, it hides it.
// ----------------------------------------------------------------------

function HUDInfoLinkDisplay CreateInfoLinkWindow()
{
   if ( infolink != None )
      return None;

   infolink = SummerHUDInfoLinkDisplay(NewChild(Class'SummerHUDInfoLinkDisplay'));

   // Hide Log window
   if ( msgLog != None )
      msgLog.Hide();

   infolink.AskParentForReconfigure();

   return infolink;
}

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
defaultproperties
{
}

[/spoiler]

PostPosted: Fri Nov 18, 11 12:10 pm
by James
Edited your post just to give you a concept on using spoiler tags and what they can do.

PostPosted: Fri Nov 18, 11 1:01 pm
by SimonDenton
Thanks DJ! It works really well now! (mind finding and giving me the textures for the IBM computer box and monitor? Thanks in advance)

I'll be adding a custom icon to the log display in conjunction with a custom sound for the datalink. Thanks to everyone who is helping me!

PostPosted: Sat Nov 19, 11 1:51 am
by ~DJ~
No problem I suppose.. all I changed in your code was to remove the 'crosshair' and 'msg' thingie from the 'variables' as in var section in the top.

SimonDenton wrote:(mind finding and giving me the textures for the IBM computer box and monitor? Thanks in advance)


Alright, I'll try doing that when I get in my PC :oops:

@James

AWSUM MATE THNX

PostPosted: Tue Nov 22, 11 5:25 am
by SimonDenton
I tried emulating the DXMP bio energy recharge for up to 25%. In game it *sort* of does that, but the meter i.e HUD line for BE, stays at 100%

[spoiler]
Code: Select all
// Energy the player has
var travel float Energy;
var travel float EnergyMax;
var travel float EnergyDrain;            // amount of energy left to drain
var travel float EnergyDrainTotal;      // total amount of energy to drain
var float MaxRegenPoint;     // in multiplayer, the highest that auto regen will take you
var float RegenRate;         // the number of points healed per second in mp

// ----------------------------------------------------------------------
// MaintainEnergy()
// ----------------------------------------------------------------------

function MaintainEnergy(float deltaTime)
{
   local Float energyUse;
   local Float energyRegen;

   // make sure we can't continue to go negative if we take damage
   // after we're already out of energy
   if (Energy <= 0)
   {
      Energy = 0;
      EnergyDrain = 0;
      EnergyDrainTotal = 0;
   }

   energyUse = 0;

   // Don't waste time doing this if the player is dead or paralyzed
   if ((!IsInState('Dying')) && (!IsInState('Paralyzed')))
   {
      if (Energy > 0)
      {
         // Decrement energy used for augmentations
         energyUse = AugmentationSystem.CalcEnergyUse(deltaTime);
         
         Energy -= EnergyUse;
         
         // Calculate the energy drain due to EMP attacks
         if (EnergyDrain > 0)
         {
            energyUse = EnergyDrainTotal * deltaTime;
            Energy -= EnergyUse;
            EnergyDrain -= EnergyUse;
            if (EnergyDrain <= 0)
            {
               EnergyDrain = 0;
               EnergyDrainTotal = 0;
            }
         }
      }

      //Do check if energy is 0. 
      // If the player's energy drops to zero, deactivate
      // all augmentations
      if (Energy <0> 0)         
            ClientMessage(EnergyDepleted);
         Energy = 0;
         EnergyDrain = 0;
         EnergyDrainTotal = 0;         
         AugmentationSystem.DeactivateAll();
      }

      // If all augs are off, then start regenerating ,
      // up to 25%.
      if ((energyUse == 0) && (Energy <= MaxRegenPoint))
      {
         energyRegen = RegenRate * deltaTime;
         Energy += energyRegen;
      }
   }
}
[/spoiler]

PostPosted: Tue Nov 22, 11 12:29 pm
by ~DJ~
remove the vars

PostPosted: Tue Nov 22, 11 12:44 pm
by SimonDenton
Thanks buddy! It works properly now! Funny what a difference omitting variables can make :D

PostPosted: Tue Nov 22, 11 1:02 pm
by ~DJ~
yeah you were declaring the variables already defined in the super class, (as you've extended it to Human) and a function which already uses them so there was no need to create 2x of the same thing your using.

PostPosted: Tue Nov 22, 11 2:28 pm
by ~ô¿ô~Nobody~
There's a reason, why a class EXTENDS another class.
Class properties(variables) and functions are inherited from its parent classes.

Perhaps you should make a crash course in OOP programming, Simon.

PostPosted: Sun Dec 04, 11 3:59 am
by SimonDenton
I am trying to set a flag when this item is picked up and let the name of the flag we set be a default property we can manipulate in the editor.

[spoiler]
Code: Select all
//=============================================================================
// SmartCardChip.
//=============================================================================
class SmartCardChip extends NanoKey;

var localized String Flag; //What flag do we set when we pick this up?



// ----------------------------------------------------------------------
// HandlePickupQuery()
//
// Adds the NanoKey to the player's NanoKeyRing and then destroys
// this object
// ----------------------------------------------------------------------

function bool HandlePickupQuery( inventory Item )
{
   local DeusExPlayer player;

   if ( Item.Class == Class )
   {
      player = DeusExPlayer(Owner);
      player.PickupNanoKey(NanoKey(item));
      SetBool('Flag');
      item.Destroy();
         
      return True;
   }

   return Super.HandlePickupQuery(Item);
}

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
defaultproperties
{
    ItemName="SC Chip"
    PlayerViewOffset=(X=30.00,Y=0.00,Z=-12.00),
    PlayerViewMesh=LodMesh'DeusExItems.NanoKey'
    PickupViewMesh=LodMesh'DeusExItems.NanoKey'
    ThirdPersonMesh=LodMesh'DeusExItems.NanoKey'
    Icon=Texture'DeusExUI.Icons.BeltIconNanoKey'
    Description="NO KEY DESCRIPTION - REPORT THIS AS A BUG!"
    beltDescription="CHIP"
    Mesh=LodMesh'DeusExItems.NanoKey'
    CollisionRadius=2.05
    CollisionHeight=3.11
    Mass=1.00
    Flag='K_RoomA'
}
[/spoiler]

PostPosted: Mon Dec 05, 11 8:38 am
by EXetoC
SimonDenton wrote:I am trying to set a flag when this item is picked up and let the name of the flag we set be a default property we can manipulate in the editor.

[spoiler]
Code: Select all
//=============================================================================
// SmartCardChip.
//=============================================================================
class SmartCardChip extends NanoKey;

var localized String Flag; //What flag do we set when we pick this up?



// ----------------------------------------------------------------------
// HandlePickupQuery()
//
// Adds the NanoKey to the player's NanoKeyRing and then destroys
// this object
// ----------------------------------------------------------------------

function bool HandlePickupQuery( inventory Item )
{
   local DeusExPlayer player;

   if ( Item.Class == Class )
   {
      player = DeusExPlayer(Owner);
      player.PickupNanoKey(NanoKey(item));
      SetBool('Flag');
      item.Destroy();
         
      return True;
   }

   return Super.HandlePickupQuery(Item);
}

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
defaultproperties
{
    ItemName="SC Chip"
    PlayerViewOffset=(X=30.00,Y=0.00,Z=-12.00),
    PlayerViewMesh=LodMesh'DeusExItems.NanoKey'
    PickupViewMesh=LodMesh'DeusExItems.NanoKey'
    ThirdPersonMesh=LodMesh'DeusExItems.NanoKey'
    Icon=Texture'DeusExUI.Icons.BeltIconNanoKey'
    Description="NO KEY DESCRIPTION - REPORT THIS AS A BUG!"
    beltDescription="CHIP"
    Mesh=LodMesh'DeusExItems.NanoKey'
    CollisionRadius=2.05
    CollisionHeight=3.11
    Mass=1.00
    Flag='K_RoomA'
}
[/spoiler]

A var needs to be a group in order for it to show up in the editor. Like this
Code: Select all
var(Info) localized String Flag;

Not putting anything between the parentheses will put the var in a group named after the class in which it is a member of.

I'm pretty sure that this is correct.

PostPosted: Mon Dec 05, 11 1:02 pm
by ~DJ~
Yep, pretty correct.

PostPosted: Tue Dec 06, 11 3:52 am
by SimonDenton
Thanks for that :D I don't think SetBool is the correct command though. Guess I have been browsing too many mission scripts :D

Also would it be possible to find out how decoration items GetBool, or check for a flag? I know this can all be done with triggers but having this built into the classes might improve workflow and make it even neater.

EDIT: I guess an alternative would be having a conversation with the decoration item that only activates and does the trigger when the convo can be enabled...is that acceptable?

PostPosted: Tue Dec 06, 11 2:02 pm
by EXetoC
SimonDenton wrote:Thanks for that :D I don't think SetBool is the correct command though. Guess I have been browsing too many mission scripts :D

Also would it be possible to find out how decoration items GetBool, or check for a flag? I know this can all be done with triggers but having this built into the classes might improve workflow and make it even neater.

EDIT: I guess an alternative would be having a conversation with the decoration item that only activates and does the trigger when the convo can be enabled...is that acceptable?

SetBool etc is defined in FlagBase, (which seems to be defined in native code, which in this case is C++). NanoKey doesn't inherit from it, so calling SetBool directly isn't going to work. And also, it seems to take about four parameters, two of which seem to be required. Here's an example from FlagTrigger.uc
Code: Select all
player.flagBase.SetBool(flagName, !flagValue,, flagExpiration);

The second parameter sets the bool value of the flag, and i don't know what the third parameter does, but it's ignored here and it seems to be set to true in other cases. I think the fourth parameter is at which mission the flag expires (perhaps 0 means never).

DeusExPlayer has a member called flagBase, which might be the variable that you want to use, although i'm not entirely sure. Doing a search for all flagBase references might reveal how it all works.

PostPosted: Tue Dec 13, 11 10:38 pm
by ~ô¿ô~Nobody~
Topic moved to 'Editing issues'.

PostPosted: Wed Dec 14, 11 7:20 am
by SimonDenton
Here's a REAL problem:

[img]http://img716.imageshack.us/img716/3766/whatno.jpg
[/img]
But whenever I change the .ini file to making Player=DeusEx.JCDentonMale the HUD is fine. So I guess it has something to do with my player class:

[spoiler]
class SummerPlayer extends Human;


// Summer Demo

// If this is the demo, show the demo splash screen, which
// will exit the game after the player presses a key/mouseclick
// if (NextMap == "C2")
// ShowDemoSplash();
// else
// Level.Game.SendPlayer(Self, NextMap);



// ----------------------------------------------------------------------
// ResetPlayer()
//
// Called when a new game is started.
//
// 1) Erase all flags except those beginning with "SKTemp_"
// 2) Dumps inventory
// 3) Restore any other defaults
//
// burden comments: stolen from DeusExPlayer.uc to remove part
// below where player is given pistol, prod and medkit
// ----------------------------------------------------------------------

function ResetPlayer(optional bool bTraining)
{
local inventory anItem;
local inventory nextItem;

ResetPlayerToDefaults();

// Reset Augmentations
if (AugmentationSystem != None)
{
AugmentationSystem.ResetAugmentations();
AugmentationSystem.Destroy();
AugmentationSystem = None;
}

// Give the player a pistol and a prod
if (!bTraining)
{
anItem = None;
anItem.Frob(Self, None);
anItem.bInObjectBelt = True;
anItem = None;
anItem.Frob(Self, None);
anItem.bInObjectBelt = True;
anItem = None;
anItem.Frob(Self, None);
anItem.bInObjectBelt = True;
}
}



// ----------------------------------------------------------------------
// ActivateAugmentation()
//
// removes pesky 'there is no augmentation in that slot' message
// ----------------------------------------------------------------------

exec function ActivateAugmentation(int num)
{
}


// ----------------------------------------------------------------------
// CreateKeyRing()
// ----------------------------------------------------------------------

//Give us the smart card instead of the keyring

function CreateKeyRing()
{
local inventory anItem;
local inventory nextItem;

if (KeyRing == None)
{
KeyRing = Spawn(class'SmartCard', Self);
KeyRing.InitialState='Idle2';
KeyRing.GiveTo(Self);
KeyRing.SetBase(Self);
}

}



// ----------------------------------------------------------------------
// InitializeSubSystems()
// ----------------------------------------------------------------------

function InitializeSubSystems()
{
// Spawn the BarkManager
if (BarkManager == None)
BarkManager = Spawn(class'BarkManager', Self);

// Spawn the Color Manager
CreateColorThemeManager();
ThemeManager.SetOwner(self);

// install the augmentation system if not found
if (AugmentationSystem == None)
{
AugmentationSystem = Spawn(class'SummerAugmentationManager', Self);
AugmentationSystem.CreateAugmentations(Self);
AugmentationSystem.AddDefaultAugmentations();
AugmentationSystem.SetOwner(Self);
}
else
{
AugmentationSystem.SetPlayer(Self);
AugmentationSystem.SetOwner(Self);
}

// install the skill system if not found
if (SkillSystem == None)
{
SkillSystem = Spawn(class'SummerSkillManager', Self);
SkillSystem.CreateSkills(Self);
}
else
{
SkillSystem.SetPlayer(Self);
}
}

// ----------------------------------------------------------------------
// ShowMainMenu()
// ----------------------------------------------------------------------

exec function ShowMainMenu()
{
local DeusExRootWindow root;
local DeusExLevelInfo info;
local MissionEndgame Script;

if (bIgnoreNextShowMenu)
{
bIgnoreNextShowMenu = False;
return;
}

info = GetLevelInfo();

ConsoleCommand("FLUSH");

if ((info != None) && (info.MissionNumber == 98))
{
bIgnoreNextShowMenu = True;
PostIntro();
}
else if ((info != None) && (info.MissionNumber == 99))
{
foreach AllActors(class'MissionEndgame', Script)
break;

if (Script != None)
Script.FinishCinematic();
}
else
{
root = DeusExRootWindow(rootWindow);
if (root != None)
root.InvokeMenu(Class'SummerMenuMain');
}
}


// ----------------------------------------------------------------------
// overrides the original so we can use custom InfoLinks
// ----------------------------------------------------------------------
function Possess()
{
local DeusExRootWindow root;

Super.Possess();

root = DeusExRootWindow(rootWindow);

root.hud.Destroy();
root.hud = DeusexHUD(root.NewChild(Class'SummerHUD'));

}


// ----------------------------------------------------------------------
// ShowCredits()
// This is stuff for setting up custom end credits
// ----------------------------------------------------------------------

function ShowCredits(optional bool bLoadIntro)
{
local DeusExRootWindow root;
local SummerCreditsWindow winCredits;

root = DeusExRootWindow(rootWindow);

if (root != None)
{
// Show the credits screen and force the game not to pause
// if we're showing the credits after the endgame
winCredits = SummerCreditsWindow(root.InvokeMenuScreen(Class'SummerCreditsWindow', bLoadIntro));
winCredits.SetLoadIntro(bLoadIntro);
}
}





// ----------------------------------------------------------------------
// Cheat functions
//-----------------------------------------------------------------------


function PostBeginPlay()
{

bCheatsEnabled = False;

}
// ----------------------------------------------------------------------





defaultproperties
{
CarcassType=None
Mesh=LodMesh'DeusExCharacters.GM_Trench'
SkillPointsTotal=0
SkillPointsAvail=0
//MaxRegenPoint=25.00
//RegenRate=1.50
HandsFull="My hands are full"
NoteAdded="Noted - Check Notepad"
GoalAdded="Task Received - Check Notepad"
PrimaryGoalCompleted="Task Completed"
SecondaryGoalCompleted="Errand Completed"
EnergyDepleted="Out of energy, need a breather..."
MultiSkins(0)=Texture'DeusExCharacters.Skins.WaltonSimonsTex0'
MultiSkins(1)=Texture'DeusExCharacters.Skins.WaltonSimonsTex2'
MultiSkins(2)=Texture'DeusExCharacters.Skins.PantsTex5'
MultiSkins(3)=Texture'DeusExCharacters.Skins.WaltonSimonsTex0'
MultiSkins(4)=Texture'DeusExCharacters.Skins.WaltonSimonsTex1'
MultiSkins(5)=Texture'DeusExCharacters.Skins.WaltonSimonsTex2'
MultiSkins(6)=Texture'DeusExItems.Skins.GrayMaskTex'
MultiSkins(7)=Texture'DeusExItems.Skins.BlackMaskTex'
BindName="JCDenton"
TruePlayerName="Jack"
FamiliarName="Jack"
UnfamiliarName="Jack"
Credits=0
strStartMap="31_SchoolInterior"
}
[/spoiler]

Here is Summer.log when I press escape:
[spoiler]
ScriptWarning: MenuUITitleWindow dx.SummerPlayer0.DeusExRootWindow0.SummerMenuMain0.MenuUITitleWindow0 (Function DeusEx.MenuUITitleWindow.StyleChanged:002A) Accessed None
ScriptWarning: MenuUITitleWindow dx.SummerPlayer0.DeusExRootWindow0.SummerMenuMain0.MenuUITitleWindow0 (Function DeusEx.MenuUITitleWindow.StyleChanged:0044) Accessed None
ScriptWarning: MenuUITitleWindow dx.SummerPlayer0.DeusExRootWindow0.SummerMenuMain0.MenuUITitleWindow0 (Function DeusEx.MenuUITitleWindow.StyleChanged:005E) Accessed None
ScriptWarning: MenuUIClientWindow dx.SummerPlayer0.DeusExRootWindow0.SummerMenuMain0.MenuUIClientWindow0 (Function DeusEx.MenuUIClientWindow.StyleChanged:004F) Accessed None
ScriptWarning: SummerMenuMain dx.SummerPlayer0.DeusExRootWindow0.SummerMenuMain0 (Function DeusEx.MenuUIWindow.StyleChanged:002A) Accessed None
ScriptWarning: MenuUIMenuButtonWindow dx.SummerPlayer0.DeusExRootWindow0.SummerMenuMain0.MenuUIClientWindow0.MenuUIMenuButtonWindow0 (Function DeusEx.MenuUIBorderButtonWindow.StyleChanged:002A) Accessed None
ScriptWarning: MenuUIMenuButtonWindow dx.SummerPlayer0.DeusExRootWindow0.SummerMenuMain0.MenuUIClientWindow0.MenuUIMenuButtonWindow0 (Function DeusEx.MenuUIBorderButtonWindow.StyleChanged:0046) Accessed None
ScriptWarning: MenuUIMenuButtonWindow dx.SummerPlayer0.DeusExRootWindow0.SummerMenuMain0.MenuUIClientWindow0.MenuUIMenuButtonWindow0 (Function DeusEx.MenuUIBorderButtonWindow.StyleChanged:0062) Accessed None
ScriptWarning: MenuUIMenuButtonWindow dx.SummerPlayer0.DeusExRootWindow0.SummerMenuMain0.MenuUIClientWindow0.MenuUIMenuButtonWindow0 (Function DeusEx.MenuUIBorderButtonWindow.StyleChanged:008F) Accessed None

etc. etc.
[/spoiler]

PostPosted: Wed Dec 14, 11 9:03 am
by ~ô¿ô~Nobody~
From what I see you got some problem with your theme manager.
It causes an accessed none in the inherited function StyleChanged of the class MenuUIBorderButtonWindow.

Parsing the content of the function, this can only happen on this line:

        theme = player.ThemeManager.GetCurrentMenuColorTheme();

So.. assuming the variable player contains a player reference..
Either the player got no ThemeManager or the ThemeManager got no ColorTheme.

The same counts to the accessed nones within the other objects.

PostPosted: Sat Dec 17, 11 8:37 am
by SimonDenton
Thanks for your input but I still get the error and not 100% sure. Am I just missing something in my player class? I recycle the color theme restore stuff but none of it works =/

PostPosted: Sat Dec 17, 11 12:29 pm
by ~DJ~
I'm pretty sure it's nothing to do with your modification. or I hope so.. Try doing this..

When you launch DX, just press ESC. This will open the main menu.. yet being invisible.. DON'T MOVE YOUR MOUSE.
Press the down arrow key TWO times, press ENTER. Then press the down arrow key FOUR more times, press ENTER again.. then lastly press the down arrow key EIGHT times, and press ENTER again.
This will probably fix it.. MAKE SURE it was on MAIN MENU of DX without moving the mouse, if it doesn't work do it from the starting.. :oops:

PostPosted: Sun Dec 18, 11 1:13 pm
by ~ô¿ô~Nobody~
Oh, you think the theme is generally invalid :?

PostPosted: Mon Dec 19, 11 5:47 am
by SimonDenton
No it only happens within Summer 101. Must be something wrong with my player class code...

PostPosted: Mon Dec 19, 11 2:38 pm
by ~DJ~
Have you even tried it though? because your Summer 101 probably has a different INI, doesn't mean it has to be something with the player? :oops:

PostPosted: Tue Dec 20, 11 1:38 am
by SimonDenton
I did try it and nothing happened. When I change the player class to JCDenton everything is normal.

PostPosted: Thu Dec 22, 11 1:46 am
by SimonDenton
Never mind guys, I did the player code from scratch and all is good for the time being.

PostPosted: Thu Jan 19, 12 1:23 pm
by SimonDenton
Hey guys! Been having fun coding for Summer 101! Just a quick question:
I am replacing skills with "Attributes", unique qualities you determine at the start of the mod. How can I change my player code from the below to accomodating for a skill? so I have a strength skill, how can I make it that when the strength skill is trained, you can lift heavy objects?

[spoiler]
Code: Select all
// check to see if the player can lift a certain decoration taking
// into account his muscle augs
function bool CanBeLifted(Decoration deco)
{
   local int augLevel, augMult;
   local float maxLift;

   maxLift = 50;
   if (AugmentationSystem != None)
   {
      augLevel = AugmentationSystem.GetClassLevel(class'AugMuscle');
      augMult = 1;
      if (augLevel >= 0)
         augMult = augLevel+2;
      maxLift *= augMult;
   }

   if (!deco.bPushable || (deco.Mass > maxLift) || (deco.StandingCount > 0))
   {
      if (deco.bPushable)
         ClientMessage(TooHeavyToLift);
      else
         ClientMessage(CannotLift);

      return False;
   }

   return True;
}
[/spoiler]

Thanks!

PostPosted: Thu Jan 26, 12 8:20 am
by SimonDenton
Alright I did a simple skill replacement and it works! :)

[spoiler]
Code: Select all
//------------------
//Strength Attribute
//------------------


function bool CanBeLifted(Decoration deco)
{
   local int skillLevel, skillMult;
   local float maxLift;

   maxLift = 50;
   
      skillLevel = SkillSystem.GetSkillLevelValue(class'AttributeStrength');
      skillMult = 1;
      if (skillLevel >= 0)
         skillMult = skillLevel+2;
      maxLift *= skillMult;
   

   if (!deco.bPushable || (deco.Mass > maxLift) || (deco.StandingCount > 0))
   {
      if (deco.bPushable)
         ClientMessage(TooHeavyToLift);
      else
         ClientMessage(CannotLift);

      return False;
   }

   return True;
}

[/spoiler]

Now I just need to do the same but with allowing the player to pick up heavy weapons. I have an extended class called HeavyWeapons. Somehow if we can edit properties like in mission script we can change the variable allowing us to pick the heavy weapon up....Thoughts?