Ejemplo n.º 1
0
Expr* DerefExpr::Clone(Mapping *m) const
{
        if (m && (fValue & kVirtualVarBase))
        {
                const Expr *e = m->Get(fValue);
                if (e)
                {
                  // a deref expression always needs to return a deref expr clone
                  // regardless of the type of expression in the Mapping
                  // the expression in the map is used only to pass us the variable number
                  int val;
                  if (!e->Evaluate(val))
                   {
                       val = e->GetLValue();
                       if (val == kIllegalVar)
                       {
                           Error(kErr_ParamType, "pointer").Raise(&e->GetLoc());
                           return e->Clone(0);
                       }
                   }
//                   return new DerefExpr(((val & kPointerFlag) ? val - kPointerFlag : val), GetLoc());
                   return new DerefExpr(val, GetLoc());
                }
        }

        return new DerefExpr(fValue, GetLoc());
}
Ejemplo n.º 2
0
void OuchField::OuchSetFX(hTXT gasImg, BYTE r, BYTE g, BYTE b)
{
    fxGas_init tFX;

    tFX.gasTxt = gasImg;

    tFX.r = r;
    tFX.g = g;
    tFX.b = b;

    tFX.dir[eX] = tFX.dir[eZ] = 0;
    tFX.dir[eY] = 1;

    tFX.spd = OUCH_GAS_SPEED;

    tFX.spawnDelay = OUCH_GAS_SPAWN_DELAY;

    memcpy(tFX.min, (float*)(BoundGetMin()+GetLoc()), sizeof(float)*eMaxPt);
    memcpy(tFX.max, (float*)(BoundGetMax()+GetLoc()), sizeof(float)*eMaxPt);

    tFX.maxParticle = OUCH_GAS_MAX_PARTICLE;

    tFX.scaleMax = OUCH_GAS_SIZE;

    tFX.scaleDelayMin = OUCH_GAS_DELAY_SCALE_MIN;
    tFX.scaleDelayMax = OUCH_GAS_DELAY_SCALE_MAX;

    tFX.alphaDelayMin = OUCH_GAS_DELAY_ALPHA_MIN;
    tFX.alphaDelayMax = OUCH_GAS_DELAY_ALPHA_MAX;

    tFX.bRepeat = true;

    PARFXCreate(ePARFX_GAS, &tFX, -1, 0, -1, 0);
}
Ejemplo n.º 3
0
int Doodad::Callback(unsigned int msg, unsigned int wParam, int lParam)
{
	switch(msg)
	{
	case ENTITYMSG_UPDATE:
		//Update waypoint
		if(m_pWayPt)
		{
			D3DXVECTOR3 destPt, target, lookDir;

			//GetCurrentLinearLoc(&destPt);
			m_pWayPt->GetCurrentCurvedLoc(&destPt, &target);

			lookDir = target - GetLoc();
			//D3DXVec3Normalize(&lookDir, &lookDir);
			SetDir(lookDir);

			D3DXVECTOR3 dir(destPt - GetLoc());
			float len = D3DXVec3Length(&dir);

			float spd = m_moveSpd.MoveUpdate(g_timeElapse);
			
			if(len > spd)
			{
				dir /= len;

				SetVel(GetVel() + (spd*dir));
			}
			//we are close enough
			//get to next waypoint node
			else
			{
				SetVel(dir);

				m_pWayPt->GotoNext();
			}
			
			//if(m_pWayPt->IsDone())
			//	RemoveWayPt();
		}
		break;

	case ENTITYMSG_ALLOWGRAVITY:
		//simply don't allow gravity
		return 0;

	case ENTITYMSG_PROFILEPREP:
		Show(wParam == 1 ? true : false);
		break;
	}

	return RETCODE_SUCCESS;
}
Ejemplo n.º 4
0
void Geyser::GeyserInitParticle(hTXT gasImg, BYTE r, BYTE g, BYTE b)
{
	if(m_particle)
		PARFXDestroy(&m_particle);

	if(gasImg)
	{
		fxGas_init tFX;

		tFX.gasTxt = gasImg;

		tFX.r = r;
		tFX.g = g;
		tFX.b = b;

		tFX.dir[eX] = tFX.dir[eZ] = 0;
		tFX.dir[eY] = 1;

		tFX.spd = m_upSpd.MoveGetSpeed()/2;

		tFX.spawnDelay = GEYSER_GAS_SPAWN_DELAY;

		memcpy(tFX.min, (float*)(BoundGetMin()+GetLoc()), sizeof(float)*eMaxPt);
		memcpy(tFX.max, (float*)(BoundGetMax()+GetLoc()), sizeof(float)*eMaxPt);

		tFX.maxParticle = GEYSER_GAS_MAX_PARTICLE;
		
		tFX.scaleMax = GEYSER_GAS_SIZE;

		tFX.scaleDelayMin = GEYSER_GAS_DELAY_SCALE_MIN;
		tFX.scaleDelayMax = GEYSER_GAS_DELAY_SCALE_MAX;

		tFX.alphaDelayMin = GEYSER_GAS_DELAY_ALPHA_MIN;
		tFX.alphaDelayMax = GEYSER_GAS_DELAY_ALPHA_MAX;

		tFX.bRepeat = true;

		m_particle = PARFXCreate(ePARFX_GAS, &tFX, -1, 0, -1, 0);
	}
}
Ejemplo n.º 5
0
/// verify the data structure consistency
void TPZFracSet::CheckPointMapConsistency()
{
    int64_t nnodes = fNodeVec.NElements();
    for (int64_t in=0; in<nnodes; in++) {
        uint64_t locnode  = GetLoc(fNodeVec[in]);
        if (fPointMap.find(locnode) == fPointMap.end()) {
            DebugStop();
        }
        int64_t nodeindex = fPointMap[locnode];
        if (nodeindex != in) {
            DebugStop();
        }
    }
}
Ejemplo n.º 6
0
/// will project the endnodes on the MHM mesh if they fall within the tolerance
int64_t TPZFracSet::InsertNode(TPZGeoNode &gnode)
{
    uint64_t nodekey = GetLoc(gnode);
    if (fPointMap.find(nodekey) == fPointMap.end()) {
        int64_t index = fNodeVec.AllocateNewElement();
        gnode.SetCoord(ConvertNodekey(nodekey));
        fNodeVec[index] = gnode;
        fPointMap[nodekey] = index;
        return index;
    }
    else
    {
        return fPointMap[nodekey];
    }
}
Ejemplo n.º 7
0
_Spit::_Spit(const Id & owner, float spd, bool bBounce, int bounceMax, int sndInd)
: Projectile(PROJ_SPIT, owner), m_bBounce(bBounce), m_bounceMax(bounceMax),
m_bounceCur(0), m_tSnd(0)
{
	//set move
	m_spd.MoveSetSpeed(spd);

	SetFlag(PROJ_FLAG_OBJINVUL, bBounce);

	if(sndInd > -1)
	{
		BASS_3DVECTOR pos, orient;

		memcpy(&pos, (float*)GetLoc(), sizeof(pos)); pos.z *= -1;
		memcpy(&orient, (float*)GetDir(), sizeof(orient)); orient.z *= -1;

		m_tSnd = TaTaSoundPlay(sndInd, &pos, &orient, 0);
	}
}
int AttackMelee::Callback(unsigned int msg, unsigned int wParam, int lParam)
{
	switch(msg)
	{
	case ENTITYMSG_UPDATE:
		{
			//check to see if the owner's animation is done...
			//ENTITY_FLAG_POLLDEATH
			EntityCommon *pEntity = (EntityCommon *)IDPageQuery(GetOwner());

			if(pEntity)
			{
				hOBJ obj = pEntity->GetOBJ();

				if(OBJIsStateEnd(obj))
				{
					//Poll ourself to death!
					SetFlag(ENTITY_FLAG_POLLDEATH, true);
				}
				else
				{
					if(m_jointInd != -1)
					{
						D3DXVECTOR3 cPt;

						//set location
						OBJJointGetWorldLoc(obj, m_jointInd, (float*)cPt);
						SetLoc(cPt);

						//set dir and velocity
						SetDir(pEntity->GetDir());
						SetVel(pEntity->GetDir());
					}
				}
			}
		}
		break;
	
	case ENTITYMSG_ENTITYCOLLIDE://, (WPARAM)pEntity
		{
			EntityCommon *pEntity = (EntityCommon *)wParam;
			EntityCommon *pOwner = (EntityCommon *)IDPageQuery(GetOwner());

			//play a sound if ind is > -1
			int sndInd = -1;

			if(pOwner)
			{
				//check to see if the owner is not the same type as entity
				//also make sure this entity is not immune
				if(pOwner->GetEntityType() != pEntity->GetEntityType()
					&& !pEntity->CheckFlag(CRE_FLAG_MELEEIMMUNE))
				{
					//check to see if the entity is a creature
					if(pEntity->GetEntityType() == ENTITY_TYPE_TATA
						|| pEntity->GetEntityType() == ENTITY_TYPE_ENEMY)
					{
						//hit this fella
						Creature *pCre = (Creature *)pEntity;

						if(!pCre->Hit())
						{
							OBJSetState(pOwner->GetOBJ(), CREANIM_IDLE1);
							pOwner->Callback(ENTITYMSG_REQUESTSOUND, SND_REQ_PROJ_HIT_WALL, (LPARAM)&sndInd);
						}
						else
							pOwner->Callback(ENTITYMSG_REQUESTSOUND, SND_REQ_PROJ_HIT_CRE, (LPARAM)&sndInd);

						SetFlag(ENTITY_FLAG_POLLDEATH, true);
					}
					else
					{
						//Poll ourself to death!
						SetFlag(ENTITY_FLAG_POLLDEATH, true);
						OBJSetState(pOwner->GetOBJ(), CREANIM_IDLE1);

						pOwner->Callback(ENTITYMSG_REQUESTSOUND, SND_REQ_PROJ_HIT_WALL, (LPARAM)&sndInd);
					}
				}
				else
				{
					//Poll ourself to death!
					SetFlag(ENTITY_FLAG_POLLDEATH, true);
					OBJSetState(pOwner->GetOBJ(), CREANIM_IDLE1);

					pOwner->Callback(ENTITYMSG_REQUESTSOUND, SND_REQ_PROJ_HIT_WALL, (LPARAM)&sndInd);
				}
			}

			//play sound
			if(sndInd > -1)
			{
				BASS_3DVECTOR pos, orient;
				memcpy(&pos, (float*)GetLoc(), sizeof(pos)); pos.z *= -1;
				memcpy(&orient, (float*)GetDir(), sizeof(orient)); orient.z *= -1;

				TaTaSoundPlay(sndInd, &pos, &orient, 0);
			}
		}
		break;

	case ENTITYMSG_WORLDCOLLIDE: //(WPARAM)hQBSP, (LPARAM)txtID
		{
			//stop the attack and set the owner back to normal state
			EntityCommon *pEntity = (EntityCommon *)IDPageQuery(GetOwner());

			if(pEntity)
			{
				OBJSetState(pEntity->GetOBJ(), CREANIM_IDLE1);

				//Poll ourself to death!
				SetFlag(ENTITY_FLAG_POLLDEATH, true);

				int sndInd=-1;
				pEntity->Callback(ENTITYMSG_REQUESTSOUND, SND_REQ_PROJ_HIT_WALL, (LPARAM)&sndInd);

				//play sound
				if(sndInd > -1)
				{
					BASS_3DVECTOR pos, orient;
					memcpy(&pos, (float*)GetLoc(), sizeof(pos)); pos.z *= -1;
					memcpy(&orient, (float*)GetDir(), sizeof(orient)); orient.z *= -1;

					TaTaSoundPlay(sndInd, &pos, &orient, 0);
				}
			}
		}
		break;

	case ENTITYMSG_DEATH:
		break;

	case ENTITYMSG_ALLOWGRAVITY:
		//simply don't allow gravity
		return 0;
	}

	return RETCODE_SUCCESS;
}
Ejemplo n.º 9
0
/// add the cornernodes of the MHM mesh
void TPZFracSet::AddMHMNodes()
{
    int64_t nfrac = fFractureVec.NElements();
    int numx = (fTopRight[0]-fLowLeft[0])/fMHMSpacing[0];
    int numy = (fTopRight[1]-fLowLeft[1])/fMHMSpacing[1];
    for (int i=0; i<=numx; i++) {
        for (int j=0; j<=numy; j++) {
            TPZManVector<REAL,3> co(3,0.);
            co[0] = fLowLeft[0]+i*fMHMSpacing[0];
            co[1] = fLowLeft[1]+j*fMHMSpacing[1];
            TPZGeoNode node;
            node.SetCoord(co);
            int64_t index = InsertNode(node);
            fNodeVec[index].GetCoordinates(co);
            std::pair<uint32_t, uint32_t> p1 = NodeKey(co);
            if (p1.first % fMHMSpacingInt[0] != 0 || p1.second%fMHMSpacingInt[1] != 0) {
                DebugStop();
            }
        }
    }
    // build the datastructure for horizontal and vertical lines
    fHorizontalLines.Resize(numy+1);
    fVerticalLines.Resize(numx+1);
    int64_t nnodes = fNodeVec.NElements();
    for (int64_t in=0; in<nnodes; in++) {
        TPZManVector<REAL,3> co(3);
        fNodeVec[in].GetCoordinates(co);
        uint64_t locprev = GetLoc(fNodeVec[in]);
        std::pair<uint32_t, uint32_t> p1 = NodeKey(co);
        if (p1.first%fMHMSpacingInt[0] == 0) {
            int line = p1.first/fMHMSpacingInt[0];
            REAL coprev = fNodeVec[in].Coord(0);
            REAL conew = line*fTol*fMHMSpacingInt[0];
            fNodeVec[in].SetCoord(0, conew);
            uint64_t locafter = GetLoc(fNodeVec[in]);
            if (locprev != locafter) {
                DebugStop();
            }
            fVerticalLines[line][co[1]] = in;
        }
        if (p1.second%fMHMSpacingInt[1] == 0) {
            int line = p1.second/fMHMSpacingInt[1];
            REAL coprev = fNodeVec[in].Coord(1);
            REAL conew = line*fTol*fMHMSpacingInt[1];
            fNodeVec[in].SetCoord(1, conew);
            uint64_t locafter = GetLoc(fNodeVec[in]);
            if (locprev != locafter) {
                DebugStop();
            }
            fHorizontalLines[line][co[0]] = in;
        }
    }
    
    int64_t nhor = fHorizontalLines.NElements();
    for (int64_t hor = 0; hor < nhor; hor++) {
        for (auto it = fHorizontalLines[hor].begin(); it != fHorizontalLines[hor].end(); it++) {
            auto it2 = it;
            it2++;
            if (it2 == fHorizontalLines[hor].end()) {
                continue;
            }
            TPZManVector<int64_t,2> nodes(2);
            nodes[0] = it->second;
            nodes[1] = it2->second;
            int64_t index;
            int matid = matid_MHM_line;
            if (hor == 0 || hor == nhor-1) {
                matid = matid_BC;
            }
            TPZFracture frac = TPZFracture(nfrac++, matid, nodes[0], nodes[1]);
            frac.fFracPerm = 0;
            frac.fPhysicalName="MHMLine";
            if (hor == 0 || hor == nhor-1) {
                frac.fPhysicalName = "BC";
            }
            index  = fFractureVec.AllocateNewElement();
            fFractureVec[index] = frac;
        }
    }
    int64_t nver = fVerticalLines.NElements();
    for (int64_t ver = 0; ver < nver; ver++) {
        for (auto it = fVerticalLines[ver].begin(); it != fVerticalLines[ver].end(); it++) {
            auto it2 = it;
            it2++;
            if (it2 == fVerticalLines[ver].end()) {
                continue;
            }
            TPZManVector<int64_t,2> nodes(2);
            nodes[0] = it->second;
            nodes[1] = it2->second;
            int matid = matid_MHM_line;
            if (ver==0 || ver==nver-1) {
                matid = matid_BC;
            }
            int64_t index;
            TPZFracture frac = TPZFracture(nfrac++, matid, nodes[0], nodes[1]);
            frac.fFracPerm = 0.;
            frac.fPhysicalName = "MHMLine";
            if (ver == 0 || ver == nver-1) {
                frac.fPhysicalName = "BC";
            }
            index  = fFractureVec.AllocateNewElement();
            fFractureVec[index] = frac;
        }
    }

}
Ejemplo n.º 10
0
int _Spit::Callback(unsigned int msg, unsigned int wParam, int lParam)
{
	switch(msg)
	{
	case ENTITYMSG_UPDATE:
		//update velocity
		SetVel(GetDir()*m_spd.MoveUpdate(g_timeElapse));

		//update sound position
		if(m_tSnd)
		{
			BASS_3DVECTOR pos, orient, vel;

			memcpy(&pos, (float*)GetLoc(), sizeof(pos)); pos.z *= -1;
			memcpy(&orient, (float*)GetDir(), sizeof(orient)); orient.z *= -1;
			memcpy(&vel, (float*)GetVel(), sizeof(vel)); vel.z *= -1;

			BASS_ChannelSet3DPosition(m_tSnd, &pos, &orient, &vel);
		}
		break;

	case ENTITYMSG_ENTITYCOLLIDE://, (WPARAM)pEntity
		{
			EntityCommon *pEntity = (EntityCommon *)wParam;
			EntityCommon *pOwner = (EntityCommon *)IDPageQuery(GetOwner());

			//check to see if the owner is not the same type as entity
			if(pOwner)
			{
				if(pOwner->GetEntityType() != pEntity->GetEntityType())
				{
					//check to see if the entity is a creature
					if((pEntity->GetEntityType() == ENTITY_TYPE_TATA
						|| pEntity->GetEntityType() == ENTITY_TYPE_ENEMY)
						&& !pEntity->CheckFlag(CRE_FLAG_SPITIMMUNE))
					{
						//hit this fella
						Creature *pCre = (Creature *)pEntity;

						if(pCre->Hit())
						{
							int sndInd = -1;
							pOwner->Callback(ENTITYMSG_REQUESTSOUND, SND_REQ_PROJ_HIT_CRE, (LPARAM)&sndInd);

							pCre->CREPlaySound(sndInd);
						}

						SetFlag(ENTITY_FLAG_POLLDEATH, true);
					}
				}
			}

			if(!m_bBounce || m_bounceCur == m_bounceMax)
				SetFlag(ENTITY_FLAG_POLLDEATH, true);
			else
			{
				//bounce off
				gfxTrace *pTrace = (gfxTrace*)lParam;

				D3DXVECTOR3 norm(pTrace->norm), refl;

				float nd = D3DXVec3Dot(&GetDir(), &norm);

				refl = GetDir() - (2*nd*norm);

				SetDir(refl);

				m_bounceCur++;
			}
		}
		break;

	case ENTITYMSG_WORLDCOLLIDE:
		{
			if(!m_bBounce || m_bounceCur == m_bounceMax)
				SetFlag(ENTITY_FLAG_POLLDEATH, true);
			else
			{
				//bounce off
				gfxTrace *pTrace = (gfxTrace*)lParam;

				D3DXVECTOR3 norm(pTrace->norm), refl;

				float nd = D3DXVec3Dot(&GetDir(), &norm);

				refl = GetDir() - (2*nd*norm);

				SetDir(refl);

				m_bounceCur++;
			}
		}
		break;

	case ENTITYMSG_DEATH:
		//cool FX explosion
		break;

	case ENTITYMSG_ALLOWGRAVITY:
		//simply don't allow gravity
		return 0;
	}

	return RETCODE_SUCCESS;
}