Creates chidren from a dying weapon
| 3168 | |
| 3169 | // Creates chidren from a dying weapon |
| 3170 | void CreateTimeoutSpawnFromWeapon(object *obj) { |
| 3171 | int n = obj->id; |
| 3172 | |
| 3173 | ASSERT(Weapons[n].spawn_count > 0 && Weapons[n].spawn_handle >= 0); |
| 3174 | |
| 3175 | int num = Weapons[n].spawn_count; |
| 3176 | int spawn_index = Weapons[n].spawn_handle; |
| 3177 | vector pos; |
| 3178 | matrix orient; |
| 3179 | |
| 3180 | // See if we should spawn the alternate |
| 3181 | if (Weapons[n].alternate_spawn_handle >= 0 && Weapons[n].alternate_chance > 0) { |
| 3182 | if ((ps_rand() % 100) < Weapons[n].alternate_chance) |
| 3183 | spawn_index = Weapons[n].alternate_spawn_handle; |
| 3184 | } |
| 3185 | |
| 3186 | for (int i = 0; i < num; i++) { |
| 3187 | if (i == 0) // Make first one fire from the center of the ring |
| 3188 | { |
| 3189 | pos = obj->pos + (obj->orient.fvec * obj->size / 2); |
| 3190 | |
| 3191 | CreateAndFireWeapon(&pos, &obj->orient.fvec, obj, spawn_index); |
| 3192 | } else { |
| 3193 | matrix temp_mat; |
| 3194 | pos = obj->pos + (obj->orient.fvec * obj->size / 2); |
| 3195 | |
| 3196 | float norm = ((float)(i - 1)) / ((float)num - 1); |
| 3197 | |
| 3198 | float mysin = FixSin(norm * 65536); |
| 3199 | float mycos = FixCos(norm * 65536); |
| 3200 | |
| 3201 | int x_twist = mycos * 4096; |
| 3202 | int y_twist = mysin * 4096; |
| 3203 | |
| 3204 | vm_AnglesToMatrix(&temp_mat, x_twist, y_twist, 0); |
| 3205 | vm_TransposeMatrix(&temp_mat); |
| 3206 | |
| 3207 | orient = obj->orient * temp_mat; |
| 3208 | |
| 3209 | CreateAndFireWeapon(&pos, &orient.fvec, obj, spawn_index); |
| 3210 | } |
| 3211 | } |
| 3212 | } |
| 3213 | |
| 3214 | // Creates a robot as a countermeasure |
| 3215 | void CreateRobotSpawnFromWeapon(object *obj) { |
no test coverage detected