Example #1
0
func HitByHook(hook)
{
	if(!snapped)
		return;
		
	Unstuck();
	snapped = 0;
	var fx = GetEffect("Travel", this);
	RemoveEffect("Travel", this);
	SetAction("Idle");
	
	/*
	var dir;
	if(GetX() > hook->GetX())
		dir = 1;
	else
		dir = -1;*/
		
	var angle = Angle(hook->GetX(), hook->GetY(), GetX(), GetY());
	
	//var angle = fx.angle - 45 * -fx.dir;
	var xdir = Sin(angle, Speed);
	var ydir = -Cos(angle, Speed);
	//var xdir = Cos(angle, Speed);
	//var ydir = Sin(angle, Speed);
	Bounce(xdir, ydir);
}
Example #2
0
void CAIBomber::DoBehavior()
{
	// reset jump and attack
	m_Jump = 0;
	m_Attack = 0;
	
	CheckAITiles();
	SeekPlayer();

	
	if (m_PlayerSpotCount > 0)
	{
		m_TargetTimer = 0;
	
		// on "first" sight
		if (m_PlayerSpotCount == 1 && m_BombTimer == 0)
		{
			Player()->GetCharacter()->SetEmoteFor(EMOTE_HAPPY, 1200, 1200);
			GameServer()->SendEmoticon(Player()->GetCID(), EMOTICON_HEARTS);
		}

		MoveTowardsPlayer(40);
		JumpIfPlayerIsAbove();
		
		m_Direction = m_PlayerDirection;
		
	
		if (m_BombTimer == 0)
		{
			if (m_PlayerDistance < 200)
			{
				m_BombTimer = 60;
				
				Player()->GetCharacter()->SetEmoteFor(EMOTE_HAPPY, 1200, 1200);
				GameServer()->SendEmoticon(Player()->GetCID(), EMOTICON_DEVILTEE);
				GameServer()->CreateSound(m_Pos, SOUND_PLAYER_PAIN_LONG);
			}
		}

		
		if (m_Pos.y < m_PlayerPos.y)
			m_Jump = 0;
	}
	
	Unstuck();
	HeadToMovingDirection();
	
	// next reaction in
	m_ReactionTime = 6 + frandom()*3;
	
}
Example #3
0
void CAIElectro::DoBehavior()
{
	vec2 Pos;

	// character check
	if (Player()->GetCharacter())
		Pos = Player()->GetCharacter()->m_Pos;
	else
		return;

	// reset jump and attack
	m_Jump = 0;
	m_Attack = 0;
	
	CheckAITiles();
	SeekPlayer();
	
	
	if (m_PlayerSpotCount > 0)
	{
		m_TargetTimer = 0;
	
		// on first time standstill and look stupid
		if (m_PlayerSpotCount == 1)
		{
			m_Move = 0;
			m_Jump = 0;
			m_Direction = m_PlayerDirection;

			Player()->GetCharacter()->SetEmoteFor(EMOTE_HAPPY, 1200, 1200);
			m_ReactionTime = 40;
			return;
		}

		MoveTowardsPlayer(40);
		m_Direction = m_PlayerDirection;
		
		if (m_PlayerDistance < 120)
			m_Attack = 1;
			
		if (m_PlayerDistance < 600)
		{
			float Angle = frandom()*360.0f*RAD;
			new CLightning(Player()->GetCharacter()->GameWorld(), Pos, vec2(cosf(Angle), sinf(Angle)), 50, 50, Player()->GetCID(), 1);
			Angle = frandom()*360.0f*RAD;
			new CLightning(Player()->GetCharacter()->GameWorld(), Pos, vec2(cosf(Angle), sinf(Angle)), 50, 50, Player()->GetCID(), 1);
		}
		
		
		JumpIfPlayerIsAbove();
			
		if (Pos.y < m_PlayerPos.y)
			m_Jump = 0;
	}
	
	Unstuck();
	HeadToMovingDirection();
	
	m_ReactionTime = 5;
	
}
Example #4
0
void CAILaserbot::DoBehavior()
{
	// reset jump and attack
	m_Jump = 0;
	m_Attack = 0;
	
	CheckAITiles();
	SeekPlayer();
	
	if (m_PlayerSpotCount == 0)	
		m_Hook = 0;
	
	Unstuck();

	// hook moving (sucks)
	vec2 HookPos = m_Pos - vec2(0, 300);
			
	if (m_Move < 0)
		HookPos.x -= 250;
	else
		HookPos.x += 250;
			
				
	// hook if something in sight
	if (GameServer()->Collision()->IntersectLine(m_Pos, HookPos, NULL, NULL) && 
		m_LastHook == 0 && m_PlayerSpotCount == 0 && frandom()*10 < 4)
	{
		m_Hook = 1;
		m_Direction = HookPos - m_Pos;
		if (Player()->GetCharacter()->IsGrounded())
			m_Jump = 1;
	}
	else
		HeadToMovingDirection();
	
	
	if (m_PlayerSpotCount > 0)
	{
		m_TargetTimer = 0;
	
		// on first time standstill and look stupid
		if (m_PlayerSpotCount == 1)
		{
			m_Move = 0;
			m_Direction = m_PlayerDirection;
			m_TargetPos = m_PlayerPos;
			m_Jump = 0;

			Player()->GetCharacter()->SetEmoteFor(EMOTE_ANGRY, 1200, 1200);
			m_ReactionTime = 40;
			return;
		}


		if (m_PlayerPos.x < m_Pos.x)
			m_TargetPos.x = m_PlayerPos.x + 600;
		else
			m_TargetPos.x = m_PlayerPos.x - 600;
		
		MoveTowardsTarget(140);
		
		if (m_PlayerDistance < 700)
			m_Attack = 1;
		
		
		if (m_PlayerDistance < 1000)
			m_Direction = m_PlayerDirection;
	}

	// next reaction in
	m_ReactionTime = 6 + frandom()*3;
	
}