Jump to content

Pumarolonius

Inactive Member
  • Posts

    3
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by Pumarolonius

  1. I tried to translate this:

    double uniform_random(double a, double 
    {
    	return thecore_random() / (RAND_MAX + 1.f) * (b - a) + a;
    }
    
    float gauss_random(float avg, float sigma)
    {
    	static bool haveNextGaussian = false;
    	static float nextGaussian = 0.0f;
    
    	if (haveNextGaussian) 
    	{
    		haveNextGaussian = false;
    		return nextGaussian * sigma + avg;
    	} 
    	else 
    	{
    		double v1, v2, s;
    		do { 
    			//v1 = 2 * nextDouble() - 1;   // between -1.0 and 1.0
    			//v2 = 2 * nextDouble() - 1;   // between -1.0 and 1.0
    			v1 = uniform_random(-1.f, 1.f);
    			v2 = uniform_random(-1.f, 1.f);
    			s = v1 * v1 + v2 * v2;
    		} while (s >= 1.f || fabs(s) < FLT_EPSILON);
    		double multiplier = sqrtf(-2 * logf(s)/s);
    		nextGaussian = v2 * multiplier;
    		haveNextGaussian = true;
    		return v1 * multiplier * sigma + avg;
    	}
    }
    

    To this in php:

    function uniform_random($a, $
    {
    	return rand() / (32767 + 1) * ($b - $a) + $a;
    }
    function gauss_random($avg, $sigma)
    {
    	$haveNextGaussian = FALSE;
    	$nextGaussian = 0;
    
    	if ($haveNextGaussian) 
    	{
    		$haveNextGaussian = FALSE;
    		return $nextGaussian * $sigma + $avg;
    	} 
    	else 
    	{
    		do { 
    			$v1 = uniform_random(-1, 1);
    			$v2 = uniform_random(-1, 1);
    			$s = $v1 * $v1 + $v2 * $v2;
    		} while ($s >= 1 || abs($s) < 0.00001);
    		$multiplier = sqrt(-2 * log($s)/$s);
    		$nextGaussian = $v2 * $multiplier;
    		$haveNextGaussian = TRUE;
    		return $v1 * $multiplier * $sigma + $avg;
    	}
    }
    

    But it don't work. Can someone help me? Is it even possible to translate it to php? 

  2. Good day,

     

    I'm using the Vanilla Core 2.4.1 and I'm trying to write some quests but i got a problem.

    The pet.summon function only works if it's called over 

    when item.use 

    but i need it for

    when login or enter

    I also tried timer, letter,info... etc. Has anybody an idea or solution for that problem?

    Sorry for my bad english

     

    //Add After i called the pet.summon function over an item once, timer and and other when clauses work but i need it immediately for login

×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.