DarkPlacesEngine / DarkPlaces

The DarkPlaces Quake engine, created by LadyHavoc. Official Git repository (replaces SVN).
https://icculus.org/twilight/darkplaces/
GNU General Public License v2.0
286 stars 40 forks source link

Easy modification -- Coronas Via QuakeC, no .rtlights needed #128

Open Baker7 opened 8 months ago

Baker7 commented 8 months ago

cl_main.c : CL_LinkNetworkEntity

its_a_blast

Step 1: Find the if block that looks mostly like this ....

    if (Have_Flag (e->state_current.lightpflags, PFLAGS_FULLDYNAMIC_128) && r_refdef.scene.numlights < MAX_DLIGHTS_256)
    {
        matrix4x4_t dlightmatrix;
        vec4_t light;
        VectorScale(e->state_current.light, (1.0f / 256.0f), light);
        light[3] = e->state_current.light[3];
        if (light[0] == 0 && light[1] == 0 && light[2] == 0)
            VectorSet(light, 1, 1, 1);
        if (light[3] == 0)
            light[3] = 350;
        // FIXME: add ambient/diffuse/specular scales as an extension ontop of TENEBRAE_GFX_DLIGHTS?
        Matrix4x4_Normalize(&dlightmatrix, &e->render.matrix);
        Matrix4x4_Scale(&dlightmatrix, light[3], 1);
        R_RTLight_Update (
            &r_refdef.scene.templights[r_refdef.scene.numlights], 
            /*isstatic*/ false, 
            &dlightmatrix, 
            light, 
            e->state_current.lightstyle, 
            e->state_current.skin > 0 ? va(vabuf, sizeof(vabuf), "cubemaps/%d", e->state_current.skin) : NULL, !(e->state_current.lightpflags & PFLAGS_NOSHADOW_1), 
            (e->state_current.lightpflags & PFLAGS_CORONA_2) != 0, 
            0.25, 
            0, 
            1, // diffuse
            1, // specular
            LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE
        );
        r_refdef.scene.lights[r_refdef.scene.numlights] = &r_refdef.scene.templights[r_refdef.scene.numlights];r_refdef.scene.numlights++;
    }

Step 2: Slam this else clause (--->THEN YOU ARE DONE, MODIFICATION COMPLETE!!! <---- )


    else if (Have_Flag (e->state_current.lightpflags, PFLAGS_CORONA_2) && r_refdef.scene.numlights < MAX_DLIGHTS_256)
    {
        // Baker: This is not having PFLAGS_FULLDYNAMIC_128 but having PFLAGS_CORONA_2
        matrix4x4_t dlightmatrix;
        vec4_t light;
        VectorScale(e->state_current.light, (1.0f / 256.0f), light);
        light[3] = e->state_current.light[3];
        if (light[0] == 0 && light[1] == 0 && light[2] == 0)
            VectorSet(light, 1, 1, 1);
        if (light[3] == 0)
            light[3] = 350;
        // FIXME: add ambient/diffuse/specular scales as an extension ontop of TENEBRAE_GFX_DLIGHTS?
        Matrix4x4_Normalize(&dlightmatrix, &e->render.matrix);
        Matrix4x4_Scale(&dlightmatrix, light[3], 1);
        R_RTLight_Update (
            &r_refdef.scene.templights[r_refdef.scene.numlights], 
            /*isstatic*/ false, 
            &dlightmatrix, 
            light, 
            e->state_current.lightstyle, 
            NULL /*e->state_current.skin > 0 ? va(vabuf, sizeof(vabuf), "cubemaps/%d", e->state_current.skin) : NULL*/, // Baker: No cube map for you
            false, //!(e->state_current.lightpflags & PFLAGS_NOSHADOW_1),  // No shadow for you
            (e->state_current.lightpflags & PFLAGS_CORONA_2) != 0, 
            e->state_current.scale,// 0.25, // Hmmm.  Corona size is always 0.25?
            0, 
            0, // diffuse <=============================== BAKER: WE SET ZERO
            0, // specular<=============================== BAKER: WE SET ZERO
            LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE
        );
        r_refdef.scene.lights[r_refdef.scene.numlights] = &r_refdef.scene.templights[r_refdef.scene.numlights];r_refdef.scene.numlights++;
    }

Step 3: Profit

The corona size uses the .scale field <----

An entity looks like this ....

PFLAGS_CORONA_2 is the magic.

Green corona ...

green_corona

Green corona entity looks like ...

server EDICT 94:
origin         '1246 -1194 376'
classname      info_corona
model          
effects        4
light_lev      13
pflags         3
color          '0 4 0'
scale          0.129999995

The coronas in the first screenshot look like this ... because it is QuakeC progs.dat controlled ... you can add or remove them in QuakeC.

server EDICT 91:
absmin         '1164 -1345 321'
absmax         '1166 -1343 323'
origin         '1165 -1344 322'
classname      info_corona
model          
effects        4
light_lev      270
pflags         3
color          '1.5 1 0'
scale          0.340000004

server EDICT 92:
absmin         '1196 -1329 337'
absmax         '1198 -1327 339'
origin         '1197 -1328 338'
classname      info_corona
model          
effects        4
light_lev      270
pflags         3
color          '1.5 1 0'
scale          0.479999989

server EDICT 93:
absmin         '1132 -1361 305'
absmax         '1134 -1359 307'
origin         '1133 -1360 306'
classname      info_corona
model          
effects        4
light_lev      270
pflags         3
color          '1.5 1 0'
scale          0.340000004

For completion ... QuakeC for info_corona

void info_corona ()
{
    setmodel        (self, "");
    setorigin       (self, self.origin);
    self.solid      = SOLID_NOT;
    self.movetype   = MOVETYPE_NONE;
    self.effects    = EF_BRIGHTLIGHT; // 4
    self.pflags     = PFLAGS_CORONA_2 | PFLAGS_NOSHADOW_1;
}

.fgd (map editor definition for J.A.C.K. and Trenchbroom mostly supports fgd)

// Baker: Needs pflags, color, light_lev
@PointClass base(PlayerClass, Targetname) iconsprite("sprites/corona_sprite.spr") = info_corona : "Corona" [
    color(choices) : "color - " :  "" : "describe" = [
        "" : ""
        "1 0 0" : "1 0 0 - red"
        "1.46 0.52 0" : "1.46 0.52 - orange"
        "1.8 1.5 0" : "1.8 1.5 0 - yellow"
    ]
    light_lev(choices) : "light_lev - radius" :  100  = [
        "" : ""
        50 : "50"
        75 : "75"
        100 : "100"
        200 : "200"
        300 : "300"
        400 : "400"
        500 : "500"
        600 : "600"
        700 : "700"
        800 : "800"
        900 : "900"
        1000 : "1000"
        2000 : "2000"
    ]   
    scale(choices) : "scale - corona size" :  1  = [
        "" : ""
        "0.34" : "0.34"
        "0.48" : "0.48"
    ]   
]