IL | Zoning system, targetClass implementation

Find the proper support area, Saga-Version.
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
User avatar
Tryskell
Posts: 256
Joined: Wed Nov 25, 2009 5:57 pm
Location: France :)

IL | Zoning system, targetClass implementation

Post by Tryskell »

/!\ If you have no idea of what I talk just don't post... Spare me "Update to Freya/HI5" answers aswell.

Well I post to Legacy, but I currently implemented Freya zoning implementation using IL zones.

As you perhpas know, some areas affect only a certain instance type (such as stakato zones, bighead zones, etc). Before that was hardcoded, but since Freya it's DP side (as it should).

I would like to implement "targetClass". I got a problem on isAffected( method, as you currently use isInstanceType. I don't want implement that crap, which is heavy only for that (you use it for handlers too, but I don't need).

My question is simple : can I do it from a string using Class.forName( ? More generally, can I find back a Class from a String, and doing a check (using instanceof) from it ?

If no, what would you suggest ?
User avatar
Tryskell
Posts: 256
Joined: Wed Nov 25, 2009 5:57 pm
Location: France :)

Re: IL | Zoning system, targetClass implementation

Post by Tryskell »

I found that, but the parameter is an Object.

Going from following, how can I translate a string to an Object ?

Code: Select all

private String _target = "L2Character"; // default all chars
For initialization.

Code: Select all

else if (name.equals("targetClass")){    _target = value;}
To fill, if different of initialization.

Code: Select all

private boolean isAffected(L2Character character){    // Check lvl    if (character.getLevel() < _minLvl || character.getLevel() > _maxLvl)        return false;            // check obj class    if (character.isInstance(_target))        << ADENAS PLX        return false;
Blebleblebleble, that is just broken.
User avatar
Tryskell
Posts: 256
Joined: Wed Nov 25, 2009 5:57 pm
Location: France :)

Re: IL | Zoning system, targetClass implementation

Post by Tryskell »

I like to talk to myself.

It seems after 2min of test than I successfully corrected it. Stakato zoning don't apply anymore on players, if target is setuped to "L2Npc".

Code: Select all

// check obj classtry{    if (!(Class.forName("net.sf.l2j.gameserver.model.actor."+_target).isInstance(character)))        return false;}catch (ClassNotFoundException e){    e.printStackTrace();}
Ty to that website for the main idea => http://mindprod.com/jgloss/instanceof.html.

If you find an issue to my code, or if you know a better way to do the same thing, drop a word here.

PS : after implementing setTargetType( at both L2DamageZone and L2EffectZone, it seems "all is the best in the best of possible world". HS mobs haven't their heads x3, and stakato don't die anymore from zoning system ^^.
Post Reply