L2JLisvus

Would you like to react to this message? Create an account in a few clicks or log in to continue.

2 posters

    Timak Orc Troop Leader AI [COMMITED]

    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    Timak Orc Troop Leader AI [COMMITED] Empty Timak Orc Troop Leader AI [COMMITED]

    Post  Karakan 23rd June 2019, 17:10

    Not much to say about this one....

    Timak Orc Troop Leader ->CreatureSay on attack     Cool


    Just for info :
    In later chronicles NcSoft added a "spawnMinionsOnAttack" feature.



    Code:

    /*
     * This program is free software: you can redistribute it and/or modify it under
     * the terms of the GNU General Public License as published by the Free Software
     * Foundation, either version 3 of the License, or (at your option) any later
     * version.
     *
     * 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 General Public License for more
     * details.
     *
     * You should have received a copy of the GNU General Public License along with
     * this program. If not, see <http://www.gnu.org/licenses/>.
     */
    package ai.individual;

    import net.sf.l2j.gameserver.model.L2Object;
    import net.sf.l2j.gameserver.model.L2Skill;
    import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
    import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
    import net.sf.l2j.gameserver.model.quest.Quest;
    import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
    import net.sf.l2j.util.Rnd;

    /**
     * @by Karakan for L2JLisvus
     */
    public class TimakOrcTroopLeader extends Quest
    {
     private static final int TIMAK_ORC_TROOP_LEADER = 767;
     
     public TimakOrcTroopLeader (int questId, String name, String descr)
     {
     super(questId, name, descr);
     int[] mobs = {TIMAK_ORC_TROOP_LEADER};
     registerMobs(mobs);
     }
     
     @Override
        public String onSpawn(L2NpcInstance npc)
        {
     // Reset script value
            if (npc.getScriptValue() > 0)
            {
             npc.setScriptValue(0);
            }
            return super.onSpawn(npc);
        }

     @Override
        public String onAttack (L2NpcInstance npc, L2PcInstance attacker, int damage, boolean isPet)
        {
     if (npc.getScriptValue() == 0 && Rnd.get(100) <= 50)
            {
     npc.broadcastPacket(new CreatureSay(npc.getObjectId(),1,npc.getName(),"Destroy the enemy, my brothers!"));
     npc.setScriptValue(1);
            }

     return super.onAttack(npc, attacker, damage, isPet);
        }
     
     @Override
     public String onSkillSee(L2NpcInstance npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet)
     {
     if (skill.isOffensive() && targets[0] == npc)
     {
     if (npc.getScriptValue() == 0 && Rnd.get(100) <= 50)
     {
     npc.broadcastPacket(new CreatureSay(npc.getObjectId(),1,npc.getName(),"Destroy the enemy, my brothers!"));
     npc.setScriptValue(1);
     }
     }

     return super.onSkillSee(npc, caster, skill, targets, isPet);
     }

     public static void main(String[] args)
     {
     // now call the constructor (starts up the ai)
     new TimakOrcTroopLeader(-1, "timakorctroopleader", "ai/individual");
     }
    }


    Last edited by Karakan on 12th July 2019, 15:34; edited 1 time in total
    DnR
    DnR
    Admin
    Admin


    Posts : 1475
    Join date : 2012-12-03
    Age : 34

    Timak Orc Troop Leader AI [COMMITED] Empty Re: Timak Orc Troop Leader AI [COMMITED]

    Post  DnR 30th June 2019, 18:06

    Script added. Thanks for your work. Wink

      Current date/time is 19th May 2024, 08:42