Imported from JieZhiF/zombie_survival_chinese (
gamemodes/zombiesurvival/entities/effects/AGENTS.md). Install upstream withnpx skills add JieZhiF/zombie_survival_chinese --skill effects. Copyright stays with the author.
Effects (entities/effects/)
OVERVIEW
Client-side Lua EFFECTs (particles, beams, sprites, world-space text) spawned from weapon/entity code.
STRUCTURE
Flat: one .lua per effect, filename (no ext) = effect name. Three folder-effects hold init.lua, folder name = effect name:
spearpierce/init.luasillytracer/init.luastundeflection/init.lua
WHERE TO LOOK
| Need | Files | Notes |
|---|---|---|
| Projectile tracers/beams | tracer_* (18) |
Render() draws beams/sprites; use self:GetTracerShootPos(); see tracer_gluon.lua |
| Bullet/projectile impacts | hit_* (20) |
One-shot particle bursts; hit_flesh.lua, hit_hunter.lua |
| Explosions | explosion_* (15) |
Multi-group particle burst + decaying glow sprite; explosion_rocket.lua |
| Zombie death | death_* (5) |
death_wraith.lua, death_shade.lua |
| Floating score/damage text | floatingscore_* (5), damagenumber.lua, melee_*_text.lua |
3D2D text via render hook, not Render() |
| Gore/blood | bloodstream*, gib_player.lua, gore_blast.lua, dismemberment.lua, headshot.lua |
ClientsideModel gibs + util.Blood |
| Sigils/decals/misc | sigil_*, decal_scorch.lua, nailrepaired.lua, redeem.lua, corrupted_teleport.lua, weapon_shattered.lua |
Assorted one-shots |
CONVENTIONS
- Each file defines the
EFFECTtable:Init(data)(required; read inputs viadata:Get*(), spawn particles/sounds/clientside models),Think()(returnfalsefor one-shot; returnself.Life < 1to keep a fading effect alive),Render()(empty for particle-only; tracers draw beams/sprites here). dataaccessors used:GetOrigin,GetNormal,GetEntity,GetStart,GetAttachment,GetMagnitude,GetScale,GetFlags.- Dispatch: server/shared code calls
util.Effect("name", effectData[, allowOverride, ignorePred]), or a weapon setsSWEP.TracerName = "name"."name"must match the filename/folder exactly. Some call sites use GMod built-ins ("Explosion","Impact","RagdollImpact","TeslaHitBoxes") - those are NOT defined here. - Particle idiom (47 files):
local emitter = ParticleEmitter(pos), loops ofemitter:Add(mat, pos)+ setter calls, then end withemitter:Finish() emitter = nil collectgarbage("step", 64). - Cache
Material(...)and localize globals (local draw = draw) at file top, never inside Render. - One-shot: all work in Init,
Thinkreturnsfalse. Fading: storeself.Life/self.Alpha/self.StartTimein Init, decay in Think, draw in Render. - Newer files (
explosion_rocket.lua,death_*) carry a Chinese-- ====banner header + Chinese inline comments; older files are English-only. - Variant suffixes are distinct registered names, not overrides:
_sb,_alt,_com/_heal/_rep/_und, trailing2(hit_healdart2.lua).
ANTI-PATTERNS
- C-style
//comments and!=operator inspearpierce/init.luaandstundeflection/init.lua- forbidden here; use--and~=. trancer_laser.luais a filename typo (trancer, not tracer) but load-bearing:weapon_zs_tokamak.luasetsSWEP.TracerName = "trancer_laser". Do not rename without updating the weapon.damagenumber.lua/floatingscore_*do not render inEFFECT:Render; they push particles into a module-level table drawn by aPostDrawTranslucentRenderableshook. Copy that pattern only for world-space text, not for ordinary particle effects.