1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Get campaign mode working, fix health/damage config

This commit is contained in:
NGnius (Graham)
2025-03-29 22:08:08 -04:00
parent 78941fb8ff
commit 610f54e236
23 changed files with 1601 additions and 56 deletions

View File

@@ -36,7 +36,7 @@ pub(super) fn all_customisations_provider() -> SimpleFunc<216, crate::UserTy, im
id: "Spawn".to_string(),
localised_name: "strSpawnFXWarpIn".to_string(),
skin_scene_name: "Splash_Loading_Screen".to_string(),
simulation_prefab: "Respawn_WarpIn".to_string(),
simulation_prefab: "Spawn".to_string(),
preview_image_name: "RC_Splash_Screen_01_Japanese".to_string(),
is_default: true,
}.as_transmissible(),
@@ -44,7 +44,7 @@ pub(super) fn all_customisations_provider() -> SimpleFunc<216, crate::UserTy, im
id: "Spawn_BlackHole".to_string(),
localised_name: "strSpawnFXWarpIn".to_string(),
skin_scene_name: "Splash_Loading_Screen".to_string(),
simulation_prefab: "Respawn_WarpIn".to_string(),
simulation_prefab: "Spawn_BlackHole".to_string(),
preview_image_name: "RC_Splash_Screen_01_Japanese".to_string(),
is_default: true,
}.as_transmissible(),
@@ -52,7 +52,7 @@ pub(super) fn all_customisations_provider() -> SimpleFunc<216, crate::UserTy, im
id: "Spawn_Lander".to_string(),
localised_name: "strSpawnFXWarpIn".to_string(),
skin_scene_name: "Splash_Loading_Screen".to_string(),
simulation_prefab: "Respawn_WarpIn".to_string(),
simulation_prefab: "Spawn_Lander".to_string(),
preview_image_name: "RC_Splash_Screen_01_Japanese".to_string(),
is_default: true,
}.as_transmissible(),
@@ -60,7 +60,7 @@ pub(super) fn all_customisations_provider() -> SimpleFunc<216, crate::UserTy, im
id: "Spawn_Lootcrate".to_string(),
localised_name: "strSpawnFXWarpIn".to_string(),
skin_scene_name: "Splash_Loading_Screen".to_string(),
simulation_prefab: "Respawn_WarpIn".to_string(),
simulation_prefab: "Spawn_Lootcrate".to_string(),
preview_image_name: "RC_Splash_Screen_01_Japanese".to_string(),
is_default: true,
}.as_transmissible(),
@@ -68,7 +68,7 @@ pub(super) fn all_customisations_provider() -> SimpleFunc<216, crate::UserTy, im
id: "Spawn_Warp".to_string(),
localised_name: "strSpawnFXWarpIn".to_string(),
skin_scene_name: "Splash_Loading_Screen".to_string(),
simulation_prefab: "Respawn_WarpIn".to_string(),
simulation_prefab: "Spawn_Warp".to_string(),
preview_image_name: "RC_Splash_Screen_01_Japanese".to_string(),
is_default: true,
}.as_transmissible(),
@@ -76,7 +76,7 @@ pub(super) fn all_customisations_provider() -> SimpleFunc<216, crate::UserTy, im
id: "Spawn_Present".to_string(),
localised_name: "strSpawnFXWarpIn".to_string(),
skin_scene_name: "Splash_Loading_Screen".to_string(),
simulation_prefab: "Respawn_WarpIn".to_string(),
simulation_prefab: "Spawn_Present".to_string(),
preview_image_name: "RC_Splash_Screen_01_Japanese".to_string(),
is_default: true,
}.as_transmissible(),
@@ -84,7 +84,7 @@ pub(super) fn all_customisations_provider() -> SimpleFunc<216, crate::UserTy, im
id: "Spawn_EasterEgg".to_string(),
localised_name: "strSpawnFXWarpIn".to_string(),
skin_scene_name: "Splash_Loading_Screen".to_string(),
simulation_prefab: "Respawn_WarpIn".to_string(),
simulation_prefab: "Spawn_EasterEgg".to_string(),
preview_image_name: "RC_Splash_Screen_01_Japanese".to_string(),
is_default: true,
}.as_transmissible(),
@@ -98,7 +98,7 @@ pub(super) fn all_customisations_provider() -> SimpleFunc<216, crate::UserTy, im
id: "Explosion".to_string(),
localised_name: "strDeathFXEmergencyWarp".to_string(),
skin_scene_name: "Splash_Loading_Screen".to_string(),
simulation_prefab: "Death_WarpOut".to_string(),
simulation_prefab: "Explosion".to_string(),
preview_image_name: "RC_Splash_Screen_01_Japanese".to_string(),
is_default: true,
}.as_transmissible(),
@@ -106,7 +106,7 @@ pub(super) fn all_customisations_provider() -> SimpleFunc<216, crate::UserTy, im
id: "Explosion_Toon".to_string(),
localised_name: "strDeathFXEmergencyWarp".to_string(),
skin_scene_name: "Splash_Loading_Screen".to_string(),
simulation_prefab: "Death_WarpOut".to_string(),
simulation_prefab: "Explosion_Toon".to_string(),
preview_image_name: "RC_Splash_Screen_01_Japanese".to_string(),
is_default: true,
}.as_transmissible(),
@@ -114,7 +114,7 @@ pub(super) fn all_customisations_provider() -> SimpleFunc<216, crate::UserTy, im
id: "Explosion_Feathers_Rainbow".to_string(),
localised_name: "strDeathFXEmergencyWarp".to_string(),
skin_scene_name: "Splash_Loading_Screen".to_string(),
simulation_prefab: "Death_WarpOut".to_string(),
simulation_prefab: "Explosion_Feathers_Rainbow".to_string(),
preview_image_name: "RC_Splash_Screen_01_Japanese".to_string(),
is_default: true,
}.as_transmissible(),
@@ -122,7 +122,7 @@ pub(super) fn all_customisations_provider() -> SimpleFunc<216, crate::UserTy, im
id: "Explosion_Nuclear".to_string(),
localised_name: "strDeathFXEmergencyWarp".to_string(),
skin_scene_name: "Splash_Loading_Screen".to_string(),
simulation_prefab: "Death_WarpOut".to_string(),
simulation_prefab: "Explosion_Nuclear".to_string(),
preview_image_name: "RC_Splash_Screen_01_Japanese".to_string(),
is_default: true,
}.as_transmissible(),
@@ -130,7 +130,7 @@ pub(super) fn all_customisations_provider() -> SimpleFunc<216, crate::UserTy, im
id: "Explosion_Warp".to_string(),
localised_name: "strDeathFXEmergencyWarp".to_string(),
skin_scene_name: "Splash_Loading_Screen".to_string(),
simulation_prefab: "Death_WarpOut".to_string(),
simulation_prefab: "Explosion_Warp".to_string(),
preview_image_name: "RC_Splash_Screen_01_Japanese".to_string(),
is_default: true,
}.as_transmissible(),
@@ -138,7 +138,7 @@ pub(super) fn all_customisations_provider() -> SimpleFunc<216, crate::UserTy, im
id: "Explosion_BlackHole".to_string(),
localised_name: "strDeathFXEmergencyWarp".to_string(),
skin_scene_name: "Splash_Loading_Screen".to_string(),
simulation_prefab: "Death_WarpOut".to_string(),
simulation_prefab: "Explosion_BlackHole".to_string(),
preview_image_name: "RC_Splash_Screen_01_Japanese".to_string(),
is_default: true,
}.as_transmissible(),
@@ -146,7 +146,7 @@ pub(super) fn all_customisations_provider() -> SimpleFunc<216, crate::UserTy, im
id: "Explosion_Firework".to_string(),
localised_name: "strDeathFXEmergencyWarp".to_string(),
skin_scene_name: "Splash_Loading_Screen".to_string(),
simulation_prefab: "Death_WarpOut".to_string(),
simulation_prefab: "Explosion_Firework".to_string(),
preview_image_name: "RC_Splash_Screen_01_Japanese".to_string(),
is_default: true,
}.as_transmissible(),

View File

@@ -13,14 +13,14 @@ pub(super) fn client_config_provider() -> SimpleFunc<34, crate::UserTy, impl (Fn
val_ty: TypePrefix::HashMap, // hashtable
items: vec![
(Typed::Str("GameplaySettings".into()), GameplaySettings {
show_tutorial_after_date: "2025-01-01".to_owned(),
health_threshold: 10.0,
show_tutorial_after_date: "2030-01-01".to_owned(),
health_threshold: 0.20,
microbot_sphere: 10.0,
misfire_angle: 20.0,
misfire_angle: 10.0,
shield_dps: 100,
shield_hps: 2_000,
request_review_level: 10_000,
critical_ratio: 10.0,
critical_ratio: 5.0,
cross_promo_image: "https://git.ngram.ca/assets/img/logo.png".to_owned(),
cross_promo_link: "https://git.ngram.ca/OpenJam/servers".to_owned(),
}.as_transmissible())

View File

@@ -12,8 +12,8 @@ pub(super) fn cpu_config_provider() -> SimpleFunc<75, crate::UserTy, impl (Fn(Pa
premium_for_life_cosmetic_gpu: 12,
premium_cosmetic_cpu: 6,
no_premium_cosmetic_cpu: 3,
max_regular_health: 2_000_000,
max_megabot_health: 200_000_000,
max_regular_health: 200_000_000,
max_megabot_health: 2_000_000_000,
}.as_transmissible());
Ok(params.into())
})

View File

@@ -14,9 +14,9 @@ pub(super) fn damage_boost_provider() -> SimpleFunc<163, crate::UserTy, impl (Fn
items: vec![
(Typed::Str("damageBoost".into()), DamageBoostData {
damage_map: vec![
(100, 1000.0),
(1000, 100.0),
(0, 1.0),
(2000, 1.0),
(10_000, 1.0),
],
}.as_transmissible())
],

View File

@@ -76,16 +76,3 @@ pub(super) fn garage_machine_save_provider() -> SimpleFunc<41, crate::UserTy, im
})
}
pub const DEFAULT_WEAPON_ORDER_PARAM_KEY: u8 = 138;
pub(super) fn weapon_order_provider() -> SimpleFunc<118, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
SimpleFunc::new(|params, user: &crate::UserTy| {
let mut params = params.to_dict();
let lock = user.read().unwrap();
let user_info = lock.user()?;
let weapon_order = user_info.slot_by_id(user_info.selected_garage_slot() as i32)?.weapon_order;
params.insert(DEFAULT_WEAPON_ORDER_PARAM_KEY, weapon_order);
Ok(params.into())
})
}

View File

@@ -79,6 +79,7 @@ mod validate_machine;
mod game_mode_config;
mod score_multipliers_config;
mod player_robot_rank;
mod weapon_order;
use polariton_server::operations::OperationsHandler;
@@ -150,7 +151,7 @@ pub fn handler(init_ctx: &crate::InitConfig) -> OperationsHandler<crate::UserTy>
.without_state(prebuilt_robots::garage_robot_data_provider())
.without_state(prebuilt_colours::garage_colour_combo_provider())
.without_state(robopass_preview_items::robopass_preview_provider())
.without_state(singleplayer_campaigns::singleplayer_campaigns_provider())
.without_state(singleplayer_campaigns::singleplayer_campaigns_provider(&init_ctx.cubes))
.without_state(purchases::pending_purchases_provider())
.without_state(building_xp_config::building_xp_config_provider())
.without_state(weapon_rating_static::weapon_rating_provider())
@@ -168,7 +169,7 @@ pub fn handler(init_ctx: &crate::InitConfig) -> OperationsHandler<crate::UserTy>
.without_state(machine::garage_machine_save_provider())
.without_state(polariton_server::operations::Ack::<32, _>::default()) // TODO handle SaveMachineColorRequest instead of ignoring it
.without_state(polariton_server::operations::Ack::<45, _>::default()) // TODO handle UpdateThumbnailVersionRequest instead of ignoring it
.without_state(machine::weapon_order_provider())
.without_state(weapon_order::weapon_order_provider(&init_ctx.cubes))
.without_state(regen_config::auto_regen_config_provider(&init_ctx.cubes))
.without_state(pageantry::after_battle_vote_thresholds_provider(&init_ctx.cubes))
.without_state(signup_time::user_signup_date_provider())
@@ -176,4 +177,8 @@ pub fn handler(init_ctx: &crate::InitConfig) -> OperationsHandler<crate::UserTy>
.without_state(game_mode_config::game_mode_config_provider(&init_ctx.cubes))
.without_state(score_multipliers_config::tdm_ai_score_config_provider())
.without_state(player_robot_rank::player_robot_rank_provider())
.without_state(validate_machine::validate_campaign_robot_provider())
.without_state(singleplayer_campaigns::singleplayer_complete_campaign_provider(&init_ctx.cubes))
.without_state(polariton_server::operations::Ack::<78, _>::default()) // TODO handle SaveCampaignGameAwardsRequest instead of ignoring it
.without_state(singleplayer_campaigns::singleplayer_save_complete_campaign_provider()) // TODO handle UpdatePlayerCompletedCampaignWaveRequest saving
}

View File

@@ -7,8 +7,8 @@ pub(super) fn power_bar_provider() -> SimpleFunc<51, crate::UserTy, impl (Fn(Par
SimpleFunc::new(|params, _| {
let mut params = params.to_dict();
params.insert(PARAM_KEY, Typed::HashMap(vec![
(Typed::Str("refillRatePerSecond".into()), Typed::Float(1000.0)),
(Typed::Str("powerForAllRobots".into()), Typed::Int(1_000_000 /* converted to u32 */)),
(Typed::Str("refillRatePerSecond".into()), Typed::Float(1255.0)),
(Typed::Str("powerForAllRobots".into()), Typed::Int(12_550 /* converted to u32 */)),
].into()
));
Ok(params.into())

View File

@@ -10,8 +10,8 @@ pub(super) fn bay_customisations_provider() -> SimpleFunc<218, crate::UserTy, im
SimpleFunc::new(|params, _| {
let mut params = params.to_dict();
params.insert(BAY_SKIN_KEY, Typed::Str("RC_MothershipSkin_Neptune_01".into()));
params.insert(SPAWN_EFFECT_KEY, Typed::Str("RE_todo_spawn_effect".into()));
params.insert(DEATH_EFFECT_KEY, Typed::Str("RE_todo_death_effect".into()));
params.insert(SPAWN_EFFECT_KEY, Typed::Str("Spawn_Warp".into()));
params.insert(DEATH_EFFECT_KEY, Typed::Str("Explosion_Warp".into()));
Ok(params.into())
})
}

View File

@@ -1,22 +1,65 @@
use polariton_server::operations::SimpleFunc;
use polariton_server::operations::{Immediate, SimpleFunc};
use polariton::operation::{ParameterTable, Typed};
use crate::persist::config::ConfigProvider;
const CAMPAIGNS_BYTES_PARAM_KEY: u8 = 64; // list of bytes (serialised data)
const CAMPAIGNS_WAVES_PARAM_KEY: u8 = 70; // hashtable
const CAMPAIGNS_VERSIONS_PARAM_KEY: u8 = 69; // hashtable
pub(super) fn singleplayer_campaigns_provider() -> SimpleFunc<65, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
SimpleFunc::new(|params, _| {
pub(super) fn singleplayer_campaigns_provider(conf: &crate::persist::config::ConfigImpl) -> Immediate<65, crate::UserTy> {
Immediate::new(|| {
let mut params = std::collections::HashMap::new();
params.insert(CAMPAIGNS_BYTES_PARAM_KEY, conf.campaigns_parameters()); // first 4 bytes are i32 for length of the rest
//params.insert(CAMPAIGNS_BYTES_PARAM_KEY, Typed::Bytes(vec![0u8, 0u8, 0u8, 0u8].into())); // first 4 bytes are i32 for length of the rest
params.insert(CAMPAIGNS_WAVES_PARAM_KEY, conf.campaign_waves());
//params.insert(CAMPAIGNS_WAVES_PARAM_KEY, Typed::HashMap(vec![].into()));
params.insert(CAMPAIGNS_VERSIONS_PARAM_KEY, conf.campaign_version());
// params.insert(CAMPAIGNS_VERSIONS_PARAM_KEY, Typed::HashMap(vec![
// (Typed::Str("CurrentVersionNumber".into()), Typed::Int(0)),
// (Typed::Str("LockedCampaignsInfo".into()), Typed::HashMap(vec![
// (Typed::Str("0".into()), Typed::Bool(false.into()))
// ].into())),
// ].into()));
params.into()
})
}
const CAMPAIGN_ID_PARAM_KEY: u8 = 22; // string; in
const CAMPAIGN_DIFFICULTY_PARAM_KEY: u8 = 23; // i32; in
const CAMPAIGN_WAVES_PARAM_KEY: u8 = 75; // bytes; out
pub(super) fn singleplayer_complete_campaign_provider(conf: &crate::persist::config::ConfigImpl) -> SimpleFunc<64, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
let campaign_details = <crate::persist::config::ConfigImpl as crate::persist::config::ConfigProvider<()>>::campaign_details(conf);
SimpleFunc::new(move |params, _| {
let mut params = params.to_dict();
// TODO implement serialisation of Campaign[] properly
params.insert(CAMPAIGNS_BYTES_PARAM_KEY, Typed::Bytes(vec![0u8, 0u8, 0u8, 0u8].into())); // first 4 bytes are i32 for length of the rest
params.insert(CAMPAIGNS_WAVES_PARAM_KEY, Typed::HashMap(vec![].into()));
params.insert(CAMPAIGNS_VERSIONS_PARAM_KEY, Typed::HashMap(vec![
(Typed::Str("CurrentVersionNumber".into()), Typed::Int(0)),
(Typed::Str("LockedCampaignsInfo".into()), Typed::HashMap(vec![
(Typed::Str("0".into()), Typed::Bool(false.into()))
].into())),
].into()));
if let Some(Typed::Str(campaign_id)) = params.get(&CAMPAIGN_ID_PARAM_KEY) {
if let Some(Typed::Int(campaign_difficulty)) = params.get(&CAMPAIGN_DIFFICULTY_PARAM_KEY) {
let complete_campaign = campaign_details.get(&campaign_id.string, campaign_difficulty)?;
params.clear();
params.insert(CAMPAIGN_WAVES_PARAM_KEY, complete_campaign);
}
}
Ok(params.into())
})
}
const CAMPAIGN_WAVE_NUMBER_PARAM_KEYL: u8 = 73;
pub(super) fn singleplayer_save_complete_campaign_provider() -> SimpleFunc<68, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
//let campaign_details = <crate::persist::config::ConfigImpl as crate::persist::config::ConfigProvider<()>>::campaign_details(conf);
SimpleFunc::new(move |params, user: &crate::UserTy| {
let mut params = params.to_dict();
if let Some(Typed::Str(campaign_id)) = params.get(&CAMPAIGN_ID_PARAM_KEY) {
if let Some(Typed::Int(campaign_difficulty)) = params.get(&CAMPAIGN_DIFFICULTY_PARAM_KEY) {
if let Some(Typed::Int(wave_number)) = params.get(&CAMPAIGN_WAVE_NUMBER_PARAM_KEYL) {
let user_lock = user.read().unwrap();
log::info!("User {} completed campaign {} difficulty {} wave {}", user_lock.user()?.token().uuid, campaign_id.string, campaign_difficulty, wave_number);
// TODO save wave as completed
params.clear();
}
}
}
Ok(params.into())
})
}

View File

@@ -28,3 +28,19 @@ pub(super) fn validate_robot_provider() -> SimpleFunc<102, crate::UserTy, impl (
Ok(params.into())
})
}
const CAMPAIGN_ID_PARAM_KEY: u8 = 22;
pub(super) fn validate_campaign_robot_provider() -> SimpleFunc<59, crate::UserTy, impl (Fn(ParameterTable, &crate::UserTy) -> Result<ParameterTable, i16>) + Sync + Sync> {
SimpleFunc::new(|params, _user: &crate::UserTy| {
let mut params = params.to_dict();
if let Some(Typed::Str(campaign_id)) = params.get(&CAMPAIGN_ID_PARAM_KEY) {
log::info!("Got campaign id {}", campaign_id.string);
}
// let lock = user.read().unwrap();
// let user_info = lock.user()?;
// TODO actually validate the vehicle
params.insert(VALIDATE_ROBOT_RESULT_PARAM_KEY, Typed::Int(ValidateMachineResult::Ok as _)); // this is ignored
Ok(params.into())
})
}

View File

@@ -0,0 +1,14 @@
use polariton_server::operations::Immediate;
use crate::persist::config::ConfigProvider;
pub const DEFAULT_WEAPON_ORDER_PARAM_KEY: u8 = 138;
pub(super) fn weapon_order_provider(conf: &crate::persist::config::ConfigImpl) -> Immediate<118, crate::UserTy> {
let weapon_orders = conf.weapon_keys();
Immediate::new(|| {
let mut params = std::collections::HashMap::with_capacity(1);
params.insert(DEFAULT_WEAPON_ORDER_PARAM_KEY, weapon_orders.clone());
params.into()
})
}