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

Function Map_Bloom_ExplodeSpecial

src/map.c:833–908  ·  view source on GitHub ↗

* A unit drove over a special bloom, which can either give credits, a friendly * Trike, an enemy Trike, or an enemy Infantry. * @param packed The tile where the bloom is on. * @param houseID The HouseID that is driving over the bloom. */

Source from the content-addressed store, hash-verified

831 * @param houseID The HouseID that is driving over the bloom.
832 */
833void Map_Bloom_ExplodeSpecial(uint16 packed, uint8 houseID)
834{
835 House *h;
836 PoolFindStruct find;
837 uint8 enemyHouseID;
838
839 h = House_Get_ByIndex(houseID);
840
841 g_map[packed].groundTileID = g_landscapeTileID;
842 g_mapTileID[packed] = 0x8000 | g_landscapeTileID;
843
844 Map_Update(packed, 0, false);
845
846 enemyHouseID = houseID;
847
848 find.houseID = HOUSE_INVALID;
849 find.index = 0xFFFF;
850 find.type = 0xFFFF;
851
852 /* Find a house that belongs to the enemy */
853 while (true) {
854 Unit *u;
855
856 u = Unit_Find(&find);
857 if (u == NULL) break;
858
859 if (u->o.houseID == houseID) continue;
860
861 enemyHouseID = u->o.houseID;
862 break;
863 }
864
865 switch (Tools_Random_256() & 0x3) {
866 case 0:
867 h->credits += Tools_RandomLCG_Range(150, 400);
868 break;
869
870 case 1: {
871 tile32 position = Tile_UnpackTile(packed);
872
873 position = Tile_MoveByRandom(position, 16, true);
874
875 /* ENHANCEMENT -- Dune2 inverted houseID and typeID arguments. */
876 Unit_Create(UNIT_INDEX_INVALID, UNIT_TRIKE, houseID, position, Tools_Random_256());
877 break;
878 }
879
880 case 2: {
881 tile32 position = Tile_UnpackTile(packed);
882 Unit *u;
883
884 position = Tile_MoveByRandom(position, 16, true);
885
886 /* ENHANCEMENT -- Dune2 inverted houseID and typeID arguments. */
887 u = Unit_Create(UNIT_INDEX_INVALID, UNIT_TRIKE, enemyHouseID, position, Tools_Random_256());
888
889 if (u != NULL) Unit_SetAction(u, ACTION_HUNT);
890 break;

Callers 1

Unit_MoveFunction · 0.85

Calls 9

House_Get_ByIndexFunction · 0.85
Map_UpdateFunction · 0.85
Unit_FindFunction · 0.85
Tools_Random_256Function · 0.85
Tools_RandomLCG_RangeFunction · 0.85
Tile_UnpackTileFunction · 0.85
Tile_MoveByRandomFunction · 0.85
Unit_CreateFunction · 0.85
Unit_SetActionFunction · 0.85

Tested by

no test coverage detected