Skip to content

Instantly share code, notes, and snippets.

@jam1garner
Created June 21, 2020 22:09
Show Gist options
  • Save jam1garner/d3fc2a3eabee07349038f3b03957a0b9 to your computer and use it in GitHub Desktop.
Save jam1garner/d3fc2a3eabee07349038f3b03957a0b9 to your computer and use it in GitHub Desktop.
ACMD Example
[package]
name = "acmd_test"
version = "0.1.0"
authors = ["jam1garner <jam1.mcleod@hotmail.com>"]
edition = "2018"
[package.metadata.skyline]
titleid = "01006A800016E000"
[lib]
crate-type = ["cdylib"]
[dependencies]
skyline = { git = "https://github.com/ultimate-research/skyline-rs.git" }
skyline_smash = { git = "https://github.com/ultimate-research/skyline-smash.git" }
acmd = { git = "https://github.com/ultimate-research/skyline-acmd.git" }
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"
lto = true
#![feature(proc_macro_hygiene)]
use smash::app::{self, lua_bind::*, sv_system};
use smash::hash40;
use smash::lib::lua_const::*;
use smash::lua2cpp::L2CFighterCommon;
use acmd::acmd;
pub fn get_category(boma: &mut app::BattleObjectModuleAccessor) -> i32{
return (boma.info >> 28) as u8 as i32;
}
extern "C"{
#[link_name = "\u{1}_ZN3app7utility8get_kindEPKNS_26BattleObjectModuleAccessorE"]
pub fn get_kind(module_accessor: &mut app::BattleObjectModuleAccessor) -> i32;
}
pub fn per_frame_updater(fighter: &mut L2CFighterCommon) {
unsafe {
let boma = sv_system::battle_object_module_accessor(fighter.lua_state_agent);
let lua_state = fighter.lua_state_agent;
if get_category(boma) == *BATTLE_OBJECT_CATEGORY_FIGHTER && get_kind(boma) == *FIGHTER_KIND_MARIO { //check for the current battle object being a fighter, and being mario
if MotionModule::motion_kind(boma) == hash40("attack_air_f") { //check for forward aerial
acmd!(lua_state, {
frame(16)
AttackModule::clear_all() // clear all previous hitboxes
if(is_execute) {
ATTACK(
ID=0, Part=0, Bone=hash40("arml"), 19.0, 361, 80, 0, 30, 113.0, 3.2, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0,
ATTACK_SETOFF_KIND_ON, ATTACK_LR_CHECK_F, ATTACK_LR_CHECK_F, ATTACK_LR_CHECK_F,
ATTACK_LR_CHECK_F, ATTACK_LR_CHECK_F, false, false, false, false, true,
COLLISION_SITUATION_MASK_GA, COLLISION_CATEGORY_MASK_ALL, COLLISION_PART_MASK_ALL,
false, hash40("collision_attr_fire"), ATTACK_SOUND_LEVEL_M, COLLISION_SOUND_ATTR_PUNCH,
ATTACK_REGION_PUNCH
)
rust {
println!("Fair frame 16");
}
}
sv_kinetic_energy::add_speed(1.0);
});
}
}
}
}
#[skyline::main(name = "acmd_test")]
pub fn main() {
acmd::add_hook(per_frame_updater);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment