FGD editing - 'string' or 'integer' for numerical values? Created 4 years ago2019-09-28 22:06:13 UTC by MOCOLONI MOCOLONI

Created 4 years ago2019-09-28 22:06:13 UTC by MOCOLONI MOCOLONI

Posted 4 years ago2019-09-28 22:06:13 UTC Post #343176
Ever since learning how certain FGD elements work, I've been working on my own version of it based on the original/full Half-Life file, last updated for Hammer 3.5

Thus, I've seen and learnt a lot pretty quickly, but there's one thing I can't really figure out: should numerical keyvalues be Strings or Integers, especially the ones defaulted to "0"?

The confusion mainly comes from two (identical?) keyvalues with different properties; one is a "_minlight(string)" and the other is a "_minlight(integer)", the latter displaying "_minlight" as the text to display in Hammer and "0" as the value, even if not originally specified (the former doesn't have a value, but I guess it's still defaulted to "0"). Then, there are others like "framerate" and "delay".
MOCOLONI MOCOLONIinfo_player_mocoloni
Posted 4 years ago2019-09-29 11:36:55 UTC Post #343180
Quite simple:

If it's a whole number, then integer. Candidates: 0, 1, 2, 3 etc.
If it's a real number (such as a delay in seconds), then string. Candidates: 0.1, 0.2, 2.0, 0.2948 etc.
String is rather used for alphanumerical values, but since there's apparently no floating point type in FGDs, we improvise.

If you don't provide a value for a keyvalue, then that keyvalue won't be written into the .map file.
As such, it's gonna default to 0 in-game.

The safest (but also the longest) way would be to take a look at the HL SDK code, and see each KeyValue() function of each entity (as well as the definition of the entvars_t structure). There you'll know for sure which keyvalue is supposed to be which type.
Admer456 Admer456If it ain't broken, don't fox it!
Posted 4 years ago2019-09-29 13:02:52 UTC Post #343181
Admer456 said:Quite simple:

If it's a whole number, then integer. Candidates: 0, 1, 2, 3 etc.
If it's a real number (such as a delay in seconds), then string. Candidates: 0.1, 0.2, 2.0, 0.2948 etc.
String is rather used for alphanumerical values, but since there's apparently no floating point type in FGDs, we improvise.
Thank you!
Admer456 said:If you don't provide a value for a keyvalue, then that keyvalue won't be written into the .map file.
As such, it's gonna default to 0 in-game.
One thing that I noticed (and was going to include it in the thread but left that one out) is that, when it's an integer and a value isn't entered into the FGD, it will be "0" in Hammer (rather than an empty field, even if it's still defaulted to "0" in-game).

Given your information, I guess I shouldn't be messing with properties in case they're intended to support decimals, but the "framerate" keyvalue sure made me wonder as to why one is a String (env_sprite) and the other is an Integer (cycler_sprite).
MOCOLONI MOCOLONIinfo_player_mocoloni
Posted 4 years ago2019-09-29 19:05:26 UTC Post #343182
Taking a look at the source code reveals that "framerate" is actually a float. :)
User posted image
Here's the entire thing (not all keyvalues are included here as some entities have their own ones):
typedef struct entvars_s
{
    string_t    classname;
    string_t    globalname;

    vec3_t        origin;
    vec3_t        oldorigin;
    vec3_t        velocity;
    vec3_t        basevelocity;
    vec3_t      clbasevelocity;  // Base velocity that was passed in to server physics so
                                 //  client can predict conveyors correctly.  Server zeroes it, so we need to store here, too.
    vec3_t        movedir;

    vec3_t        angles;            // Model angles
    vec3_t        avelocity;        // angle velocity (degrees per second)
    vec3_t        punchangle;        // auto-decaying view angle adjustment
    vec3_t        v_angle;        // Viewing angle (player only)

    // For parametric entities
    vec3_t        endpos;
    vec3_t        startpos;
    float        impacttime;
    float        starttime;

    int            fixangle;        // 0:nothing, 1:force view angles, 2:add avelocity
    float        idealpitch;
    float        pitch_speed;
    float        ideal_yaw;
    float        yaw_speed;

    int            modelindex;
    string_t    model;

    int            viewmodel;        // player's viewmodel
    int            weaponmodel;    // what other players see

    vec3_t        absmin;        // BB max translated to world coord
    vec3_t        absmax;        // BB max translated to world coord
    vec3_t        mins;        // local BB min
    vec3_t        maxs;        // local BB max
    vec3_t        size;        // maxs - mins

    float        ltime;
    float        nextthink;

    int            movetype;
    int            solid;

    int            skin;
    int            body;            // sub-model selection for studiomodels
    int         effects;

    float        gravity;        // % of "normal" gravity
    float        friction;        // inverse elasticity of MOVETYPE_BOUNCE

    int            light_level;

    int            sequence;        // animation sequence
    int            gaitsequence;    // movement animation sequence for player (0 for none)
    float        frame;            // % playback position in animation sequences (0..255)
    float        animtime;        // world time when frame was set
    float        framerate;        // animation playback rate (-8x to 8x)
    byte        controller[4];    // bone controller setting (0..255)
    byte        blending[2];    // blending amount between sub-sequences (0..255)

    float        scale;            // sprite rendering scale (0..255)

    int            rendermode;
    float        renderamt;
    vec3_t        rendercolor;
    int            renderfx;

    float        health;
    float        frags;
    int            weapons;  // bit mask for available weapons
    float        takedamage;

    int            deadflag;
    vec3_t        view_ofs;    // eye position

    int            button;
    int            impulse;

    edict_t        *chain;            // Entity pointer when linked into a linked list
    edict_t        *dmg_inflictor;
    edict_t        *enemy;
    edict_t        *aiment;        // entity pointer when MOVETYPE_FOLLOW
    edict_t        *owner;
    edict_t        *groundentity;

    int            spawnflags;
    int            flags;

    int            colormap;        // lowbyte topcolor, highbyte bottomcolor
    int            team;

    float        max_health;
    float        teleport_time;
    float        armortype;
    float        armorvalue;
    int            waterlevel;
    int            watertype;

    string_t    target;
    string_t    targetname;
    string_t    netname;
    string_t    message;

    float        dmg_take;
    float        dmg_save;
    float        dmg;
    float        dmgtime;

    string_t    noise;
    string_t    noise1;
    string_t    noise2;
    string_t    noise3;

    float        speed;
    float        air_finished;
    float        pain_finished;
    float        radsuit_finished;

    edict_t        *pContainingEntity;

    int            playerclass;
    float        maxspeed;

    float        fov;
    int            weaponanim;

    int            pushmsec;

    int            bInDuck;
    int            flTimeStepSound;
    int            flSwimTime;
    int            flDuckTime;
    int            iStepLeft;
    float        flFallVelocity;

    int            gamestate;

    int            oldbuttons;

    int            groupinfo;

    // For mods
    int            iuser1;
    int            iuser2;
    int            iuser3;
    int            iuser4;
    float         fuser1;
    float         fuser2;
    float         fuser3;
    float         fuser4;
    vec3_t        vuser1;
    vec3_t        vuser2;
    vec3_t        vuser3;
    vec3_t        vuser4;
    edict_t        *euser1;
    edict_t        *euser2;
    edict_t        *euser3;
    edict_t        *euser4;
} entvars_t;
vec3_t -> string
edict_t -> don't list these as keyvalues
string_t -> string
byte -> normally you shouldn't do this, but it'll be an integer
int -> integer
Also, everything after // For mods shouldn't be included in FGDs.
Admer456 Admer456If it ain't broken, don't fox it!
You must be logged in to post a response.