Jump to content

Recommended Posts

Posted (edited)

findAny() can't be used as a counterpart of Rnd. It only means it doesn't guarantee any order based on your Stream. You can - or can't - retrieve exactly the same order. But most likely, it will produce exactly the same content. Meaning you will never see some of your maps.

 

In a non-parallel operation, it will most likely return the first element in the Stream but there is no guarantee for this.

You have to Rnd.get(list).

Edited by Tryskell
Posted
34 minutes ago, SweeTs said:

Yep, just did some tests and it's returning first element. Yet, it can do the trick, BUT first you have to use shuffle.

 

Less costy to pick a random element than to shuffle a whole container. And your point is to pick a single element, not the whole list, so shuffling the whole list is pointless.

 

:goodsir:

Posted
2 hours ago, Kara` said:

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

 

 

did you just imply that you wrote this code right out of your mind in a simple text editor?

 

What kind of psychotic autistic lair attention whore bitch can someone be, really 

Posted (edited)

for randomness I would go with a jackpot-like random generator pool, feel free to use my code

 

https://pastebin.com/SZq07PZy

 

your jackpot weight should be an inversion of current zone hits

Edited by xdem
  • 2 months later...
Posted (edited)

Hello MXC members, maybe anyone try this zone changer? I try but I can't change zones from ZoneManager.xml 

If I change loc's not move me to other zone or maybe only can use arena type? anyone know how to fix?

Also only Cuboid can use? Because i try make NPoly and get error to console. Help to me pls.

Edited by Gezis
Posted
5 hours ago, Gezis said:

...

Code is working fine and with zone type RandomZone not with Arena
Also ofc you can use NPoly, the diff is coded on aCis 377 if you have older version or newest you have to adapt parts of code.

Posted (edited)
50 minutes ago, Gezis said:

Yes code working to me, but I say about random zone with other locs :) maybe my fault with xml idk. But I chancge only from "CuboId" to "NPoly" 


Cuboid required : 2 node locations.
NPoly required : 3+ node locations.

//Edit
Here is one good tutorial from @SweeTs Tutorial Link

Edited by StinkyMadness
Posted

Yes my bad, working with NPoly, but not move to next zone, with default zones (Arena) move.

My zones:

<?xml version="1.0" encoding="UTF-8"?>
<list>
	<!-- Random Zones -->
	<zone type="RandomZone" shape="NPoly" minZ="9080" maxZ="11080"><!-- gludin_pvp -->
		<stat name="id" val="1"/>
		<stat name="name" val="Gludin Arena"/>
		<stat name="time" val="120"/><!-- time in seconds -->
		<stat name="locs" val="114264,16280,10080;115009,15114,10080"/>
	        <node X="115736" Y="16152" />
	        <node X="116056" Y="16872" />
	        <node X="114856" Y="17768" />
	        <node X="114083" Y="17376" />
	        <node X="113140" Y="14874" />
	        <node X="114264" Y="15650" />
		<spawn X="114264" Y="16280" Z="10080" />
	</zone>
		<zone type="RandomZone" shape="NPoly" minZ="9080" maxZ="11080"><!-- gludin_pvp -->
		<stat name="id" val="2"/>
		<stat name="name" val="Arena"/>
		<stat name="time" val="120"/><!-- time in seconds -->
		<stat name="locs" val="114264,16280,10080;115009,15114,10080"/>
	        <node X="115736" Y="16152" />
	        <node X="116056" Y="16872" />
	        <node X="114856" Y="17768" />
	        <node X="114083" Y="17376" />
	        <node X="113140" Y="14874" />
	        <node X="114264" Y="15650" />
		<spawn X="114264" Y="16280" Z="10080" />
	</zone>
</list>

 

Posted (edited)
43 minutes ago, Gezis said:

....


Nice zone... its around the TOP of the Sky take a look on you minZ maxZ.... also aCis have //check_zone if there not appear "random zone" then your nodes are wrong... but on current XML the minZ maxZ looks TOTAL to much... If you are not inside zone how you will be teleport ?

Edited by StinkyMadness

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...