baldera-mods / fast-fire

Pingless Rapid Fire, Burning Heart, and Burst Fire.
2 stars 7 forks source link

is there any possibility to update this? #7

Open nicojelek opened 5 years ago

nicojelek commented 5 years ago

im trying to update this, but, it still got error :

dispatch.hook('S_ABNORMALITY_BEGIN', 3 , (event) => {
    if (!enabled || !(event.target == cid) return;

    if (job === JOB_NINJA && event.id === BUFF_BLAZING_ATTUNEMENT) {
      buff = Date.now() + event.duration;
    }
  });

Untitled

Snugglez commented 5 years ago

you're missing a) in the first if statement there

if (!enabled || !(event.target == cid)) return;

nicojelek commented 5 years ago

@Snugglez tq.. my bad didnt see it.. now, no error, also not working. i think i miss slot while updating to recent definition? `const BUFF_BLAZING_ATTUNEMENT = 32058;

const JOB_ARCHER = 5; const JOB_GUNNER = 9; const JOB_NINJA = 11;

const SKILL_RAPID_FIRE = 8; const SKILL_BURST_FIRE = 5; const SKILL_BURNING_HEART = 15;

module.exports = function FastFire(dispatch) { let cid; let job; let model; let enabled = false;

let aspd = 1; let atkid = 0x7F000000; let sent = {}; let attacks = {};

let buff = 0;

dispatch.hook('S_LOGIN', 13, (event) => { gameId = event.gameId; model = event.templateId;//used to get player class setClass((model - 10101) % 100); enabled = [JOB_ARCHER, JOB_GUNNER, JOB_NINJA].includes(job); });

dispatch.hook('S_PLAYER_STAT_UPDATE', 10 , (event) => { aspd = 1 + (event.bonusAttackSpeed / event.baseAttackSpeed);

});

dispatch.hook('S_ABNORMALITY_BEGIN', 3 , (event) => { if (!enabled || !(event.target == gameId)) return;

if (job === JOB_NINJA && event.id === BUFF_BLAZING_ATTUNEMENT) {
  buff = Date.now() + event.duration;
}

});

dispatch.hook('S_ABNORMALITY_REFRESH', 1 , (event) => { if (!enabled || !(event.target == gameId)) return;

if (job === JOB_NINJA && event.id === BUFF_BLAZING_ATTUNEMENT) {
  buff = Date.now() + event.duration;
}

});

dispatch.hook('S_ABNORMALITY_END', 1 , (event) => { if (!enabled || !(event.target == gameId)) return;

if (job === JOB_NINJA && event.id === BUFF_BLAZING_ATTUNEMENT) {
  buff = 0;
}

});

dispatch.hook('C_START_COMBO_INSTANT_SKILL', 4, (event) => { if (!enabled) return;

const skill = event.skill - 0x4000000;
const group = Math.floor(skill / 10000);
const hit = skill % 100;

let speed = aspd;
let baseDuration = -1;

if (job === JOB_ARCHER && group === SKILL_RAPID_FIRE) {
  // send sActionEnd for previous attack in combo
  const last = attacks[event.skill - 1];
  if (last) {
    clearTimeout(last.timer);
    last.timer = null;

    dispatch.toClient('S_ACTION_END', 5, {
      source: cid,
      x: event.x,
      y: event.y,
      z: event.z,
      w: event.w,
      model: model,
      skill: event.skill - 1,
      unk: 6,
      id: last.atkid,
    });
  }

  baseDuration = [425, 600, 700, 700, 700, 700, 1235][hit] || -1;
}

if (job === JOB_GUNNER && group === SKILL_BURST_FIRE) {
  if(hit === 0) speed *= 0.9;
  else speed = 1;
  baseDuration = (hit === 0) ? 1275 : 122;
}

// if no match, don't fake it
if (baseDuration < 0) return;

// send sActionStage
dispatch.hook('S_ACTION_STAGE', 8 , {
  source: cid,
  x: event.x,
  y: event.y,
  z: event.z,
  w: event.w,
  model: model,
  skill: event.skill,
  stage: 0,
  speed: speed,
  id: atkid,
  unk: 1,
  unk1: 0,
  toX: 0,
  toY: 0,
  toZ: 0,
  unk2: 0,
  unk3: 0,
  movement: []
});

const timer = setTimeout(forceEnd, baseDuration / speed, event);

attacks[event.skill] = { atkid, timer };
atkid++;

});

dispatch.hook('C_START_SKILL', 7 , (event) => { if (!enabled || job !== JOB_NINJA) return;

const skill = event.skill - 0x4000000;
const group = Math.floor(skill / 10000);
const hit = skill % 100;

if (group !== SKILL_BURNING_HEART) return;

const speed = aspd * (Date.now() < buff ? 1.3 : 1);
const baseDuration = (hit === 0) ? 880 : 390;

dispatch.toClient('S_ACTION_STAGE', 8, {
  source: cid,
  x: event.x1,
  y: event.y1,
  z: event.z1,
  w: event.w,
  model: model,
  skill: event.skill,
  stage: 0,
  speed: speed,
  id: atkid,
  unk: 1,
  unk1: 0,
  toX: 0,
  toY: 0,
  toZ: 0,
  unk2: 0,
  unk3: 0,
  movement: []
});

const timer = setTimeout(forceEnd, baseDuration / speed, event);

attacks[event.skill] = { atkid, timer };
atkid++;

});

dispatch.hook('S_ACTION_STAGE', 8 , (event) => { if (!enabled || !(event.target == cid)) return; if (attacks[event.skill]) return false; });

dispatch.hook('S_ACTION_END', 5, (event) => { if (!enabled || !(event.target == cid)) return;

const attack = attacks[event.skill];
if (!attack) return;

delete attacks[event.skill];

if (attack.timer) {
  clearTimeout(attack.timer);
  event.id = attack.atkid;
  return true;
} else {
  return false;
}

});

function forceEnd(event) { const attack = attacks[event.skill]; if (!attack) return;

attack.timer = null;

dispatch.toClient('sActionEnd', {
  source: cid,
  x: event.x || event.x1,
  y: event.y || event.y1,
  z: event.z || event.z1,
  w: event.w,
  model: model,
  skill: event.skill,
  unk: 0,
  id: attack.atkid,
});

} }; i didnt make too much changes. still learning.. this code didn't makes error, but not working.. compare to other script,dispatch.hook('S_ACTION_STAGE', 8 , (event)missing something in there.. others using something like{order: -1000000, filter: {fake: null}} script already hasif (baseDuration < 0) return;`

maybe anyone can help, and little explanation would be great..

Risenio commented 5 years ago

When you're changing the version for the definitions of the packets you're sending or hooking, you should also check that definition file for the data you're trying to hook or send if it still exist the same, or changed, or doesn't exist anymore. What I mean is... for example, When you change replaced this:

  dispatch.hook('sLogin', (event) => {
    ({cid, model} = event);

    job = (model - 10101) % 100;
    enabled = [JOB_ARCHER, JOB_GUNNER, JOB_NINJA].includes(job);
  });

with

  dispatch.hook('S_LOGIN', 13, (event) => {
    gameId = event.gameId;
    model = event.templateId;//used to get player class
    setClass((model - 10101) % 100);
    enabled = [JOB_ARCHER, JOB_GUNNER, JOB_NINJA].includes(job);
  });

you made couple of mistakes right there.

  1. Where did you get the setClass function from? that something doesn't exist at all in the code.
  2. What you did @ changing dispatch.hook('sLogin', (event) => { to dispatch.hook('S_LOGIN', 13, (event) => { is good, but there is a problem right there:
    • After you changed to new definition, did you check for the definition contents? I mean you have changed event.cid into event.gameId, that's nice, but the gameId variable that you've assigned the data (event.gameId) on isn't defined, that will throw error and will not be used in the script at all.
    • Since you've changed the variable cid to gameId, you should've did search for all cid matches in the script and replaced them with the new assigned variable, which in your script would be gameId, because simply that variable is now empty and will remain empty, as the cid only used to get assigned once at the sLogin packet, which you've already changed.
  3. @ model, that's correct, model is defined in the main function scoop and you have assigned a valid data value on it event.templateId because templateId exist in the sLogin v13 packet definition.
  4. We back, You can just remove the whole line @ setClass((model - 10101) % 100); because that will just throw errors, as the function doesn't exist at all, and you can replace it back to what it used to be, easily copy-paste from old one: job = (model - 10101) % 100; and that will do the job.

    ** Side note: Since the setClass didn't exist in the contest, I believe you've tried to copy-paste from another script, but you gotta be careful, because copy-pasting can be disaster if the data didn't match or exist at first place. \:)


Another example of what I said about checking the new definition is here: You changed:

  dispatch.hook('sPlayerStatUpdate', (event) => {
    aspd = 1 + (event.bonusAttackSpeed / event.baseAttackSpeed);
  });

into

  dispatch.hook('S_PLAYER_STAT_UPDATE', 10 , (event) => {
    aspd = 1 + (event.bonusAttackSpeed / event.baseAttackSpeed);

  });

Now... The updated name change is good, as camelCase are not longer used in new proxy versions. But there is something wrong you did with version changing from 1 to 10.

  1. Version 10 is used for patch version 75 or less, so it will not work by nature on patch 80 or above.
  2. After you changed the definition number, you should also check for the data structure change in the definition itself, ok what that means? You see the event.bonusAttackSpeed or event.baseAttackSpeed right there? They exist in v1 of that packet defintion, but they no longer exist on version 10 (patch 75 or below) or version 12 (patch 80 or above), as they got replaced with new naming.
  3. So, by looking into the change from version 1 of the packet definition to version 10 or 12, I can notice that:
    • baseAttackSpeed has got renamed into attackSpeed.
    • bonusAttackSpeed got renamed into attackSpeedBonus.
  4. Now you can replace the old data name fields with new ones, and that would make it work, don't forget to change the packet version to 12, as I said version 10 for patch 75 or below, we need version 12 because we're now patch 80 or above.

    ** Side note: sometimes the data field gets renamed, changed type, replaced, merged, or deleted, each new patch may change the structure of any packet, therefore the packet definition might need to be updated, depending whether it changed or not), Also don't take my words strict, I said may & sometimes, as some packets can never changes, and some may changes each huge update, et cetera.


Ps. You've made the 2nd mistake for pretty much all the rest of the hooks and sends, so you gotta fix that if you want the script to run properly. Ps 2. When you're pasting into the comment section here, and you don't want the code block to look messed up, you gotta do like this: So here's the pretty one:

    # As you can see, opening on separate line.
  - I added "md" right there to the opening so it consider the written inside this code block 
    as markdown, you can put "js" or any coding language, it's not necessary; just for coloring.
   * ....some code here....
   * ....and here...
  - and we close it on separate line as well.

And here is the raw version of it: ```md   # As you can see, opening on separate line.   - I added "md" right there to the opening so it consider the written inside this code block   as markdown, you can put "js" or any coding language, it's not necessary; just for coloring.   ....some code here....   ....and here...   - and we close it on separate line as well. ``` As you can see here you gotta make the opening (```) and closing (```) each in different and separated lines, so nothing get messed up, just for your information. \:)


Hope you find that helpful.

SaltyMonkey commented 5 years ago

and this thingy will flag you fast/ghost

nicojelek commented 5 years ago

yes that vry much helpful. this what i hope for. as u can see that im learning by taking example from other working script, and try to implement to others that didn't.. @Risenio i appreciate everything and hope i came back with good result.. @SaltyMonkey i think it will. coz i see that sending packet to "client" not "server" & atkspeed to max by (buff + 1 atkspeed).. since this purpose for client side and with user ping will make it ghosting?

nicojelek commented 5 years ago

this what i've done so far, not much but i learn alot from @Risenio explanation. some,i dont understand some part or make a mistakes maybe.

  1. let atkid = 0x7F000000; //what is this 0x7f?
  2. const skill = event.skill - 0x4000000; // and this one 0x40?
  3. dispatch.toClient('S_ACTION_STAGE', 8, { //should i change the xyz to loc=event.loc // some using {order: 50, filter: {fake: null}} ?
  4. dispatch.toClient('S_ACTION_END', 5, { //this one xyz to loc=event.loc?
  5. delete attacks[event.skill]; //why do we need delete atk after atk end?
  6. i remove gunner and archer for make it simple to understand.. any other mistakes ?

const JOB_ARCHER = 5;
const JOB_GUNNER = 9;
const JOB_NINJA = 11;

const SKILL_RAPID_FIRE = 8;
const SKILL_BURST_FIRE = 5;
const SKILL_BURNING_HEART = 15;

module.exports = function FastFire(dispatch) {
  let gameId;
  let job;
  let model;
  let enabled = true;

  let aspd = 1;
  let atkid = 0x7F000000;
  let sent = {};
  let attacks = {};

  let buff = 0;

  dispatch.hook('S_LOGIN', 13, (event) => {
    gameId = event.gameId;
    model = event.templateId;//used to get player class
    job = (model - 10101) % 100;
    enabled = [JOB_NINJA].includes(job);
  });

  dispatch.hook('S_PLAYER_STAT_UPDATE', 12 , (event) => {
    aspd = 1 + (event.attackSpeedBonus / event.attackSpeed);

  });

  dispatch.hook('S_ABNORMALITY_BEGIN', 3 , (event) => {
    if (!enabled || !(event.target == gameId)) return;

    if (job === JOB_NINJA && event.Id === BUFF_BLAZING_ATTUNEMENT) {
      buff = Date.now() + event.duration;
    }
  });

  dispatch.hook('S_ABNORMALITY_REFRESH', 1 ,  (event) => {
    if (!enabled || !(event.target == gameId)) return;

    if (job === JOB_NINJA && event.id === BUFF_BLAZING_ATTUNEMENT) {
      buff = Date.now() + event.duration;
    }
  });

  dispatch.hook('S_ABNORMALITY_END', 1 ,  (event) => {
    if (!enabled || !(event.target == gameId)) return;

    if (job === JOB_NINJA && event.id === BUFF_BLAZING_ATTUNEMENT) {
      buff = 0;
    }
  });

  dispatch.hook('C_START_SKILL', 8 , (event) => {
    if (!enabled || job !== JOB_NINJA) return;

    const skill = event.skill - 0x4000000;
    const group = Math.floor(skill / 10000);
    const hit = skill % 100;

    if (group !== SKILL_BURNING_HEART) return;

    const speed = aspd * (Date.now() < buff ? 1.3 : 1);
    const baseDuration = (hit === 0) ? 880 : 390;

    dispatch.toClient('S_ACTION_STAGE', 8, {
      source: gameId,
      x: event.x1, //loc=event.loc ?
      y: event.y1,
      z: event.z1,
      w: event.w,
      model: model,
      skill: event.skill,
      stage: 0,
      speed: speed,
      id: atkid,
      unk: 1,
      unk1: 0,
      toX: 0,
      toY: 0,
      toZ: 0,
      unk2: 0,
      unk3: 0,
      movement: []
    });

    const timer = setTimeout(forceEnd, baseDuration / speed, event);

    attacks[event.skill] = { atkid, timer };
    atkid++;
  });

  dispatch.hook('S_ACTION_STAGE', 8 , (event) => {
    if (!enabled || !(event.target == gameId)) return;
    if (attacks[event.skill]) return false;
  });

  dispatch.hook('S_ACTION_END', 5,  (event) => {
    if (!enabled || !(event.target == gameId)) return;

    const attack = attacks[event.skill];
    if (!attack) return;

    delete attacks[event.skill];

    if (attack.timer) {
      clearTimeout(attack.timer);
      event.id = attack.atkid;
      return true;
    } else {
      return false;
    }
  });

  function forceEnd(event) {
    const attack = attacks[event.skill];
    if (!attack) return;

    attack.timer = null;

    dispatch.toClient('S_ACTION_END', 5, {
      source: gameId,
      x: event.x || event.x1, //loc=event.loc?
      y: event.y || event.y1,
      z: event.z || event.z1,
      w: event.w,
      model: model,
      skill: event.skill,
      unk: 0,
      id: attack.atkid,
    });
  }
};
nicojelek commented 5 years ago

last update: with error: fast-fire-master\index.js:65 const group = Math.floor(skill / 10000); ^^^^^



const JOB_ARCHER = 5;
const JOB_GUNNER = 9;
const JOB_NINJA = 11;

const SKILL_RAPID_FIRE = 8;
const SKILL_BURST_FIRE = 5;
const SKILL_BURNING_HEART = 15;

module.exports = function FastFire(dispatch) {
  let gameId;
  let job;
  let model;
  let enabled = true;

  let aspd = 1;
  let atkid = 0x7F000000;
  let sent = {};
  let attacks = {};
  let buff = 0;

  dispatch.hook('S_LOGIN', 13, (event) => {
    gameId = event.gameId;
    model = event.templateId;//used to get player class
    job = (model - 10101) % 100;
    enabled = [JOB_NINJA].includes(job);
  });

  dispatch.hook('S_PLAYER_STAT_UPDATE', 12 , (event) => {
    aspd = 1+(event.attackSpeed + event.attackSpeedBonus) / event.attackSpeed; //1+?

  });

  dispatch.hook('S_ABNORMALITY_BEGIN', 3 , (event) => {
    if (!enabled || !(event.target == gameId)) return;

    if (job === JOB_NINJA && event.Id === BUFF_BLAZING_ATTUNEMENT) {
      buff = Date.now() + event.duration;
    }
  });

  dispatch.hook('S_ABNORMALITY_REFRESH', 1 ,  (event) => {
    if (!enabled || !(event.target == gameId)) return;

    if (job === JOB_NINJA && event.id === BUFF_BLAZING_ATTUNEMENT) {
      buff = Date.now() + event.duration;
    }
  });

  dispatch.hook('S_ABNORMALITY_END', 1 ,  (event) => {
    if (!enabled || !(event.target == gameId)) return;

    if (job === JOB_NINJA && event.id === BUFF_BLAZING_ATTUNEMENT) {
      buff = 0;
    }
  });

  dispatch.hook('C_START_SKILL', 8 , (event) => {
    if (!enabled || job !== JOB_NINJA) return;

    const skill = event.skill.id,
    const group = Math.floor(skill / 10000);
    const hit = skill % 100;

    if (group !== SKILL_BURNING_HEART) return;

    const speed = aspd * (Date.now() < buff ? 1.3 : 1);
    const baseDuration = (hit === 0) ? 880 : 390;

    dispatch.toClient('S_ACTION_STAGE', 8, {
      gameId: gameId,
            loc: { x: event.loc.x, y: event.loc.y, z: event.loc.z },
            w: event.w,
            templateId: model,
            skill: event.skill.id,
            stage: 0,
            speed: speed,
            projectileSpeed: speed,
            id: atkid,
            effectScale: 1.0, 
            moving: false, 
            dest: { x: 0, y: 0, z: 0 }, 
            target: 0n, movement: [],

    });

    const timer = setTimeout(forceEnd, baseDuration / speed, event);

    attacks[event.skill] = { atkid, timer };
    atkid++;
  });

  dispatch.hook('S_ACTION_STAGE', 8 , (event) => {
    if (!enabled || !(event.target == gameId)) return;
    if (attacks[event.skill]) return false;
  });

  dispatch.hook('S_ACTION_END', 5,  (event) => {
    if (!enabled || !(event.target == gameId)) return;

    const attack = attacks[event.skill];
    if (!attack) return;

    delete attacks[event.skill];

    if (attack.timer) {
      clearTimeout(attack.timer);
      event.id = attack.atkid;
      return true;
    } else {
      return false;
    }
  });

  function forceEnd(event) {
    const attack = attacks[event.skill];
    if (!attack) return;

    attack.timer = null;

    dispatch.toClient('S_ACTION_END', 5, {
     gameId: gameId,
     loc: { x: event.loc.x, y: event.loc.y, z: event.loc.z },
     w: event.w,
     templateId: model,
     skill: event.skill.id,
     id: atkid,

    });
  }
};