From: Mario Date: Sat, 9 Jun 2018 16:29:39 +0000 (+1000) Subject: Move dynlight to mapobjects X-Git-Tag: xonotic-v0.8.5~2096 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=19c5cdd6bddcc21d57b75d9aa63011c32b380233;p=xonotic%2Fxonotic-data.pk3dir.git Move dynlight to mapobjects --- diff --git a/qcsrc/common/mapobjects/misc/_mod.inc b/qcsrc/common/mapobjects/misc/_mod.inc index 3698cf822..498f6c521 100644 --- a/qcsrc/common/mapobjects/misc/_mod.inc +++ b/qcsrc/common/mapobjects/misc/_mod.inc @@ -1,5 +1,6 @@ // generated file; do not modify #include +#include #include #include #include diff --git a/qcsrc/common/mapobjects/misc/_mod.qh b/qcsrc/common/mapobjects/misc/_mod.qh index 5b156176e..3415919f8 100644 --- a/qcsrc/common/mapobjects/misc/_mod.qh +++ b/qcsrc/common/mapobjects/misc/_mod.qh @@ -1,5 +1,6 @@ // generated file; do not modify #include +#include #include #include #include diff --git a/qcsrc/common/mapobjects/misc/dynlight.qc b/qcsrc/common/mapobjects/misc/dynlight.qc new file mode 100644 index 000000000..7c70b8444 --- /dev/null +++ b/qcsrc/common/mapobjects/misc/dynlight.qc @@ -0,0 +1,135 @@ +#include "dynlight.qh" + +#ifdef SVQC +#include +#include + +const float LOOP = 1; + +.float speed; + +//const int DNOSHADOW = 2; +const int DFOLLOW = 4; +.float light_lev; +.float lefty; +.vector color; +.string dtagname; + +/*QUAKED dynlight (0 1 0) (-8 -8 -8) (8 8 8) START_OFF NOSHADOW FOLLOW +Dynamic spawnfunc_light. +Can do one of these things: sit still and be just a silly spawnfunc_light, travel along a path, follow an entity around, attach to a tag on an entity. +It can spin around it's own axis in all the above cases. +If targeted, it will toggle between on or off. +keys: +"light_lev" spawnfunc_light radius, default 200 +"color" spawnfunc_light color in rgb and brightness, 1 1 1 produces bright white, up to 255 255 255 (nuclear blast), recommended values up to 1 1 1, default 1 1 1 +"style" lightstyle, same as for static lights +"angles" initial orientation +"avelocity" a vector value, the direction and speed it rotates in +"skin" cubemap number, must be 16 or above +"dtagname" will attach to this tag on the entity which "targetname" matches "target". If the "target" is either not an md3 model or is missing tags, it will attach to the targets origin. Note that the "target" must be visible to the spawnfunc_light +"targetname" will toggle on and off when triggered +"target" if issued with a target, preferrably spawnfunc_path_corner, it will move along the path. If also issued with the FOLLOW spawnflag, then this is the entity it will follow. If issued with the "tagname" key it will attach it to this targets tag called "tagname", does not work together with FOLLOW or path movement +"speed" the speed it will travel along the path, default 100 +flags: +"START_OFF" spawnfunc_light will be in off state until targeted +"NOSHADOW" will not cast shadows in realtime lighting mode +"FOLLOW" will follow the entity which "targetname" matches "target" +*/ +void dynlight_think(entity this) +{ + if(!this.owner) + delete(this); + + this.nextthink = time + 0.1; +} +void dynlight_find_aiment(entity this) +{ + entity targ; + if (!this.target) + objerror (this, "dynlight: no target to follow"); + + targ = find(NULL, targetname, this.target); + set_movetype(this, MOVETYPE_FOLLOW); + this.aiment = targ; + this.owner = targ; + this.punchangle = targ.angles; + this.view_ofs = this.origin - targ.origin; + this.v_angle = this.angles - targ.angles; + setthink(this, dynlight_think); + this.nextthink = time + 0.1; +} +void dynlight_find_path(entity this) +{ + entity targ; + if (!this.target) + objerror (this, "dynlight: no target to follow"); + + targ = find(NULL, targetname, this.target); + this.target = targ.target; + setorigin(this, targ.origin); + setthink(this, train_next); // TODO: reliant on the train's pathing functions + this.nextthink = time + 0.1; +} +void dynlight_find_target(entity this) +{ + entity targ; + if (!this.target) + objerror (this, "dynlight: no target to follow"); + + targ = find(NULL, targetname, this.target); + setattachment(this, targ, this.dtagname); + this.owner = targ; + setthink(this, dynlight_think); + this.nextthink = time + 0.1; +} +void dynlight_use(entity this, entity actor, entity trigger) +{ + if (this.light_lev == 0) + this.light_lev = this.lefty; + else + this.light_lev = 0; +} +spawnfunc(dynlight) +{ + if (!this.light_lev) + this.light_lev = 200; + if (!this.color) + this.color = '1 1 1'; + this.lefty = this.light_lev; + this.use = dynlight_use; + setsize (this, '0 0 0', '0 0 0'); + setorigin(this, this.origin); + //this.pflags = PFLAGS_FULLDYNAMIC; + this.solid = SOLID_NOT; + //this.blocked = func_null; + //if (this.spawnflags & DNOSHADOW) + // this.pflags = this.pflags + PFLAGS_NOSHADOW; + //if (this.spawnflags & START_OFF) + // this.light_lev = 0; + +//tag attaching + if (this.dtagname) + { + InitializeEntity(this, dynlight_find_target, INITPRIO_FINDTARGET); + return; + } + +// entity following + if (this.spawnflags & DFOLLOW) + { + InitializeEntity(this, dynlight_find_aiment, INITPRIO_FINDTARGET); + return; + } +// path following + if (this.target) +// if (!(this.spawnflags & DFOLLOW)) + { + set_movetype(this, MOVETYPE_NOCLIP); + if (!this.speed) + this.speed = 100; + InitializeEntity(this, dynlight_find_path, INITPRIO_FINDTARGET); + return; + } +} +#endif diff --git a/qcsrc/common/mapobjects/misc/dynlight.qh b/qcsrc/common/mapobjects/misc/dynlight.qh new file mode 100644 index 000000000..6f70f09be --- /dev/null +++ b/qcsrc/common/mapobjects/misc/dynlight.qh @@ -0,0 +1 @@ +#pragma once diff --git a/qcsrc/server/_mod.inc b/qcsrc/server/_mod.inc index cffc7f507..ca0dec4bb 100644 --- a/qcsrc/server/_mod.inc +++ b/qcsrc/server/_mod.inc @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include diff --git a/qcsrc/server/_mod.qh b/qcsrc/server/_mod.qh index cb66bc888..c87bb2a03 100644 --- a/qcsrc/server/_mod.qh +++ b/qcsrc/server/_mod.qh @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include diff --git a/qcsrc/server/g_lights.qc b/qcsrc/server/g_lights.qc deleted file mode 100644 index 852f1efc0..000000000 --- a/qcsrc/server/g_lights.qc +++ /dev/null @@ -1,135 +0,0 @@ -#include "g_lights.qh" - -#include -#include - -void train_next(entity this); - -const float LOOP = 1; - -.float speed; - -const float DNOSHADOW = 2; -const float DFOLLOW = 4; -.float light_lev; -.float lefty; -.vector color; -.string dtagname; - -/*QUAKED dynlight (0 1 0) (-8 -8 -8) (8 8 8) START_OFF NOSHADOW FOLLOW -Dynamic spawnfunc_light. -Can do one of these things: sit still and be just a silly spawnfunc_light, travel along a path, follow an entity around, attach to a tag on an entity. -It can spin around it's own axis in all the above cases. -If targeted, it will toggle between on or off. -keys: -"light_lev" spawnfunc_light radius, default 200 -"color" spawnfunc_light color in rgb and brightness, 1 1 1 produces bright white, up to 255 255 255 (nuclear blast), recommended values up to 1 1 1, default 1 1 1 -"style" lightstyle, same as for static lights -"angles" initial orientation -"avelocity" a vector value, the direction and speed it rotates in -"skin" cubemap number, must be 16 or above -"dtagname" will attach to this tag on the entity which "targetname" matches "target". If the "target" is either not an md3 model or is missing tags, it will attach to the targets origin. Note that the "target" must be visible to the spawnfunc_light -"targetname" will toggle on and off when triggered -"target" if issued with a target, preferrably spawnfunc_path_corner, it will move along the path. If also issued with the FOLLOW spawnflag, then this is the entity it will follow. If issued with the "tagname" key it will attach it to this targets tag called "tagname", does not work together with FOLLOW or path movement -"speed" the speed it will travel along the path, default 100 -flags: -"START_OFF" spawnfunc_light will be in off state until targeted -"NOSHADOW" will not cast shadows in realtime lighting mode -"FOLLOW" will follow the entity which "targetname" matches "target" -*/ -void dynlight_think(entity this) -{ - if(!this.owner) - delete(this); - - this.nextthink = time + 0.1; -} -void dynlight_find_aiment(entity this) -{ - entity targ; - if (!this.target) - objerror (this, "dynlight: no target to follow"); - - targ = find(NULL, targetname, this.target); - set_movetype(this, MOVETYPE_FOLLOW); - this.aiment = targ; - this.owner = targ; - this.punchangle = targ.angles; - this.view_ofs = this.origin - targ.origin; - this.v_angle = this.angles - targ.angles; - setthink(this, dynlight_think); - this.nextthink = time + 0.1; -} -void dynlight_find_path(entity this) -{ - entity targ; - if (!this.target) - objerror (this, "dynlight: no target to follow"); - - targ = find(NULL, targetname, this.target); - this.target = targ.target; - setorigin(this, targ.origin); - setthink(this, train_next); - this.nextthink = time + 0.1; -} -void dynlight_find_target(entity this) -{ - entity targ; - if (!this.target) - objerror (this, "dynlight: no target to follow"); - - targ = find(NULL, targetname, this.target); - setattachment(this, targ, this.dtagname); - this.owner = targ; - setthink(this, dynlight_think); - this.nextthink = time + 0.1; -} -void dynlight_use(entity this, entity actor, entity trigger) -{ - if (this.light_lev == 0) - this.light_lev = this.lefty; - else - this.light_lev = 0; -} -spawnfunc(dynlight) -{ - if (!this.light_lev) - this.light_lev = 200; - if (!this.color) - this.color = '1 1 1'; - this.lefty = this.light_lev; - this.use = dynlight_use; - setsize (this, '0 0 0', '0 0 0'); - setorigin(this, this.origin); - //this.pflags = PFLAGS_FULLDYNAMIC; - this.solid = SOLID_NOT; - //this.blocked = func_null; - //if (this.spawnflags & DNOSHADOW) - // this.pflags = this.pflags + PFLAGS_NOSHADOW; - //if (this.spawnflags & START_OFF) - // this.light_lev = 0; - -//tag attaching - if (this.dtagname) - { - InitializeEntity(this, dynlight_find_target, INITPRIO_FINDTARGET); - return; - } - -// entity following - if (this.spawnflags & DFOLLOW) - { - InitializeEntity(this, dynlight_find_aiment, INITPRIO_FINDTARGET); - return; - } -// path following - if (this.target) -// if (!(this.spawnflags & DFOLLOW)) - { - set_movetype(this, MOVETYPE_NOCLIP); - if (!this.speed) - this.speed = 100; - InitializeEntity(this, dynlight_find_path, INITPRIO_FINDTARGET); - return; - } -} diff --git a/qcsrc/server/g_lights.qh b/qcsrc/server/g_lights.qh deleted file mode 100644 index 6f70f09be..000000000 --- a/qcsrc/server/g_lights.qh +++ /dev/null @@ -1 +0,0 @@ -#pragma once