MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DrawVirusLightning

Function DrawVirusLightning

Descent3/renderobject.cpp:2268–2309  ·  view source on GitHub ↗

Creates Virus infected lightning on an object

Source from the content-addressed store, hash-verified

2266
2267// Creates Virus infected lightning on an object
2268void DrawVirusLightning(object *obj) {
2269 if (!obj->effect_info)
2270 return;
2271 if (!(obj->effect_info->type_flags & EF_VIRUS_INFECTED))
2272 return;
2273
2274 float shield_norm = (float)(ps_rand() % D3_RAND_MAX) / (float)D3_RAND_MAX;
2275 shield_norm = 1 - shield_norm;
2276
2277 ASSERT(shield_norm >= 0 && shield_norm <= 1);
2278 int shield_modulo = 20 - (16 * shield_norm);
2279 if (shield_modulo < 1)
2280 shield_modulo = 1;
2281 if ((ps_rand() % shield_modulo) == 0) {
2282 poly_model *pm = &Poly_models[obj->rtype.pobj_info.model_num];
2283 if (pm->n_models == 0)
2284 return;
2285 int subnum = ps_rand() % pm->n_models;
2286 if (IsNonRenderableSubmodel(pm, subnum))
2287 return;
2288
2289 bsp_info *sm = &pm->submodel[subnum];
2290 if (sm->nverts == 0)
2291 return;
2292 int visnum = VisEffectCreate(VIS_FIREBALL, GRAY_LIGHTNING_BOLT_INDEX, obj->roomnum, &obj->pos);
2293 if (visnum >= 0) {
2294 vis_effect *vis = &VisEffects[visnum];
2295 vis->lifeleft = 1.0;
2296 vis->lifetime = 1.0;
2297 vis->end_pos = obj->pos;
2298 vis->velocity.x = .15f;
2299 vis->velocity.y = 3;
2300 vis->attach_info.obj_handle = obj->handle;
2301 vis->attach_info.subnum = subnum;
2302 vis->attach_info.vertnum = ps_rand() % sm->nverts;
2303 vis->attach_info.end_vertnum = ps_rand() % sm->nverts;
2304 vis->attach_info.modelnum = obj->rtype.pobj_info.model_num;
2305 vis->flags = VF_USES_LIFELEFT | VF_EXPAND | VF_ATTACHED;
2306 vis->lighting_color = GR_RGB16(40, 250, 40);
2307 }
2308 }
2309}
2310
2311void DrawPlayerSightVector(object *obj) {
2312 if (obj->type != OBJ_PLAYER || obj->id != Player_num)

Callers 1

RenderObjectFunction · 0.85

Calls 4

ps_randFunction · 0.85
IsNonRenderableSubmodelFunction · 0.85
VisEffectCreateFunction · 0.85
GR_RGB16Function · 0.85

Tested by

no test coverage detected