예제 #1
0
/**
 * Handle damage to a tile, removing spice, removing concrete, stuff like that.
 * @param e The Explosion to handle damage on.
 * @param parameter Unused parameter.
 */
static void Explosion_Func_TileDamage(Explosion *e, uint16 parameter)
{
    static const int16 craterIconMapIndex[] = { -1, 2, 1 };

    uint16 packed;
    uint16 type;
    Tile *t;
    int16 iconMapIndex;
    uint16 overlaySpriteID;
    uint16 *iconMap;

    VARIABLE_NOT_USED(parameter);

    packed = Tile_PackTile(e->position);

    if (!Map_IsPositionUnveiled(packed)) return;

    type = Map_GetLandscapeType(packed);

    if (type == LST_STRUCTURE || type == LST_DESTROYED_WALL) return;

    t = &g_map[packed];

    if (type == LST_CONCRETE_SLAB) {
        t->groundSpriteID = g_mapSpriteID[packed];
        Map_Update(packed, 0, false);
    }

    if (g_table_landscapeInfo[type].craterType == 0) return;

    /* You cannot damage veiled tiles */
    overlaySpriteID = t->overlaySpriteID;
    if (!Sprite_IsUnveiled(overlaySpriteID)) return;

    iconMapIndex = craterIconMapIndex[g_table_landscapeInfo[type].craterType];
    iconMap = &g_iconMap[g_iconMap[iconMapIndex]];

    if (iconMap[0] <= overlaySpriteID && overlaySpriteID <= iconMap[10]) {
        /* There already is a crater; make it bigger */
        overlaySpriteID -= iconMap[0];
        if (overlaySpriteID < 4) overlaySpriteID += 2;
    } else {
        /* Randomly pick 1 of the 2 possible craters */
        overlaySpriteID = Tools_Random_256() & 1;
    }

    /* Reduce spice if there is any */
    Map_ChangeSpiceAmount(packed, -1);

    /* Boom a bloom if there is one */
    if (t->groundSpriteID == g_bloomSpriteID) {
        Map_Bloom_ExplodeSpice(packed, g_playerHouseID);
        return;
    }

    /* Update the tile with the crater */
    t->overlaySpriteID = overlaySpriteID + iconMap[0];
    Map_Update(packed, 0, false);
}
예제 #2
0
파일: scenario.c 프로젝트: HBTeun/OpenDUNE
static void Scenario_Load_Map_Field(uint16 packed, Tile *t)
{
	Map_Bloom_ExplodeSpice(packed, HOUSE_INVALID);

	/* Show where a field started in the preview mode by making it an odd looking sprite */
	if (g_debugScenario) {
		t->groundSpriteID = 0x01FF;
	}
}
예제 #3
0
/**
 * Check if there is a bloom at the location, and make it explode if needed.
 * @param e The Explosion to perform the explosion on.
 * @param parameter Unused parameter.
 */
static void Explosion_Func_BloomExplosion(Explosion *e, uint16 parameter)
{
    uint16 packed;

    VARIABLE_NOT_USED(parameter);

    packed = Tile_PackTile(e->position);

    if (g_map[packed].groundSpriteID != g_bloomSpriteID) return;

    Map_Bloom_ExplodeSpice(packed, g_playerHouseID);
}