void ShipSpecialHitpoints::OnOk() { float temp_initial_hull_strength; UpdateData(TRUE); // TODO: Add extra validation here if (m_special_hitpoints_enabled) { int start; if (Ships[m_ship_num].special_hitpoint_index == -1) { // get free sexp_variables start = sexp_variable_allocate_block(Ships[m_ship_num].ship_name, SEXP_VARIABLE_BLOCK | SEXP_VARIABLE_BLOCK_HIT); if (start == -1) { MessageBox("Unable to allocate storage, try deleting Sexp variables"); return; } else { Ships[m_ship_num].special_hitpoint_index = start; } } else { start = Ships[m_ship_num].special_hitpoint_index; } // set to update set_modified(); // set em sprintf(Sexp_variables[start+SHIELD_STRENGTH].text, "%d", m_shields); sprintf(Sexp_variables[start+HULL_STRENGTH].text, "%d", m_hull); } else { if (Ships[m_ship_num].special_hitpoint_index != -1) { // set to update set_modified(); // free block sexp_variable_block_free(Ships[m_ship_num].ship_name, Ships[m_ship_num].special_hitpoint_index, SEXP_VARIABLE_BLOCK | SEXP_VARIABLE_BLOCK_HIT); // set index to no hit block Ships[m_ship_num].special_hitpoint_index = -1; } } // calc kamikaze stuff if (Ships[m_ship_num].special_hitpoint_index != -1) { temp_initial_hull_strength = (float) atoi(Sexp_variables[Ships[m_ship_num].special_hitpoint_index+HULL_STRENGTH].text); } else { temp_initial_hull_strength = Ship_info[Ships[m_ship_num].ship_info_index].initial_hull_strength; } Ai_info[Ships[m_ship_num].ai_index].kamikaze_damage = min(1000.0f, 200.0f + (temp_initial_hull_strength / 4.0f)); CDialog::OnOK(); }
void ShipSpecialDamage::OnOK() { UpdateData(TRUE); // TODO: Add extra validation here if (m_special_exp_enabled) { int start; if (m_inner_rad > m_outer_rad) { MessageBox("Inner radius must be less than outer radius"); return; } if (Ships[m_ship_num].special_exp_index == -1) { // get free sexp_variables start = sexp_variable_allocate_block(Ships[m_ship_num].ship_name, SEXP_VARIABLE_BLOCK | SEXP_VARIABLE_BLOCK_EXP); if (start == -1) { MessageBox("Unable to allocate storage, try deleting Sexp variables"); return; } else { Ships[m_ship_num].special_exp_index = start; } } else { start = Ships[m_ship_num].special_exp_index; } // set to update set_modified(); // set em sprintf(Sexp_variables[start+INNER_RAD].text, "%d", m_inner_rad); sprintf(Sexp_variables[start+OUTER_RAD].text, "%d", m_outer_rad); sprintf(Sexp_variables[start+DAMAGE].text, "%d", m_damage); sprintf(Sexp_variables[start+BLAST].text, "%d", m_blast); sprintf(Sexp_variables[start+PROPAGATE].text, "%d", m_shock_enabled); sprintf(Sexp_variables[start+SHOCK_SPEED].text, "%d", m_shock_speed); } else { if (Ships[m_ship_num].special_exp_index != -1) { // set to update set_modified(); // free block sexp_variable_block_free(Ships[m_ship_num].ship_name, Ships[m_ship_num].special_exp_index, SEXP_VARIABLE_BLOCK |SEXP_VARIABLE_BLOCK_EXP); // set index to no exp block Ships[m_ship_num].special_exp_index = -1; } } CDialog::OnOK(); }