* Kill a unit. When it was a saboteur, expect a big explosion. * * Stack: *none*. * * @param script The script engine to operate on. * @return The value 0. Always. */
| 488 | * @return The value 0. Always. |
| 489 | */ |
| 490 | uint16 Script_Unit_Die(ScriptEngine *script) |
| 491 | { |
| 492 | const UnitInfo *ui; |
| 493 | Unit *u; |
| 494 | |
| 495 | VARIABLE_NOT_USED(script); |
| 496 | |
| 497 | u = g_scriptCurrentUnit; |
| 498 | ui = &g_table_unitInfo[u->o.type]; |
| 499 | |
| 500 | Unit_Remove(u); |
| 501 | |
| 502 | if (ui->movementType != MOVEMENT_WINGER) { |
| 503 | uint16 credits; |
| 504 | |
| 505 | credits = max(ui->o.buildCredits / 100, 1); |
| 506 | |
| 507 | if (u->o.houseID == g_playerHouseID) { |
| 508 | g_scenario.killedAllied++; |
| 509 | g_scenario.score -= credits; |
| 510 | } else { |
| 511 | g_scenario.killedEnemy++; |
| 512 | g_scenario.score += credits; |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | Unit_HouseUnitCount_Remove(u); |
| 517 | |
| 518 | if (u->o.type != UNIT_SABOTEUR) return 0; |
| 519 | |
| 520 | Map_MakeExplosion(EXPLOSION_SABOTEUR_DEATH, u->o.position, 300, 0); |
| 521 | return 0; |
| 522 | } |
| 523 | |
| 524 | /** |
| 525 | * Make an explosion at the coordinates of the unit. |
nothing calls this directly
no test coverage detected