Пример #1
0
void
LockableButton::MouseDown(BPoint point)
{
	if ((modifiers() & B_SHIFT_KEY) != 0 || Value() == B_CONTROL_ON)
		SetBehavior(B_TOGGLE_BEHAVIOR);
	else
		SetBehavior(B_BUTTON_BEHAVIOR);

	Message()->SetInt32("behavior", Behavior());
	BButton::MouseDown(point);
}
Пример #2
0
	void OnAddDied()
	{
		if (mAliveAdds > 0)
		{
			--mAliveAdds;
			if (mAliveAdds > 1)
			{
				uint32 RandomText = RandomUInt(1);
				while (RandomText == mLastYell)
				{
					RandomText = RandomUInt(1);
				}

				switch (RandomText)
				{
				case 0:
					Emote("You not kill next one so easy!", Text_Yell, 11369);
					break;
				case 1:
					Emote("Does not prove anything!", Text_Yell, 11370);
					break;
				}

				mLastYell = RandomText;
			}
			else if (mAliveAdds == 1)
			{
				Emote("Good, now you fight me!", Text_Yell, 0);
				SetCanEnterCombat(true);
				SetBehavior(Behavior_Default);
				SetCanMove(true);
			}
		}
	}
Пример #3
0
	void OnCombatStart(Unit* pTarget)
	{
		SetDisplayWeapon(true, true);
		ParentClass::OnCombatStart(pTarget);

		mAliveAdds = 0;
		mLastYell = -1;
		for (int i = 0; i < 4; ++i)
		{
			Unit* pAdd = ForceCreatureFind(Adds[i]);
			if (pAdd != NULL && pAdd->isAlive())
			{
				Unit* pTarget = GetBestPlayerTarget();
				if (pTarget != NULL)
				{
					pAdd->GetAIInterface()->AttackReaction(pTarget, 200);
				}

				++mAliveAdds;
			}
		}
		if (mAliveAdds > 1)
		{
			SetCanEnterCombat(false);
			SetBehavior(Behavior_Spell);
			SetCanMove(false);
		}
	}
Пример #4
0
void MoonScriptCreatureAI::StopWaypointMovement()
{
	SetBehavior(Behavior_Default);
	_unit->GetAIInterface()->SetAIState(STATE_SCRIPTIDLE);
	SetMoveType(Move_DontMoveWP);
	SetWaypointToMove(0);
}
Пример #5
0
	void OnCombatStart(Unit* pTarget)
	{
		ParentClass::OnCombatStart(pTarget);

		if (GetRangeToUnit(pTarget) <= 40.0f)
		{
			SetBehavior(Behavior_Spell);
			SetCanMove(false);
		}
	}
Пример #6
0
void ArcScriptCreatureAI::OnCombatStop(Unit* pTarget)
{
	CancelAllSpells();
	CancelAllTimers();
	RemoveAllAuras();
	SetBehavior(Behavior_Default);
	_unit->GetAIInterface()->SetAIState(STATE_IDLE);
	RemoveAIUpdateEvent();
	if( mDespawnWhenInactive ) Despawn(DEFAULT_DESPAWN_TIMER);
}
Пример #7
0
void MoonScriptCreatureAI::OnCombatStop(Unit *pTarget)
{
	CancelAllSpells();
	CancelAllTimers();
	RemoveAllAuras();
	SetCanMove(true);
	SetBehavior(Behavior_Default);
	if( mDespawnWhenInactive )
		Despawn(DEFAULT_DESPAWN_TIMER);
}
Пример #8
0
	void SinisterReflect()
	{
		_unit->Root();
		SetBehavior(Behavior_Spell);

		SpawnCreature(CREATURE_SINISTER_REFLECTION, 1729.00f, 634.00f, 28.00f, 0.00f, true);
		SpawnCreature(CREATURE_SINISTER_REFLECTION, 1701.00f, 658.00f, 28.00f, 0.00f, true);
		SpawnCreature(CREATURE_SINISTER_REFLECTION, 1637.00f, 647.00f, 28.00f, 0.00f, true);
		SpawnCreature(CREATURE_SINISTER_REFLECTION, 1672.00f, 612.00f, 28.00f, 0.00f, true);
		SpawnCreature(CREATURE_SINISTER_REFLECTION, 1702.00f, 597.00f, 28.00f, 0.00f, true);
	}
Пример #9
0
void MoonScriptCreatureAI::OnCombatStop(Unit* pTarget)
{
	CancelAllSpells();
	CancelAllTimers();
	RemoveAllAuras();
	SetCanMove(true);
	SetBehavior(Behavior_Default);
	//_unit->GetAIInterface()->SetAIState(STATE_IDLE);				// Fix for stucking mobs that don't regen
	RemoveAIUpdateEvent();
	if( mDespawnWhenInactive ) Despawn(DEFAULT_DESPAWN_TIMER);
}
Пример #10
0
	void phaseTester()
	{

		_unit->Root();
		GetAllowMelee();
		SetBehavior(Behavior_Spell);

		if ((HandOfTheDeceiver1 && HandOfTheDeceiver2 && HandOfTheDeceiver3) && (HandOfTheDeceiver1->isDead() && HandOfTheDeceiver2->isDead() && HandOfTheDeceiver3->isDead()) && (GetPhase() != 1) && (GetPhase() != 2) && (starter == 0))
		{
			_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, SAY_KJ_EMERGE);
			_unit->PlaySoundToSet(SOUND_KJ_EMERGE);
			RemoveAura(42866);
			_unit->m_invisible = false;
			starter = 1;
		}

		switch(GetPhase())
		{
		case 1:
			{
				if(GetHealthPercent()<=85 && phase == 2)
				{
					_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, SAY_KJ_PHASE3);
					_unit->PlaySoundToSet(SOUND_KJ_PHASE3);
					AddPhaseSpell(1, AddSpell(SPELL_SINISTER_REFLECTION, Target_RandomPlayer, 10, 1.5f, 4, 0, 35));
					AddPhaseSpell(1, AddSpell(SPELL_SHADOW_SPIKE, Target_RandomDestination, 10, 2.0f, 6, 0, 35));
					AddPhaseSpell(1, AddSpell(SPELL_FLAME_DART, Target_RandomPlayer, 10, 1.3f, 4, 0, 35));
					ShieldOrb2 = _unit->GetMapMgr()->GetInterface()->SpawnCreature(CN_SHIELD_ORB, 1712.00f, 604.00f, 48.00f, 0.00f, true, true, 0, 0);
					phase++;
				}

				if(GetHealthPercent()<=55 && phase == 3)
				{
					_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, SAY_KJ_PHASE4);
					_unit->PlaySoundToSet(SOUND_KJ_PHASE4);
					ShieldOrb3 = _unit->GetMapMgr()->GetInterface()->SpawnCreature(CN_SHIELD_ORB, 1684.00f, 651.00f, 48.00f, 0.00f, true, true, 0, 0);
					dtimmer = 0;
					phase++;
				}

				if(GetHealthPercent()<=25 && phase == 4 && (dtimmer > 54 || dtimmer == 0))
				{
					_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, SAY_KJ_PHASE5);
					_unit->PlaySoundToSet(SOUND_KJ_PHASE5);
					ShieldOrb4 = _unit->GetMapMgr()->GetInterface()->SpawnCreature(CN_SHIELD_ORB, 1720.00f, 642.00f, 48.00f, 0.00f, true, true, 0, 0);
					CastSpellOnTarget(_unit, Target_Self, dbcSpell.LookupEntry(SPELL_SACRIFICE_OF_ANVEENA), true);
					dtimmer = 0;
					phase++;
				}
			}break;
		}
	}
Пример #11
0
    void AIUpdate()
    {
		if(GetHealthPercent() <= 10 && GetBehavior() != Behavior_Flee)
		{
			Emote("Skum tries to run away in fear", Text_Emote);
			SetBehavior(Behavior_Flee);
			SetAllowMelee(false);
			SetAllowRanged(false);
			SetAllowSpell(false);
			MoveTo(-262.829742f, -299.363159f, -68.293579f, true);
		}
		ParentClass::AIUpdate();
	}
Пример #12
0
	void BlueShild()
	{
        for (std::set<Player*>::iterator itr = _unit->GetInRangePlayerSetBegin(); itr != _unit->GetInRangePlayerSetEnd(); ++itr)
			{
				Player *pPlayer = static_cast<Player*>(*itr);
				if (pPlayer->isAlive() && _unit->CalcDistance(pPlayer) <= 16.0f)
					pPlayer->CastSpell(pPlayer, dbcSpell.LookupEntry(38916), true);
			}

		_unit->Root();
		GetAllowMelee();
		SetBehavior(Behavior_Spell);
	}
Пример #13
0
	void AIUpdate()
	{
		ParentClass::AIUpdate();

		Unit* pTarget = _unit->GetAIInterface()->GetNextTarget();
		if (pTarget != NULL)
		{
			if (GetRangeToUnit(pTarget) <= 40.0f)
			{
				SetBehavior(Behavior_Spell);
				SetCanMove(false);
			}
		}
	}
Пример #14
0
	void SteeringBehaviorSystem::Update(float elapsedTime)
	{
		auto entities = std::move(_layer->GetEntities());
		for (auto entity : entities)
		{
			if (entity->HasC<TransformComponent>() &&
				entity->HasC<SteeringBehaviorComponent>() &&
				entity->HasC<MovementComponent>())
			{
				auto sbc = entity->GetC<SteeringBehaviorComponent>();
				auto type = sbc->GetType();
				auto& behavior = sbc->GetBehavior();

				if (!behavior.valid())
					SetBehavior(entity, type, behavior);

				behavior->Update(elapsedTime);
			}
		}
	}
Пример #15
0
void ArcScriptCreatureAI::AIUpdate()
{
	SpellDesc*	Spell;
	uint32		CurrentTime = (uint32)time(NULL);

	//Elapse timers
	for( TimerArray::iterator TimerIter = mTimers.begin(); TimerIter != mTimers.end(); ++TimerIter )
	{
		TimerIter->second -= mAIUpdateFrequency;
	}

	//Check if we have a spell scheduled to be cast
	for( SpellDescList::iterator SpellIter = mScheduledSpells.begin(); SpellIter != mScheduledSpells.end(); ++SpellIter )
	{
		Spell = (*SpellIter);
		if( CastSpellInternal(Spell, CurrentTime) )	//Can fail if we are already casting a spell, or if the spell is on cooldown
		{
			mScheduledSpells.erase(SpellIter);
			break;
		}
	}

	//Do not schedule spell if we are *currently* casting a non-instant cast spell
	if( !IsCasting() && !mRunToTargetCache )
	{
		//Check if have queued spells that needs to be scheduled before we go back to random casting
		for( SpellDescList::iterator SpellIter = mQueuedSpells.begin(); SpellIter != mQueuedSpells.end(); ++SpellIter )
		{
			Spell = (*SpellIter);
			mScheduledSpells.push_back(Spell);
			mQueuedSpells.erase(SpellIter);

			//Stop melee attack for a short while for scheduled spell cast
			if( Spell->mCastTime >= 0 )
			{
				DelayNextAttack(mAIUpdateFrequency + CalcSpellAttackTime(Spell));
				if( Spell->mCastTime > 0 )
				{
					SetCanMove(false);
					SetBehavior(Behavior_Spell);
				}
			}
			return;	//Scheduling one spell at a time, exit now
		}

		//Try our chance at casting a spell (Will actually be cast on next ai update, so we just
		//schedule it. This is needed to avoid next dealt melee damage while we cast the spell.)
		float ChanceRoll = RandomFloat(100), ChanceTotal = 0;
		for( SpellDescArray::iterator SpellIter = mSpells.begin(); SpellIter != mSpells.end(); ++SpellIter )
		{
			Spell = (*SpellIter);
			if( Spell->mEnabled == false ) continue;
			if( Spell->mChance == 0 ) continue;

			//Check if spell won the roll
			if( (Spell->mChance == 100 || (ChanceRoll >= ChanceTotal && ChanceRoll < ChanceTotal + Spell->mChance)) &&
				(Spell->mLastCastTime + Spell->mCooldown <= CurrentTime) &&
				!IsSpellScheduled(Spell) )
			{
				mScheduledSpells.push_back(Spell);

				//Stop melee attack for a short while for scheduled spell cast
				if( Spell->mCastTime >= 0 )
				{
					DelayNextAttack(mAIUpdateFrequency + CalcSpellAttackTime(Spell));
					if( Spell->mCastTime > 0 )
					{
						SetCanMove(false);
						SetBehavior(Behavior_Spell);
					}
				}
				return;	//Scheduling one spell at a time, exit now
			}
			else if( Spell->mChance != 100 ) ChanceTotal += Spell->mChance;	//Only add spells that aren't 100% chance of casting
		}

		//Go back to default behavior since we didn't decide anything
		SetCanMove(true);
		SetBehavior(Behavior_Melee);

		//Random taunts
		if( ChanceRoll >= 95 ) RandomEmote(mOnTauntEmotes);
	}
}
Пример #16
0
void ArcScriptCreatureAI::OnCombatStart(Unit* pTarget)
{
	RandomEmote(mOnCombatStartEmotes);
	SetBehavior(Behavior_Melee);
	RegisterAIUpdateEvent(mAIUpdateFrequency);
}
Пример #17
0
void MoonScriptCreatureAI::OnCombatStart(Unit *pTarget)
{
	RandomEmote(mOnCombatStartEmotes);
	SetBehavior(Behavior_Melee);
}
Пример #18
0
	void AIUpdate()
	{
		_unit->Root();
		GetAllowMelee();
		SetBehavior(Behavior_Spell);

		phaseTester();

		switch (starter)
		{
		case 3:
			{
				_unit->CastSpell(_unit, dbcSpell.LookupEntry(35177), true);
			}break;
		case 16:
			{
				SetPhase(1);
				_unit->SetUInt64Value(UNIT_FIELD_FLAGS, ( true ) ? 0 : UNIT_FLAG_NOT_ATTACKABLE_9);
				_unit->GetAIInterface()->SetAllowedToEnterCombat(true);
				ShieldOrb1 = _unit->GetMapMgr()->GetInterface()->SpawnCreature(CN_SHIELD_ORB, 1678.00f, 610.00f, 48.00f, 0.00f, true, true, 0, 0);
				//BlueDragon = _unit->GetMapMgr()->GetInterface()->SpawnCreature(CREATURE_POWER_OF_THE_BLUE_DRAGONFLIGHT, 1720.00f, 642.00f, 28.00f, 0.00f, true, true, 0, 0);
				phase = 2;
				starter++;
			}break;
		}

		if (starter > 0 && starter < 16)
			starter++;

		if (phase == 4)
		{
			switch (dtimmer)
			{
				case 2:
					{
						ArmageddonSpawn();
						dtimmer++;
					}break;
				case 10:
					{
						_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL,LANG_UNIVERSAL,"Who can you trust?");
						_unit->PlaySoundToSet(12503);
						SinisterReflect();
						dtimmer++;
					}break;
				case 104:
				{
					SetPhase(2);
					ClearHateList();
					SetAllowMelee(true);
					_unit->Root();
					_unit->SetUInt64Value(UNIT_FIELD_FLAGS, ( false ) ? 0 : UNIT_FLAG_NOT_ATTACKABLE_9);
					_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, SAY_KJ_DARKNESS1);
					_unit->PlaySoundToSet(SOUND_KJ_DARKNESS1);
					_unit->SetUInt32Value(UNIT_NPC_EMOTESTATE, 407);
					dtimmer++;
					}break;
				case 112:
				{
					SetAllowMelee(true);
					BlueShild();
					dtimmer++;
				}break;
				case 120:
				{
					CastSpellOnTarget(_unit, Target_RandomPlayer, Darkness, true);
					_unit->Root();
					SetAllowMelee(true);
					dtimmer++;
					}break;
				case 122:
				{
					SetPhase(1);
					_unit->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
					_unit->SetUInt64Value(UNIT_FIELD_FLAGS, ( true ) ? 0 : UNIT_FLAG_NOT_ATTACKABLE_9);
					ClearHateList();
					dtimmer = 0;
					}break;
				default:
				{
					_unit->Root();
					dtimmer++;
				}break;
			}
		}

		if (phase == 5)
		{
			switch (dtimmer)
			{
				case 10:
				{
					SinisterReflect();
					dtimmer++;
				}break;
				case 54:
				{
					SetPhase(2);
					ClearHateList();
					SetAllowMelee(true);
					_unit->Root();
					_unit->SetUInt64Value(UNIT_FIELD_FLAGS, ( false ) ? 0 : UNIT_FLAG_NOT_ATTACKABLE_9);
					_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, SAY_KJ_DARKNESS2);
					_unit->PlaySoundToSet(SOUND_KJ_DARKNESS2);
					_unit->SetUInt32Value(UNIT_NPC_EMOTESTATE, 407);
					dtimmer++;
					}break;
				case 62:
				{
					BlueShild();
					SetAllowMelee(true);
					dtimmer++;
				}break;
				case 70:
				{
					CastSpellOnTarget(_unit, Target_RandomPlayer, Darkness, true);
					SetAllowMelee(true);
					_unit->Root();
					dtimmer++;
					}break;
				case 72:
				{
					SetPhase(1);
					_unit->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
					_unit->SetUInt64Value(UNIT_FIELD_FLAGS, ( true ) ? 0 : UNIT_FLAG_NOT_ATTACKABLE_9);
					ClearHateList();
					dtimmer = 0;
					}break;
				default:
				{
					SetAllowMelee(true);
					_unit->Root();
					dtimmer++;
				}break;
			}
		}
		ParentClass::AIUpdate();
	}