Beispiel #1
0
void Creature::onAddCondition(ConditionType_t type, bool hadCondition)
{
	switch(type)
	{
		case CONDITION_INVISIBLE:
		{
			if(!hadCondition)
				g_game.internalCreatureChangeVisible(this, VISIBLE_DISAPPEAR);

			break;
		}

		case CONDITION_PARALYZE:
		{
			if(hasCondition(CONDITION_HASTE, -1, false))
				removeCondition(CONDITION_HASTE);

			break;
		}

		case CONDITION_HASTE:
		{
			if(hasCondition(CONDITION_PARALYZE, -1, false))
				removeCondition(CONDITION_PARALYZE);

			break;
		}

		default:
			break;
	}
}
void Creature::onAddCondition(ConditionType_t type)
{
	if (type == CONDITION_PARALYZE && hasCondition(CONDITION_HASTE)) {
		removeCondition(CONDITION_HASTE);
	} else if (type == CONDITION_HASTE && hasCondition(CONDITION_PARALYZE)) {
		removeCondition(CONDITION_PARALYZE);
	}
}
Beispiel #3
0
void Creature::onAddCondition(const Condition* condition, bool preAdd /*= true*/)
{
	if(preAdd && condition->getName() == CONDITION_INVISIBLE.toString() && !hasCondition(CONDITION_INVISIBLE)){
		g_game.internalCreatureChangeVisible(this, false);
	}
	else if(condition->getMechanicType() == MECHANIC_PARALYZED){
		removeCondition(CONDITION_HASTE);
	}
	else if(condition->getName() == "haste" ){
		removeCondition(MECHANIC_PARALYZED);
	}
}
Beispiel #4
0
void ProcessView::contextMenuEvent(QContextMenuEvent* event)
{
    Q_UNUSED(event);

    const QModelIndex idx(this->selectionModel()->currentIndex());
    QMenu menu;

    if (isProcessVarItem(idx))
    {
        // QAction* saveCondAction  = menu.addAction("Save FEM Conditions...");
        QAction* removeProcessVarAction =
            menu.addAction("Remove process variable");
        // connect(saveCondAction, SIGNAL(triggered()), this,
        // SLOT(saveConditions()));
        connect(removeProcessVarAction, SIGNAL(triggered()), this,
                SLOT(removeProcessVar()));
    }
    else if (isConditionItem(idx))
    {
        QAction* removeCondAction = menu.addAction("Remove condition");
        connect(removeCondAction, SIGNAL(triggered()), this,
                SLOT(removeCondition()));
        // QAction* editCondAction = menu.addAction("Edit condition");
        // connect(editCondAction, SIGNAL(triggered()), this,
        // SLOT(editCondition()));  else  editCondAction->setEnabled(false);
    }

    menu.exec(event->globalPos());
}
Beispiel #5
0
void Monster::drainHealth(Creature* attacker, CombatType_t combatType, int32_t damage)
{
	Creature::drainHealth(attacker, combatType, damage);

	if(isInvisible())
		removeCondition(CONDITION_INVISIBLE);
}
Beispiel #6
0
bool Creature::setAttackedCreature(Creature* creature)
{
	if(creature)
	{
		const Position& creaturePos = creature->getPosition();
		if(creaturePos.z != getPosition().z || !canSee(creaturePos))
		{
			attackedCreature = NULL;
			return false;
		}
	}

	attackedCreature = creature;
	if(attackedCreature)
	{
		onTarget(attackedCreature);
		attackedCreature->onAttacked();
	}

	for(std::list<Creature*>::iterator cit = summons.begin(); cit != summons.end(); ++cit)
		(*cit)->setAttackedCreature(creature);

	Condition* condition = getCondition(CONDITION_LOGINPROTECTION, CONDITIONID_DEFAULT);
	if(condition)
		removeCondition(condition);

	return true;
}
Beispiel #7
0
void ProcessView::contextMenuEvent( QContextMenuEvent* event )
{
	Q_UNUSED(event);

	const QModelIndex idx(this->selectionModel()->currentIndex());
	QMenu menu;

	if (this->isProcessItem(idx))
	{
		QAction* saveCondAction  = menu.addAction("Save FEM Conditions...");
		QAction* removePCSAction = menu.addAction("Remove process");
		connect(saveCondAction, SIGNAL(triggered()), this, SLOT(saveConditions()));
		connect(removePCSAction, SIGNAL(triggered()), this, SLOT(removeProcess()));
	}
	else if (this->isListItem(idx))
	{
		QAction* removeCondAction = menu.addAction("Remove conditions");
		connect(removeCondAction, SIGNAL(triggered()), this, SLOT(removeCondition()));
	}
	else if (this->isConditionItem(idx))
	{
		QAction* editCondAction = menu.addAction("Edit condition");
		connect(editCondAction, SIGNAL(triggered()), this, SLOT(editCondition()));
	}

	menu.exec(event->globalPos());
}
Beispiel #8
0
void Actor::drainHealth(CombatType combatType, const CombatSource& combatSource, int32_t damage, bool showtext)
{
  Creature::drainHealth(combatType, combatSource, damage, showtext);

  if(isInvisible()){
    removeCondition(CONDITION_INVISIBLE);
  }
}
Beispiel #9
0
void Creature::onAddCondition(ConditionType_t type, bool hadCondition)
{
	if(type == CONDITION_INVISIBLE)
	{
		if(!hadCondition)
			g_game.internalCreatureChangeVisible(this, VISIBLE_DISAPPEAR);
	}
	else if(type == CONDITION_PARALYZE)
	{
		if(hasCondition(CONDITION_HASTE))
			removeCondition(CONDITION_HASTE);
	}
	else if(type == CONDITION_HASTE)
	{
		if(hasCondition(CONDITION_PARALYZE))
			removeCondition(CONDITION_PARALYZE);
	}
}
//--------------------------------------------------------------------------------
int QmvSqlQuery::addCondition( QmvQueryCondition * cond, int pos )
{
    if ( querylist.findRef( cond ) >= 0 )
        removeCondition( cond );
    
    if ( pos >= 0 && pos < querylist.count() )
        querylist.insert( pos, cond );
    else
        querylist.append( cond );

    if ( !conjunctive_index.find(cond) )
    {
        connect( cond, SIGNAL( queryChanged( QmvQueryCondition *, int, bool ) ),
                 this, SLOT( noticeChanges( QmvQueryCondition *, int, bool ) ) );
        conjunction_types * cj = new conjunction_types;
        *cj = QmvSqlQuery::And;
        conjunctive_index.insert( cond, cj );
    }
void Creature::onCombatRemoveCondition(const Creature* attacker, Condition* condition)
{
	removeCondition(condition);
}
Beispiel #12
0
void Creature::onCombatRemoveCondition(Condition* condition)
{
	removeCondition(condition);
}
Beispiel #13
0
void Creature::removeCondition(ConditionId id)
{
	removeCondition(id.toString());
}
Beispiel #14
0
void Creature::onCombatRemoveCondition(const CombatSource& combatSource, Condition* condition)
{
	removeCondition(condition);
}
Beispiel #15
0
// time to think about something new to do
void CHLDMBot :: getTasks (unsigned int iIgnore)
{
	static CBotUtilities utils;
	static CBotUtility *next;
	static CBotWeapon *gravgun;
	static CBotWeapon *crossbow;
	static CWeapon *pWeapon;
	static bool bCheckCurrent;

	if ( !hasSomeConditions(CONDITION_CHANGED) && !m_pSchedules->isEmpty() )
		return;

	removeCondition(CONDITION_CHANGED);

	bCheckCurrent = true; // important for checking current schedule

	gravgun = m_pWeapons->getWeapon(CWeapons::getWeapon(HL2DM_WEAPON_PHYSCANNON));

	// If I have the grav gun, think about picking something up
	if ( gravgun )
	{
		edict_t *pent = INDEXENT(gravgun->getWeaponIndex());

		if ( CBotGlobals::entityIsValid(pent) )
		{
			ADD_UTILITY(BOT_UTIL_HL2DM_GRAVIGUN_PICKUP,(!m_pEnemy||(m_pCurrentWeapon&&(strcmp("weapon_physcannon",m_pCurrentWeapon->GetClassName())))) && gravgun && gravgun->hasWeapon() && (m_NearestPhysObj.get()!=NULL) && (gravgun->getWeaponIndex() > 0) && (CClassInterface::gravityGunObject(INDEXENT(gravgun->getWeaponIndex()))==NULL),0.9f);
		}
	}

	if ( (crossbow = m_pWeapons->getWeapon(CWeapons::getWeapon(HL2DM_WEAPON_CROSSBOW))) != NULL )
	{
		if ( crossbow->hasWeapon() && !crossbow->outOfAmmo(this) )
			ADD_UTILITY(BOT_UTIL_SNIPE,true,0.91f);
	}

	// low on health? Pick some up if there's any near by
	ADD_UTILITY(BOT_UTIL_HL2DM_USE_HEALTH_CHARGER,(m_pHealthCharger.get() != NULL) && (CClassInterface::getAnimCycle(m_pHealthCharger)<1.0f) && (getHealthPercent()<1.0f),(1.0f-getHealthPercent()));
	ADD_UTILITY(BOT_UTIL_FIND_NEAREST_HEALTH,(m_pHealthKit.get()!=NULL) && (getHealthPercent()<1.0f),1.0f-getHealthPercent());

	// low on armor?
	ADD_UTILITY(BOT_UTIL_HL2DM_FIND_ARMOR,(m_pBattery.get() !=NULL) && (getArmorPercent()<1.0f),(1.0f-getArmorPercent())*0.75f);
	ADD_UTILITY(BOT_UTIL_HL2DM_USE_CHARGER,(m_pCharger.get() !=NULL) && (CClassInterface::getAnimCycle(m_pCharger)<1.0f) && (getArmorPercent()<1.0f),(1.0f-getArmorPercent())*0.75f);
	
	ADD_UTILITY(BOT_UTIL_HL2DM_USE_CRATE,(m_pAmmoCrate.get()!=NULL) && (m_fUseCrateTime < engine->Time()),1.0f);
	// low on ammo? ammo nearby?
	ADD_UTILITY(BOT_UTIL_FIND_NEAREST_AMMO,(m_pAmmoKit.get() !=NULL) && (getAmmo(0)<5),0.01f*(100-getAmmo(0)));

	// always able to roam around
	ADD_UTILITY(BOT_UTIL_ROAM,true,0.01f);

	// I have an enemy 
	ADD_UTILITY(BOT_UTIL_FIND_LAST_ENEMY,wantToFollowEnemy() && !m_bLookedForEnemyLast && m_pLastEnemy && CBotGlobals::entityIsValid(m_pLastEnemy) && CBotGlobals::entityIsAlive(m_pLastEnemy),getHealthPercent()*(getArmorPercent()+0.1));

	if ( !hasSomeConditions(CONDITION_SEE_CUR_ENEMY) && hasSomeConditions(CONDITION_SEE_LAST_ENEMY_POS) && m_pLastEnemy && m_fLastSeeEnemy && ((m_fLastSeeEnemy + 10.0) > engine->Time()) && m_pWeapons->hasWeapon(HL2DM_WEAPON_FRAG) )
	{
		float fDistance = distanceFrom(m_vLastSeeEnemyBlastWaypoint);

		if ( ( fDistance > BLAST_RADIUS ) && ( fDistance < 1500 ) )
		{
			CWeapon *pWeapon = CWeapons::getWeapon(HL2DM_WEAPON_FRAG);
			CBotWeapon *pBotWeapon = m_pWeapons->getWeapon(pWeapon);

			ADD_UTILITY(BOT_UTIL_THROW_GRENADE, pBotWeapon && (pBotWeapon->getAmmo(this) > 0) ,1.0f-(getHealthPercent()*0.2));
		}
	}

	if ( m_pNearbyWeapon.get() )
	{
		pWeapon = CWeapons::getWeapon(m_pNearbyWeapon.get()->GetClassName());

		if ( pWeapon && !m_pWeapons->hasWeapon(pWeapon->getID()) )
		{
			ADD_UTILITY(BOT_UTIL_PICKUP_WEAPON, true , 0.6f + pWeapon->getPreference()*0.1f);
		}
	}


	utils.execute();

	while ( (next = utils.nextBest()) != NULL )
	{
		if ( !m_pSchedules->isEmpty() && bCheckCurrent )
		{
			if ( m_CurrentUtil != next->getId() )
				m_pSchedules->freeMemory();
			else
				break;
		} 

		bCheckCurrent = false;

		if ( executeAction(next->getId()) )
		{
			m_CurrentUtil = next->getId();

			if ( m_fUtilTimes[next->getId()] < engine->Time() )
				m_fUtilTimes[next->getId()] = engine->Time() + randomFloat(0.1f,2.0f); // saves problems with consistent failing

			if ( CClients::clientsDebugging(BOT_DEBUG_UTIL) )
			{
				CClients::clientDebugMsg(BOT_DEBUG_UTIL,g_szUtils[next->getId()],this);
			}
			break;
		}
	}

	utils.freeMemory();
}