Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do "you" organize your .hps files?
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#11
RE: How do "you" organize your .hps files?

I do like Chaser & Damascus, try and keep related functions in the same sections. It gives a logical layout of the script in the same way a player would be progressing through a level. A section in my script tends to be around a specific event, room or section of a level, but also in Spacies we use a lot of scripts for custom entity or light actions that are not related to any event or room in particular, so I group those together too, with a title and description for the group

Additionally, since OnStart & OnEnter can get very, very cluttered on large levels I tend to have custom 'setup' functions where I put all of the function calls that normally go into OnStart & OnEnter, then call to those functions from OnStart & OnEnter so it's nice and clean.

lil' snippet here
void OnStart()
{
    AutoDoorSetup();      // AUTO-DOORS
    PowerCableSetup();    // POWER CABLE PUZZLE
    HallwayLightsSetup(); // HALLWAY LIGHTS
}

...


/**************************************************
    HALLWAY LIGHTS
    
    Progressively turn on lights, with flickering
****************************************************/

void HallwayLightsSetup()
    {
        AddEntityCollideCallback("Player", "SA_hallway_lights_2", "Hallway_lights_start", true, 1);
        for (int c=1; c<=12; c++)
        {
            SetLightVisible("spot_hallway_left_"+c, false);
            SetLightVisible("spot_hallway_right_"+c, false);
            SetLightVisible("point_hallway_"+c, false);
        }
        for (int c=1; c<=3; c++) SetLocalVarInt("inHallwayLightsFlicker"+c, 0);
    }

...

This has an additional benefit of meaning that if a setup stage needs to be performed every time you go into the level, instead of having 2 lots of the same code in OnStart & OnEnter, I can simply call to 'EventSetup()' again and have the code only in 1 place if it needs changing

Basic rule is, your going to read your code 100 times more than you're going to write it, and chances are if your going to spend a decent amount of time on your mod your going to have to read code you wrote months ago, so having a logical & consistent layout that you understand is important, regardless of what that layout is

(This post was last modified: 08-08-2013, 12:44 PM by Adrianis.)
08-08-2013, 12:38 PM
Find
DeAngelo Offline
Senior Member

Posts: 263
Threads: 26
Joined: Feb 2013
Reputation: 11
#12
RE: How do "you" organize your .hps files?

I try to keep mine organized into little sections based either on locations in the map or sometimes types of callbacks (Like all door unlock stuff in one area) but once each hps file starts getting upwards of a thousand lines each it gets really hard. I'm thinking of taking a few days off just to re-organize them all.

A Late Night Drink http://www.moddb.com/mods/a-late-night-drink
Check out my LP channel, CatBearGaming, I take all Custom Story requests!
08-09-2013, 02:48 PM
Find
CarnivorousJelly Offline
Posting Freak

Posts: 1,196
Threads: 41
Joined: Dec 2012
Reputation: 80
#13
RE: How do "you" organize your .hps files?

I do something that's pretty similar to what's already been said:
PHP Code: (Select All)
void OnEnter()
{
///////////////////////////////////
///////////TIME CHANGES///////////
///////////////////////////////////

if (GetGlobalVarInt("NightTriggered") == 0//Daylight to Sunset
    
{
        
FadeLightTo("PointLight_1"1.000f0.558f0.138f0.500f3.50f300.0f);
        
        
AddTimer("FogColour"200.0f"timer_fogcolour");
    }

    if (
GetGlobalVarInt("NightTriggered") == 1//visited map for Sunset-Night
    
{
        
FadeLightTo("PointLight_1"0.061f0.082f0.106f0.500f3.50f0.0f);
                
        
DestroyParticleSystem("ParticleSystem_1");
        
        
SetFogColor(0.053f0.058f0.071f0.500f);
    }
}

////////////////////
///////TIMERS///////
////////////////////
void timer_stoplook(string &in asTimer//Used to stop LookAt
{
    
StopPlayerLookAt();
}

/////////////////////////////////
////////Player Thoughts/////////
/////////////////////////////////
void script_darkness(string &in asParentstring &in asChildint alState)
{
    
SetMessage("Hints""NightTime"0);


So pretty much, large headers to organize based on the type of script or what I'm using it for with side-notes in case I forget what the script does, since I'm not a strong scripter

[Image: quote_by_rueppells_fox-d9ciupp.png]
(This post was last modified: 08-09-2013, 07:57 PM by CarnivorousJelly.)
08-09-2013, 07:57 PM
Find




Users browsing this thread: 1 Guest(s)