예제 #1
0
     UInt8 BattleRideFighter::BeForAction()
     { 
         return 0;
         //40%启动
        if(!isRunSend)
        {
            if(uRand(100) < 40)  //XXX
                return 1;
        } 

        //if(!GetGone())
        //    GoForward();

        return 0;
     } 
예제 #2
0
파일: Fighter.cpp 프로젝트: jacobxy/test
 void Fighter::updateEuipmentLoad(UInt8 index)
 { 
     static UInt32 chance[] = {7000,8000,8600,9200,10000};
     UInt32 load = 1;
     UInt8 level = 1;
     while(level < 10)
     { 
         UInt32 rand = uRand(10000);
         for(UInt8 i = 0; i < 5; ++i)
         { 
             if(rand < chance[i])
             {
                 level += (i+1);
                 if(level >= 10)
                     level = 10;
                 break;
             }
         } 
         load |= (1 << (level - 1));
     } 
     SetVar(FVAR_WEAPON_ROAD + index , load);
 } 
예제 #3
0
파일: URandom.cpp 프로젝트: jacobxy/test
extern "C" unsigned int uRandom(unsigned int modulo)
{
	return uRand(modulo);
}
예제 #4
0
boost::shared_ptr<PrimVars> EmitterMesh::particlesOnFace(int faceIdx)
{
	const MeshFace& face = m_faces[faceIdx];

	boost::shared_ptr<PrimVars> interpVars(new PrimVars());

	float numParticlesCts = face.weight*m_totParticles;
	int numParticles = Aqsis::lfloor(face.weight*m_totParticles);
	if(numParticlesCts - numParticles > uRand())
		++numParticles;
	if(numParticles == 0)
		return boost::shared_ptr<PrimVars>();
	std::vector<int> storageCounts;
	// Create storage for all interpolated output parameters.
	for(PrimVars::const_iterator i = m_primVars->begin(), end = m_primVars->end();
			i != end; ++i)
	{
		if(i->token.Class() == Aqsis::class_constant
				|| i->token.Class() == Aqsis::class_uniform)
		{
			storageCounts.push_back(0);
			// uniform and constant primvars on the mesh interpolate to
			// constant primvars on the curves
			interpVars->append(Aqsis::CqPrimvarToken(Aqsis::class_constant,
				i->token.type(), i->token.count(), i->token.name() + "_emit"));
			// We can just copy over constant/uniform data; no interpolation needed.
			if(i->token.Class() == Aqsis::class_constant)
				*interpVars->back().value = *i->value;
			else
			{
				int stride = i->token.storageCount();
				interpVars->back().value->assign(
						i->value->begin() + stride*faceIdx,
						i->value->begin() + stride*(faceIdx+1));
			}
		}
		else
		{
			storageCounts.push_back(i->token.storageCount());
			// varying, vertex, facevarying and facevertex primvars interpolate
			// to uniform primvars on the curves
			interpVars->append(Aqsis::CqPrimvarToken(Aqsis::class_uniform,
				i->token.type(), i->token.count(), i->token.name() + "_emit"));
			// Allocate storage
			interpVars->back().value->assign(numParticles*storageCounts.back(), 0);
		}
	}

	// Float offsets for randomized quasi Monte-Carlo distribution
	float uOffset = float(std::rand())/RAND_MAX;
	float vOffset = float(std::rand())/RAND_MAX;
	// loop over child particles
	for(int particleNum = 0; particleNum < numParticles; ++particleNum)
	{
		// get random weights for the vertices of the current face.
		float u = uOffset + m_lowDiscrep.Generate(0, particleNum);
		if(u > 1)
			u -= 1;
		float v = vOffset + m_lowDiscrep.Generate(1, particleNum);
		if(v > 1)
			v -= 1;
		float weights[4];
		if(face.numVerts == 3)
		{
			if(u + v > 1)
			{
				u = 1-u;
				v = 1-v;
			}
			weights[0] = 1 - u - v;
			weights[1] = u;
			weights[2] = v;
			weights[3] = 0.0f;
		}
		else
		{
			weights[0] = (1-u)*(1-v);
			weights[1] = (1-u)*v;
			weights[2] = u*v;
			weights[3] = u*(1-v);
		}

		// loop over primitive variables.  Each varying/vertex/facevarying
		// /facevertex primvar is interpolated from the parent mesh to the
		// current child particle.
		int storageIndex = 0;
		PrimVars::iterator destVar = interpVars->begin();
		for(PrimVars::const_iterator srcVar = m_primVars->begin(),
				end = m_primVars->end(); srcVar != end;
				++srcVar, ++storageIndex, ++destVar)
		{
			int storageStride = storageCounts[storageIndex];
			// Get pointers to source parameters for the vertices
			const float* src[4] = {0,0,0,0};
			switch(srcVar->token.Class())
			{
				case Aqsis::class_varying:
				case Aqsis::class_vertex:
					for(int i = 0; i < face.numVerts; ++i)
						src[i] = &(*srcVar->value)[storageStride*face.v[i]];
					break;
				case Aqsis::class_facevarying:
				case Aqsis::class_facevertex:
					for(int i = 0; i < face.numVerts; ++i)
						src[i] = &(*srcVar->value)[
							storageStride*(face.faceVaryingIndex+i) ];
					break;
				default:
					// Other classes don't need any interpolation, so we just
					// go to the next primvar in m_primVars
					continue;
			}

			// Interpolate the primvar pointed to by srcVar to the current
			// particle position.  This is just a a weighted average of values
			// attached to vertices of the current face.
			float* dest = &(*destVar->value)[storageStride*particleNum];
			for(int k = 0; k < storageStride; ++k, ++dest)
			{
				*dest = 0;
				for(int i = 0; i < face.numVerts; ++i)
				{
					*dest += *src[i] * weights[i];
					++src[i];
				}
			}
		}
	}

	// Finally, add extra face-constant parameters.
	Vec3 Ng_emitVec = faceNormal(face);
	float Ng_emit[] = {Ng_emitVec.x(), Ng_emitVec.y(), Ng_emitVec.z()};
	interpVars->append(Aqsis::CqPrimvarToken(Aqsis::class_constant, Aqsis::type_normal,
				1, "Ng_emit"), FloatArray(Ng_emit, Ng_emit+3));

	return interpVars;
}
예제 #5
0
std::vector<UInt8>* BattleReport::getTitleBattle()
{
	return (*this)[0xFFFFFFFF - uRand(4)];
}