Env quadraticbeam: Difference between revisions
Jump to navigation
Jump to search

Important:Other than
and
).
No edit summary |
(Add bigger note about netprops, slightly better grammar and more detailed info, expand VScript example.) |
||
Line 3: | Line 3: | ||
{{CD|CEnvQuadraticBeam|file1=1}} | {{CD|CEnvQuadraticBeam|file1=1}} | ||
{{CD|C_QuadraticBeam|game=client side|base=C_BaseEntity|file1=[https://github.com/ValveSoftware/source-sdk-2013/blob/master/mp/src/game/client/c_effects.cpp#L1500 c_effects.cpp]}} | {{CD|C_QuadraticBeam|game=client side|base=C_BaseEntity|file1=[https://github.com/ValveSoftware/source-sdk-2013/blob/master/mp/src/game/client/c_effects.cpp#L1500 c_effects.cpp]}} | ||
{{this is a|[[entity]]|name=env_quadraticbeam}} | {{this is a|[[entity]]|name=env_quadraticbeam}} It is a duplicate of the {{ent|beam}} entity, but with ability to arc by using a quadratic equation. It can be used to produce a similar effect to the {{gmod}} physics gun. The formula used to form the curve can be found [https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/mp/src/game/client/beamdraw.cpp#L1489 here]. | ||
{{Important|Other than <code>origin</code> and <code>color</code>, this entity has no keyvalues or inputs! Values listed under 'Fields' can only be accessed with an external plugin, or the NetProp manager found in certain [[VScript]]-supported titles ({{tf2}} and {{l4d2}}).}} | |||
== Fields == | == Fields == | ||
Line 11: | Line 12: | ||
{{DEFINE_FIELD|m_flWidth|FIELD_FLOAT}} | {{DEFINE_FIELD|m_flWidth|FIELD_FLOAT}} | ||
== | == Keyvalues == | ||
{{KV|Origin|intn=origin|vector|Start point of the beam}} | {{KV|Origin|intn=origin|vector|Start point of the beam}} | ||
== Inputs == | |||
{{IO|Color|param=rgb|Changes color}} | {{IO|Color|param=rgb|Changes color}} | ||
Line 21: | Line 21: | ||
== Spawning via vscript example == | == Spawning via vscript example == | ||
<syntaxhighlight lang=js style="background:initial;"> | <syntaxhighlight lang=js style="background:initial;"> | ||
function SpawnQuadBeam(start, end, control, color="255 0 0", model="sprites/laserbeam.spr") { | function SpawnQuadBeam(start, end, control, color="255 0 0", model="sprites/laserbeam.spr") { | ||
local ent = SpawnEntityFromTable("env_quadraticbeam", { | // precache the beam sprite | ||
PrecacheModel(model) | |||
// spawn the beam and set the start point | |||
local ent = SpawnEntityFromTable("env_quadraticbeam", { origin = start }) | |||
// set the end point for the beam | |||
NetProps.SetPropVector(ent, "m_targetPosition", end) | NetProps.SetPropVector(ent, "m_targetPosition", end) | ||
// set the control point for the curve | |||
NetProps.SetPropVector(ent, "m_controlPosition", control) | NetProps.SetPropVector(ent, "m_controlPosition", control) | ||
NetProps.SetPropFloat(ent, "m_scrollRate", 2) | NetProps.SetPropFloat(ent, "m_scrollRate", 2) | ||
NetProps.SetPropFloat(ent, "m_flWidth", 5) | NetProps.SetPropFloat(ent, "m_flWidth", 5) | ||
// set the beam color | |||
DoEntFire("!self", "color", color, 0, null, ent) | DoEntFire("!self", "color", color, 0, null, ent) | ||
ent.SetModel(model) | // set the beam sprite | ||
ent.SetModel(model) | |||
} | } | ||
//Draw a beam from the players origin point to the nearest prop_dynamic in a 2048hu radius | |||
local start_pos = GetListenServerHost().GetOrigin() | |||
local end_pos = Entities.FindByClassnameNearest("prop_dynamic", eye_pos, 2048) | |||
//spawn our beam with a control value of 4 | |||
SpawnQuadBeam(start_pos, end_pos, 4) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 07:29, 29 August 2024



![]() |
---|
CEnvQuadraticBeam |
![]() |
![]() |
---|
client side |
C_QuadraticBeam |
![]() |
env_quadraticbeam
is an entity available in all Source games. It is a duplicate of the beam entity, but with ability to arc by using a quadratic equation. It can be used to produce a similar effect to the
physics gun. The formula used to form the curve can be found here.

origin
and color
, this entity has no keyvalues or inputs! Values listed under 'Fields' can only be accessed with an external plugin, or the NetProp manager found in certain VScript-supported titles (

Fields
m_targetPosition <FIELD_POSITION_VECTOR>
- END point
m_controlPosition <FIELD_POSITION_VECTOR>
- CONTROL point (see picture)
m_scrollRate <FIELD_FLOAT>
- Must be value between -4, 4
m_flWidth <FIELD_FLOAT>
Keyvalues
- Origin (origin) <vector>
- Start point of the beam
Inputs
- Color <color255 >
- Changes color
Spawning via vscript example
function SpawnQuadBeam(start, end, control, color="255 0 0", model="sprites/laserbeam.spr") {
// precache the beam sprite
PrecacheModel(model)
// spawn the beam and set the start point
local ent = SpawnEntityFromTable("env_quadraticbeam", { origin = start })
// set the end point for the beam
NetProps.SetPropVector(ent, "m_targetPosition", end)
// set the control point for the curve
NetProps.SetPropVector(ent, "m_controlPosition", control)
NetProps.SetPropFloat(ent, "m_scrollRate", 2)
NetProps.SetPropFloat(ent, "m_flWidth", 5)
// set the beam color
DoEntFire("!self", "color", color, 0, null, ent)
// set the beam sprite
ent.SetModel(model)
}
//Draw a beam from the players origin point to the nearest prop_dynamic in a 2048hu radius
local start_pos = GetListenServerHost().GetOrigin()
local end_pos = Entities.FindByClassnameNearest("prop_dynamic", eye_pos, 2048)
//spawn our beam with a control value of 4
SpawnQuadBeam(start_pos, end_pos, 4)