Proper Monster Attack & Skills GMS-ALike *OdinTeh Rev 187*

Results 1 to 6 of 6
  1. #1
    Account Upgraded | Title Enabled! ExtremeDevilz is offline
    MemberRank
    Apr 2008 Join Date
    647Posts

    Proper Monster Attack & Skills GMS-ALike *OdinTeh Rev 187*

    the following is for OdinTeh, while this was ported from Vana.. I believe this was cause of how it was coded by Danner back in the days.. further clarification by Vana Developers has revealed that the monster skills in earlier Vana version was wrong and they have now fixed the issue..

    so pretty much everyone who are using Lithium/Odin has Wrong Monster skills.. and is inaccurate

    Code:
    Vana: The code in every other source is based on my old code.
    Vana: My old code was stupid, yes, but that's because I didn't understand what it was doing.
    Vana: Took quite a bit of effort to figure it out.
    while the monster attack now works fine to gms alike the skills isnt working properly

    anyone with clue can provide who can help me can either pm me or help me out.
    Bugs :

    No Disease On Player ( Seduce,Stun) By Mob (?)

    Code:
    /*
        This file is part of the OdinMS Maple Story Server
        Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc> 
                           Matthias Butz <matze@odinms.de>
                           Jan Christian Meyer <vimes@odinms.de>
    
        This program is free software: you can redistribute it and/or modify
        it under the terms of the GNU Affero General Public License version 3
        as published by the Free Software Foundation. You may not use, modify
        or distribute this program under any other version of the
        GNU Affero General Public License.
    
        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU Affero General Public License for more details.
    
        You should have received a copy of the GNU Affero General Public License
        along with this program.  If not, see <http://www.gnu.org/licenses/>.
     */
    
    package net.sf.odinms.net.channel.handler;
    
    import java.awt.Point;
    import java.util.List;
    import java.util.Random;
    import java.util.concurrent.TimeUnit;
    
    import net.sf.odinms.client.MapleClient;
    import net.sf.odinms.net.MaplePacket;
    import net.sf.odinms.server.TimerManager;
    import net.sf.odinms.server.life.MapleMonster;
    import net.sf.odinms.server.life.MobSkill;
    import net.sf.odinms.server.life.MobSkillFactory;
    import net.sf.odinms.server.maps.MapleMapObject;
    import net.sf.odinms.server.maps.MapleMapObjectType;
    import net.sf.odinms.server.movement.LifeMovementFragment;
    import net.sf.odinms.tools.CollectionUtil;
    import net.sf.odinms.tools.MaplePacketCreator;
    import net.sf.odinms.tools.Pair;
    import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;
    
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    
    public class MoveLifeHandler extends AbstractMovementPacketHandler {
        private static Logger log = LoggerFactory.getLogger(MoveLifeHandler.class);
    
        @Override
        public void handlePacket(SeekableLittleEndianAccessor slea,
                final MapleClient c) {
    
            int objectid = slea.readInt();
            short moveid = slea.readShort();
    
            MapleMapObject mmo = c.getPlayer().getMap().getMapObject(objectid);
            if (mmo == null || mmo.getType() != MapleMapObjectType.MONSTER) {
                return;
            }
            final MapleMonster monster = (MapleMonster) mmo;
            List<LifeMovementFragment> res = null;
    
            byte pNibbles = slea.readByte();
            byte rawActivity = slea.readByte();
            byte useSkillId = slea.readByte();
            byte useSkillLevel = slea.readByte();
            short pOption = slea.readShort();
    
            byte parsedActivity = rawActivity;
    
            if (parsedActivity >= 0) {
                parsedActivity = (byte) (parsedActivity & 0xFF >> 1);
            }
    
            boolean isAttack = CollectionUtil.inRangeInclusive(parsedActivity, 12,
                    20);
            boolean isSkill = CollectionUtil.inRangeInclusive(parsedActivity, 21,
                    25);
    
            byte attackId = (byte) (isAttack ? parsedActivity - 12 : -1);
            boolean nextMovementCouldBeSkill = (pNibbles & 0x0F) != 0;
            boolean pUnk = (pNibbles & 0xF0) != 0;
            
            MobSkill toUse = null;
        
    
            Random mRandom = new Random();
    
            if (isSkill && useSkillId > 0 && monster.getNoSkills() > 0) {
                if (nextMovementCouldBeSkill) {
                    System.out.println("nextMovementCouldBeSkill: " + nextMovementCouldBeSkill);
                    int Random = mRandom.nextInt(monster.getNoSkills());
                    Pair<Integer, Integer> skillToUse = monster.getSkills().get(Random);
                    int nextCastSkill = skillToUse.getLeft();
                    int nextCastSkillLevel = skillToUse.getRight();
                    long currentTime = System.currentTimeMillis();
                    long lastSkillUsed = monster.getLastSkillUsed(nextCastSkill);
                    toUse = MobSkillFactory.getMobSkill(nextCastSkill, nextCastSkillLevel);
                    toUse.applyEffect(c.getPlayer(), monster, true); // Apply Skill To Use
    
                    if (lastSkillUsed == 0 || ((currentTime - lastSkillUsed) > toUse.getCoolTime()) || toUse.checkCurrentBuff(c.getPlayer(), monster)) {
                        monster.setLastSkillUsed(nextCastSkill, currentTime, toUse.getCoolTime());
                        toUse = null;
                        System.out.println("Skill On Cool Down..");
                    }
                }
            }
    
            slea.skip(1);
            slea.skip(4);
            int start_x = slea.readShort(); // hmm.. startpos?
            int start_y = slea.readShort(); // hmm...
            Point startPos = new Point(start_x, start_y);
            res = parseMovement(slea);
    
            if (monster.getController() != c.getPlayer()) {
                if (monster.isAttackedBy(c.getPlayer())) { // aggro and controller
                                                            // change
                    monster.switchController(c.getPlayer(), true);
                } else {
                    return;
                }
            } else {
                if (parsedActivity == -1 && monster.isControllerKnowsAboutAggro()
                        && !monster.isMobile() && !monster.isFirstAttack()) {
                    monster.setControllerHasAggro(false);
                    monster.setControllerKnowsAboutAggro(false);
                }
            }
    
            boolean aggro = monster.isControllerHasAggro();
            if (aggro) {
                monster.setControllerKnowsAboutAggro(true);
                monster.setControllerHasAggro(true);
            }
    
            if (isAttack) {
                c.getSession().write(
                        MaplePacketCreator.moveMonsterResponse(objectid, moveid,
                                monster.getMp(), aggro, useSkillId, useSkillLevel));
            } else {
                c.getSession().write(
                        MaplePacketCreator.moveMonsterResponse(objectid, moveid,
                                monster.getMp(), aggro));
            }
    
            if (res != null) {
                return;
            }
            MaplePacket packet = MaplePacketCreator.moveMonster(objectid,
                    nextMovementCouldBeSkill, rawActivity, useSkillId,
                    useSkillLevel, pOption, startPos, res);
            c.getPlayer().getMap()
                    .broadcastMessage(c.getPlayer(), packet, monster.getPosition());
            updatePosition(res, monster, -1);
            c.getPlayer().getMap().moveMonster(monster, monster.getPosition());
            c.getPlayer().getCheatTracker().checkMoveMonster(monster.getPosition());
        }
    }

    Code:
    public static boolean inRangeInclusive(Byte pVal, Integer pMin, Integer pMax) {
             return !(pVal < pMin) || (pVal > pMax);
        }

    while I have tried everything to fixed it :\ Im out of ideas..
    Last edited by ExtremeDevilz; 10-05-14 at 10:43 AM. Reason: Version 2


  2. #2
    Account Upgraded | Title Enabled! ExtremeDevilz is offline
    MemberRank
    Apr 2008 Join Date
    647Posts

    Re: Proper Monster Attack & Skills GMS-ALike *OdinTeh Rev 187*

    Updated Version 2 :

    Fixed Constant Spawning On Mob
    Fixed Constant Disease On Mob
    Fixed Spawns Mob Unable To Die ( Revert Back OdinTeh Rev 187 Removed Horntail Release)

    Much GMS Like....

    Updated Bug List.
    Last edited by ExtremeDevilz; 10-05-14 at 10:39 AM.

  3. #3
    Account Upgraded | Title Enabled! Snopboy is offline
    MemberRank
    Sep 2011 Join Date
    Kerning PQLocation
    1,057Posts

    Re: Proper Monster Attack & Skills GMS-ALike *OdinTeh Rev 187*

    Great, thanks for posting :)

  4. #4
    Account Upgraded | Title Enabled! ExtremeDevilz is offline
    MemberRank
    Apr 2008 Join Date
    647Posts

    Re: Proper Monster Attack & Skills GMS-ALike *OdinTeh Rev 187*

    The Mob Skill is wrong

    so after so many years the monster skill was coded wrongly

    The thresholds for HP are 95%, 85%, 75%, 55%, and 45%.
    it goes Green Cornian, Dark Cornian, Red Wyvern, Blue Wyvern, and Dark Wyvern.
    In that order.

    just so you know that pretty much writing something or fixing something will cause odd issues.. in odin

    terrible..
    Last edited by ExtremeDevilz; 10-05-14 at 02:57 PM.

  5. #5
    while(true) spam(); kevintjuh93 is offline
    MemberRank
    Jun 2008 Join Date
    The NetherlandsLocation
    4,119Posts

    Re: Proper Monster Attack & Skills GMS-ALike *OdinTeh Rev 187*

    This still isn't fully gms-like.

    Also parsedActivity is the 'nAction' and that 12-20,21-25 is different for higher versions as there are more actions available.
    pUnk is the old activity btw.

    There are so many more things that are so wrong insid all the sources, fixing everything up in Moople.

  6. #6
    Victus Mortuus Kreeate is offline
    LegendRank
    Aug 2010 Join Date
    2,364Posts

    Re: Proper Monster Attack & Skills GMS-ALike *OdinTeh Rev 187*

    Anymore spam/off-topic/insults will be infracted. Go spam elsewhere for your post counts.

    Thanks.



Advertisement