void CZombieOlfateador::CalculaSiguientePosicionZombie(float _elapsedTime)
{
  Vect3f l_v3MiPosicion = GetInstance()->GetPosition();
  //m_v3PosicionNodoAVisitar
  Vect3f l_v3VectorDirector = m_v3PosicionNodoAVisitar - l_v3MiPosicion;
  l_v3VectorDirector = l_v3VectorDirector.GetNormalized();
  l_v3MiPosicion.x += l_v3VectorDirector.x * _elapsedTime * GetMoveSpeed();//TODO..m_fMoveSpeed;
  l_v3MiPosicion.y = 0.0f;
  l_v3MiPosicion.z += l_v3VectorDirector.z * _elapsedTime * GetMoveSpeed();//m_fMoveSpeed;
  GetInstance()->SetPosition(l_v3MiPosicion);
  GetInstance()->SetYaw(-l_v3VectorDirector.GetAngleY());
}
Exemplo n.º 2
0
float MoveMonitor::GetMoveSpeedRecover()
{ 
	// 单位格子的矫正时间
	float correctTimeOneCell = m_Path.size()>0?(float)GetMoveTimeCorrect()/(float)m_Path.size():(float)GetMoveTimeCorrect();

	// 如果移动时间小于或者等于矫正时间,直接返回0
	if ( GetMoveSpeed() <= correctTimeOneCell )
	{
		return 0.0f;
	}
	
	return GetMoveSpeed()-correctTimeOneCell; 
}
Exemplo n.º 3
0
// set monster stats values
bool CMonster::SetStats( )
{
    if(thisnpc==NULL) return false;
    Stats->Level = thisnpc->level;
    Stats->Attack_Power = GetAttackPower( );
    Stats->Defense = GetDefense( );
    Stats->Attack_Speed = GetAttackSpeed( );
    Stats->Move_Speed = GetMoveSpeed( );
    Stats->Dodge = GetDodge( );
    Stats->Accury = GetAccury( );
    Stats->Critical = GetCritical( );
    Stats->Magic_Defense = GetMagicDefense( );
    Stats->Attack_Distance = GetAttackDistance( );
    Stats->MaxHP = GetMaxHP( );
    Stats->MaxMP = GetMaxMP( );
    //Stats->HP = Stats->MaxHP;
    //Stats->MP = Stats->MaxMP;

    for(int i=0; i<20; i++)
    {
        AIVar[i] = 0;
    }


    return true;
}
Exemplo n.º 4
0
bool Game_Player::GetOnVehicle() {
	int front_x = Game_Map::XwithDirection(GetX(), GetDirection());
	int front_y = Game_Map::YwithDirection(GetY(), GetDirection());
	Game_Vehicle::Type type;

	if (Game_Map::GetVehicle(Game_Vehicle::Airship)->IsInPosition(GetX(), GetY()))
		type = Game_Vehicle::Airship;
	else if (Game_Map::GetVehicle(Game_Vehicle::Ship)->IsInPosition(front_x, front_y))
		type = Game_Vehicle::Ship;
	else if (Game_Map::GetVehicle(Game_Vehicle::Boat)->IsInPosition(front_x, front_y))
		type = Game_Vehicle::Boat;
	else
		return false;

	location.vehicle = type;
	location.preboard_move_speed = GetMoveSpeed();
	if (type != Game_Vehicle::Airship) {
		location.boarding = true;
		through = true;
		MoveForward();
		through = false;
	} else {
		location.aboard = true;
		SetMoveSpeed(GetVehicle()->GetMoveSpeed());
		SetDirection(RPG::EventPage::Direction_left);
	}

	walking_bgm = Game_System::GetCurrentBGM();
	GetVehicle()->GetOn();
	return true;
}
Exemplo n.º 5
0
void CClientVehicle::Serialize(CBitStream * pBitStream)
{
	// Write the vehicle position
	CVector3 vecPosition;
	GetPosition(vecPosition);
	pBitStream->Write(vecPosition);

	// Write the vehicle rotation
	CVector3 vecRotation;
	GetRotation(vecRotation);
	pBitStream->Write(vecRotation);

	// Write the vehicle move speed
	CVector3 vecMoveSpeed;
	GetMoveSpeed(vecMoveSpeed);
	pBitStream->Write(vecMoveSpeed);

	// Write the vehicle turn speed
	CVector3 vecTurnSpeed;
	GetTurnSpeed(vecTurnSpeed);
	pBitStream->Write(vecTurnSpeed);

	// Write the vehicle health
	pBitStream->Write(GetHealth());
}
Exemplo n.º 6
0
int Game_Character::EndJump(const RPG::MoveRoute* current_route, int current_index) {
	jumping = false;

	if (!IsLandable(jump_x + jump_plus_x, jump_y + jump_plus_y)) {
		// Reset to begin jump command and try again...
		move_failed = true;

		if (current_route->skippable) {
			return current_index;
		}

		return jump_index;
	}

	SetX(jump_x + jump_plus_x);
	SetY(jump_y + jump_plus_y);

	//TODO: C++11 got round() function defined in math.h
	float distance = sqrt((float)(jump_plus_x * jump_plus_x + jump_plus_y * jump_plus_y));
	if (distance >= floor(distance) + 0.5) distance = ceil(distance);
	else distance = floor(distance);

	jump_peak = 10 + (int)distance - GetMoveSpeed();
	move_count = jump_peak * 2;

	stop_count = 0;
	move_failed = false;

	return current_index;
}
Exemplo n.º 7
0
//-----------------------------------------
//perseguir por posicion de personaje(sin colisiones)
//-----------------------------------------
//void CZombie::Perseguir(Vect3f hisPosition,float _elapsedtime)
//{
//  Vect3f myPosition = GetInstance()->GetPosition();
//  GetEjeMovimientoIA()->MovAgentIA(hisPosition,myPosition,GetMoveSpeed(),_elapsedtime);
//  
//  //posicion y rotacion del muñeco
//  
////  GetInstance()->SetPosition(Vect3f(myPosition.x,0,myPosition.z));
//  //GetInstance()->SetYaw(-(GetEjeMovimientoIA()->m_fAngleTotalPlayer2));
//
//  CRenderableObject* myinstance = CORE->GetRenderableObjectsManager()->GetInstance(this->GetInstance()->GetName());
//  myinstance->SetPosition(Vect3f(myPosition.x,0,myPosition.z));
//  myinstance->SetYaw(-(GetEjeMovimientoIA()->m_fAngleTotalPlayer2));
//  SetInstance((CRenderableAnimatedInstanceModel*)myinstance);
//}
//-----------------------------------------
//perseguir por vector director
//-----------------------------------------
void CZombie::Perseguir(Vect3f hisPosition,float _elapsedtime, float height)
{
  Vect3f myPosition = GetInstance()->GetPosition();
  float mySpeed = GetMoveSpeed();

  GetEjeMovimientoIA()->MovAgentIA(hisPosition,myPosition,mySpeed,_elapsedtime);
  
  Vect3f aux = GetEjeMovimientoIA()->GetVectorDirector();
  aux.y = 0.0f;
  GetPhysicController()->Move(aux /** _elapsedtime*/ * mySpeed, _elapsedtime);

  Vect3f controllerPosition = GetPhysicController()->GetPosition();
  //controllerPosition.y = 0.0f;
  //myinstance->SetPosition(Vect3f(myPosition.x,0,myPosition.z));
  CRenderableObject* myinstance = GetInstance();
  float l_fPosY = controllerPosition.y - GetPhysicController()->GetRadius()*height ;
  if(height == 1.0f)//boss
    myinstance->SetPosition(Vect3f(controllerPosition.x, l_fPosY -(height/4.0f), controllerPosition.z));
  else              //zombie
    myinstance->SetPosition(Vect3f(controllerPosition.x, l_fPosY, controllerPosition.z));
    
  myinstance->SetYaw(-(GetEjeMovimientoIA()->m_fAngleTotalPlayer2));
  
  SetInstance((CRenderableAnimatedInstanceModel*)myinstance);
}
Exemplo n.º 8
0
VOID Obj_Monster::InitBackupAttr()
{
__ENTER_FUNCTION

	m_AttrBackUp.m_bNameModified		= FALSE;
	m_AttrBackUp.m_bTitleModified		= FALSE;
	m_AttrBackUp.m_HP					= GetHP();
	m_AttrBackUp.m_MP					= GetMP();	//	add by gh 2010/03/25
	const _CAMP_DATA *pCampData = GetCampData();
	if ( pCampData != NULL )
		m_AttrBackUp.m_CampData			= *pCampData;
	m_AttrBackUp.m_MaxHp				= GetMaxHP();
	m_AttrBackUp.m_MaxMp				= GetMaxMP();	//	add by gh 2010/03/25
	m_AttrBackUp.m_MoveSpeed			= GetMoveSpeed();
	m_AttrBackUp.m_nDataID				= GetDataID();
	m_AttrBackUp.m_nModelID				= GetModelID();
	m_AttrBackUp.m_nMountID				= GetMountID();
	m_AttrBackUp.m_nAIType				= GetAIType();
	m_AttrBackUp.m_OwnerID				= GetOwnerID();
	m_AttrBackUp.m_OccupantGUID			= GetOccupantGUID();
	m_AttrBackUp.m_nStealthLevel		= GetStealthLevel();
	m_AttrBackUp.m_nMoodState			= GetMoodState();
	m_AttrBackUp.m_iHorseID				= GetHorseID();
	m_AttrBackUp.m_iWeaponID			= GetWeaponID();
__LEAVE_FUNCTION
}
Exemplo n.º 9
0
void Game_Player::UpdateScroll() {
	int center_x = DisplayUi->GetWidth() / 2 - TILE_SIZE / 2 - Game_Map::GetPanX() / (SCREEN_TILE_WIDTH / TILE_SIZE);
	int center_y = DisplayUi->GetHeight() / 2 + TILE_SIZE / 2 - Game_Map::GetPanY() / (SCREEN_TILE_WIDTH / TILE_SIZE);
	int dx = 0;
	int dy = 0;

	if (!Game_Map::IsPanLocked()) {
		if (IsMoving()) {
			int d = GetDirection();
			if ((d == Right || d == UpRight || d == DownRight) && GetScreenX() >= center_x)
				dx = 1;
			else if ((d == Left || d == UpLeft || d == DownLeft) && GetScreenX() <= center_x)
				dx = -1;
			dx <<= 1 + GetMoveSpeed();

			if ((d == Down || d == DownRight || d == DownLeft) && GetScreenY() >= center_y)
				dy = 1;
			else if ((d == Up || d == UpRight || d == UpLeft) && GetScreenY() <= center_y)
				dy = -1;
			dy <<= 1 + GetMoveSpeed();
		} else if (IsJumping()) {
			int move_speed = GetMoveSpeed();
			int diff = move_speed < 5 ? 48 / (2 + pow(2.0, 3 - move_speed)) : 64 / (7 - move_speed);
			dx += (GetX() - jump_x) * diff;
			dy += (GetY() - jump_y) * diff;
		}
	}

	if (Game_Map::GetPanX() != last_pan_x || Game_Map::GetPanY() != last_pan_y) {
		dx += Game_Map::GetPanX() - last_pan_x;
		dy += Game_Map::GetPanY() - last_pan_y;

		last_pan_x = Game_Map::GetPanX();
		last_pan_y = Game_Map::GetPanY();
	}

	if (dx > 0)
		Game_Map::ScrollRight(dx);
	else if (dx < 0)
		Game_Map::ScrollLeft(-dx);
	if (dy > 0)
		Game_Map::ScrollDown(dy);
	else if (dy < 0)
		Game_Map::ScrollUp(-dy);
}
Exemplo n.º 10
0
void Game_Character::Update() {
	if (IsJumping()) {
		UpdateJump();
		if (IsSpinning())
			anime_count++;
	} else if (IsMoving()) {
		remaining_step -= 1 << (1 + GetMoveSpeed());
		if (IsSpinning() || (animation_type != RPG::EventPage::AnimType_fixed_graphic && walk_animation))
			anime_count++;
	} else {
		stop_count++;
		if (IsSpinning() || IsContinuous() || pattern != original_pattern)
			anime_count++;
	}

	if (anime_count >= GetSteppingSpeed()) {
		if (IsSpinning()) {
			SetSpriteDirection((GetSpriteDirection() + 1) % 4);
		} else if (!IsContinuous() && IsStopping()) {
			pattern = original_pattern;
			last_pattern = last_pattern == RPG::EventPage::Frame_left ? RPG::EventPage::Frame_right : RPG::EventPage::Frame_left;
		} else {
			if (last_pattern == RPG::EventPage::Frame_left) {
				if (pattern == RPG::EventPage::Frame_right) {
					pattern = RPG::EventPage::Frame_middle;
					last_pattern = RPG::EventPage::Frame_right;
				} else {
					pattern = RPG::EventPage::Frame_right;
				}
			} else {
				if (pattern == RPG::EventPage::Frame_left) {
					pattern = RPG::EventPage::Frame_middle;
					last_pattern = RPG::EventPage::Frame_left;
				} else {
					pattern = RPG::EventPage::Frame_left;
				}
			}
		}

		anime_count = 0;
	}

	if (wait_count > 0) {
		wait_count -= 1;
		return;
	}

	if (stop_count >= max_stop_count) {
		if (IsMoveRouteOverwritten()) {
			MoveTypeCustom();
		} else {
			// Only events
			UpdateSelfMovement();
		}
	}
}
Exemplo n.º 11
0
bool CVehicleEntity::IsMoving()
{
    CVector3 vecMoveSpeed;
    GetMoveSpeed(vecMoveSpeed);

    if(!vecMoveSpeed.IsEmpty())
		return true;

    return false;
}
Exemplo n.º 12
0
void Game_Character::Update() {
	if (IsJumping()) {
		UpdateJump();
		anime_count += (IsSpinning() ? 1.0 : 0);
	} else if (IsContinuous() || IsSpinning()) {
		UpdateMove();
		UpdateStop();
	} else {
		if (IsMoving()) {
			UpdateMove();
		} else {
			UpdateStop();
		}
	}

	if (anime_count > 36.0/(GetMoveSpeed()+1)) {
		if (IsSpinning()) {
			SetPrelockDirection((GetPrelockDirection() + 1) % 4);
		} else if (!IsContinuous() && IsStopping()) {
			pattern = original_pattern;
			last_pattern = last_pattern == RPG::EventPage::Frame_left ? RPG::EventPage::Frame_right : RPG::EventPage::Frame_left;
		} else {
			if (last_pattern == RPG::EventPage::Frame_left) {
				if (pattern == RPG::EventPage::Frame_right) {
					pattern = RPG::EventPage::Frame_middle;
					last_pattern = RPG::EventPage::Frame_right;
				} else {
					pattern = RPG::EventPage::Frame_right;
				}
			} else {
				if (pattern == RPG::EventPage::Frame_left) {
					pattern = RPG::EventPage::Frame_middle;
					last_pattern = RPG::EventPage::Frame_left;
				} else {
					pattern = RPG::EventPage::Frame_left;
				}
			}
		}

		anime_count = 0;
	}

	if (wait_count > 0) {
		wait_count -= 1;
		return;
	}

	if (stop_count >= ((GetMoveFrequency() > 7) ? 0 : pow(2.0, 9 - GetMoveFrequency()))) {
		if (IsMoveRouteOverwritten()) {
			MoveTypeCustom();
		} else if (Game_Message::GetContinueEvents() || !Game_Message::message_waiting) {
			UpdateSelfMovement();
		}
	}
}
Exemplo n.º 13
0
void Radicorn::DashTowards()
{
	//TODO: make it keep going rather that stopping once it hits the target location if it hasn't anything yet!
	SGD::Vector toTarget = (Point(targetPosition.x, targetPosition.y)) - m_ptPosition;
	toTarget.Normalize();
	targetPosition = toTarget;
	toTarget *= (float)GetMoveSpeed();
	
	m_vtVelocity += toTarget;
	isMoving = true;
}
Exemplo n.º 14
0
int Game_Character::GetSteppingSpeed() const {
	int move_speed = GetMoveSpeed();
	if (IsSpinning()) {
		// 24, 16, 12, 8, 6, 4
		return (move_speed < 4) ? 48 / (move_speed + 1) : 24 / (move_speed - 1);
	} else if (IsMoving()) {
		// 12, 10, 8, 6, 5, 4
		return (move_speed < 4) ? 60 / (move_speed + 4) : 30 / (move_speed + 1);
	} else {
		// 16, 12, 10, 8, 7, 6
		return (move_speed < 2) ? 16 : 60 / (move_speed + 3);
	}
}
Exemplo n.º 15
0
//-----------------------------------------------------------------------------
// Purpose: Draw any debug text overlays
// Input  :
// Output : Current text offset from the top
//-----------------------------------------------------------------------------
int CFuncRotating::DrawDebugTextOverlays(void) 
{
	int text_offset = BaseClass::DrawDebugTextOverlays();

	if (m_debugOverlays & OVERLAY_TEXT_BIT) 
	{
		char tempstr[512];
		Q_snprintf( tempstr, sizeof( tempstr ),"Speed cur (target): %3.2f (%3.2f)", GetMoveSpeed( m_flSpeed ), GetMoveSpeed( m_flTargetSpeed ) );
		EntityText(text_offset,tempstr,0);
		text_offset++;
	}
	return text_offset;

}
Exemplo n.º 16
0
void Game_Character::UpdateMove() {
	int distance = ((SCREEN_TILE_WIDTH / 128) << GetMoveSpeed());
	if (GetY() * SCREEN_TILE_WIDTH > real_y)
		real_y = min(real_y + distance, GetY() * SCREEN_TILE_WIDTH);

	if (GetX() * SCREEN_TILE_WIDTH < real_x)
		real_x = max(real_x - distance, GetX() * SCREEN_TILE_WIDTH);

	if (GetX() * SCREEN_TILE_WIDTH > real_x)
		real_x = min(real_x + distance, GetX() * SCREEN_TILE_WIDTH);

	if (GetY() * SCREEN_TILE_WIDTH < real_y)
		real_y = max(real_y - distance, GetY() * SCREEN_TILE_WIDTH);

	anime_count += 
		(IsSpinning() ? 1.0 :
		(animation_type != RPG::EventPage::AnimType_fixed_graphic && walk_animation) ? 1.5 :
		0);
}
Exemplo n.º 17
0
void Game_Character::UpdateSprite() {
	if (IsJumping()) {
		UpdateJump();
		if (IsSpinning())
			anime_count++;
	} else if (IsMoving()) {
		remaining_step -= min(1 << (1 + GetMoveSpeed()), remaining_step);
		if (IsSpinning() || (animation_type != RPG::EventPage::AnimType_fixed_graphic && walk_animation))
			anime_count++;
	} else {
		stop_count++;
		if ((walk_animation && (IsSpinning() || IsContinuous())) || pattern != original_pattern)
			anime_count++;
	}

	if (anime_count >= GetSteppingSpeed()) {
		if (IsSpinning()) {
			SetSpriteDirection((GetSpriteDirection() + 1) % 4);
		} else if (!IsContinuous() && IsStopping()) {
			pattern = original_pattern;
			last_pattern = last_pattern == RPG::EventPage::Frame_left ? RPG::EventPage::Frame_right : RPG::EventPage::Frame_left;
		} else {
			if (last_pattern == RPG::EventPage::Frame_left) {
				if (pattern == RPG::EventPage::Frame_right) {
					pattern = RPG::EventPage::Frame_middle;
					last_pattern = RPG::EventPage::Frame_right;
				} else {
					pattern = RPG::EventPage::Frame_right;
				}
			} else {
				if (pattern == RPG::EventPage::Frame_left) {
					pattern = RPG::EventPage::Frame_middle;
					last_pattern = RPG::EventPage::Frame_left;
				} else {
					pattern = RPG::EventPage::Frame_left;
				}
			}
		}

		anime_count = 0;
	}
}
Exemplo n.º 18
0
void CClientVehicle::StreamOut()
{
	// Get the position
	GetPosition(m_vecPosition);

	// Get the rotation
	GetRotation(m_vecRotation);

	// Get the move speed
	GetMoveSpeed(m_vecMoveSpeed);

	// Get the turn speed
	GetTurnSpeed(m_vecTurnSpeed);

	// Get the health
	m_fHealth = GetHealth();

	// Destroy the vehicle
	Destroy();
}
Exemplo n.º 19
0
void Character::CollisionMovingRight()
{
    SetPlayerFacingDirection(CHARACTERFACINGDIRECTION::CHARACTERRIGHT);
    for (int i = 0; i < GetMoveSpeed(); i++)
    {
        float nextPosX = GetCurrentPositionX()*Constants::TileSize() + GetMoveSpeedDelta();

        if (CheckNextXPositionGoingRight(nextPosX, GetCurrentPositionY()*Constants::TileSize()))
        {
            AdjustPlayerRotation();
            SetCurrentPositionX(nextPosX / Constants::TileSize());


        }
        else {
            SetKeyLeft(true);
            return;
        }
    }
}
Exemplo n.º 20
0
//Set Monster Stats Values
bool CMonster::SetStats(bool all)
{
    if(thisnpc == NULL) return false;
    
    Stats->Attack_Power = GetAttackPower( );
    Stats->Defense = GetDefense( );
    Stats->xprate = GetXPRate( );
    Stats->itemdroprate = GetItemDropRate( );
    //Stats->zulydroprate = GetZulyDropRate( );		//PY: pointless stat. It's always zero. Use thisnpc->money to get the value directly from the STB
    Stats->Attack_Speed = GetAttackSpeed( );
    Stats->Move_Speed = GetMoveSpeed( );
    Stats->Dodge = GetDodge( );
    Stats->Accury = GetAccury( );
    Stats->Critical = GetCritical( );
    Stats->Magic_Defense = GetMagicDefense( );
    Stats->magicattack = GetMagicAttack( );
    Stats->Attack_Distance = GetAttackDistance( );
    for(int i=0;i<20;i++)
    {
        AIVar[i] = 0;        
    }
    return true;
}
Exemplo n.º 21
0
// set monster stats values
bool CMonster::SetStats()
{
    if(thisnpc == NULL)
    {
        return false;
    }
    Stats->Level = thisnpc->level;
    Stats->Attack_Power = GetAttackPower( );
    Stats->Defense = GetDefense( );
    Stats->Attack_Speed = GetAttackSpeed( );
    Stats->Move_Speed = GetMoveSpeed( );
    Stats->Dodge = GetDodge( );
    Stats->Accury = GetAccury( );
    Stats->Critical = GetCritical( );
    Stats->Magic_Defense = GetMagicDefense( );
    Stats->magicattack = GetMagicAttack( );
    Stats->Attack_Distance = GetAttackDistance( );
    //Stats->MaxHP = GetMaxHP( );
    //Stats->HP = Stats->MaxHP;
    //Stats->MaxMP = GetMaxMP( );
    //Stats->MP = Stats->MaxMP;
    return true;
}
Exemplo n.º 22
0
//Set Monster Stats Values
bool CMonster::SetStats(bool all)
{
    if(thisnpc == NULL) return false;
    Stats->Level = thisnpc->level;    
    Stats->Attack_Power = GetAttackPower( );
    Stats->Defense = GetDefense( );
    Stats->xprate = GetXPRate( );
    Stats->itemdroprate = GetItemDropRate( );
    Stats->zulydroprate = GetZulyDropRate( );
    Stats->Attack_Speed = GetAttackSpeed( );
    Stats->Move_Speed = GetMoveSpeed( );
    Stats->Dodge = GetDodge( );
    Stats->Accury = GetAccury( );
    Stats->Critical = GetCritical( );
    Stats->Magic_Defense = GetMagicDefense( );
    Stats->magicattack = GetMagicAttack( );
    Stats->Attack_Distance = GetAttackDistance( );
    for(int i=0;i<20;i++)
    {
        AIVar[i] = 0;        
    }
    return true;
}
Exemplo n.º 23
0
void Character::Falling()
{
    for (int i = 0; i < GetMoveSpeed(); i++)
    {
        float nextPosY = GetCurrentPositionY()*Constants::TileSize() + GetVelocityY();
        if (CheckNextYPositionFalling(GetCurrentPositionX()*Constants::TileSize(), nextPosY))
        {
            SetCurrentPositionY(nextPosY / Constants::TileSize());
            SetCharacterYAxisState(CHARACTERYAXISSTATES::CHARACTERFALLING);

        }
        else {
            SetCharacterYAxisState(CHARACTERYAXISSTATES::CHARACTERONGROUND);

            break;
        }
    }
    //Every tick update the fall speed
    if (GetVelocityY() + GetAccelerationY() <= GetMaxVelocityY() && GetCharacterYAxisState() != CHARACTERYAXISSTATES::CHARACTERONGROUND)
    {
        SetVelocityY(GetVelocityY() + GetAccelerationY());
    }
}
Exemplo n.º 24
0
void Game_Character::MoveTypeCustom() {
	// Detect if custom movement or event overwrite
	const RPG::MoveRoute* active_route;
	int active_route_index;
	bool overwrite_changed = IsMoveRouteOverwritten();
	if (IsMoveRouteOverwritten()) {
		active_route = &GetMoveRoute();
		active_route_index = GetMoveRouteIndex();
	}
	else {
		active_route = &original_move_route;
		active_route_index = GetOriginalMoveRouteIndex();
	}

	if (IsStopping()) {
		move_failed = false;
		if ((size_t)active_route_index >= active_route->move_commands.size()) {
			// End of Move list
			if (active_route->repeat) {
				active_route_index = 0;
				SetMoveRouteRepeated(true);
			} else if (IsMoveRouteOverwritten()) {
				SetMoveRouteOverwritten(false);
				EndMoveRoute();
				stop_count = 0;
			}
		} else {
			do {
				const RPG::MoveCommand& move_command = active_route->move_commands[active_route_index];

				int command_id = move_command.command_id;
				if (!jumping && command_id == RPG::MoveCommand::Code::begin_jump) {
					active_route_index = BeginJump(active_route, active_route_index);
				}

				switch (move_command.command_id) {
				case RPG::MoveCommand::Code::move_up:
					MoveUp();
					break;
				case RPG::MoveCommand::Code::move_right:
					MoveRight();
					break;
				case RPG::MoveCommand::Code::move_down:
					MoveDown();
					break;
				case RPG::MoveCommand::Code::move_left:
					MoveLeft();
					break;
				case RPG::MoveCommand::Code::move_upright:
					MoveUpRight();
					break;
				case RPG::MoveCommand::Code::move_downright:
					MoveDownRight();
					break;
				case RPG::MoveCommand::Code::move_downleft:
					MoveDownLeft();
					break;
				case RPG::MoveCommand::Code::move_upleft:
					MoveUpLeft();
					break;
				case RPG::MoveCommand::Code::move_random:
					MoveRandom();
					break;
				case RPG::MoveCommand::Code::move_towards_hero:
					MoveTowardsPlayer();
					break;
				case RPG::MoveCommand::Code::move_away_from_hero:
					MoveAwayFromPlayer();
					break;
				case RPG::MoveCommand::Code::move_forward:
					MoveForward();
					break;
				case RPG::MoveCommand::Code::face_up:
					TurnUp();
					break;
				case RPG::MoveCommand::Code::face_right:
					TurnRight();
					break;
				case RPG::MoveCommand::Code::face_down:
					TurnDown();
					break;
				case RPG::MoveCommand::Code::face_left:
					TurnLeft();
					break;
				case RPG::MoveCommand::Code::turn_90_degree_right:
					Turn90DegreeRight();
					break;
				case RPG::MoveCommand::Code::turn_90_degree_left:
					Turn90DegreeLeft();
					break;
				case RPG::MoveCommand::Code::turn_180_degree:
					Turn180Degree();
					break;
				case RPG::MoveCommand::Code::turn_90_degree_random:
					Turn90DegreeLeftOrRight();
					break;
				case RPG::MoveCommand::Code::face_random_direction:
					FaceRandomDirection();
					break;
				case RPG::MoveCommand::Code::face_hero:
					TurnTowardHero();
					break;
				case RPG::MoveCommand::Code::face_away_from_hero:
					TurnAwayFromHero();
					break;
				case RPG::MoveCommand::Code::wait:
					Wait();
					break;
				case RPG::MoveCommand::Code::begin_jump:
					// Multiple BeginJumps are ignored
					break;
				case RPG::MoveCommand::Code::end_jump:
					active_route_index = EndJump(active_route, active_route_index);
					break;
				case RPG::MoveCommand::Code::lock_facing:
					SetFacingLocked(true);
					break;
				case RPG::MoveCommand::Code::unlock_facing:
					SetFacingLocked(false);
					break;
				case RPG::MoveCommand::Code::increase_movement_speed:
					SetMoveSpeed(min(GetMoveSpeed() + 1, 6));
					break;
				case RPG::MoveCommand::Code::decrease_movement_speed:
					SetMoveSpeed(max(GetMoveSpeed() - 1, 1));
					break;
				case RPG::MoveCommand::Code::increase_movement_frequence:
					SetMoveFrequency(min(GetMoveFrequency() + 1, 8));
					break;
				case RPG::MoveCommand::Code::decrease_movement_frequence:
					SetMoveFrequency(max(GetMoveFrequency() - 1, 1));
					break;
				case RPG::MoveCommand::Code::switch_on: // Parameter A: Switch to turn on
					Game_Switches[move_command.parameter_a] = true;
					Game_Map::SetNeedRefresh(true);
					break;
				case RPG::MoveCommand::Code::switch_off: // Parameter A: Switch to turn off
					Game_Switches[move_command.parameter_a] = false;
					Game_Map::SetNeedRefresh(true);
					break;
				case RPG::MoveCommand::Code::change_graphic: // String: File, Parameter A: index
					SetGraphic(move_command.parameter_string, move_command.parameter_a);
					break;
				case RPG::MoveCommand::Code::play_sound_effect: // String: File, Parameters: Volume, Tempo, Balance
					if (move_command.parameter_string != "(OFF)") {
						Audio().SE_Play(move_command.parameter_string,
							move_command.parameter_a, move_command.parameter_b);
					}
					break;
				case RPG::MoveCommand::Code::walk_everywhere_on:
					through = true;
					break;
				case RPG::MoveCommand::Code::walk_everywhere_off:
					through = false;
					break;
				case RPG::MoveCommand::Code::stop_animation:
					walk_animation = false;
					break;
				case RPG::MoveCommand::Code::start_animation:
					walk_animation = true;
					break;
				case RPG::MoveCommand::Code::increase_transp:
					SetOpacity(max(40, GetOpacity() - 45));
					break;
				case RPG::MoveCommand::Code::decrease_transp:
					SetOpacity(GetOpacity() + 45);
					break;
				}

				if (active_route->skippable || !move_failed) {
					++active_route_index;
				}
			} while (jumping);

			if ((size_t)active_route_index >= active_route->move_commands.size()) {
				stop_count = (active_route->repeat ? 0 : 256);
			}
		}
	}

	// When the overwrite status changed the active_index belongs to the
	// current non-active move route
	if (overwrite_changed != IsMoveRouteOverwritten()) {
		if (IsMoveRouteOverwritten()) {
			SetOriginalMoveRouteIndex(active_route_index);
		}
		else {
			SetMoveRouteIndex(active_route_index);
		}
	}
	else {
		if (IsMoveRouteOverwritten()) {
			SetMoveRouteIndex(active_route_index);
		}
		else {
			SetOriginalMoveRouteIndex(active_route_index);
		}
	}
}
Exemplo n.º 25
0
void CCharacter::RefreshBuff( )
{
    bool bflag = false;
    for( UINT i=0;i<32;i++)
    {
        if(MagicStatus[i].Buff == 0) continue;
        clock_t etime = clock() - MagicStatus[i].BuffTime;
        if( etime >= MagicStatus[i].Duration * CLOCKS_PER_SEC )
        {

            Log(MSG_INFO,"Magic Status %i, vanish after: %i", MagicStatus[i].Status, MagicStatus[i].Duration);

            switch(MagicStatus[i].Status)
            {
                case STATUS_HP_8: case STATUS_HP_18: case STATUS_HP_30: case STATUS_HP_43: case STATUS_HP_58: case STATUS_HP_75: case STATUS_SUMMON_HP:
                case STATUS_HP_92: case STATUS_HP_111: case STATUS_HP_131: case STATUS_HP_152: case STATUS_HP_174: case STATUS_HP_197: case STATUS_HP_221:
                case STATUS_HP_246: case STATUS_HP_272: case STATUS_HP_299: case STATUS_HP_326: case STATUS_HP_354: case STATUS_HP_383: case STATUS_HP_413:
                case STATUS_HP_443: case STATUS_HP_475: case STATUS_HP_539: case STATUS_HP_572: case STATUS_HP_5_PC: case 115:
                {
                    Status->HPHeal = 0xff;
                }
                break;

                case STATUS_MP_6: case STATUS_MP_10: case STATUS_MP_14: case STATUS_MP_18: case STATUS_MP_21: case STATUS_MP_25: case STATUS_MP_29:
                case STATUS_MP_33: case STATUS_MP_36: case STATUS_MP_40: case STATUS_MP_44: case STATUS_MP_48: case STATUS_MP_51: case STATUS_MP_55:
                case STATUS_MP_59: case STATUS_MP_63: case STATUS_MP_66: case STATUS_MP_70: case STATUS_MP_74: case STATUS_MP_78: case STATUS_MP_81:
                case STATUS_MP_85: case STATUS_MP_89: case STATUS_MP_93: case STATUS_MP_96: case 116:
                {
                    Status->MPHeal = 0xff;
                }
                break;

                case 18: // attack power up
                case 19: // attack power down
                case 48: // attack power up
                {
                    if(i == BUFF_ATTACK_UP_POS)
                    {
                        Status->Attack_up = 0xff;
                    }
                    else
                    {
                        Status->Attack_down = 0xff;
                    }
                    Stats->Attack_Power = GetAttackPower( );
                }
                break;
                case 20: // def up
                case 21: // def down
                case 49: // def up
                {
                    if(i==BUFF_DEFENSE_UP_POS)
                    {
                        Status->Defense_up= 0xff;
                    }
                    else
                    {
                        Status->Defense_down = 0xff;
                    }
                    Stats->Defense = GetDefense( );
                }
                break;
                case 24: //Accuracy up
                case 25: //Accuracy down
                case 51: //attack Accuracy up.
                {
                    if(i==BUFF_HITRATE_UP_POS)
                    {
                        Status->Accuracy_up= 0xff;
                    }
                    else
                    {
                        Status->Accuracy_down = 0xff;
                    }
                    Stats->Accuracy = GetAccuracy( );
                }
                break;
                case 22: // macic resistance up
                case 23: // magic resistance down
                case 50: // magic resistance up
                {
                    if(i==BUFF_MDEFENSE_UP_POS)
                    {
                        Status->Magic_Defense_up = 0xff;
                    }
                    else
                    {
                        Status->Magic_Defense_down = 0xff;
                    }
                    Stats->Magic_Defense = GetMagicDefense( );
                }
                break;
                case 28: //dodge up
                case 29: //dodge down
                case 53: //dodge rate up
                {
                    if(i==BUFF_DODGE_UP_POS)
                    {
                        Status->Dodge_up = 0xff;
                    }
                    else
                    {
                        Status->Dodge_down = 0xff;
                    }
                    Stats->Dodge = GetDodge( );
                }
                break;
                case 14: //dash
                case 15: //slow
                case 46: //movement speed increased
                {
                    if(i==BUFF_DASH_UP_POS)
                    {
                        Status->Dash_up = 0xff;
                    }
                    else
                    {
                        Status->Dash_down = 0xff;
                    }
                    Stats->Move_Speed = GetMoveSpeed( );
                }
                break;
                case 16: // haste attack
                case 17: // slow attack
                case 47: // attack speed up
                {
                    if(i==BUFF_HASTE_UP_POS)
                    {
                        Status->Haste_up = 0xff;
                    }
                    else
                    {
                        Status->Haste_down = 0xff;
                    }
                    //Stats->Attack_Speed_Percent = GetAttackSpeedPercent( );
                }
                break;
                case 26: // crit up
                case 27: // crit down
                case 52: // crit up
                {
                    if(i==BUFF_CRITICAL_UP_POS)
                    {
                        Status->Critical_up = 0xff;
                    }
                    else
                    {
                        Status->Critical_down = 0xff;
                    }
                    Stats->Critical = GetCritical( );
                }
                break;
                case 12: // max HP up
                case 44: // max HP up
                {
                    if(i==BUFF_MAX_HP_POS)
                    {
                        Status->HP_up = 0xff;
                    }
                    else
                    {
                        Status->HP_down = 0xff;
                    }
                    Stats->MaxHP = GetMaxHP( );

                    if(Stats->HP > Stats->MaxHP)
                    {
                        Stats->HP = Stats->MaxHP;
                    }
                }
                break;
                case 13: // max MP up
                case 45: // max MP up
                {
                    if(i==BUFF_MAX_MP_POS)
                    {
                        Status->MP_up = 0xff;
                    }
                    else
                    {
                        Status->MP_down = 0xff;
                    }
                    Stats->MaxMP = GetMaxMP( );

                    if(Stats->MP > Stats->MaxMP)
                    {
                        Stats->MP = Stats->MaxMP;
                    }
                }
                break;
                case 32: // faint
                {
                    Status->Faint = 0xff;
                    Status->CanMove = true;
                    Status->CanCastSkill = true;
                    Status->CanAttack = true;
                    //printf("removing stun\n");
                }
                break;
                case 7: case 8: case 9: case 10: case 11: case 89: //poisoned
                {
                    Status->Poisoned = 0xff;
                    //printf("removing poison\n");
                }
                break;
                case 30: // muted
                {
                    Status->Muted = 0xff;
                    Status->CanCastSkill = true;
                }
                break;
                case 31: // sleep May need to be fixed later to accomodate multiple status effects.
                {
                    Status->Sleep = 0xff;
                    Status->CanMove = true;
                    Status->CanCastSkill = true;
                    Status->CanAttack = true;
                }
                break;
                case 36: //A_Extra_Damage:
                case 54: //A_GMExtra_Damage:
                case 83: //Valkyrie Charm:
                {
                    if(i==BUFF_DUMMY_DAMAGE_POS)
                    {
                        Status->ExtraDamage_up = 0xff;
                        Stats->ExtraDamage_add = 0;//We put extardamage add value to 0 if we lost the adddmg buff
                    }
                    else
                    {
                        Status->ExtraDamage_down = 0xff;
                        Stats->ExtraDamage_add = 0;//We put extardamage add value to 0 if we lost the adddmg buff
                    }
                }
                break;
                case 56: //Taunt
                {
                    Status->Taunt = 0xff;
                    //printf("removing Taunt\n");
                }
                break;
                case 58: case 61: case 74: case 77:  case 78: case 79: case 80: //flame
                {
                    Status->Flamed = 0xff;
                }
                break;
                case 33://Stealth,Camoflauge
                {
                    if(IsAttacking( ))
                    {
                        MagicStatus[i].Duration = 0;
                    }
                    Status->Stealth = 0xff;
                    //printf("removing Stealth\n");
                }
                break;
                case 86://Stealth,Weary
                {
                    Status->Weary = 0xff;
                    Status->CanCastSkill = true;
                    //printf("removing Weary\n");
                }
                break;
                case 34://Cloaking
                {
                    Status->Cloaking = 0xff;
                    //printf("removing Cloaking\n");
                }
                break;
                case 35: //ShieldDamage:
                {
                    if(i==BUFF_SHIELD_DAMAGE_POS)
                    {
                        Status->ShieldDamage_up = 0xff;
                        //Stats->ShieldDamage = 0xff;
                    }
                    else
                    {
                        Status->ShieldDamage_down = 0xff;
                        //Stats->ShieldDamage = 0xff;
                    }
                }
                break;
                case 55://Detect
                {
                    Status->Detect = 0xff;
                    Status->Cloaking = 0xff;
                    Status->Stealth = 0xff;
                    //printf("Detect Done\n");
                }
                break;
                case 38://Purify
                {
                    //Buff_Down
                    Status->Attack_down = 0xff;
                    Status->Defense_down = 0xff;
                    Status->Accuracy_down = 0xff;
                    Status->Magic_Defense_down = 0xff;
                    Status->Dodge_down = 0xff;
                    Status->Dash_down = 0xff;
                    Status->Haste_down = 0xff;
                    Status->Critical_down = 0xff;
                    Status->HP_down = 0xff;
                    Status->MP_down = 0xff;
                    Status->ExtraDamage_down = 0xff;
                    Status->ShieldDamage_down = 0xff;
                    Status->ALL_down = 0xff;

                    //Bad Status
                    //Status->Stun = 0xff;
                    Status->Poisoned = 0xff;
                    Status->Muted = 0xff;
                    Status->Sleep = 0xff;
                    Status->Flamed = 0xff;
                    Status->Faint = 0xff;

                    //Stats
                    Stats->Attack_Power = GetAttackPower( );
                    Stats->Defense = GetDefense( );
                    Stats->Accuracy = GetAccuracy( );
                    Stats->Magic_Defense = GetMagicDefense( );
                    Stats->Dodge = GetDodge( );
                    Stats->Move_Speed = GetMoveSpeed( );
                    Stats->Attack_Speed = GetAttackSpeed( );
                    //Stats->Attack_Speed_Percent = GetAttackSpeedPercent();
                    Stats->Critical = GetCritical( );
                    Stats->MaxHP = GetMaxHP( );
                    Stats->MaxMP = GetMaxMP( );
                    //printf("Purify Done\n");
                }
                break;
				case 39:// Dispell
                {
                    //Buff_Down
                    Status->Attack_down = 0xff;
                    Status->Defense_down = 0xff;
                    Status->Accuracy_down = 0xff;
                    Status->Magic_Defense_down = 0xff;
                    Status->Dodge_down = 0xff;
                    Status->Dash_down = 0xff;
                    Status->Haste_down = 0xff;
                    Status->Critical_down = 0xff;
                    Status->HP_down = 0xff;
                    Status->MP_down = 0xff;
                    Status->ExtraDamage_down = 0xff;
                    Status->ShieldDamage_down = 0xff;
                    Status->ALL_down = 0xff;

                    //Buff_Up
                    Status->Attack_up = 0xff;
                    Status->Defense_up = 0xff;
                    Status->Accuracy_up = 0xff;
                    Status->Magic_Defense_up = 0xff;
                    Status->Dodge_up = 0xff;
                    Status->Dash_up = 0xff;
                    Status->Haste_up = 0xff;
                    Status->Critical_up = 0xff;
                    Status->HP_up = 0xff;
                    Status->MP_up = 0xff;
                    Status->ExtraDamage_up = 0xff;
                    Status->ShieldDamage_up = 0xff;
                    Status->ALL_up = 0xff;

                    //Bad Status
                    //Status->Stun = 0xff;
                    Status->Poisoned = 0xff;
                    Status->Muted = 0xff;
                    Status->Sleep = 0xff;
                    Status->Flamed = 0xff;
                    Status->Faint = 0xff;

                    //Stats
                    Stats->Attack_Power = GetAttackPower( );
                    Stats->Defense = GetDefense( );
                    Stats->Accuracy = GetAccuracy( );
                    Stats->Magic_Defense = GetMagicDefense( );
                    Stats->Dodge = GetDodge( );
                    Stats->Move_Speed = GetMoveSpeed( );
                    Stats->Attack_Speed = GetAttackSpeed( );
                    Stats->Critical = GetCritical( );
                    Stats->MaxHP = GetMaxHP( );
                    Stats->MaxMP = GetMaxMP( );
                    //printf("Dispell Done\n");
                }
                break;
                default:
                {
                    Log(MSG_WARNING,"Unknow skill status in charfunctions %u.",MagicStatus[i].Status);
                }
            }
            BEGINPACKET( pak,0x7b7 );
            ADDWORD    ( pak, clientid );
            ADDDWORD   ( pak, GServer->BuildBuffs( this ) );
            GServer->SendToVisible( &pak, this );
            MagicStatus[i].Status = 0;
            MagicStatus[i].Buff = 0;
            MagicStatus[i].BuffTime = 0;
            MagicStatus[i].Duration = 0;
            MagicStatus[i].Value = 0;
            bflag = true;
        }
        else if ( ((MagicStatus[i].Status >= 7 && MagicStatus[i].Status <= 11) || MagicStatus[i].Status == 89) && etime > 1*CLOCKS_PER_SEC) //Do poison dmg every 1.5 seconds
        {
             Stats->HP -= MagicStatus[i].Status; //Actually take 7, 8, 9, 10 or 11 from the health. Based on the Status itself, LMA: can be 89 noc too.
             MagicStatus[i].BuffTime += 1*CLOCKS_PER_SEC;
             MagicStatus[i].Duration -= 1;
             //printf("did %i poison dmg to the player, still %i seconds and %i HP remain \n", MagicStatus[i].Status, MagicStatus[i].Duration, Stats->HP);
             //Log(MSG_WARNING,"did %i poison dmg to the player / monster, still %i seconds and %I64i HP remain", MagicStatus[i].Status, MagicStatus[i].Duration, Stats->HP);

            //LMA: If dead, let's the client resynch
            if(IsDead())
            {
                BEGINPACKET( pak, 0x79f );
                ADDWORD    ( pak, clientid );
                ADDDWORD   ( pak, 1);
                GServer->SendToVisible( &pak, this );
                Log(MSG_INFO,"death poison for %i, amount: %i",clientid,MagicStatus[i].Status);
            }

             //A bunch of messy code to send dmg packet
             BEGINPACKET( pak, 0x7b6 );
             ADDWORD    ( pak, clientid );
             ADDWORD    ( pak, 0 );
             ADDDWORD   ( pak, 0x000007f8 );
             ADDBYTE    ( pak, 0x00 );
             ADDDWORD   ( pak, MagicStatus[i].Status );

             //If Enemy is killed
             if( IsDead())
             {
                 //printf("char died\n");
                 CDrop* thisdrop = NULL;
                 ADDDWORD   ( pak, 16 );
                 if( !IsSummon( ) && !IsPlayer( ))
                 {
                    //LMA: No drop if already dead and drop done.
                    if(drop_dead)
                    {
                        Log(MSG_WARNING,"Trying to make a monster (CID %u, type %u) drop again but already did.",clientid,char_montype);
                    }
                    else
                    {
                         thisdrop = GetDrop( );
                         if( thisdrop!=NULL)
                         {
                             CMap* map = GServer->MapList.Index[thisdrop->posMap];
                             map->AddDrop( thisdrop );
                         }

                    }

                 }

                 //GServer->SendToVisible( &pak, this, thisdrop );
                 GServer->SendToVisible( &pak, this);
             }
             else
             {
                 //If enemy is still alive
                 ADDDWORD   ( pak, 4 );
                 GServer->SendToVisible( &pak, this );
             }
         }
        else if ( MagicStatus[i].Status == 58 || MagicStatus[i].Status == 61 || MagicStatus[i].Status == 71 || MagicStatus[i].Status >= 77 && MagicStatus[i].Status <= 80 || MagicStatus[i].Status == 88 && etime > 1*CLOCKS_PER_SEC) //Do flame dmg every 1.5 seconds
        {
             Stats->HP -= MagicStatus[i].Status;
             MagicStatus[i].BuffTime += 1*CLOCKS_PER_SEC;
             MagicStatus[i].Duration -= 1;
             printf("did %i flame dmg to the player, still %i seconds and %i HP remain \n", MagicStatus[i].Status, MagicStatus[i].Duration, Stats->HP);

            //LMA: If dead, let's the client resynch
            if(IsDead())
            {
                BEGINPACKET( pak, 0x79f );
                ADDWORD    ( pak, clientid );
                ADDDWORD   ( pak, 1);
                GServer->SendToVisible( &pak, this );
                Log(MSG_INFO,"death flame for %i, amount: %i",clientid,MagicStatus[i].Status);
            }

             //A bunch of messy code to send dmg packet
             BEGINPACKET( pak, 0x7b6 );
             ADDWORD    ( pak, clientid );
             ADDWORD    ( pak, 0 );
             ADDDWORD   ( pak, 0x000007f8 );
             ADDBYTE    ( pak, 0x00 );
             ADDDWORD   ( pak, MagicStatus[i].Status );

             //If Enemy is killed
             if( IsDead())
             {
                 //printf("char died\n");
                 CDrop* thisdrop = NULL;
                 ADDDWORD   ( pak, 16 );
                 if( !IsSummon( ) && !IsPlayer( ))
                 {
                    //LMA: No drop if already dead and drop done.
                    if(drop_dead)
                    {
                        Log(MSG_WARNING,"Trying to make a monster (CID %u, type %u) drop again but already did.",clientid,char_montype);
                    }
                    else
                    {
                         thisdrop = GetDrop( );
                         if( thisdrop!=NULL)
                         {
                             CMap* map = GServer->MapList.Index[thisdrop->posMap];
                             map->AddDrop( thisdrop );
                         }

                    }

                 }
                 //GServer->SendToVisible( &pak, this, thisdrop );
                 GServer->SendToVisible( &pak, this);
             }
             else
             {
                 //If enemy is still alive
                 ADDDWORD   ( pak, 4 );
                 GServer->SendToVisible( &pak, this );
             }
         }

    }
    for( UINT i=0;i<32;i++)
    {
        if(MagicStatus2[i].Buff == 0) continue;
        clock_t etime = clock() - MagicStatus2[i].BuffTime;
        if( etime >= MagicStatus2[i].Duration * CLOCKS_PER_SEC )
        {
        CPlayer* thisplayer = GServer->GetClientByID(clientid);
            Log(MSG_INFO,"Magic Status %i, vanish after: %i", MagicStatus2[i].Status, MagicStatus2[i].Duration);

            switch(MagicStatus2[i].Status)
            {
                case 126: // ALLbuff up
                {
                    if(i == BUFF_ATTACK_UP_POS)
                    {
                        Status->Attack_up = 0xff;
                        thisplayer->Attr->ALLbuff = 0;
                    }
                    else
                    {
                        Status->Attack_down = 0xff;
                        thisplayer->Attr->ALLbuff = 0;
                    }
                }
                default:
                {
                    Log(MSG_WARNING,"Unknow skill status in charfunctions %u.",MagicStatus[i].Status);
                }
            }
            BEGINPACKET( pak,0x7b7 );
            ADDWORD    ( pak, clientid );
            ADDDWORD   ( pak, GServer->BuildBuffs( this ) );
            GServer->SendToVisible( &pak, this );
            MagicStatus2[i].Status = 0;
            MagicStatus2[i].Buff = 0;
            MagicStatus2[i].BuffTime = 0;
            MagicStatus2[i].Duration = 0;
            MagicStatus2[i].Value = 0;
        }
    }
//    if(bflag)
//    {
//        BEGINPACKET( pak,0x7b7 );
//        ADDWORD    ( pak, clientid );
//        ADDDWORD   ( pak, GServer->BuildBuffs( this ) );
//        GServer->SendToVisible( &pak, this );
//    }
}
Exemplo n.º 26
0
// Check For Debuffs
void CCharacter::RefreshBuff( )
{
    bool bflag = false;
    for( UINT i=0; i<30; i++)
    {
        if(MagicStatus[i].Buff==0) continue;
        clock_t etime = clock() - MagicStatus[i].BuffTime;
        if( etime >= MagicStatus[i].Duration * CLOCKS_PER_SEC )
        {
            switch(MagicStatus[i].Buff)
            {
            case A_ATTACK:
                if(i<15)
                    Status->Attack_up = 0xff;
                else
                    Status->Attack_down = 0xff;
                Stats->Attack_Power = GetAttackPower( );
                break;
            case A_DEFENSE:
                if(i<15)
                    Status->Defense_up= 0xff;
                else
                    Status->Defense_down = 0xff;
                Stats->Defense = GetDefense( );
                break;
            case A_ACCUR:
                if(i<15)
                    Status->Accury_up= 0xff;
                else
                    Status->Accury_down = 0xff;
                Stats->Accury = GetAccury( );
                break;
            case A_MRESIST:
                if(i<15)
                    Status->Magic_Defense_up = 0xff;
                else
                    Status->Magic_Defense_down = 0xff;
                Stats->Magic_Defense = GetMagicDefense( );
                break;
            case A_DODGE:
                if(i<15)
                    Status->Dodge_up = 0xff;
                else
                    Status->Dodge_down = 0xff;
                Stats->Dodge = GetDodge( );
                break;
            case A_DASH:
                if(i<15)
                    Status->Dash_up = 0xff;
                else
                    Status->Dash_down = 0xff;
                Stats->Move_Speed = GetMoveSpeed( );
                break;
            case A_HASTE:
                if(i < 15)
                {
                    Status->Haste_up = 0xff;
                }
                else
                {
                    Status->Haste_down = 0xff;
                }
                Stats->Attack_Speed = GetAttackSpeed();
                break;
            case A_CRITICAL:
                if(i<15)
                    Status->Critical_up = 0xff;
                else
                    Status->Critical_down = 0xff;
                Stats->Critical = GetCritical( );
                break;
            case A_MAX_HP:
                if(i<15)
                    Status->HP_up = 0xff;
                else
                    Status->HP_down = 0xff;
                Stats->MaxHP = GetMaxHP( );
                break;
            case A_MAX_MP:
                if(i<15)
                    Status->MP_up = 0xff;
                else
                    Status->MP_down = 0xff;
                Stats->MaxMP = GetMaxMP( );
                break;
            case A_STUN:
                Status->Stuned = 0xff;
                printf("removing stun\n");
                //StartAction2(NULL, 0, 0, true);
                break;
            case A_POISON:
                Status->Poisoned = 0xff;
                printf("removing poison\n");
                break;
            case A_MUTE:
                Status->Muted = 0xff;
                break;
            case A_GMExtra_Damage:
            case A_Extra_Damage:
                if(i<15)
                {
                    Status->ExtraDamage_up = 0xff;
                    Stats->ExtraDamage = 0;
                }

                else
                    Status->ExtraDamage_down = 0xff;

                break;
            }
            MagicStatus[i].Buff = 0;
            MagicStatus[i].BuffTime = 0;
            MagicStatus[i].Duration = 0;
            MagicStatus[i].Value = 0;
            bflag = true;
        }
        else if (MagicStatus[i].Buff == A_POISON && etime > 1*CLOCKS_PER_SEC) //Do poison dmg every 1.5 seconds
        {
            Stats->HP -= MagicStatus[i].Value;
            MagicStatus[i].BuffTime+= 1*CLOCKS_PER_SEC;
            MagicStatus[i].Duration-=1;
            printf("did %i poison dmg to the player, still %i seconds and %i HP remain \n", MagicStatus[i].Value, MagicStatus[i].Duration, Stats->HP);

            //A bunch of messy code to send dmg packet
            BEGINPACKET( pak, 0x7b6 );
            ADDWORD    ( pak, clientid );
            ADDWORD    ( pak, 0 );
            ADDDWORD   ( pak, 0x000007f8 );
            ADDBYTE    ( pak, 0x00 );
            ADDDWORD   ( pak, MagicStatus[i].Value );

            //If Enemy is killed
            if( IsDead())
            {
                printf("char died\n");
                CDrop* thisdrop = NULL;
                //ADDDWORD   ( pak, 16 );//i don't think this one belongs in irose
                if( !IsSummon( ) && !IsPlayer( ))
                {
                    thisdrop = GetDrop( );
                    if( thisdrop!=NULL)
                    {
                        ADDFLOAT   ( pak, thisdrop->pos.x*100 );
                        ADDFLOAT   ( pak, thisdrop->pos.y*100 );
                        if( thisdrop->type==1)
                        {
                            ADDDWORD( pak, 0xccdf );//0xccccccdf );
                            ADDDWORD( pak, thisdrop->amount );
                        }
                        else
                        {
                            ADDDWORD   ( pak, GServer->BuildItemHead( thisdrop->item ) );
                            ADDDWORD   ( pak, GServer->BuildItemData( thisdrop->item ) );
                        }
                        ADDWORD    ( pak, thisdrop->clientid );
                        ADDWORD    ( pak, thisdrop->owner );
                        CMap* map = GServer->MapList.Index[thisdrop->posMap];
                        map->AddDrop( thisdrop );
                    }
                }
                GServer->SendToVisible( &pak, this, thisdrop );
            }

            //If enemy is still alive
            else
            {
                ADDDWORD   ( pak, 4 );
                GServer->SendToVisible( &pak, this );
            }
        }
    }
    if(bflag)
    {
        BEGINPACKET( pak,0x7b7 );
        ADDWORD    ( pak, clientid );
        ADDDWORD   ( pak, GServer->BuildBuffs( this ) );
        GServer->SendToVisible( &pak, this );
    }
}
Exemplo n.º 27
0
void CMinotaur::CollisionResponse(IObject* _cCollidedObject)
{
	//DBG_UNREFERENCED_PARAMETER(_cCollidedObject);
	/*if (_cCollidedObject->GetTag() == "Floor" || _cCollidedObject->GetTag() == "SafeHavenFloor")
	{
	if (m_mWorld.m[3][1] > -20.0f && m_f3Velocity.y < 0.0f)
	{
	CapsuleToFloor(this, m_pvColliders[1], _cCollidedObject->GetColliders()[0]);

	}
	}*/

	if (_cCollidedObject->GetTag() == "Wall" || _cCollidedObject->GetTag() == "Door" || _cCollidedObject->GetTag() == "CrackedWall" || _cCollidedObject->GetTag() == "Enemy Cave Wall")
	{

		for (size_t i = 1; i < _cCollidedObject->GetColliders().size(); i++)
		{
			if (_cCollidedObject->GetColliders()[i]->GetCollided())
			{
				if (_cCollidedObject->GetColliders()[i]->GetType() == Bounds::AABB)
				{
					CapsuleToWall(this, m_pvColliders[1], _cCollidedObject->GetColliders()[i]);
					_cCollidedObject->GetColliders()[i]->SetCollided(false);
				}
				else if (_cCollidedObject->GetColliders()[i]->GetType() == Bounds::Plane)
				{
					if (m_mWorld.m[3][1] > -20.0f && m_f3Velocity.y < 0.0f)
					{
						CapsuleToFloor(this, m_pvColliders[1], _cCollidedObject->GetColliders()[i]);
						_cCollidedObject->GetColliders()[i]->SetCollided(false);
						m_bIsGrounded = true;
					}
				}
			}
		}
	}
	else if (_cCollidedObject->GetTag() == "MinotaurSpawn")
	{
	
		for (size_t i = 1; i < _cCollidedObject->GetColliders().size(); i++)
		{
			if (_cCollidedObject->GetColliders()[i]->GetCollided())
			{
				if (_cCollidedObject->GetColliders()[i]->GetType() == Bounds::AABB)
				{
					CAABB* bounds = (CAABB*)(_cCollidedObject->GetColliders()[i]->GetBounds());

					CapsuleToWall(this, m_pvColliders[1], _cCollidedObject->GetColliders()[i]);

					_cCollidedObject->GetColliders()[i]->SetCollided(false);
				}
				else if (_cCollidedObject->GetColliders()[i]->GetType() == Bounds::Plane)
				{
					if (m_mWorld.m[3][1] > -20.0f && m_f3Velocity.y < 0.0f)
					{
						CapsuleToFloor(this, m_pvColliders[1], _cCollidedObject->GetColliders()[i]);
						_cCollidedObject->GetColliders()[i]->SetCollided(false);
						m_bIsGrounded = true;
					}
				}
			}
		}
	}
	else if (_cCollidedObject->GetTag() == "SmallPit")
	{
		if (m_mWorld.m[3][1] > -20.0f && m_f3Velocity.y < 0.0f)
		{
			CapsuleToFloor(this, m_pvColliders[1], _cCollidedObject->GetColliders()[_cCollidedObject->GetColliders().size() - 1]);
			_cCollidedObject->GetColliders()[_cCollidedObject->GetColliders().size() - 1]->SetCollided(false);

			m_bIsGrounded = true;

		}
		else if (m_f3Velocity.y < 0.0f)
		{
			m_bIsGrounded = true;

			for (size_t i = 1; i < _cCollidedObject->GetColliders().size() - 1; i++)
			{
				if (_cCollidedObject->GetColliders()[i]->GetCollided())
				{
					CapsuleToWall(this, m_pvColliders[1], _cCollidedObject->GetColliders()[i]);
					_cCollidedObject->GetColliders()[i]->SetCollided(false);
				}
			}
		}
		//CapsuleToFloor(this, m_pvColliders[1], _cCollidedObject->GetColliders()[GetColliders().size() - 1]);
	}
	else if (_cCollidedObject->GetTag() == "BigPit")
	{
		if (m_mWorld.m[3][1] > -20.0f && m_f3Velocity.y < 0.0f)
		{
			CapsuleToFloor(this, m_pvColliders[1], _cCollidedObject->GetColliders()[_cCollidedObject->GetColliders().size() - 1]);
			_cCollidedObject->GetColliders()[_cCollidedObject->GetColliders().size() - 1]->SetCollided(false);

			m_bIsGrounded = true;

		}
		else if (m_f3Velocity.y < 0.0f)
		{

			for (size_t i = 1; i < _cCollidedObject->GetColliders().size() - 1; i++)
			{
				if (_cCollidedObject->GetColliders()[i]->GetCollided())
				{
					CapsuleToWall(this, m_pvColliders[1], _cCollidedObject->GetColliders()[i]);
					_cCollidedObject->GetColliders()[i]->SetCollided(false);
				}
			}
		}
	}
	else if (_cCollidedObject->GetTag() == "CaveSpawn")
	{
		CapsuleToWall(this, m_pvColliders[1], _cCollidedObject->GetColliders()[0]);
		_cCollidedObject->GetColliders()[0]->SetCollided(false);

	}
	else if (_cCollidedObject->GetTag() == "Player")
	{
		CPlayer* player = reinterpret_cast<CPlayer*>(GetPlayer());
		player->TakeDamage(200);
		if (player->GetHealth() > 0)
		{
			XMFLOAT3 pos = *GetPosition();
			XMFLOAT3 playerPos = *player->GetPosition();
			AudioSystemWwise::Get()->PostEvent(AK::EVENTS::MINOGRUNT, pos);
			AudioSystemWwise::Get()->PostEvent(AK::EVENTS::PLAYERTRAMPLE, playerPos);
		}
		//_cCollidedObject->GetColliders()[1]->SetCollided(false);

	}
	else if (_cCollidedObject->GetTag() == "SafeHavenFloor")
	{
		ChangeState(eDeadState);
	}
	else if (_cCollidedObject->GetTag() == "Floor")
	{
		if (m_mWorld.m[3][1] > -20.0f && m_f3Velocity.y < 0.0f)
		{
			CapsuleToFloor(this, m_pvColliders[1], _cCollidedObject->GetColliders()[0]);
			m_bIsGrounded = true;
		}
	}

	else if (_cCollidedObject->GetTag() == "SpikeTrap" || _cCollidedObject->GetTag() == "SpinningBlade")
	{
		if (m_fSlowTimer >= 0.0f)
		{
			m_fSlowTimer = SLOW_TIME;
			SetMoveSpeed(GetMoveSpeed() * 0.5f);
			m_fCurrentHealth -= 10.0f;
		}
	}
	else if (_cCollidedObject->GetTag() == "TrapPrefab")
	{

		CapsuleToFloor(this, m_pvColliders[1], _cCollidedObject->GetColliders()[0]);
		m_bIsGrounded = true;

		/*for (size_t i = 1; i < _cCollidedObject->GetColliders().size(); i++)
		{
		if (_cCollidedObject->GetColliders()[i]->GetCollided())
		{
		if (_cCollidedObject->GetColliders()[i]->GetType() == Bounds::AABB)
		{
		if (m_mWorld.m[3][1] > -20.0f && m_f3Velocity.y < 0.0f)
		CapsuleToFloor(this, m_pvColliders[1], _cCollidedObject->GetColliders()[i]);
		else
		CapsuleToWall(this, m_pvColliders[1], _cCollidedObject->GetColliders()[i]);

		m_bIsGrounded = true;

		_cCollidedObject->GetColliders()[i]->SetCollided(false);
		}
		else if (_cCollidedObject->GetColliders()[i]->GetType() == Bounds::Plane)
		{
		if (m_mWorld.m[3][1] > -20.0f && m_f3Velocity.y < 0.0f)
		{
		CapsuleToFloor(this, m_pvColliders[1], _cCollidedObject->GetColliders()[i]);
		_cCollidedObject->GetColliders()[i]->SetCollided(false);
		m_bIsGrounded = true;
		}
		}
		}
		}*/
	}
	else if (_cCollidedObject->GetTag() == "ExitDoor")
	{

		CapsuleToWall(this, m_pvColliders[1], _cCollidedObject->GetColliders()[0]);
		_cCollidedObject->GetColliders()[0]->SetCollided(false);

	}
	else if (_cCollidedObject->GetTag() == "Bridge")
	{
		CBridge* curBridge = reinterpret_cast<CBridge*>(_cCollidedObject);


		if (curBridge->IsActive() && curBridge->IsIntact())
		{



			if (curBridge->IsActive() && curBridge->IsIntact())
			{
				if (_cCollidedObject->GetColliders()[1]->GetCollided())
				{
					CAABB* bounds = ((CAABB*)_cCollidedObject->GetColliders()[1]->GetBounds());
					if ((bounds->GetExtents().x == 250.0f &&
						bounds->GetExtents().y == 150.0f &&
						bounds->GetExtents().z == 50.0f) || (bounds->GetExtents().x == 50.0f &&
						bounds->GetExtents().y == 150.0f &&
						bounds->GetExtents().z == 250.0f))
					{
						CBridge* bridge = (CBridge*)_cCollidedObject;
						bridge->Destroy();
						m_bIsGrounded = false;
						ChangeState(EMinotaurStates::eDeadState);

					}
					_cCollidedObject->GetColliders()[1]->SetCollided(false);


				}
				for (size_t i = 2; i < 10; i++)
				{
					if (_cCollidedObject->GetColliders()[i]->GetCollided())
					{
						if (GetPosition()->y < 20.0f)
						{
							CapsuleToFloor(this, m_pvColliders[1], _cCollidedObject->GetColliders()[i]);
							_cCollidedObject->GetColliders()[i]->SetCollided(false);
							m_bIsGrounded = true;
						}
						else
						{
							CapsuleToWall(this, m_pvColliders[1], _cCollidedObject->GetColliders()[i]);
							_cCollidedObject->GetColliders()[i]->SetCollided(false);
						}
					}
				}
				for (size_t i = 10; i < _cCollidedObject->GetColliders().size(); i++)
				{
					if (_cCollidedObject->GetColliders()[i]->GetCollided())
					{

						CapsuleToWall(this, m_pvColliders[1], _cCollidedObject->GetColliders()[i]);
						_cCollidedObject->GetColliders()[i]->SetCollided(false);
					}
				}

				//for (size_t i = 1; i < _cCollidedObject->GetColliders().size(); i++)
				//{
				//	if (_cCollidedObject->GetColliders()[i]->GetCollided())
				//	{
				//		//CapsuleToWall(this, m_pvColliders[1], _cCollidedObject->GetColliders()[i]);
				//		_cCollidedObject->GetColliders()[i]->SetCollided(false);
				//	}
				//}
				//if (_cCollidedObject->GetColliders()[0]->GetCollided())
				//{
				//	//CapsuleToFloor(this, m_pvColliders[1], _cCollidedObject->GetColliders()[0]);
				//	_cCollidedObject->GetColliders()[0]->SetCollided(false);
				//	m_bIsGrounded = true;
				//}
			}

		}
	}

	else if (_cCollidedObject->GetTag() == "CrackedWall")
	{
		for (size_t i = 0; i < _cCollidedObject->GetColliders().size() - 4; i++)
		{
			if ((_cCollidedObject->GetColliders()[i])->GetCollided())
			{
				if (_cCollidedObject->GetColliders()[i]->GetType() == Bounds::AABB)
				{
					CapsuleToWall(this, m_pvColliders[1], _cCollidedObject->GetColliders()[i]);
					_cCollidedObject->GetColliders()[i]->SetCollided(false);
				}
				else if (_cCollidedObject->GetColliders()[i]->GetType() == Bounds::Plane)
				{
					CapsuleToFloor(this, m_pvColliders[1], _cCollidedObject->GetColliders()[i]);
					_cCollidedObject->GetColliders()[i]->SetCollided(false);
					m_bIsGrounded = true;
				}
			}
		}
	}
	else if (_cCollidedObject->GetTag() == "Minotaur")
	{
		CapsuleToCapsule(this, m_pvColliders[1], _cCollidedObject->GetColliders()[1]);
	}
	else if (_cCollidedObject->GetTag() == "Skeleton")
	{
		reinterpret_cast<CSkeleton*>(_cCollidedObject)->TakeDamage(200);
	}
	else if (_cCollidedObject->GetTag() == "PitWall")
	{
		//		m_f3Velocity.y = 1000.0f;
	}
}
Exemplo n.º 28
0
VOID Obj_Monster::SendMsg_RefeshAttrib( VOID )
{
__ENTER_FUNCTION

	BOOL bPublicAttrModified ;
	bPublicAttrModified		= FALSE;

	GCCharBaseAttrib msgPublicAttr, msgProtectedAttr;

	msgPublicAttr.setObjID( GetID() );
	msgProtectedAttr.setObjID( GetID() );

	//msgPublicAttr.setName( GetName() );
	//msgProtectedAttr.setName( GetName() );

	//msgPublicAttr.setTitle( GetTitle() );
	//msgProtectedAttr.setTitle( GetTitle() );

	if(m_AttrBackUp.m_HP != GetHP())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_HP = GetHP();

		BYTE yHPPercent = (GetMaxHP())?((BYTE)((GetHP()*100 + GetMaxHP() - 1)/GetMaxHP())):(0);
		msgPublicAttr.setHPPercent( yHPPercent );
		msgProtectedAttr.setHPPercent( yHPPercent );
	}

	if(m_AttrBackUp.m_MaxHp != GetMaxHP())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_MaxHp = GetMaxHP();

		BYTE yHPPercent = (GetMaxHP())?((BYTE)((GetHP()*100 + GetMaxHP() - 1)/GetMaxHP())):(0);
		msgPublicAttr.setHPPercent( yHPPercent );
		msgProtectedAttr.setHPPercent( yHPPercent );
	}

	// add by gh 2010/03/30
	if(m_AttrBackUp.m_MP != GetMP())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_MP = GetMP();

		BYTE yMPPercent = (GetMaxMP())?((BYTE)((GetMP()*100 + GetMaxMP() - 1)/GetMaxMP())):(0);
		msgPublicAttr.setMPPercent( yMPPercent );
		msgProtectedAttr.setMPPercent( yMPPercent );
	}

	if(m_AttrBackUp.m_MaxMp != GetMaxMP())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_MaxMp = GetMaxMP();

		BYTE yMPPercent = (GetMaxMP())?((BYTE)((GetMP()*100 + GetMaxMP() - 1)/GetMaxMP())):(0);
		msgPublicAttr.setMPPercent( yMPPercent );
		msgProtectedAttr.setMPPercent( yMPPercent );
	}
	// end of add
	if(fabs(m_AttrBackUp.m_MoveSpeed-GetMoveSpeed()) > 0.001f)
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_MoveSpeed = GetMoveSpeed();

		msgPublicAttr.setMoveSpeed( GetMoveSpeed() );
		msgProtectedAttr.setMoveSpeed( GetMoveSpeed() );
	}

	if(m_AttrBackUp.m_nDataID != GetDataID())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_nDataID = GetDataID();

	}

	const _CAMP_DATA *pCampData = GetCampData();
	if ( pCampData != NULL )
	{
		if(m_AttrBackUp.m_CampData != *pCampData)
		{
			bPublicAttrModified = TRUE;
			m_AttrBackUp.m_CampData = *pCampData;

			msgPublicAttr.setCampData( pCampData );
			msgProtectedAttr.setCampData( pCampData );
		}
	}

	if(m_AttrBackUp.m_OwnerID != GetOwnerID())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_OwnerID = GetOwnerID();

		msgPublicAttr.setOwnerID( GetOwnerID() );
		msgProtectedAttr.setOwnerID( GetOwnerID() );
	}

	if(m_AttrBackUp.m_OccupantGUID != GetOccupantGUID())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_OccupantGUID = GetOccupantGUID();

		msgPublicAttr.setOccupantGUID( GetOccupantGUID() );
		msgProtectedAttr.setOccupantGUID( GetOccupantGUID() );
	}

	if(m_AttrBackUp.m_nModelID != GetModelID())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_nModelID = GetModelID();
		msgPublicAttr.setModelID( GetModelID() );
		msgProtectedAttr.setModelID( GetModelID() );
	}

	if(m_AttrBackUp.m_nMountID != GetMountID())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_nMountID = GetMountID();
		msgPublicAttr.setMountID( GetMountID() );
		msgProtectedAttr.setMountID( GetMountID() );
	}

	if (m_AttrBackUp.m_nAIType != GetAIType() )
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_nAIType = GetAIType();
		INT nRet = GetMonsterAIType();
		msgPublicAttr.setAIType(nRet);
		msgProtectedAttr.setAIType(nRet);
	}

	if(m_AttrBackUp.m_nStealthLevel != GetStealthLevel())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_nStealthLevel = GetStealthLevel();

		msgPublicAttr.setStealthLevel( GetStealthLevel() );
		msgProtectedAttr.setStealthLevel( GetStealthLevel() );
	}

	if(m_AttrBackUp.m_nMoodState != GetMoodState())
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_nMoodState = GetMoodState();

		msgPublicAttr.setMoodState( GetMoodState() );
		msgProtectedAttr.setMoodState( GetMoodState() );
	}

	//if( m_AttrBackUp.m_iWeaponID != GetWeaponID() )
	//{
	//	bPublicAttrModified = TRUE;
	//	m_AttrBackUp.m_iWeaponID = GetWeaponID();
	//	//msgPublicAttr.setWeaponID( m_AttrBackUp.m_iWeaponID );
	//	msgProtectedAttr.setWeaponID( m_AttrBackUp.m_iWeaponID );
	//}

	if( m_AttrBackUp.m_iHorseID != GetHorseID() )
	{
		bPublicAttrModified = TRUE;
		m_AttrBackUp.m_iHorseID = GetHorseID();
		msgPublicAttr.setMountID( m_AttrBackUp.m_iHorseID );
		msgProtectedAttr.setMountID( m_AttrBackUp.m_iHorseID );
	}

	if ( bPublicAttrModified )
	{
		if ( bPublicAttrModified )
		{
			m_PublicAttrVersion++;
		}

		if ( bPublicAttrModified || m_ProtectedAttrVersion )
		{
			m_ProtectedAttrVersion++;
		}

		HUMANLIST listHuman;
		getScene()->ScanHuman( getZoneID(), MAX_REFESH_OBJ_ZONE_RADIUS, &(listHuman) );

		BOOL bSendPublicMsg				= bPublicAttrModified;
		BOOL bSendProtectedMsg			= (BOOL)(bPublicAttrModified || m_ProtectedAttrVersion);
		BYTE i;
		for ( i = 0; i < listHuman.m_Count; i++ )
		{
			Obj_Human *pTargetHuman = listHuman.m_aHuman[i];
			if ( IsCanViewMe( pTargetHuman ) )
			{
				ENUM_REFESH_ATTR_TYPE eType = CalcRefeshAttrType( this, pTargetHuman );
				switch( eType )
				{
				case REFESH_ATTR_TYPE_NONE:
					break;
				case REFESH_ATTR_TYPE_PUBLIC:
				case REFESH_ATTR_TYPE_PUBLIC_AND_LEVEL:
					if ( bSendPublicMsg )
					{
						pTargetHuman->GetPlayer()->SendPacket( &msgPublicAttr );
					}
					break;
				case REFESH_ATTR_TYPE_PROTECTED:
					if ( bSendProtectedMsg )
					{
						pTargetHuman->GetPlayer()->SendPacket( &msgProtectedAttr );
					}
					break;
				default:
					break;
				}
			}
		}
	}

__LEAVE_FUNCTION
}
Exemplo n.º 29
0
void Game_Character::UpdateJump() {
	static const int jump_speed[] = {8, 12, 16, 24, 32, 64};
	remaining_step -= jump_speed[GetMoveSpeed() - 1];
	if (remaining_step <= 0)
		jumping = false;
}
Exemplo n.º 30
0
void Game_Character::MoveTypeCustom() {
	// Detect if custom movement or event overwrite
	const RPG::MoveRoute* active_route;
	int active_route_index;
	bool overwrite_changed = IsMoveRouteOverwritten();
	if (IsMoveRouteOverwritten()) {
		active_route = &GetMoveRoute();
		active_route_index = GetMoveRouteIndex();
	}
	else {
		active_route = &original_move_route;
		active_route_index = GetOriginalMoveRouteIndex();
	}

	if (IsStopping()) {
		move_failed = false;

		for (; (size_t)active_route_index < active_route->move_commands.size(); ++active_route_index) {
			if (!IsStopping() || wait_count > 0 || stop_count < max_stop_count)
				break;

			const RPG::MoveCommand& move_command = active_route->move_commands[active_route_index];

			switch (move_command.command_id) {
			case RPG::MoveCommand::Code::move_up:
			case RPG::MoveCommand::Code::move_right:
			case RPG::MoveCommand::Code::move_down:
			case RPG::MoveCommand::Code::move_left:
			case RPG::MoveCommand::Code::move_upright:
			case RPG::MoveCommand::Code::move_downright:
			case RPG::MoveCommand::Code::move_downleft:
			case RPG::MoveCommand::Code::move_upleft:
				Move(move_command.command_id);
				break;
			case RPG::MoveCommand::Code::move_random:
				MoveRandom();
				break;
			case RPG::MoveCommand::Code::move_towards_hero:
				MoveTowardsPlayer();
				break;
			case RPG::MoveCommand::Code::move_away_from_hero:
				MoveAwayFromPlayer();
				break;
			case RPG::MoveCommand::Code::move_forward:
				MoveForward();
				break;
			case RPG::MoveCommand::Code::face_up:
				Turn(Up);
				break;
			case RPG::MoveCommand::Code::face_right:
				Turn(Right);
				break;
			case RPG::MoveCommand::Code::face_down:
				Turn(Down);
				break;
			case RPG::MoveCommand::Code::face_left:
				Turn(Left);
				break;
			case RPG::MoveCommand::Code::turn_90_degree_right:
				Turn90DegreeRight();
				break;
			case RPG::MoveCommand::Code::turn_90_degree_left:
				Turn90DegreeLeft();
				break;
			case RPG::MoveCommand::Code::turn_180_degree:
				Turn180Degree();
				break;
			case RPG::MoveCommand::Code::turn_90_degree_random:
				Turn90DegreeLeftOrRight();
				break;
			case RPG::MoveCommand::Code::face_random_direction:
				FaceRandomDirection();
				break;
			case RPG::MoveCommand::Code::face_hero:
				TurnTowardHero();
				break;
			case RPG::MoveCommand::Code::face_away_from_hero:
				TurnAwayFromHero();
				break;
			case RPG::MoveCommand::Code::wait:
				Wait();
				break;
			case RPG::MoveCommand::Code::begin_jump:
				BeginJump(active_route, &active_route_index);
				break;
			case RPG::MoveCommand::Code::end_jump:
				// EndJump();
				break;
			case RPG::MoveCommand::Code::lock_facing:
				SetFacingLocked(true);
				break;
			case RPG::MoveCommand::Code::unlock_facing:
				SetFacingLocked(false);
				break;
			case RPG::MoveCommand::Code::increase_movement_speed:
				SetMoveSpeed(min(GetMoveSpeed() + 1, 6));
				break;
			case RPG::MoveCommand::Code::decrease_movement_speed:
				SetMoveSpeed(max(GetMoveSpeed() - 1, 1));
				break;
			case RPG::MoveCommand::Code::increase_movement_frequence:
				SetMoveFrequency(min(GetMoveFrequency() + 1, 8));
				break;
			case RPG::MoveCommand::Code::decrease_movement_frequence:
				SetMoveFrequency(max(GetMoveFrequency() - 1, 1));
				break;
			case RPG::MoveCommand::Code::switch_on: // Parameter A: Switch to turn on
				Game_Switches[move_command.parameter_a] = true;
				Game_Map::SetNeedRefresh(Game_Map::Refresh_All);
				break;
			case RPG::MoveCommand::Code::switch_off: // Parameter A: Switch to turn off
				Game_Switches[move_command.parameter_a] = false;
				Game_Map::SetNeedRefresh(Game_Map::Refresh_All);
				break;
			case RPG::MoveCommand::Code::change_graphic: // String: File, Parameter A: index
				SetGraphic(move_command.parameter_string, move_command.parameter_a);
				break;
			case RPG::MoveCommand::Code::play_sound_effect: // String: File, Parameters: Volume, Tempo, Balance
				if (move_command.parameter_string != "(OFF)" && move_command.parameter_string != "(Brak)") {
					RPG::Sound sound;
					sound.name = move_command.parameter_string;
					sound.volume = move_command.parameter_a;
					sound.tempo = move_command.parameter_b;
					sound.balance = move_command.parameter_c;

					Game_System::SePlay(sound);
				}
				break;
			case RPG::MoveCommand::Code::walk_everywhere_on:
				through = true;
				break;
			case RPG::MoveCommand::Code::walk_everywhere_off:
				through = false;
					break;
			case RPG::MoveCommand::Code::stop_animation:
				walk_animation = false;
				break;
			case RPG::MoveCommand::Code::start_animation:
				walk_animation = true;
				break;
			case RPG::MoveCommand::Code::increase_transp:
				SetOpacity(max(40, GetOpacity() - 45));
				break;
			case RPG::MoveCommand::Code::decrease_transp:
				SetOpacity(GetOpacity() + 45);
				break;
			}

			last_move_failed = move_failed;
			if (move_failed) {
				if (active_route->skippable) {
					last_move_failed = false;
					continue;
				}

				break;
			}
		}

		if ((size_t)active_route_index >= active_route->move_commands.size() && IsStopping()) {
			// End of Move list
			if (active_route->repeat) {
				active_route_index = 0;
				SetMoveRouteRepeated(true);
			} else if (IsMoveRouteOverwritten()) {
				CancelMoveRoute();
				Game_Map::RemovePendingMove(this);
				stop_count = 0;
			}
		}
	}

	// When the overwrite status changed the active_index belongs to the
	// current non-active move route
	if (overwrite_changed != IsMoveRouteOverwritten()) {
		if (IsMoveRouteOverwritten()) {
			SetOriginalMoveRouteIndex(active_route_index);
		}
		else {
			SetMoveRouteIndex(active_route_index);
		}
	}
	else {
		if (IsMoveRouteOverwritten()) {
			SetMoveRouteIndex(active_route_index);
		}
		else {
			SetOriginalMoveRouteIndex(active_route_index);
		}
	}
}