Creates vis effects but has the caller set their parameters initialize a new viseffect. adds to the list for the given room returns the vis number
| 630 | // initialize a new viseffect. adds to the list for the given room |
| 631 | // returns the vis number |
| 632 | int VisEffectCreateControlled(uint8_t type, object *parent, uint8_t id, int roomnum, vector *pos, float lifetime, |
| 633 | vector *velocity, int phys_flags, float size, float drag, float mass, bool isreal) { |
| 634 | int visnum; |
| 635 | vis_effect *vis; |
| 636 | static int napalm_id = -1; |
| 637 | |
| 638 | if (napalm_id == -1) |
| 639 | napalm_id = FindWeaponName("Napalm"); |
| 640 | |
| 641 | if (isreal) { |
| 642 | ASSERT(parent != NULL); // You have a spew that has no parent object? |
| 643 | |
| 644 | if (ROOMNUM_OUTSIDE(roomnum)) { |
| 645 | if (CELLNUM(roomnum) > TERRAIN_WIDTH * TERRAIN_DEPTH) |
| 646 | return -1; |
| 647 | if (CELLNUM(roomnum) < 0) |
| 648 | return -1; |
| 649 | |
| 650 | if (Gametime - Last_terrain_render_time > 5.0) |
| 651 | return -1; |
| 652 | } else { |
| 653 | ASSERT(roomnum >= 0 && roomnum <= Highest_room_index && Rooms[roomnum].used); |
| 654 | |
| 655 | // Don't create real objects in rooms we haven't seen in a while |
| 656 | if (Gametime - Rooms[roomnum].last_render_time > 5.0) |
| 657 | return -1; |
| 658 | } |
| 659 | |
| 660 | int objnum = CreateAndFireWeapon(pos, velocity, parent, napalm_id); |
| 661 | if (objnum >= 0) { |
| 662 | object *obj = &Objects[objnum]; |
| 663 | |
| 664 | obj->lifeleft = lifetime; |
| 665 | obj->lifetime = lifetime; |
| 666 | obj->movement_type = MT_PHYSICS; |
| 667 | |
| 668 | if (mass > 0 && drag > 0) { |
| 669 | obj->mtype.phys_info.mass = mass; |
| 670 | obj->mtype.phys_info.drag = drag; |
| 671 | } |
| 672 | |
| 673 | if (size > 0) |
| 674 | obj->size = size; |
| 675 | |
| 676 | obj->mtype.phys_info.velocity = *velocity; |
| 677 | |
| 678 | if (phys_flags) |
| 679 | obj->mtype.phys_info.flags = phys_flags; |
| 680 | |
| 681 | obj->ctype.laser_info.casts_light = false; |
| 682 | } |
| 683 | |
| 684 | return objnum; |
| 685 | } |
| 686 | |
| 687 | visnum = VisEffectCreate(type, id, roomnum, pos); |
| 688 | |
| 689 | if (visnum < 0) |
no test coverage detected