/!\ 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 ?
IL | Zoning system, targetClass implementation
Forum rules
READ NOW: L2j Forums Rules of Conduct
READ NOW: L2j Forums Rules of Conduct
- Tryskell
- Posts: 256
- Joined: Wed Nov 25, 2009 5:57 pm
- Location: France :)
- Tryskell
- Posts: 256
- Joined: Wed Nov 25, 2009 5:57 pm
- Location: France :)
Re: IL | Zoning system, targetClass implementation
I found that, but the parameter is an Object.
Going from following, how can I translate a string to an Object ?
For initialization.
To fill, if different of initialization.
Blebleblebleble, that is just broken.
Going from following, how can I translate a string to an Object ?
Code: Select all
private String _target = "L2Character"; // default all chars
Code: Select all
else if (name.equals("targetClass")){ _target = value;}
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;
- Tryskell
- Posts: 256
- Joined: Wed Nov 25, 2009 5:57 pm
- Location: France :)
Re: IL | Zoning system, targetClass implementation
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".
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 ^^.
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();}
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 ^^.