//--------- Begin of function Unit::ai_escape_fire --------// // // Move away if the unit currently stands on a burning ground. // int Unit::ai_escape_fire() { if(cur_action!=SPRITE_IDLE) return 0; if(mobile_type!=UNIT_LAND) return 0; Location *locPtr = world.get_loc(next_x_loc(), next_y_loc()); if( !locPtr->fire_str() ) return 0; //--------------------------------------------// int checkLimit = 400; // checking for 400 location int xShift, yShift, checkXLoc, checkYLoc; int curXLoc = next_x_loc(); int curYLoc = next_y_loc(); for(int i=2; i<checkLimit; i++) { misc.cal_move_around_a_point(i, 20, 20, xShift, yShift); checkXLoc = curXLoc + xShift; checkYLoc = curYLoc + yShift; if(checkXLoc<0 || checkXLoc>=MAX_WORLD_X_LOC || checkYLoc<0 || checkYLoc>=MAX_WORLD_Y_LOC) continue; if(!locPtr->can_move(mobile_type)) continue; locPtr = world.get_loc(checkXLoc, checkYLoc); if( locPtr->fire_str()==0 ) // move to a safe place now { move_to(checkXLoc, checkYLoc); return 1; } } return 0; }
//---------- Begin of function Tornado::hit_fire --------// void Tornado::hit_fire() { short damageXLoc = damage_x_loc(); short damageYLoc = damage_y_loc(); if( damageXLoc < 0 || damageXLoc >= world.max_x_loc || damageYLoc < 0 || damageYLoc >= world.max_y_loc) return; Location *locPtr = world.get_loc(damageXLoc, damageYLoc); if(locPtr->fire_str() > 0) { locPtr->set_fire_str(1); } }
//--------- Begin of function Bullet::process_die --------// // // return : <int> 1 - dying animation completes. // 0 - still dying // int Bullet::process_die() { // ------- sound effect --------// se_res.sound(cur_x_loc(), cur_y_loc(), cur_frame, 'S',sprite_id,"DIE"); //--------- next frame ---------// if( ++cur_frame > sprite_info->die.frame_count ) // ####### begin Gilbert 28/6 ########// if( ++cur_frame > sprite_info->die.frame_count ) { // ------- set fire on the target area --------// if( fire_radius > 0) { Location *locPtr; if( fire_radius == 1) { locPtr = world.get_loc(target_x_loc, target_y_loc); if( locPtr->can_set_fire() && locPtr->fire_str() < 30 ) locPtr->set_fire_str(30); if( locPtr->fire_src() > 0 ) locPtr->set_fire_src(1); // such that the fire will be put out quickly } else { short x, y, x1, y1, x2, y2; // ##### begin Gilbert 2/10 ######// x1 = target_x_loc - fire_radius + 1; if( x1 < 0 ) x1 = 0; y1 = target_y_loc - fire_radius + 1; if( y1 < 0 ) y1 = 0; x2 = target_x_loc + fire_radius - 1; if( x2 >= world.max_x_loc ) x2 = world.max_x_loc-1; y2 = target_y_loc + fire_radius - 1; if( y2 >= world.max_y_loc ) y2 = world.max_y_loc-1; // ##### end Gilbert 2/10 ######// for( y = y1; y <= y2; ++y) { locPtr = world.get_loc(x1, y); for( x = x1; x <= x2; ++x, ++locPtr) { // ##### begin Gilbert 30/10 ######// int dist = abs(x-target_x_loc) + abs(y-target_y_loc); if( dist > fire_radius) continue; int fl = 30 - dist * 7; if( fl < 10 ) fl = 10; if( locPtr->can_set_fire() && locPtr->fire_str() < fl ) locPtr->set_fire_str(fl); if( locPtr->fire_src() > 0 ) locPtr->set_fire_src(1); // such that the fire will be put out quickly // ##### begin Gilbert 30/10 ######// } } } } return 1; } // ####### end Gilbert 28/6 ########// return 0; }
//---------- Begin of function MapMatrix::draw_map ------------// // see also World::explore // void MapMatrix::draw_map() { //----------- draw map now ------------// sys.yield(); short fireColor = vga_back.translate_color(FIRE_COLOR); short plantColor = vga_back.translate_color(plant_res.plant_map_color); short seaColor = vga_back.translate_color(0x32); short rockColor = vga_back.translate_color( 0x59 ); short mapModeColor = vga_back.translate_color( VGA_GRAY+10 ); short unexploredColor = vga_back.translate_color(UNEXPLORED_COLOR); short shadowColor = vga_back.translate_color( VGA_GRAY+2 ); short roadColor = vga_back.translate_color( VGA_GRAY+12 ); short nationColorArray[MAX_NATION+2]; for( int n = 0; n < MAX_NATION+2; ++n ) nationColorArray[n] = vga_back.translate_color(nation_array.nation_power_color_array[n]); // #### begin Ban 8/12 #######// int temp3 = vga_back.buf_true_pitch() -2; short *temp6 = vga_back.buf_ptr((image_x1 + image_x2)/2, image_y1); #ifdef ASM_FOR_MSVC _asm { MOV AX , DS MOV ES , AX MOV EDX, temp3 MOV EDI, temp6 CLD MOV AX, word ptr UNEXPLORED_COLOR MOV CX, AX // processing the color for drawing SHL EAX, 16 MOV AX, CX MOV EBX, 100 XOR ECX, ECX PutLineUpper: // draw upper triangle INC ECX REP STOSD MOV ECX, 101 // restore ECX after STOSD for updating EDI SUB ECX, EBX ADD EDI, EDX // updating EDI to start point of next line SUB EDI, ECX SUB EDI, ECX SUB EDI, ECX SUB EDI, ECX DEC EBX // decrease the remain height JNZ PutLineUpper // loop MOV EBX, 99 // ready parameters for drawing lower triangle ADD EDX, 4 ADD EDI, 4 PutLineLower: // draw lower triangle MOV ECX, EBX REP STOSD ADD EDI, EDX // updating EDI to start point of next line SUB EDI, EBX SUB EDI, EBX SUB EDI, EBX SUB EDI, EBX DEC EBX // decrease the remain height JNZ PutLineLower // loop } #else int lineDiff = temp3 / 2; int lineLength = 2; // Blacken upper half of minimap. for ( int i = 0; i < 100; ++i ) { for ( int j = 0; j < lineLength; ++j ) { *temp6 = UNEXPLORED_COLOR; ++temp6; } temp6 += lineDiff - lineLength; lineLength += 2; } // Blacken lower half of minimap. lineLength = 99 * 2; lineDiff += 2; temp6 += 2; for ( int i = 0; i < 99; ++i ) { for ( int j = 0; j < lineLength; ++j ) { *temp6 = UNEXPLORED_COLOR; ++temp6; } temp6 += lineDiff - lineLength; lineLength -= 2; } #endif // #### end Ban 8/12 #######// // { // traversal of location in MapMatrix // int pixelX = (image_x1 + image_x2 + 1) / 2; // int pixelY = image_y1; // int xLoc, yLoc; // int writePtrInc = vga_back.buf_pitch() + 1; // for( yLoc = 0; yLoc < max_y_loc; (yLoc&1?++pixelY:--pixelX) , ++yLoc ) // { // short* writePtr = vga_back.buf_ptr(pixelX, pixelY); // xLoc = 0; // Location *locPtr = get_loc( xLoc, yLoc ); // for( xLoc = 0; xLoc < max_x_loc; (xLoc += 2), (writePtr += writePtrInc), (locPtr+=2) ) // { // } // } // } switch(map_mode) { case MAP_MODE_TERRAIN: { int pixelX = (image_x1 + image_x2 + 1) / 2; int pixelY = image_y1; int xLoc, yLoc; int writePtrInc = vga_back.buf_pitch() + 1; for( yLoc = 0; yLoc < max_y_loc; (yLoc&1?++pixelY:--pixelX) , ++yLoc ) { short* writePtr = vga_back.buf_ptr(pixelX, pixelY); int tileYOffset = (yLoc & TERRAIN_TILE_Y_MASK) * TERRAIN_TILE_WIDTH; xLoc = 0; Location* locPtr = get_loc( xLoc, yLoc ); for( ; xLoc < max_x_loc; (xLoc += 2), (locPtr += 2), (writePtr += writePtrInc) ) { if( locPtr->explored() ) { // ##### begin Gilbert 10/2 #######// if( filter_object_flag || filter_nation_flag ) // do not anything except filtered objects when filters are on *writePtr = mapModeColor; else if( locPtr->fire_str() > 0) // ##### end Gilbert 10/2 #######// *writePtr = fireColor; else if( locPtr->is_plant() || xLoc+1<max_x_loc && locPtr[1].is_plant() ) *writePtr = plantColor; else if( locPtr->is_rock() ) *writePtr = rockColor; else if( locPtr->has_dirt() ) { Rock *dirtPtr = dirt_array[locPtr->dirt_recno()]; RockInfo *dirtInfo = rock_res.get_rock_info(dirtPtr->rock_recno); if (dirtInfo->rock_type == 'P') *writePtr = seaColor; else *writePtr = rockColor; } else if( locPtr->is_road() ) *writePtr = vga_back.translate_color(terrain_res.get_map_tile(locPtr->road_terrain_id)[tileYOffset + (xLoc & TERRAIN_TILE_X_MASK)]); else { if( xLoc < 2 || terrain_res[locPtr->terrain_id]->average_type >= terrain_res[(locPtr-2)->terrain_id]->average_type ) { // get terrain pixel from terrain_res *writePtr = vga_back.translate_color(terrain_res.get_map_tile(locPtr->terrain_id)[tileYOffset + (xLoc & TERRAIN_TILE_X_MASK)]); } else { *writePtr = shadowColor; } } } //else // not needed because filled black already //{ // *writePtr = unexploredColor; //} } } } break; // ##### begin Gilbert 2/11 #####// case MAP_MODE_TRADE: // ##### end Gilbert 2/11 #####// case MAP_MODE_SPOT: { // traversal of location in MapMatrix int pixelX = (image_x1 + image_x2 + 1) / 2; int pixelY = image_y1; int xLoc, yLoc; int writePtrInc = vga_back.buf_pitch() + 1; for( yLoc = 0; yLoc < max_y_loc; (yLoc&1?++pixelY:--pixelX) , ++yLoc ) { short* writePtr = vga_back.buf_ptr(pixelX, pixelY); xLoc = 0; Location* locPtr = get_loc( xLoc, yLoc ); for( ; xLoc < max_x_loc; (xLoc += 2), (locPtr +=2), (writePtr += writePtrInc) ) { if( locPtr->explored() ) { *writePtr = mapModeColor; } } } } break; case MAP_MODE_POWER: { int pixelX = (image_x1 + image_x2 + 1) / 2; int pixelY = image_y1; int xLoc, yLoc; int writePtrInc = vga_back.buf_pitch() + 1; for( yLoc = 0; yLoc < max_y_loc; (yLoc&1?++pixelY:--pixelX) , ++yLoc ) { short* writePtr = vga_back.buf_ptr(pixelX, pixelY); xLoc = 0; Location *locPtr = get_loc( xLoc, yLoc ); for( xLoc = 0; xLoc < max_x_loc; (xLoc += 2), (locPtr +=2), (writePtr += writePtrInc) ) { if( locPtr->explored() ) { // ####### begin Gilbert 10/2 #########// if( filter_object_flag || filter_nation_flag ) // do not anything except filtered objects when filters are on *writePtr = mapModeColor; else if( locPtr->sailable() ) // ####### end Gilbert 10/2 #########// *writePtr = seaColor; else if( locPtr->is_rock() || locPtr[1].is_rock() ) *writePtr = rockColor; /* else if( locPtr->has_dirt() ) { Rock *dirtPtr = dirt_array[locPtr->dirt_recno()]; RockInfo *dirtInfo = rock_res.get_rock_info(dirtPtr->rock_recno); if (dirtInfo->rock_type == 'P') *writePtr = seaColor; else *writePtr = rockColor; } else if( locPtr->is_plant() || xLoc+1<max_x_loc && locPtr[1].is_plant() ) *writePtr = plantColor; */ else // ###### begin Gilbert 21/12 ########// { if( power_mode ) *writePtr = nationColorArray[locPtr->power_nation_recno]; else *writePtr = nationColorArray[0]; } // ###### end Gilbert 21/12 ########// } } } } break; case MAP_MODE_ALTITUDE: { int pixelX = (image_x1 + image_x2 + 1) / 2; int pixelY = image_y1; int xLoc, yLoc; int writePtrInc = vga_back.buf_pitch() + 1; for( yLoc = 0; yLoc < max_y_loc; (yLoc&1?++pixelY:--pixelX) , ++yLoc ) { short* writePtr = vga_back.buf_ptr(pixelX, pixelY); xLoc = 0; for( xLoc = 0; xLoc < max_x_loc; (xLoc += 2), (writePtr += writePtrInc) ) { Corner *cornerPtr = get_corner( xLoc, yLoc ); short alt = cornerPtr->get_altitude(); if( alt > 255 ) alt = 255; else if( alt < 0 ) alt = 0; *writePtr = vga.make_pixel((BYTE)alt, 128, 32); } } } break; } sys.yield(); }