get map start offset
This commit is contained in:
13
src/main.rs
13
src/main.rs
@@ -1,5 +1,6 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use strafesnet_common::integer::Planar64Vec3;
|
||||
use strafesnet_physics::physics::PhysicsData;
|
||||
use strafesnet_roblox_bot_file::v0;
|
||||
use futures::{StreamExt,TryStreamExt};
|
||||
@@ -33,11 +34,10 @@ impl From<tokio::task::JoinError> for Error{
|
||||
enum SimError{
|
||||
Decode(v0::Error),
|
||||
}
|
||||
fn run_roblox_bot_in_strafe_client_physics(physics_data:&PhysicsData,block:&v0::Block,file_stem:std::ffi::OsString){
|
||||
fn run_roblox_bot_in_strafe_client_physics(physics_data:&PhysicsData,block:&v0::Block,file_stem:std::ffi::OsString,offset:Planar64Vec3){
|
||||
use strafesnet_common::instruction::TimedInstruction;
|
||||
use strafesnet_common::mouse::MouseState;
|
||||
use strafesnet_common::physics::{Instruction,MouseInstruction,SetControlInstruction,MiscInstruction};
|
||||
use strafesnet_common::integer::Planar64Vec3;
|
||||
use strafesnet_physics::physics::{PhysicsState,PhysicsContext,Time};
|
||||
|
||||
fn vector3(v:&v0::Vector3)->Planar64Vec3{
|
||||
@@ -58,8 +58,7 @@ fn run_roblox_bot_in_strafe_client_physics(physics_data:&PhysicsData,block:&v0::
|
||||
|
||||
// === State Initialization ===
|
||||
let body=strafesnet_physics::physics::Body::new(
|
||||
// TODO: ALL POSITIONS ARE RELATIVE!!!
|
||||
vector3(&output.event.position),
|
||||
offset+vector3(&output.event.position),
|
||||
vector3(&output.event.velocity),
|
||||
Time::from_nanos((output.time*1_000_000_000.0) as i64),
|
||||
);
|
||||
@@ -179,6 +178,10 @@ async fn main()->Result<(),Error>{
|
||||
.into_complete_map()
|
||||
.map_err(Error::DecodeMap2)?;
|
||||
|
||||
// grab mapstart position
|
||||
let start_zone_model_id=map.modes.clone().denormalize().get_mode(strafesnet_common::gameplay_modes::ModeId::MAIN).unwrap().get_start();
|
||||
let offset=map.models[start_zone_model_id.get() as usize].transform.translation;
|
||||
|
||||
// create recording
|
||||
println!("generating models..");
|
||||
let physics_data:&_=Box::leak(Box::new(PhysicsData::new(&map)));
|
||||
@@ -196,7 +199,7 @@ async fn main()->Result<(),Error>{
|
||||
let file_stem=path.file_stem().unwrap().to_owned();
|
||||
let result=tokio::task::spawn_blocking(move||{
|
||||
let block=v0::read_all_to_block(std::io::Cursor::new(file.as_slice())).map_err(SimError::Decode)?;
|
||||
run_roblox_bot_in_strafe_client_physics(physics_data,&block,file_stem);
|
||||
run_roblox_bot_in_strafe_client_physics(physics_data,&block,file_stem,offset);
|
||||
Ok(())
|
||||
}).await?;
|
||||
match result{
|
||||
|
||||
Reference in New Issue
Block a user