A Little Jython Help Please :)

If something doesn't fit in any other forum then post it here.
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
User avatar
Mysti
Posts: 172
Joined: Tue Jul 14, 2009 10:53 pm

A Little Jython Help Please :)

Post by Mysti »

Hello, Everyone and All
I have a Little Problem :P
Am very new to Jython so i thought to start with something very simply
... Thought it would be simply :P but it isnt :P For me...
This is What I was Trying.

-------------------------------
Having a Group of Zombie's Spawned outside of Gludio. ( Spawned 1 + attached Minions )( a Group )
And Have them Walk this Route... toward Gludio... ( to invade it :PPP )
But once i spawned it... it was walking around(brainless offcourse :P), and only when he stept on the X/y/z
given in the script... only then it starts walking the route. But once it collapsed with
any of the Minions... or other npc's then he stops walking the route and goes his own way again.
This is as far as i came :P

--------------------------------
The Idea is... that Zombie's will try to infiltrate the town Gludio...
( to make it simple... get into town where 1 npc is waiting... ) and the zombies should go toward it and kill it.
Then its Event Failed :P :P :P

--------------------------------
As you can see :P I took the Gordon script to play with :P
It has this Walking route already inside it so i thought it
would be nice to learn my ways through that script :P
But kinda hard :P all i could do so far was Changing the Route Coordinates :P

--------------------------------
Am sorry iff this is the wrong place to Post these kinda things. am not that smart :P am just the ideagirl of a server :P

Greetzy, Mystique

Code: Select all

  */package ai.individual; import java.util.Collection;import net.sf.l2j.gameserver.ai.CtrlIntention;import net.sf.l2j.gameserver.datatables.SpawnTable;import net.sf.l2j.gameserver.model.L2CharPosition;import net.sf.l2j.gameserver.model.L2Spawn;import net.sf.l2j.gameserver.model.actor.L2Attackable;import net.sf.l2j.gameserver.model.actor.L2Npc;import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;import ai.group_template.L2AttackableAIScript; /** * InvadingZombie AI * @author TOFIZ * @version $Revision: 1.1 $ $Date: 2008/08/21 $ */public class InvadingZombie extends L2AttackableAIScript{	private static final int InvadingZombie = 200000;	private static int _npcMoveX = 0;	private static int _npcMoveY = 0;	private static int _isWalkTo = 0;	private static int _npcBlock = 0;	private static int X = 0;	private static int Y = 0;	private static int Z = 0;	private static final int[][] WALKS = {        {-18648, 127084, -3333},{-18195, 125643, -3200},{-16942, 124221, -3152},        {-14489, 123716, -3116}}; 	private static boolean _isAttacked = false;	private static boolean _isSpawned = false;     public InvadingZombie (int id, String name, String descr)    {        super(id,name,descr);        int[] mobs = {InvadingZombie};        registerMobs(mobs);        // wait 1 second after Start AI        startQuestTimer("check_ai", 1000, null, null, true);         _isSpawned = false;        _isAttacked = false;        _isWalkTo = 1;        _npcMoveX = 0;        _npcMoveY = 0;        _npcBlock = 0;    }     public L2Npc findTemplate(int npcId)    {    	L2Npc npc = null;    	for (L2Spawn spawn : SpawnTable.getInstance().getSpawnTable().values())    	{    		if (spawn != null && spawn.getNpcid() == npcId)    		{    			npc = spawn.getLastSpawn();    			break;    		}    	}    	return npc;    } 	public String onAdvEvent (String event, L2Npc npc, L2PcInstance player)	{		X = WALKS[_isWalkTo-1][0];		Y = WALKS[_isWalkTo-1][1];		Z = WALKS[_isWalkTo-1][2];		if (event == "time_isAttacked")		{			_isAttacked = false;			if (npc.getNpcId() == InvadingZombie)			{				npc.setWalking();				npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(X, Y, Z, 0));			}		}		else if (event == "check_ai")		{			cancelQuestTimer("check_ai", null, null);			if (_isSpawned == false)			{				L2Npc InvadingZombie_ai = findTemplate(InvadingZombie);				if (InvadingZombie_ai != null)				{					_isSpawned = true;					startQuestTimer("Start", 1000, InvadingZombie_ai, null, true);					return super.onAdvEvent(event, npc, player);				}			}		}		else if (event == "Start")		{			if (npc != null && _isSpawned == true)			{				// check if player have Cursed Weapon and in radius				if (npc.getNpcId() == InvadingZombie)				{					Collection<L2PcInstance> chars = npc.getKnownList().getKnownPlayers().values();					if (chars != null && chars.size() > 0)					{						for (L2PcInstance pc : chars)						{							if (pc.isCursedWeaponEquipped() && pc.isInsideRadius(npc,5000,false,false))							{								npc.setRunning();								((L2Attackable)npc).addDamageHate(pc,0,9999);								npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, pc);								_isAttacked = true;								cancelQuestTimer("time_isAttacked",null, null);								startQuestTimer("time_isAttacked",180000, npc, null);								return super.onAdvEvent(event, npc, player);							}						}					}				}				// end check		        if (_isAttacked == true)		        	return super.onAdvEvent(event, npc, player);		        if (npc.getNpcId() == InvadingZombie && (npc.getX()-50) <= X && (npc.getX()+50) >= X && (npc.getY()-50) <= Y && (npc.getY()+50) >= Y)		        {		            _isWalkTo++;		            if (_isWalkTo > 55)		              _isWalkTo = 1;		    		X = WALKS[_isWalkTo-1][0];		    		Y = WALKS[_isWalkTo-1][1];		    		Z = WALKS[_isWalkTo-1][2];		            npc.setWalking();		            npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO,new L2CharPosition(X, Y, Z, 0));		        } 		        // Test for unblock Npc		        if (npc.getX() != _npcMoveX && npc.getY() != _npcMoveY)		        {		          _npcMoveX = npc.getX();		          _npcMoveY = npc.getY();		          _npcBlock = 0;		        }		        else if (npc.getNpcId() == InvadingZombie)		        {		        	_npcBlock++;		            if (_npcBlock > 2)		            {		              npc.teleToLocation(X, Y, Z);		              return super.onAdvEvent(event, npc, player);		            }		            if (_npcBlock > 0)		              npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO,new L2CharPosition(X, Y, Z, 0));		        }		       // End Test unblock Npc			}		}		return super.onAdvEvent(event, npc, player);	}     public String onSpawn (L2Npc npc)     {         if (npc.getNpcId() == InvadingZombie && _npcBlock == 0)        {            _isSpawned = true;            _isWalkTo = 1;            startQuestTimer("Start", 1000, npc, null, true);        }    	return super.onSpawn(npc);     }     public String onAttack (L2Npc npc, L2PcInstance player, int damage, boolean isPet)    {	        if (npc.getNpcId() == InvadingZombie)        {            _isAttacked = true;            cancelQuestTimer("time_isAttacked", null, null);            startQuestTimer("time_isAttacked", 180000, npc, null);            if (player != null)            {              npc.setRunning();              ((L2Attackable)npc).addDamageHate(player, 0, 100);              npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player);            }        }    	return super.onAttack(npc, player, damage, isPet);    }     public String onKill (L2Npc npc, L2PcInstance killer, boolean isPet)     {        if (npc.getNpcId() == InvadingZombie)        {            cancelQuestTimer("Start", null, null);            cancelQuestTimer("time_isAttacked", null, null);            _isSpawned = false;        }    	return super.onKill(npc,killer,isPet);    }     public static void main(String[] args)    {    	new InvadingZombie(-1,"InvadingZombie","ai");    }}
Post Reply