* Check if a Unit/Structure is an enemy. * * Stack: 1 - An encoded index. * * @param script The script engine to operate on. * @return Zero if and only if the Unit/Structure is friendly. */
| 369 | * @return Zero if and only if the Unit/Structure is friendly. |
| 370 | */ |
| 371 | uint16 Script_General_IsEnemy(ScriptEngine *script) |
| 372 | { |
| 373 | uint8 houseID; |
| 374 | uint16 index; |
| 375 | |
| 376 | index = STACK_PEEK(1); |
| 377 | |
| 378 | if (!Tools_Index_IsValid(index)) return 0; |
| 379 | |
| 380 | houseID = (g_scriptCurrentUnit != NULL) ? Unit_GetHouseID(g_scriptCurrentUnit) : g_scriptCurrentObject->houseID; |
| 381 | |
| 382 | switch (Tools_Index_GetType(index)) { |
| 383 | case IT_UNIT: return (Unit_GetHouseID(Tools_Index_GetUnit(index)) != houseID) ? 1 : 0; |
| 384 | case IT_STRUCTURE: return (Tools_Index_GetStructure(index)->o.houseID != houseID) ? 1 : 0; |
| 385 | default: return 0; |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | /** |
| 390 | * Two sided function. If the parameter is an index, it will return 1 if and |
no test coverage detected