MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / Script_Unit_Die

Function Script_Unit_Die

src/script/unit.c:490–522  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

488 * @return The value 0. Always.
489 */
490uint16 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.

Callers

nothing calls this directly

Calls 3

Unit_RemoveFunction · 0.85
Map_MakeExplosionFunction · 0.85

Tested by

no test coverage detected