Jump to content
  • 0

Custom Zone (Random Race Display)


Question

Posted (edited)

Hello.

 

I created a custom zone. And I edited the charinfo, so when a player enters the zone his/her name will be "Unknown".

 

However, my problem is that the system damage message still displays the original name of the characters. (I guess becuase the changes in charinfo only affect the client and the server still recognize the character's origianl name).

 

My question is: what should I edit or change in order to have the system message display "unknown" instead of the original names?

 

I know i could create new system messsages (instead of $c1 done $s3 damge $c2 to unknown done $s3 damage to unknown) but I'd rather avoid this if theres a better way.

 

 

EDIT:

 

Does anybody have any suggestion, ideas how could I make  Random Race displayed in a specific zone for players?

 

Either in Charinfo, or some other working method would be great.

 

Thank you.

 

 

P.S: Im using High Five latest rev.

Edited by Horse

Recommended Posts

  • 0
Posted (edited)
getAntifeedTemplate() != null 

wherever it's needed, because it is null the majority of time, and not null only for events. As you use the packets both for events and regular, it needs a null check, until you initialize it with a default template and avoids to null it after the event as you currently do.

 

PS : easiest would be to initialize and get same template for everyone. That avoid your do/while loop for race, that avoid to generate shitloads amount of pointless templates, that avoid to get NPE checks. You initialize a static template and refers to it everytime you need it ; can't be null, single object, best performance.

 

First of all, thank you for the little explanation. For me who has just started to get into "coding and java"  a few weeks ago, these tiny explonations help me to understand a whole lot about how java works.

 

On topic: I've added the null checks. This solved the npe errors that i got when i entered the custom zone where I d like to apply the race change.

 

However, currently i get no errors at all, but once i recall or enter with a second char to the zone i see the original template.  (the name change works as it should along with the system message (unknown hit unknown for xxx damage) without the need to edit systemmessage.dat directly, which is a blessing.

 

I assume that something might be wrong with the createRandomAntifeedTemplate(). So, I'm still keep trying.

 

 

You mentioned to get a given/same template for everyone. Originally this was my idea as well, however due to the lack of my knowladge or experience with l2 java, I wasn't able to figure it out, how can I pick a certain template.

To my understanding, the antifeed method which I tried to adopt uses values of the classid to verify the temlate (if im not mistaken). But this is where I'm stuck, becuase I do not know how can I get  (a) certain template(s).

 

An exemple or hint like: getting the template of "orc fighter" for each class would be very helpful.    (I find exemples the best way to learn).

 

 

In any case, thank you for the help you've already provided, it sure is useful.

Edited by Horse
  • 0
Posted (edited)

Short but gold : almost everything exists already on sources. EVERYTHING. If you don't know how to make something, be sure it already exists, on a form or another. 99,9% of time.

 

Case of templates : when you login with your player, you're (logically, as you already understand the trick with edit race template) associated with a template. According to you, is that template generated with your player instance... Or is it preloaded from static XMLs, stored on static maps and simply "pulled out" on demand ? You already know than players use PcTemplate as type of template, a simple search over sources will get you :

  • (first search with "PcTemplate" keyword) CharTemplateTable holds PcTemplate on a Map<Integer, PcTemplate> internally named _templates, but publically accessible with getter getTemplate(int/ClassId) - so a CharTemplateTable.getInstance().getTemplate( will load you the given template.
  • (another search with "CharTemplateTable.getInstance().getTemplate(" keyword) CharTemplateTable.getInstance().getTemplate( is used 16 times over (aCis) sources : character creation packets (we don't care), and 5 uses on L2PcInstance. If you got an issue with templates those 5 occurences need to be checked and eventually overidden by your own event template. Because both templates exist, and the reference template is and stay the base template.

The fact than you edit the template at a moment M doesn't mean the template is now the one you gave. It stills reference to base template. If you don't say "I'm on an event, please keep the given template for all scenarios until I give another order" it simply uses the one registered. Exactly like player name.

Edited by Tryskell
  • 0
Posted (edited)

Short but gold : almost everything exists already on sources. EVERYTHING. If you don't know how to make something, be sure it already exists, on a form or another. 99,9% of time.

 

Case of templates : when you login with your player, you're (logically, as you already understand the trick with edit race template) associated with a template. According to you, is that template generated with your player instance... Or is it preloaded from static XMLs, stored on static maps and simply "pulled out" on demand ? You already know than players use PcTemplate as type of template, a simple search over sources will get you :

  • (first search with "PcTemplate" keyword) CharTemplateTable holds PcTemplate on a Map<Integer, PcTemplate> internally named _templates, but publically accessible with getter getTemplate(int/ClassId) - so a CharTemplateTable.getInstance().getTemplate( will load you the given template.
  • (another search with "CharTemplateTable.getInstance().getTemplate(" keyword) CharTemplateTable.getInstance().getTemplate( is used 16 times over (aCis) sources : character creation packets (we don't care), and 5 uses on L2PcInstance. If you got an issue with templates those 5 occurences need to be checked and eventually overidden by your own event template. Because both templates exist, and the reference template is and stay the base template.

The fact than you edit the template at a moment M doesn't mean the template is now the one you gave. It stills reference to base template. If you don't say "I'm on an event, please keep the given template for all scenarios until I give another order" it simply uses the one registered. Exactly like player name.

Thank you once more, for the detailed explanation. Once I get home, I'll take a closer look at the things you wrote.

 

"CharTemplateTable.getInstance().getTemplate(" keyword) CharTemplateTable.getInstance().getTemplate( ---->this far I got, and more or less understood it on my own. But i wasn't sure what holds the template's themselves since it's a bit different in hi5. But I'm beginning to understand how it works.  P.S In my case there is no charTemplateTable (newer hi5 versions have this stored in some other file i assume---most likely this will be the problem).

Edited by Horse
  • 0
Posted (edited)

Basically said, search wherever L2PcTemplate is used. I gave you exemples based on aCis / IL. L2PcTemplate still exists on latest L2J sources, so...

I cleaned up and changed the method of getAntiFeedTemplate(), I picked a specific template (elvenfighter) for starters. And it seems to be working fine.

 

All that's left is to make it pick random IDs from  my own random list with Rnd.

 

Thanks a lot, Tryskell.

 

 

 

P.S : This is just a slight cosmetic issue. When an other char enters or leaves the zone ( where i applied the custom template) by simply walking out and in (NO TELEPORT), the template changes only when the character gets hit or affected by skills or some action. (ofc when it is teleported it display the changed template, so you see the new template already.  I was just wondering if the template change could be seen automatically by simply walking inside the zone.

Since, most of the time this zone and zones alike will be accasabble by teleport, or will be used as event zones it isn't that much of an issue. But I'm curious if there is some kind of way to fix that.

Edited by Horse
  • 0
Posted

Sounds like missing broadcast. Are you using decayMe, spawnMe, broadcast? Thats the order, I guess, when you change class with gm command. Do the same.

  • 0
Posted

How is your zone onEnter / onExit ? If it's not yet handled here, it should. If it is, then it's like SweeTs said.

Yes. It wasn't handled there. Now it seems to be fine.

 

Thank you guys.

 

 

 

Topic can be locked.

Guest
This topic is now closed to further replies.


×
×
  • Create New...