Esempio n. 1
0
F32 LLDrawable::getVisibilityRadius() const
{
	if (isDead())
	{
		return 0.f;
	}
	else if (isLight())
	{
		const LLVOVolume *vov = getVOVolume();
		if (vov)
		{
			return llmax(getRadius(), vov->getLightRadius());
		} else {
			// llwarns ?
		}
	}
	return getRadius();
}
Esempio n. 2
0
void Monster::update() {
    if (canDie && isDead()) {
        return;
    }
    
    engine.map->computeFOV(*this);
    
    if (canSee(engine.player->x, engine.player->y)) {
        moveCount = TRACKING_TURNS;
    }
    else {
        --moveCount;
    }
    
    if (moveCount > 0) {
        moveOrAttack(engine.player->x, engine.player->y);
    }
}
void LLDrawable::updateTexture()
{
	if (isDead())
	{
		LL_WARNS() << "Dead drawable updating texture!" << LL_ENDL;
		return;
	}
	
	if (getNumFaces() != mVObjp->getNumTEs())
	{ //drawable is transitioning its face count
		return;
	}

	if (getVOVolume())
	{
		gPipeline.markRebuild(this, LLDrawable::REBUILD_MATERIAL, TRUE);
	}
}
Esempio n. 4
0
	bool Turret::canSee(EntityRef target_ref, bool simple_test) {
		const Entity *target = refEntity(target_ref);
		if(!target || isDead())
			return false;

		const FBox &box = boundingBox();
		const FBox &target_box = target->boundingBox();
		float dist = distance(box, target_box);
		float3 eye_pos = asXZY(box.center().xz(), box.min.y + box.height() * 0.75f);

		if(dist > max_distance)
			return false;

		if(simple_test)
			return true;

		//TODO: move to ThinkingEntity?
		return world()->isVisible(eye_pos, target_ref, ref(), target->typeId() == EntityId::actor? 4 : 3);
	}
int StickMan::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QGraphicsObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 2)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 2;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QColor*>(_v) = penColor(); break;
        case 1: *reinterpret_cast< QColor*>(_v) = fillColor(); break;
        case 2: *reinterpret_cast< bool*>(_v) = isDead(); break;
        }
        _id -= 3;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setPenColor(*reinterpret_cast< QColor*>(_v)); break;
        case 1: setFillColor(*reinterpret_cast< QColor*>(_v)); break;
        case 2: setIsDead(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 3;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 3;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
void kapalterbang::draw(){
	//TODO nanti harus diganti
	if (!isDead()) {
		if (isExploding()) {
			drawPicture(getX(),getY(),3,200,"explosion.txt","explosioncolor.txt");
			deadlifetime--;
		} else {
			//drawPicture(x,y,3,200,"plane2.txt",colorFileName);
			polygon bodydraw = body.hasilSkala(scale,scale);
			polygon windraw = window.hasilSkala(scale,scale);
			bodydraw.draw(x,y,255,255,255,255,false);
			windraw.draw(x,y,0,0,0,255,false);


		}
	}
		//drawText("BOOM",4,getX(),getY(),2,255,0,0,255);
	
}
Esempio n. 7
0
void HiddenSniper::draw()
{
	if (isDead())
	{
		return;
	}

	int sx = GET_SIGN((int)(_target->getPosition().x - getPosition().x));
	sx != 0 ? _scale.x = (float)sx : 0;

	if (_mobState == MOBS_STATE_WAIT)
		if (_shootedBullet == nullptr)
			_sprites[_status]->render(0, _position, ANGLE_NO, _scale, TRANSLATE_NO, DrawCenter::BOTTOMLEFT);
		else
		{
			_sprites[_status]->render(Timer::getRoundTime(), _position,
				ANGLE_NO, _scale, TRANSLATE_NO, DrawCenter::BOTTOMLEFT,
				COLOR_NO, -1, 0);

			if (((Sprite*)_sprites[_status])->isComplete())
				_shootedBullet = nullptr;
		}
	else if (_mobState == MOBS_STATE_ACTIVATE)
	{
		if (_status == HiddenSniperStatus::HIDDEN_SNIPER_HIDE)
		{
			if (_shootedBullet == nullptr)
			{
				_sprites[_status]->render(Timer::getRoundTime(), _position, ANGLE_NO,
					_scale, TRANSLATE_NO, DrawCenter::BOTTOMLEFT);

				if (((Sprite*)_sprites[_status])->isComplete())
					_status = (int)((_currentAimingAngle % 180 == 0 ? 0 : (1 + _currentAimingAngle / 180)));
			}
		}
		else
		{
			_sprites[_status]->render(
				Timer::getRoundTime(), _position, _visiblePercent.width, _visiblePercent.height, false, _scale, DrawCenter::BOTTOMLEFT);
		}
	}
}
Esempio n. 8
0
Action ComponentBrainShooter::getNextAction_chase(float milliseconds)
{
	if(!targetPlayer ||
		isDead(targetPlayer) ||
		(!canDetectPlayer(*targetPlayer) &&
		  getTimeInState()>resumeWanderThreshold))
	{
		nextState = StateWander;
	}
	
	ComponentPhysics* component =
	  dynamic_cast<ComponentPhysics*>(targetPlayer->getComponent("Physics"));
	
	if(!component)
		return Stand;

	vec3 playerPosition3D = component->getPosition();
	vec3 ourPosition3D = getPosition3D();

	vec2 playerPosition = playerPosition3D.xy();
	vec2 ourPosition = ourPosition3D.xy();

	float angle = getAngle(playerPosition, ourPosition);
	Direction desiredDirection = getDirectionFromAngle(angle);
	Direction currentFacing = getCurrentFacing();

	if(currentFacing == desiredDirection &&
	   getDistance(playerPosition, ourPosition) < shootDistance &&
	   rayCast(*targetPlayer,
	           ourPosition3D,
	           playerPosition3D - ourPosition3D,
	           maxSightDistance))
	{
		getParentBlackBoard().relayMessage(MessagePerformAction(Stand));
		return AttackOnce;
	}
	else
	{
		Action action = getActionFromAngle(angle);
		return action;
	}
}
Esempio n. 9
0
bool BabyDragon::onCollision(OEntity* entity)
{
	if (isDead()) return false;

	if (entity->getTypeId() == ENTITY_TYPE_ID_PLAYER)
	{
		isDeadFlag = true;
		Score::sCurrentScore += saveScore;
		return true;
	}
	else if (entity->getTypeId() == ENTITY_TYPE_ID_FIREBALL)
	{
		isDeadFlag = true;
		Score::sCurrentScore += killScore;
		OSound::sSoundController.onPlaySoundEffect(SOUND_ID_BABY);
		return true;
	}

	return false;
}
void CUser::MoveProcess(Packet & pkt)
{
	ASSERT(GetMap() != NULL);
	if (m_bWarp || isDead()) 
		return;
		
	uint16 will_x, will_z, will_y, speed=0;
	float real_x, real_z, real_y;
	uint8 echo;

	pkt >> will_x >> will_z >> will_y >> speed >> echo;
	real_x = will_x/10.0f; real_z = will_z/10.0f; real_y = will_y/10.0f;

	if (!GetMap()->IsValidPosition(real_x, real_z, real_y)) 
		return;

	// TO-DO: Ensure this is checked properly to prevent speedhacking
	m_curx = real_x;
	m_curz = real_z;
	m_cury = real_y;

	if (RegisterRegion())
	{
		g_pMain->RegionNpcInfoForMe(this);
		g_pMain->RegionUserInOutForMe(this);
		g_pMain->MerchantUserInOutForMe(this);
	}

	if (m_bInvisibilityType == INVIS_DISPEL_ON_MOVE)
		StateChangeServerDirect(7, INVIS_NONE);

	Packet result(WIZ_MOVE);
	result << GetSocketID() << will_x << will_z << will_y << speed << echo;
	SendToRegion(&result);

	GetMap()->CheckEvent(real_x, real_z, this);

	result.Initialize(AG_USER_MOVE);
	result << GetSocketID() << m_curx << m_curz << m_cury << speed;
	Send_AIServer(&result);
}
Esempio n. 11
0
void LLDrawable::markDead()
{
	if (isDead())
	{
		LL_WARNS() << "Warning!  Marking dead multiple times!" << LL_ENDL;
		return;
	}
	setState(DEAD);

	if (mSpatialBridge)
	{
		mSpatialBridge->markDead();
		mSpatialBridge = NULL;
	}

	sNumZombieDrawables++;

	// We're dead.  Free up all of our references to other objects
	cleanupReferences();
//	sDeadList.push_back(this);
}
Esempio n. 12
0
void Player::move(sf::Vector2f d)
{
    coord += sf::Vector2f(d);
    rect.move(d);
    hitBox.move(d);
    float viewOrd = (scene->getCam()).y;
    if(coord.y < viewOrd - 150) {
		scene->setCam(scene->getCam()+(sf::Vector2f(0, (d.y < 0)?d.y:0)));
	}
    else if(coord.y > viewOrd+200)
    {
		if(viewOrd < scene->getHeight()-100) // TEST ME
			scene->setCam(scene->getCam()+(sf::Vector2f(0, (d.y > 0)?d.y:0)));
		else
			scene->setCam(sf::Vector2f(scene->getCam().x, 300));
    }
    isDead();

    //graphiques
    updateAnim(d);
}
LLViewerOctreeGroup* LLViewerOctreeGroup::getParent()
{
	if (isDead())
	{
		return NULL;
	}

	if(!mOctreeNode)
	{
		return NULL;
	}
	
	OctreeNode* parent = mOctreeNode->getOctParent();

	if (parent)
	{
		return (LLViewerOctreeGroup*) parent->getListener(0);
	}

	return NULL;
}
Esempio n. 14
0
void LLDrawable::updateTexture()
{
	LLMemType mt(LLMemType::MTYPE_DRAWABLE);
	
	if (isDead())
	{
		llwarns << "Dead drawable updating texture!" << llendl;
		return;
	}
	
	if (getNumFaces() != mVObjp->getNumTEs())
	{ //drawable is transitioning its face count
		return;
	}

	if (getVOVolume())
	{
		//getVOVolume()->mFaceMappingChanged = TRUE;
		gPipeline.markRebuild(this, LLDrawable::REBUILD_MATERIAL, TRUE);
	}
}
Esempio n. 15
0
const XC::Matrix &XC::CorotTruss::getMass(void) const
  {
    Matrix &Mass = *theMatrix;
    Mass.Zero();

    const double rho= getRho();
    // check for quick return
    if(Lo == 0.0 || rho == 0.0)
      return Mass;

    double M = 0.5*rho*Lo;
    int numDOF2 = numDOF/2;
    for(int i = 0; i < getNumDIM(); i++)
      {
        Mass(i,i)                 = M;
        Mass(i+numDOF2,i+numDOF2) = M;
      }
    if(isDead())
      (*theMatrix)*=dead_srf;
    return *theMatrix;
  }
void LLDrawable::markDead()
{
	if (isDead())
	{
		llwarns << "Warning!  Marking dead multiple times!" << llendl;
		return;
	}

	if (mSpatialBridge)
	{
		mSpatialBridge->markDead();
		mSpatialBridge = NULL;
	}

	sNumZombieDrawables++;

	// We're dead.  Free up all of our references to other objects
	setState(DEAD);
	cleanupReferences();
//	sDeadList.put(this);
}
Esempio n. 17
0
void LLDrawable::destroy()
{
	if (isDead())
	{
		sNumZombieDrawables--;
	}

	if (LLSpatialGroup::sNoDelete)
	{
		llwarns << "Illegal deletion of LLDrawable!" << llendl;
	}

	std::for_each(mFaces.begin(), mFaces.end(), DeletePointer());
	mFaces.clear();
		
	
	/*if (!(sNumZombieDrawables % 10))
	{
		llinfos << "- Zombie drawables: " << sNumZombieDrawables << llendl;
	}*/	
}
Esempio n. 18
0
    void optimize_no_outbound() {
	// Non-accepting states with no outbound transitions may be
	// deleted.  Then, any arcs feeding those states, and perhaps those
	// states...

	// Vertex::m_user begin: 1 indicates on the work list
	// (Otherwise we might have nodes on the list twice, and reference after deleting them.)
	m_graphp->userClearVertices();

	// Find all dead vertexes
	stack<DfaVertex*> workps;
	for (V3GraphVertex* vertexp = m_graphp->verticesBeginp(); vertexp; vertexp=vertexp->verticesNextp()) {
	    if (DfaVertex* vvertexp = dynamic_cast<DfaVertex*>(vertexp)) {
		workps.push(vvertexp);
		vertexp->user(1);
	    } else {
		// If ever remove this, need dyn cast below
		v3fatalSrc("Non DfaVertex in dfa graph");
	    }
	}

	// While deadness... Delete and find new dead nodes.
	while (!workps.empty()) {
	    DfaVertex* vertexp = workps.top(); workps.pop();
	    vertexp->user(0);
	    if (isDead(vertexp)) {
		// Add nodes that go here to the work list
		for (V3GraphEdge* edgep = vertexp->inBeginp(); edgep; edgep=edgep->inNextp()) {
		    DfaVertex* fromvertexp = static_cast<DfaVertex*>(edgep->fromp());
		    if (fromvertexp != vertexp
			&& !fromvertexp->user()) {
			workps.push(static_cast<DfaVertex*>(fromvertexp));
			fromvertexp->user(1);
		    }
		}
		// Transitions to this state removed by the unlink function
		vertexp->unlinkDelete(m_graphp); vertexp=NULL;
	    }
	}
    }
Esempio n. 19
0
	//--------------------------------------------------------------------------
	void AIController::update( Flt delta )
	{
		if(!mBaseAIGroup)
			return;

		if(mPauseThinkTime > 0)
		{
			mPauseThinkTime -= delta;
			return;
		}

		if(isDead())
		{
			return;
		}

		switch(mState)
		{
		case ACS_BIRTH:
			setPeaceState();
			break;

		case ACS_PEACE:
			break;

		case ACS_STARTFIGHT:
			break;

		case ACS_FIGHT:
			updateFightState(delta);
			break;

		case ACS_ENDFIGHT:
			break;

		case ACS_RETURN:
			updateReturn(delta);
			break;
		}
	}
Esempio n. 20
0
void IndianaJonesUnit::update() {
	if (isDead() || reachedGoal){
		return;
	}

	if (slowtimer > 0) {
		slowtimer -= gameEngine->deltaTime.asMilliseconds();

		if (slowtimer <= 0) {
			speed = maxspeed;
			slowed = false;
		}
	}

	updateMovement();

	sf::Vector2f offset(moveDirection.x * speed * gameEngine->deltaTime.asMilliseconds(), (moveDirection.y * speed * gameEngine->deltaTime.asMilliseconds()));

	posX += offset.x;
	posY += offset.y;
	moveHealthBar(offset);


	moveAnimations[currentMoveAnimationIndex]->setPos(posX, posY);


	moveAnimations[currentMoveAnimationIndex]->update();


	float percentageHP = currentHealth / maxHealth;
	if (percentageHP < 0) {
		percentageHP = 0;
	}
	healthBarFG->setSize(healthBarBG->getSize().x * percentageHP, healthBarFG->getSize().y);

	groundTilesChanged = false;
	towerRemoved = false;

}
Esempio n. 21
0
void Building::attackLogic(){
	MapModel *mm = MapModel::getModel();
	if (isDead()){
		mm->buildingDelete(this);
		return;
	}

	if (!_states.empty()){
		_states.back()->execute();
		_states.popBack();
	}

	tryToAttack();
	/*
	MapModel *mm = MapModel::getModel();
	auto target = mm->getClosestTroop(this);

	if (target != nullptr){
		bool could_attack = false;

		for (int tr = 0; tr < occupy.X; tr++) for (int tc = 0; tc < occupy.Y; tc++){
			Point pt = Point(getCoord().x + tr, getCoord().y + tc);
			Point moveVector = pt - target->getCoord();
			if (MAX(abs(moveVector.x), abs(moveVector.y)) <= 1) could_attack = true;
		}

		if (could_attack){
			//attack troop
			CCLOG("building attack");
			target->hp -= MAX(0, atk - target->def);
			CCLOG("attack : hp = %d, atk = %d, def = %d\n", hp, atk, def);
			CCLOG("defend : hp = %d, atk = %d, def = %d\n", target->hp, target->atk, target->def);

			if (target->hp <= 0) mm->troopDelete(target);

			//troop->runAction(Sequence::create(RotateTo::create(rotateDuration, cocosAngle), NULL));
		}
	}*/
}
Esempio n. 22
0
bool Axe::useOn(std::shared_ptr<Entity> other, float strength)
{
	bool success = false;
	if (isDead())
		return false;

	std::shared_ptr<Tree> tree = std::dynamic_pointer_cast<Tree>(other);

	if (tree)
	{
		tree->chop(strength);
		success = true;
		
		uses+=strength;

	}
	//there are 100hp on 1 tree
	if (uses > 350.f)
		kill();

	return success;
}
//------------------------------ Update ---------------------------------------
//-----------------------------------------------------------------------------
void SplashContinuousSkill::update(double time_elapsed)
{
	/*if (Clock.getCurrentTime() > _survive_time + _time_of_creation)
	{
		_dead = true;
	}
	*/

	if (isDead())
		return;

	_activated = _activate_strategy->test();

	
	if (_activated)
	{
		_impact_strategy->impact();
	}

	//updateMovement(time_elapsed);
	
}
Esempio n. 24
0
//////////////////////////
//更新
///////////////////////////
void NPC::update(std::list< NPC* >_NPC)
{

	//攻撃目標が制圧できた場合次の攻撃目標を探す
	if (pole[targetID]->type == type)
	{
		targetPos = searchTarget();
	}

	targetPos = enemyTarget(_NPC);

	//敵とターゲットの距離
	const auto toTarget =
		(pos.x - targetPos.x) * (pos.x - targetPos.x)
		+ (pos.z - targetPos.z) * (pos.z - targetPos.z);

	//攻撃可能距離
	const auto onAttack = 30;

	//ターゲットの方向に向く
	yaw = atan2(targetPos.x - pos.x, targetPos.z - pos.z) * 180 / M_PI;

	attackCount--;
	stepCount--;


	if (isDead() == false)
	{//死んでいなければ行動する
		move(toTarget, onAttack);
		attack(toTarget, onAttack);
	}
	else
	{//死んでいたらカウントが増える
		if (HP < 0) HP = 0;
		isDeadTimer++;
	}

}
Esempio n. 25
0
//! @brief Return the mass matrix.
const XC::Matrix &XC::FourNodeQuad::getMass(void) const
  {
    K.Zero();

    static Vector rhoi(4);
    rhoi= physicalProperties.getRhoi();
    double sum = this->physicalProperties.getRho();
    for(int i= 0;i<rhoi.Size();i++)
      sum += rhoi[i];

    if(sum != 0.0)
      {
        double rhodvol, Nrho;

        // Compute a lumped mass matrix
        for(size_t i= 0;i<physicalProperties.size();i++)
          {
            // Determine Jacobian for this integration point
            const GaussPoint &gp= getGaussModel().getGaussPoints()[i];
            rhodvol = this->shapeFunction(gp);

            // Element plus material density ... MAY WANT TO REMOVE ELEMENT DENSITY
            double tmp = physicalProperties.getRho() + rhoi[i];
            rhodvol*= (tmp*physicalProperties.getThickness()*gp.weight());

            for(int alpha = 0, ia = 0; alpha<numNodes(); alpha++, ia++)
              {
                Nrho = shp[2][alpha]*rhodvol;
                K(ia,ia) += Nrho;
                ia++;
                K(ia,ia) += Nrho;
              }
          }
      }
    if(isDead())
      K*=dead_srf;
    return K;
  }
void CreatureObject::onIncapRecovery(const IncapRecoveryEvent* event)
{
    if (isDead())
    {
        // Forget it, you are dead!
        return;
    }

    if (this->getType() == ObjType_Player)
    {
        mCurrentIncapTime = 0;
        gMessageLib->sendIncapTimerUpdate(this);
        // unblock so we can transition out
        this->states.unblock();
        gStateManager.setCurrentPostureState(this, CreaturePosture_Upright);

        // reset ham regeneration
        //if (mHam.getTaskId() == 0)
        //{
        //	mHam.setTaskId(gWorldManager->addCreatureHamToProccess(&mHam));
        //}
    }
}
Esempio n. 27
0
File: Bone.cpp Progetto: bog2k3/bugs
void Bone::draw(RenderContext const& ctx) {
	if (committed_) {
		// nothing to draw, physics will draw for us
#ifdef DEBUG_DRAW_BONE
		if (isDead()) {
			float ratio = sqrt((getFoodValue() / density_) / size_);
			float widthLeft = width_ * ratio;
			float lengthLeft = length_ * ratio;
			glm::vec3 worldTransform = getWorldTransformation();
			Shape3D::get()->drawRectangleXOYCentered(vec3xy(worldTransform),
				glm::vec2(lengthLeft, widthLeft), worldTransform.z, glm::vec3(0.5f,0,1));
		}
#endif
	} else {
		glm::vec3 worldTransform = getWorldTransformation();
		Shape3D::get()->drawRectangleXOYCentered(vec3xy(worldTransform),
				glm::vec2(length_, width_), worldTransform.z, debug_color);
		Shape3D::get()->drawLine(
				{vec3xy(worldTransform), 0},
				{vec3xy(worldTransform) + glm::rotate(getChildAttachmentPoint(0), worldTransform.z), 0},
				debug_color);
	}
}
Esempio n. 28
0
string Character::getDiscription()
{
	if (isDead())
	{
		return "dood";
	}
	else if (lifepoints == maxLifepoints)
	{
		return "ongeschonden";
	}
	else  if (lifepoints > maxLifepoints / 2)
	{
		return "gewond";
	}
	else if (lifepoints < maxLifepoints / 4)
	{
		return "ernstig gewond";
	}
	else if (lifepoints < maxLifepoints < 8)
	{
		return "bijna dood";
	}
}
Esempio n. 29
0
void Animal::startStop()
{
    if (isDead()) {
        return;
    }

    if (_state != AnimalState::Stop) {
        _state = AnimalState::Stop;
        _timeline->play("stop", true);
    }

    if (isOpponent() == false) {
        _stopMoveAction();
        _moveAction = runAction(Sequence::create(
                                    DelayTime::create(1.5f),
        CallFunc::create([this] {
            startFreeAction();
        }),
        NULL
                                ));
        _moveAction->retain();
    }
}
Esempio n. 30
0
bool CAttackState::Update(time_point tick)
{
    auto PTarget = static_cast<CBattleEntity*>(GetTarget());
    if (!PTarget || PTarget->isDead())
    {
        return true;
    }
    if (AttackReady())
    {
        //CanAttack may have set target id to 0 (disengage from out of range)
        if (m_PEntity->GetBattleTargetID() == 0)
        {
            return true;
        }
        if (CanAttack(PTarget))
        {
            action_t action;
            if (m_PEntity->OnAttack(*this, action))
            {
                m_PEntity->loc.zone->PushPacket(m_PEntity, CHAR_INRANGE_SELF, new CActionPacket(action));
            }
        }
        else if (m_PEntity->OnAttackError(*this))
        {
            m_PEntity->HandleErrorMessage(m_errorMsg);
        }
        if (m_PEntity->GetBattleTargetID() == 0)
        {
            return true;
        }
    }
    else
    {
        m_attackTime -= (m_PEntity->PAI->getTick() - m_PEntity->PAI->getPrevTick());
    }
    return false;
}