Ejemplo n.º 1
0
void Bullet::doSomething()
{
    if(!isAlive())
        return;
    
    int x = getWorld()->getXcoordOfNext(getX(), getDirection());
    int y = getWorld()->getYcoordOfNext(getY(), getDirection());
    Actor* q = getWorld()->returnActor(getX(), getY());         //return actor at bullet's current position
    Actor* p = getWorld()->returnActor(x, y);                   //return actor at bullet's next position
    
    if(q != nullptr && !getWorld()->BulletCanPass(q))   //checks bullet's current position
    {
        setDead();                                          //kill bullet if it hits something it can't pass
        setVisible(false);
        if(getWorld()->canBeHit(getX(), getY()))            //if actor can be hit, then hit it
            getWorld()->HitIt(getX(), getY());
        return;
    }
    
    moveTo(x, y);                                       //moves bullet to adjacent position

    if(p != nullptr && !getWorld()->BulletCanPass(p))    //checks bullet's next position
    {
        setDead();
        setVisible(false);
        if(getWorld()->canBeHit(getX(), getY()))
            getWorld()->HitIt(getX(), getY());
        return;
    }
    
    
}
Ejemplo n.º 2
0
bool CEnemy::update(float time_elapsed_ms,CNode * nodes)
{
	if(!isDead())
	{
		//update position
		updatePos(time_elapsed_ms);
		//if at each waypoint
		if(DistanceCheck())
		{
			setCurrNode(&nodes[getNodeIndex()+1]);
			setNodeIndex(getNodeIndex()+1);
			//special check for end waypoint
			//if at the end waypoint
			if(getNodeIndex() == ENDNODE)
			{
				if(!isDead())
				{
					setDead(true);
				}
				return true;
				//life minuses here
				//reset mob
				//change to wavemanager later
			//	enemyArray[i].spawn(currType,currLevel);
			//	enemyArray[i].setNodeIndex(0);
			//	enemyArray[i].setPos(NodeArray[0].getPos());
			}
		}
	}
	return false;
}
void LLViewerPartSourceChat::update(const F32 dt)
{
	if (!mImagep)
	{
		mImagep = LLViewerTextureManager::getFetchedTextureFromFile("pixiesmall.j2c");
	}


	const F32 RATE = 0.025f;

	mLastUpdateTime += dt;

	if (mLastUpdateTime > 2.f)
	{
		// Kill particle source because it has outlived its max age...
		setDead();
		return;
	}

	F32 dt_update = mLastUpdateTime - mLastPartTime;

	// Clamp us to generating at most one second's worth of particles on a frame.
	F32 max_time = llmax(1.f, 10.f*RATE);
	dt_update = llmin(max_time, dt_update);

	if (dt_update > RATE)
	{
		mLastPartTime = mLastUpdateTime;
		if (!LLViewerPartSim::getInstance()->shouldAddPart())
		{
			// Particle simulation says we have too many particles, skip all this
			return;
		}

		if (!mSourceObjectp.isNull() && !mSourceObjectp->mDrawable.isNull())
		{
			mPosAgent = mSourceObjectp->getRenderPosition();
		}
		LLViewerPart* part = new LLViewerPart();
		part->init(this, mImagep, updatePart);
		part->mStartColor = mColor;
		part->mEndColor = mColor;
		part->mEndColor.mV[3] = 0.f;
		part->mPosAgent = mPosAgent;
		part->mMaxAge = 1.f;
		part->mFlags = LLViewerPart::LL_PART_INTERP_COLOR_MASK;
		part->mLastUpdateTime = 0.f;
		part->mScale.mV[0] = 0.25f;
		part->mScale.mV[1] = 0.25f;
		part->mParameter = ll_frand(F_TWO_PI);
		part->mBlendFuncDest = LLRender::BF_ONE_MINUS_SOURCE_ALPHA;
		part->mBlendFuncSource = LLRender::BF_SOURCE_ALPHA;
		part->mStartGlow = 0.f;
		part->mEndGlow = 0.f;
		part->mGlow = LLColor4U(0, 0, 0, 0);


		LLViewerPartSim::getInstance()->addPart(part);
	}
}
Ejemplo n.º 4
0
Ship* Ship::removeShipFromFleet(const uint inShipId)
{
    Q_ASSERT(m_shipType == ShipTypeEnum::ST_FLEET);
    Ship* shipToRemove = 0;
    for(int i = 0; i < m_fleetShips.count(); i++)
    {
        if(m_fleetShips.at(i)->id() == inShipId)
        {
            shipToRemove = m_fleetShips[i];
            m_fleetShips.remove(i);
            break;
        }
    }

    Q_ASSERT(shipToRemove);

    // tell shipToRemove to be removed from fleet
    ShipInfo fleetInfo = info();
    shipToRemove->removeFromFleet(fleetInfo);

    // fleet is empty
    if(m_fleetShips.count() == 0)
    {   // we removed the last one
        setDead();
    }

    updateFleet();
    return shipToRemove;
}
Ejemplo n.º 5
0
bool EntityHP::update()
{
  if (getHP() <= 0.)
    {
      setDead(true);
    }
  return Entity::update();
}
Ejemplo n.º 6
0
void Player::die()
{
	setDead(true);
	deathTimeStamp = glutGet(GLUT_ELAPSED_TIME);
	parent->killAllEntities();
	Explosion e = Explosion(parent, location, "resources/particle.png", 100, 70);
	livesRemaining--;
}
Ejemplo n.º 7
0
void Squirt::doSomething(){
    if(travelDistance == 0 || getWorld()->annoyAllNearbyActors(this, 2, 3)) {
        setDead();
        return;
    }
    travelDistance--;
    move(getDirection());
}
Ejemplo n.º 8
0
void Boulder::doSomething(){
    if(!isAlive()) return;
    if(m_waitCount == 0){
        m_isWaiting = false;
        if(getWorld()->canActorMove(this, down)){
            move(down);
            if(getWorld()->annoyAllNearbyActors(this, 100, 3)) setDead();
        } else setDead();
    }
    if(m_isWaiting){
        m_waitCount--;
        return;
    }
    else if (getWorld()->canActorMove(this, down)){
        m_isWaiting = true;
    }
}
Ejemplo n.º 9
0
void Player::doSomething()
{
	int dir;
	StudentWorld *sw = getWorld();

	if(sw->getKey(dir)) //if there is an input
	{
		switch(dir)
		{
		case KEY_PRESS_SPACE:
			if(canShoot) //if the player can shoot a water droplet during this tick
			{
				int x, y;
				getLocation(x, y);

				//Determine the water droplets' positions first
				int dropletX = x;
				int dropletY = y+1;

				//while(dropletX>=0 && dropletX<GARDEN_WIDTH && dropletY>=0 && dropletY<GARDEN_HEIGHT)
				while(dropletX<=GARDEN_WIDTH-1 && dropletY<=GARDEN_HEIGHT-1)
				{
					if(getWorld()->insectThere(dropletX, dropletY) || getWorld()->mushroomThere(dropletX, dropletY))
					{
						getWorld()->attackObjects(dropletX, dropletY); //attack that object and give player points
						break; //no more droplets are to be shot!
					}
					else
					{
						WaterDroplet* w = new WaterDroplet(getWorld(), dropletX, dropletY); //Display a new water droplet
						getWorld()->storeObject(w);
						dropletY++; //Update the position of the next possible water droplet
					}
				}

				canShoot=false; //if a water droplet was shot this tick, make it so that one cannot be shot next tick
			}
			else
				canShoot=true; //if this round, no water droplet was shot, then one can be shot next tick
			break;
		default:
			movePlayer(dir); //if a key is pressed, move in that direction
			canShoot=true; //this counts as another tick, so next tick, another water droplet can be shot
			break;
		}
	}
	else
	{
		canShoot=true; //if canShoot was false earlier, no WaterDroplet was shot. Next round, the player can shoot again
	}

	int x, y;
	getLocation(x, y);
	if(getWorld()->insectThere(x, y)) //if the player is at or moves onto an insect, kill the player
		setDead();
	

}
Ejemplo n.º 10
0
bool ActivatingObject::ActivateIfNecessary() {
    FrackMan* a = getWorld()->findNearbyFrackMan(this, 3);
    if(getWorld()->isNearFrackMan(this, 3)){
        setDead();
        getWorld()->increaseScore(ptValue);
        getWorld()->playSound(sound);
    }
    return a;
}
Ejemplo n.º 11
0
void Particle::postRender(const flat2d::GameData *data)
{
	if (!deathTimer.isStarted()) {
		deathTimer.start();
	}
	if (!isDead()) {
		setDead(deathTimer.getTicks() > 3000);
	}
}
Ejemplo n.º 12
0
void GoldNugget::doSomething(){
    if(!wasDropped){
        ActivatingObject::doSomething();
        if(!isAlive()) getWorld()->giveFrackManGold();
    } else {
        if(getRemainingLifetime() == 0){
            setDead();
            return;
        }
        setTicksToLive(getRemainingLifetime()-1);
        Actor* a = getWorld()->findNearbyProtester(this, 3);
        if(a){
            a->addGold();
            getWorld()->increaseScore(25);
            setDead();
        }
    }
    
}
Ejemplo n.º 13
0
Unit::Unit(float pos_x, float pos_y, std::string name) :
  EntityAction(pos_x, pos_y, UNIT_INV_CAP)
{
  setSprite( new Sprite(pos_x, pos_y, UNIT_CLICK_WIDTH, UNIT_CLICK_HEIGHT, UNIT_CLICK_OFFSET_X, UNIT_CLICK_OFFSET_Y) );
  setPosX(pos_x);
  setPosY(pos_y);
  setName(name);
  
  setDead(false);
}
Ejemplo n.º 14
0
Resource::Resource(float pos_x, float pos_y, int type, float amount) :
  Entity(pos_x, pos_y)
{
  setSprite( new Sprite(pos_x, pos_y, RES_CLICK_WIDTH, RES_CLICK_HEIGHT, RES_CLICK_OFFSET_X, RES_CLICK_OFFSET_Y) );
  //  setPosX(pos_x);
  //setPosY(pos_y);
  setDead(false);

  setType(type);
  setAmount(amount);
}
Ejemplo n.º 15
0
bool FrackMan::annoy(unsigned int amount){
    if(Agent::annoy(amount)){
        getWorld()->playSound(SOUND_PLAYER_GIVE_UP);
        setDead();
        return true;
    }
    else{
        getWorld()->playSound(SOUND_PLAYER_ANNOYED);
        return false;
    }
}
Ejemplo n.º 16
0
void WalkThroughWallsGoodie::doSomething()
{
	Goodie::doSomething();

	if (getWorld()->getPlayer()->getX() == getX() &&
		getWorld()->getPlayer()->getY() == getY())
	{
		getWorld()->getPlayer()->PickUpWalkThroughWallsGoodie();
		getWorld()->increaseScore(1000);
		getWorld()->playSound(SOUND_GOT_GOODIE);
		setDead();
	}
}
Ejemplo n.º 17
0
void BoostSprayerGoodie::doSomething()
{
	Goodie::doSomething();

	if (getWorld()->getPlayer()->getX() == getX() &&
		getWorld()->getPlayer()->getY() == getY())
	{
		getWorld()->getPlayer()->PickUpBoosterSprayerGoodie();
		getWorld()->increaseScore(1000);
		getWorld()->playSound(SOUND_GOT_GOODIE);
		setDead();
	}
}
Ejemplo n.º 18
0
void ExtraLifeGoodie::doSomething()
{
	Goodie::doSomething();

	if (getWorld()->getPlayer()->getX() == getX() &&
		getWorld()->getPlayer()->getY() == getY())
	{
		getWorld()->getLives();
		getWorld()->increaseScore(1000);
		getWorld()->playSound(SOUND_GOT_GOODIE);
		setDead();
	}
}
Ejemplo n.º 19
0
void BugSprayer::doSomething()
{
	if (!isAlive())
		return;

	setTicks(getTicks() - 1);

	//if dead, explode
	if (getTicks() == 0)
	{
		setDead();
	}
}
Ejemplo n.º 20
0
void Spider::doSomething()
{
	if(restNow)
	{
		restNow=false; //rest every other tick
		return;
	}

	int x, y;
	getLocation(x, y); //get its current location

	if(m_distance==0) //if its distance is 0, flip its vertical direction and select a new distance
	{
		if(!movingDown) //if moving up
		{
			movingDown=true;	
			m_distance=randInt(1, y-1);
		}
		else //if moving down
		{
			movingDown=false;
			m_distance=randInt(1, GARDEN_HEIGHT-y-1);
		}
	}

	int newx, newy; //calculate the new diagonal location
	
	if(movingDown)
		newy=y-1;
	else
		newy=y+1;

	if(movingRight)
		newx=x+1;
	else
		newx=x-1;

	m_distance--; //decrement its vertical direction

	if(getWorld()->mushroomThere(newx, newy))
		getWorld()->removeMushroom(newx, newy); //if there is a mushroom, remove it

	if(newx<0 || newx>=GARDEN_WIDTH || newy<0 || newy>=GARDEN_HEIGHT) //if it moves out of bounds, set it to dead
		setDead();
	else
		moveTo(newx, newy); //move the spider

	getWorld()->killPlayer(newx, newy); //if it lands on player, kill it

	restNow=true; //if it didn't rest this tick, next tick it will rest
}
Ejemplo n.º 21
0
void Player::movePlayer(int dir)
{
	int curx, cury;
	getLocation(curx, cury); //get the current location

	if(dir==KEY_PRESS_LEFT_ARROW && curx!=0) //as long as the new p osition is within bounds
	{
		if(getWorld()->insectThere(curx-1, cury)) //if there's an insect there, kill the player
			setDead();

		if(!getWorld()->mushroomThere(curx-1, cury)) //if there's no mushroom there, then the player can move there
			moveTo(curx-1, cury);
	}
	else if(dir==KEY_PRESS_RIGHT_ARROW && curx!=GARDEN_WIDTH-1)
	{
		if(getWorld()->insectThere(curx+1, cury))
			setDead();

		if(!getWorld()->mushroomThere(curx+1, cury))
			moveTo(curx+1, cury);
	}
	else if(dir==KEY_PRESS_UP_ARROW && cury!=3)
	{
		if(getWorld()->insectThere(curx, cury+1))
			setDead();

		if(!getWorld()->mushroomThere(curx, cury+1))
			moveTo(curx, cury+1);
	}
	else if(dir==KEY_PRESS_DOWN_ARROW && cury!=0)
	{
		if(getWorld()->insectThere(curx, cury-1))
			setDead();

		if(!getWorld()->mushroomThere(curx, cury-1))
			moveTo(curx, cury-1);
	}
}
Ejemplo n.º 22
0
void Ship::takeDamage(const float inOpponentForce)
{
    if(m_shipType == ShipTypeEnum::ST_BATTLESHIP)
    {
        m_damage  =  m_damage  + inOpponentForce/m_technology;
        if(m_damage < 0.99f)
            return;
    }
    else if(m_shipType == ShipTypeEnum::ST_FLEET)
    {
        // count battleships and fleets in this fleet
        uint numMember = 0;
        for(Ship *s : m_fleetShips)
        {
            ShipTypeEnum memberType = s->info().shipType;
            if(memberType == ShipTypeEnum::ST_FLEET or memberType == ShipTypeEnum::ST_BATTLESHIP)
                numMember++;
        }
        if(numMember == 0)
        {
            setDead();
            return;
        }
        // every battleship/fleet member gets a part of the damage
        float opponentForcePart = inOpponentForce / numMember;
        for(Ship *s : m_fleetShips)
        {
            ShipTypeEnum memberType = s->info().shipType;
            if(memberType == ShipTypeEnum::ST_FLEET or memberType == ShipTypeEnum::ST_BATTLESHIP)
                s->takeDamage(opponentForcePart);
        }
        updateFleet();
        return;
    }

    // every other shiptype:
    setDead();
}
Ejemplo n.º 23
0
 void clear()
 {
     if(!v_)
         return;
     int i=(int)v_->size();
     auto &v = *v_;
     while(i-->0){
         auto l = v.at(i).get();
         l->setDead();
         l->setNode(nullptr);
     }
     delete v_;
     v_=nullptr;
 }
Ejemplo n.º 24
0
void Scorpion::doSomething()
{
	int x, y;
	getLocation(x, y); //get current location

	if(getWorld()->mushroomThere(x, y) && randInt(1, 3)==1) //if it's on a mushroom
		getWorld()->makeMushroomPoisonous(x, y); //there's a 33% chance of making it poisonous

	int newx=x+1; 

	if(newx<GARDEN_WIDTH-1) //move to the right if it's in bounds
		moveTo(newx, y);
	else
		setDead(); //otherwise, set it to dead

	getWorld()->killPlayer(newx, y); //if it lands on player, kill it
}
Ejemplo n.º 25
0
void Flea::doSomething()
{
	int x, y;
	getLocation(x, y); //get its current location

	if(!getWorld()->mushroomThere(x, y) && y>0 && y<GARDEN_HEIGHT-1) //if there's no mushroom there and it's within height bounds
		if(randInt(1, 4)==1)
			getWorld()->dropMushroom(x, y); //there's a 25% chance to drop a regular mushroom

	y--; //make the flea move down
	if(y<0) //if it leaves bottom bounds, set it to dead
		setDead();
	else
		moveTo(x, y); //otherwise, move to that new spot

	getWorld()->killPlayer(x, y);
}
Ejemplo n.º 26
0
bool Boulder::push(Direction dir)
{
    int a = getWorld()->getXcoordOfNext(getX(), dir);
    int b = getWorld()->getYcoordOfNext(getY(), dir);
    Actor* p = getWorld()->returnActor(a, b);               //return actor at Boulder's adjacent position
    if(p==nullptr)
    {
        moveTo(a, b);                                       //move boulder if adjacent position is empty
        return true;
    }
    else if(dynamic_cast<Hole*>(p) != nullptr)   //else if there is a hole, destroy both the hole and the boulder
    {
        p->setDead();
        moveTo(a, b);
        setDead();
        return true;
    }
    else
        return false;
}
Ejemplo n.º 27
0
void BugSpray::doSomething()
{
	if (!(isAlive()))
		return;

	setTicks(getTicks() - 1);

	if (getTicks() == 0)
		setDead();
	else
	{
		//Destroy Destroyable Brick
		if (getWorld()->getLev()->getContentsOf(getX(), getY()) == Level::destroyable_brick)
		{
			getWorld()->deadActor(getX(), getY(), IID_DESTROYABLE_BRICK);
		}

		//Destroy Player
		if (getWorld()->getPlayer()->getX() == getX() &&
			getWorld()->getPlayer()->getY() == getY())
		{
			getWorld()->getPlayer()->setDead();
		}

		//Destroy Zumi's
		Actor* actor = getWorld()->WhatActorHere(getX(), getY());
		SimpleZumi* sz = dynamic_cast<SimpleZumi*>(actor);
		ComplexZumi* cz = dynamic_cast<ComplexZumi*>(actor);
		if (sz)
			getWorld()->deadActor(getX(), getY(), IID_SIMPLE_ZUMI);
		else if (cz)
			getWorld()->deadActor(getX(), getY(), IID_COMPLEX_ZUMI);

		//Destory other Sprayers
		if (getWorld()->getSprayerCount() >= 1)
		{
			getWorld()->checkSprayer(getX(), getY());
		}
	}
}
Ejemplo n.º 28
0
void Mushroom::doSomething()
{
	if(m_health<=0) //check if it's out of health
		setDead(); //if so, set it dead
}
void LLViewerPartSourceScript::update(const F32 dt)
{
	if( mIsSuspended )
		return;

	LLMemType mt(LLMemType::MTYPE_PARTICLES);
	F32 old_update_time = mLastUpdateTime;
	mLastUpdateTime += dt;

	F32 ref_rate_travelspeed = llmin(LLViewerPartSim::getInstance()->getRefRate(), 1.f);
	
	F32 dt_update = mLastUpdateTime - mLastPartTime;

	// Update this for objects which have the follow flag set...
	if (!mSourceObjectp.isNull())
	{
		if (mSourceObjectp->isDead())
		{
			mSourceObjectp = NULL;
		}
		else if (mSourceObjectp->mDrawable.notNull())
		{
			mPosAgent = mSourceObjectp->getRenderPosition();
		}
	}

	if (mTargetObjectp.isNull() 
		&& mPartSysData.mTargetUUID.notNull())
	{
		//
		// Hmm, missing object, let's see if we can find it...
		//

		LLViewerObject *target_objp = gObjectList.findObject(mPartSysData.mTargetUUID);
		setTargetObject(target_objp);
	}

	if (!mTargetObjectp.isNull())
	{
		if (mTargetObjectp->isDead())
		{
			mTargetObjectp = NULL;
		}
		else if (mTargetObjectp->mDrawable.notNull())
		{
			mTargetPosAgent = mTargetObjectp->getRenderPosition();
		}
	}

	if (!mTargetObjectp)
	{
		mTargetPosAgent = mPosAgent;
	}

	if (mPartSysData.mMaxAge && ((mPartSysData.mStartAge + mLastUpdateTime + dt_update) > mPartSysData.mMaxAge))
	{
		// Kill particle source because it has outlived its max age...
		setDead();
		return;
	}


	if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PARTICLES))
	{
		if (mSourceObjectp.notNull())
		{
			std::ostringstream ostr;
			ostr << mPartSysData;
			mSourceObjectp->setDebugText(ostr.str());
		}
	}

	BOOL first_run = FALSE;
	if (old_update_time <= 0.f)
	{
		first_run = TRUE;
	}

	F32 max_time = llmax(1.f, 10.f*mPartSysData.mBurstRate);
	dt_update = llmin(max_time, dt_update);
	while ((dt_update > mPartSysData.mBurstRate) || first_run)
	{
		first_run = FALSE;
		
		// Update the rotation of the particle source by the angular velocity
		// First check to see if there is still an angular velocity.
		F32 angular_velocity_mag = mPartSysData.mAngularVelocity.magVec();
		if (angular_velocity_mag != 0.0f)
		{
			F32 av_angle = dt * angular_velocity_mag;
			LLQuaternion dquat(av_angle, mPartSysData.mAngularVelocity);
			mRotation *= dquat;
		}
		else
		{
			// No angular velocity.  Reset our rotation.
			mRotation.setQuat(0, 0, 0);
		}
		
		if (LLViewerPartSim::getInstance()->aboveParticleLimit())
		{
			// Don't bother doing any more updates if we're above the particle limit,
			// just give up.
			mLastPartTime = mLastUpdateTime;
            break;

		}
		
		// find the greatest length that the shortest side of a system
		// particle is expected to have
		F32 max_short_side =
			llmax(
			      llmax(llmin(mPartSysData.mPartData.mStartScale[0],
					  mPartSysData.mPartData.mStartScale[1]),
				    llmin(mPartSysData.mPartData.mEndScale[0],
					  mPartSysData.mPartData.mEndScale[1])),
			      llmin((mPartSysData.mPartData.mStartScale[0]
				     + mPartSysData.mPartData.mEndScale[0])/2,
				    (mPartSysData.mPartData.mStartScale[1]
				     + mPartSysData.mPartData.mEndScale[1])/2));
		
		F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio();

		// Maximum distance at which spawned particles will be viewable
		F32 max_dist = max_short_side * pixel_meter_ratio; 

		if (max_dist < 0.25f)
		{
			// < 1 pixel wide at a distance of >=25cm.  Particles
			// this tiny are useless and mostly spawned by buggy
			// sources
			mLastPartTime = mLastUpdateTime;
			break;
		}

		// Distance from camera
		F32 dist = (mPosAgent - LLViewerCamera::getInstance()->getOrigin()).magVec();

		// Particle size vs distance vs maxage throttling

		F32 limited_rate=0.f;
		if (dist - max_dist > 0.f)
		{
			if((dist - max_dist) * ref_rate_travelspeed > mPartSysData.mPartData.mMaxAge - 0.2f )
			{
				// You need to travel faster than 1 divided by reference rate m/s directly towards these particles to see them at least 0.2s
				mLastPartTime = mLastUpdateTime;
				break;
			}
			limited_rate = ((dist - max_dist) * ref_rate_travelspeed) / mPartSysData.mPartData.mMaxAge;
		}
		
		if(mDelay)
		{			
			limited_rate = llmax(limited_rate, 0.01f * mDelay--) ;
		}

		S32 i;
		for (i = 0; i < mPartSysData.mBurstPartCount; i++)
		{
			if (ll_frand() < llmax(1.0f - LLViewerPartSim::getInstance()->getBurstRate(), limited_rate))
			{
				// Limit particle generation
				continue;
			}

			LLViewerPart* part = new LLViewerPart();

			part->init(this, mImagep, NULL);
			part->mFlags = mPartSysData.mPartData.mFlags;
			if (!mSourceObjectp.isNull() && mSourceObjectp->isHUDAttachment())
			{
				part->mFlags |= LLPartData::LL_PART_HUD;
			}
			part->mMaxAge = mPartSysData.mPartData.mMaxAge;
			part->mStartColor = mPartSysData.mPartData.mStartColor;
			part->mEndColor = mPartSysData.mPartData.mEndColor;
			part->mColor = part->mStartColor;

			part->mStartScale = mPartSysData.mPartData.mStartScale;
			part->mEndScale = mPartSysData.mPartData.mEndScale;
			part->mScale = part->mStartScale;

			part->mAccel = mPartSysData.mPartAccel;

			if (mPartSysData.mPattern & LLPartSysData::LL_PART_SRC_PATTERN_DROP)
			{
				part->mPosAgent = mPosAgent;
				part->mVelocity.setVec(0.f, 0.f, 0.f);
			}
			else if (mPartSysData.mPattern & LLPartSysData::LL_PART_SRC_PATTERN_EXPLODE)
			{
				part->mPosAgent = mPosAgent;
				LLVector3 part_dir_vector;

				F32 mvs;
				do
				{
					part_dir_vector.mV[VX] = ll_frand(2.f) - 1.f;
					part_dir_vector.mV[VY] = ll_frand(2.f) - 1.f;
					part_dir_vector.mV[VZ] = ll_frand(2.f) - 1.f;
					mvs = part_dir_vector.magVecSquared();
				}
				while ((mvs > 1.f) || (mvs < 0.01f));

				part_dir_vector.normVec();
				part->mPosAgent += mPartSysData.mBurstRadius*part_dir_vector;
				part->mVelocity = part_dir_vector;
				F32 speed = mPartSysData.mBurstSpeedMin + ll_frand(mPartSysData.mBurstSpeedMax - mPartSysData.mBurstSpeedMin);
				part->mVelocity *= speed;
			}
			else if (mPartSysData.mPattern & LLPartSysData::LL_PART_SRC_PATTERN_ANGLE
				|| mPartSysData.mPattern & LLPartSysData::LL_PART_SRC_PATTERN_ANGLE_CONE)
			{				
				part->mPosAgent = mPosAgent;
				
				// original implemenetation for part_dir_vector was just:					
				LLVector3 part_dir_vector(0.0, 0.0, 1.0);
				// params from the script...
				// outer = outer cone angle
				// inner = inner cone angle
				//		between outer and inner there will be particles
				F32 innerAngle = mPartSysData.mInnerAngle;
				F32 outerAngle = mPartSysData.mOuterAngle;

				// generate a random angle within the given space...
				F32 angle = innerAngle + ll_frand(outerAngle - innerAngle);
				// split which side it will go on randomly...
				if (ll_frand() < 0.5) 
				{
					angle = -angle;
				}
				// Both patterns rotate around the x-axis first:
				part_dir_vector.rotVec(angle, 1.0, 0.0, 0.0);

				// If this is a cone pattern, rotate again to create the cone.
				if (mPartSysData.mPattern & LLPartSysData::LL_PART_SRC_PATTERN_ANGLE_CONE)
				{
					part_dir_vector.rotVec(ll_frand(4*F_PI), 0.0, 0.0, 1.0);
				}
								
				// Only apply this rotation if using the deprecated angles. 
				if (! (mPartSysData.mFlags & LLPartSysData::LL_PART_USE_NEW_ANGLE))
				{
					// Deprecated...
					part_dir_vector.rotVec(outerAngle, 1.0, 0.0, 0.0);
				}
				
				if (mSourceObjectp)
				{
					part_dir_vector = part_dir_vector * mSourceObjectp->getRenderRotation();
				}
								
				part_dir_vector = part_dir_vector * mRotation;
								
				part->mPosAgent += mPartSysData.mBurstRadius*part_dir_vector;

				part->mVelocity = part_dir_vector;

				F32 speed = mPartSysData.mBurstSpeedMin + ll_frand(mPartSysData.mBurstSpeedMax - mPartSysData.mBurstSpeedMin);
				part->mVelocity *= speed;
			}
			else
			{
				part->mPosAgent = mPosAgent;
				part->mVelocity.setVec(0.f, 0.f, 0.f);
				//llwarns << "Unknown source pattern " << (S32)mPartSysData.mPattern << llendl;
			}

			if (part->mFlags & LLPartData::LL_PART_FOLLOW_SRC_MASK ||	// SVC-193, VWR-717
				part->mFlags & LLPartData::LL_PART_TARGET_LINEAR_MASK) 
			{
				mPartSysData.mBurstRadius = 0; 
			}

			LLViewerPartSim::getInstance()->addPart(part);
		}

		mLastPartTime = mLastUpdateTime;
		dt_update -= mPartSysData.mBurstRate;
	}
}
Ejemplo n.º 30
0
void WaterDroplet::doSomething()
{
	m_ticks--; //every tick, the water droplet loses a tick count
	if(m_ticks<=0) //if it runs out, set it to dead
		setDead();
}