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

Function DoGravityFieldEffect

Descent3/fireball.cpp:1515–1705  ·  view source on GitHub ↗

Pulls every object near the gravity field into its center

Source from the content-addressed store, hash-verified

1513}
1514// Pulls every object near the gravity field into its center
1515void DoGravityFieldEffect(object *obj) {
1516 float max_size = obj->ctype.blast_info.max_size;
1517 float lifenorm = (obj->lifetime - obj->lifeleft) / obj->lifetime;
1518 float dist, force;
1519 vector vforce;
1520 int i;
1521 object *hit_obj_ptr;
1522 float time_norm = 1.0 - (obj->lifeleft / obj->lifetime);
1523 obj->size = max_size;
1524 float sphere_norm = 1.0 - ((lifenorm - .1) * 1.5);
1525 if (sphere_norm < 0)
1526 sphere_norm = 0;
1527 SetShakeMagnitude(25);
1528 float vdist = vm_VectorDistanceQuick(&Viewer_object->pos, &obj->pos);
1529 CreateRandomSparks(3, &obj->pos, obj->roomnum, -1, 2);
1530
1531 if (!(obj->flags & OF_SERVER_SAYS_DELETE)) {
1532 obj->flags |= OF_SERVER_SAYS_DELETE;
1533 int visnum = VisEffectCreate(VIS_FIREBALL, SUN_CORONA_INDEX, obj->roomnum, &obj->pos);
1534 if (visnum >= 0) {
1535 vis_effect *vis = &VisEffects[visnum];
1536 vis->size = max_size / 4;
1537 vis->lifeleft = obj->lifetime;
1538 vis->lifetime = obj->lifetime;
1539 vis->flags = VF_USES_LIFELEFT | VF_WINDSHIELD_EFFECT;
1540 }
1541 // Create lightning from the heavens
1542 if (OBJECT_OUTSIDE(obj) && vdist > 5) {
1543 int visnum = VisEffectCreate(VIS_FIREBALL, THICK_LIGHTNING_INDEX, obj->roomnum, &obj->pos);
1544 if (visnum >= 0) {
1545 vis_effect *vis = &VisEffects[visnum];
1546 vis->lifeleft = obj->lifetime;
1547 vis->lifetime = obj->lifetime;
1548 vis->end_pos = obj->pos;
1549
1550 vis->end_pos.y = obj->pos.y + (MAX_TERRAIN_HEIGHT * 2);
1551 vis->velocity.x = 2;
1552 vis->velocity.y = 1;
1553 vis->velocity.z = 3;
1554 vis->custom_handle = FindTextureName("ThickLineLightning");
1555 vis->billboard_info.width = 70;
1556 vis->billboard_info.texture = 0;
1557
1558 vis->lighting_color = OPAQUE_FLAG | GR_RGB16(100, 150, 255);
1559 vis->flags = VF_USES_LIFELEFT | VF_WINDSHIELD_EFFECT;
1560 vis->size = 50;
1561 }
1562 }
1563 // Create lightning from the heavens
1564 if (!OBJECT_OUTSIDE(obj)) {
1565 ps_srand(Gametime * 100);
1566 int count = 0;
1567 // Cast 3 rays out from the center
1568 for (i = 0; i < 3; i++) {
1569 again:
1570 vector rand_vector, test_vector;
1571 rand_vector.x = ((ps_rand() % 100 - 50) / 50.0) + .1; // So we don't get a zero vector
1572 rand_vector.y = ((ps_rand() % 100) - 50) / 50.0;

Callers 1

DoExplosionFrameFunction · 0.85

Calls 13

SetShakeMagnitudeFunction · 0.85
CreateRandomSparksFunction · 0.85
VisEffectCreateFunction · 0.85
FindTextureNameFunction · 0.85
GR_RGB16Function · 0.85
ps_srandFunction · 0.85
ps_randFunction · 0.85
vm_NormalizeVectorFunction · 0.85
fvi_FindIntersectionFunction · 0.85
phys_apply_forceFunction · 0.85
vm_VectorDistanceQuickFunction · 0.50
vm_VectorDistanceFunction · 0.50

Tested by

no test coverage detected