Jump to content

Automatic Random Zone Changer


Recommended Posts

Hello forum, i was searching around and i saw on many forum's peoples selling this code for gold. (30-40 euro) rolf...
That's who we are, sad...

So this is one "Gift" from me for the new year.

On this code you have the listed options:

  • You can add as many zones you want.
  • You can setup for each zone the running time.
  • (On the current diff i have use Giran Arena and Gludin Arena).
  • Gatekeeper command : <a action="bypass -h npc_%objectId%_pvp">Random Zone</a>
  • The codes required more then 1 zone.


Ofc you can add your own configs like "Auto Flag" "Auto Nobles" and whatever you want.. take this share like platform and work on it.
DIFF is coded on aCis 381 revision - Feel free to adapt it in whatever revision or project you need.

Credits : StinkyMadness
Code r381: Here

Edited by StinkyMadness
  • Like 7
  • Thanks 3
  • Upvote 1
Link to comment
Share on other sites

6 hours ago, N0K3 said:

Hi stinky, I really liked this change, however, by adding I'm getting this nullpointer.
Could you give me some help on?

https://imgur.com/FSe7h5y

Give a close view on your RandomZone.xml you did something wrong there.

Link to comment
Share on other sites

Change this code.

 

 public void selectNextZone()
+   {
+       int nextZoneId = Rnd.get(1, getTotalZones());
+       while (getZoneId() == nextZoneId)
+           nextZoneId = Rnd.get(1, getTotalZones());
+       _zoneId = nextZoneId;
+      
+       _timer = getCurrentZone().getTime() + 10;
+   }

You can do better

Link to comment
Share on other sites

1 hour ago, StinkyMadness said:

Give a close view on your RandomZone.xml you did something wrong there.

What's puzzling me is that things seem to be all right there.
RandomZone.xml in the zone folder and inside it contains this, just like your example.

<?xml version="1.0" encoding="UTF-8"?>
<list>
   <zone shape="Cuboid" minZ="-3752" maxZ="-352"><!-- gludin_pvp -->
       <stat name="id" val="1" />
       <stat name="name" val="Gludin Arena" />
       <stat name="time" val="30" /><!-- time in seconds -->
       <stat name="locs" val="-88339,141802,-3649;-87894,142231,-3649" />
       <node X="-88411" Y="141732" />
       <node X="-87429" Y="142708" />
   </zone>
   <zone shape="Cuboid" minZ="-3850" maxZ="-350"><!-- giran_pvp_battle -->
       <stat name="id" val="2" />
       <stat name="name" val="Giran Arena" />
      <stat name="time" val="30" /><!-- time in seconds -->
       <stat name="locs" val="73306,142440,-3775;72646,142403,-3775" />
       <node X="72493" Y="142263" />
       <node X="73493" Y="143261" />
   </zone>
</list>

 

Edited by N0K3
I was able to identify it was something with the type, because my zones had L2 prefix at the beginning and I needed to adapt RandomZone to my source, thanks for the support.
Link to comment
Share on other sites

1 hour ago, Kara` said:

You can do better

indeed. something like that would be more clean

 

private static void selectNextZone()
{
	final int maxSize = getTotalZones();
	_zoneId = _zoneId >= maxSize ? 1 : _zoneId++;
	_timer = getCurrentZone().getTime() + 10;
}

public static int getTotalZones()
{
	return ZoneManager.getInstance().getAllZones(RandomZone.class).stream().filter(zone -> zone != null).collect(Collectors.toList()).size();
}

 

Link to comment
Share on other sites

20 minutes ago, melron said:

something like that would be more clean

I believe it's supposed to be truly random, not seemingly. But yeah, one after another is also a way.

 

Zones count, simply: ZoneManager.getInstance().getAllZones(RandomZone.class).size();

Link to comment
Share on other sites

4 minutes ago, Kara` said:

RandomZone selectedZone = ZoneManager.getInstance().getAllZones(RandomZone.class).stream().findAny();

1 line code instead of 8

With that line, I believe you can pick the same zone, right? So, it's not what you really want. You must be sute the next zone is different :thinking:

Link to comment
Share on other sites

3 minutes ago, SweeTs said:

With that line, I believe you can pick the same zone, right? So, it's not what you really want. You must be sute the next zone is different :thinking:

Didn't know we need also that check.

 

RandomZone selectedZone = ZoneManager.getInstance().getAllZones(RandomZone.class).stream().filter(s -> s.getId() != getCurrentZone().getId()).findAny().orElse(null);

In null you can add to return the same zone if no other exist. I write it in notepad++ so i cannot know if syntax is ok

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




×
×
  • Create New...