Migrating - HDR-Development/smashline GitHub Wiki

Migrating from smashline to smashline-2

(For reference, this repository is for smashline-2)

As a measure of comparison, let's list the features from smashline-1 to smashline-2:

Guide:

  • :white_check_mark: - Integrated
  • :x: - Removed/Doesn't Exist
  • :paperclip: - Planned
Feature Name Smashline 1 Smashline 2
Plugin Hot Reloading :white_check_mark: :white_check_mark:
Priority-based script replacement :white_check_mark: :white_check_mark:
ACMD Asset Format :x: :white_check_mark:
ACMD Function Replacements :white_check_mark: :white_check_mark:
Status Function Replacements :white_check_mark: :white_check_mark:
OPFF Code :white_check_mark: :white_check_mark:
Init/Reset Callbacks :white_check_mark: :white_check_mark:
ACMD Language Macro :white_check_mark: :x:
Adding ACMD to weapons without it :x: :white_check_mark:
Adding Status to weapons without it :x: :white_check_mark:
call_original in ACMD/Status :white_check_mark: :white_check_mark:
Article/Weapon Cloning :x: :white_check_mark:
Adding new param objects to vl.prc :x: :white_check_mark:
Transplanting effects between fighters :x: :white_check_mark:
Symbol Hooks :white_check_mark: :x: (was poorly supported anyways)

Migrating ACMD

In smashline-1, an ACMD script consisted of a few parts:

  • Function attribute
  • Function (script)
  • Install macro

Here is an example:

#[smashline::acmd(agent = "mario", script = "game_attacks4", category = ACMD_GAME)]
unsafe fn mario_game_attacks4(fighter: &mut L2CAgentBase) {
    // insert script here
}

#[smashline::acmd(agent = "mario", script = "effect_attacks4", category = ACMD_EFFECT)]
unsafe fn mario_effect_attacks4(fighter: &mut L2CAgentBase) {
    // insert script here
}

#[smashline::acmd(agent = "mario", script = "game_attackairhi", category = ACMD_GAME)]
unsafe fn mario_game_attackairhi(fighter: &mut L2CAgentBase) {
    // insert script here
}

#[skyline::main(name = "smashline-plugin")]
pub fn main() {
    smashline::install_acmd_scripts!(
        mario_game_attacks4,
        mario_effect_attacks4,
        mario_game_attackairhi,
    );
}

Migration:

  1. Declare the functions as unsafe extern "C" fn instead of unsafe fn
  2. Remove the function attributes
  3. Replace the smashline::install_acmd_scripts!(...) with:
Agent::new("mario")
    .game_acmd("game_attacks4", mario_game_attacks4, Priority::Default)
    .effect_acmd("effect_attacks4", mario_effect_attacks4, Priority::Default)
    .game_acmd("game_attackairhi", mario_game_attackairhi, Priority::Default)
    .install();

Migrating Status

Status scripts in smashline-1 functioned very similar to ACMD scripts, so the replacement is also very similar

Example:

#[smashline::status_script(agent = "mario", status = FIGHTER_STATUS_KIND_SPECIAL_HI, condition = LUA_SCRIPT_STATUS_FUNC_STATUS_PRE)]
unsafe fn mario_pre_specialhi(fighter: &mut L2CFighterCommon) -> L2CValue {
    // script impl
}

pub fn main() {
    smashline::install_status_script!(mario_pre_specialhi);
}

Migration:

  1. Declare the functions as unsafe extern "C" fn instead of unsafe fn
  2. Remove the function attributes
  3. Replace the smashline::install_status_script!(...) with:
use smashline::Pre;

Agent::new("mario")
    .status(Pre, *FIGHTER_STATUS_KIND_SPECIAL_HI, mario_pre_specialhi)
    .install()

Migrating OPFF

Previously, in smashline-1 there were two ways to declare OPFF code:

  • As a "replacement", via #[smashline::fighter_frame]
  • As a callback, via #[smashline::fighter_frame_callback]

In smashline-2, there is only one way and it's a blend between replacements and callbacks.

#[smashline::fighter_frame(agent = FIGHTER_KIND_MARIO)]
fn mario_frame(fighter: &mut L2CFighterCommon) {
    // fighter frame
}

pub fn main() {
    smashline::install_agent_frame!(mario_frame);
}

Migration:

  1. Declare the functions as unsafe extern "C" fn
  2. Remove the function attributes
  3. Replace the smashline::install_agent_frame!(...) with:
use smashline::Main;

Agent::new("mario")
    .on_line(Main, mario_frame)
    .install();

It's worth noting that default OPFF behavior in smashline-1 was on the exec status, which is no longer supported as it is not inherently called every frame. Use Main instead.

Migrating Init/Reset Callbacks

Init/reset callbacks are not 1-1 with their previous counterparts, and might require some code changes to adapt.

Migration:

  1. Declare the functions as unsafe extern "C" fn
  2. Remove the function attributes
  3. Install with:
Agent::new("mario")
    .on_start(init_callback)
    .on_start(reset_callback)
    .install();

Note that Init/Reset callbacks in smashline-1 are both suited to be used with on_start in smashline-2.