Esempio n. 1
0
void TentacleLogicCmp::checkPlayerInRange()
{
	int nbr = 0;
	TentacleGearCmp* tmp = _start;
	PositionComponent* player = _boss->getPlayer()->GET_CMP(PositionComponent);
	PositionComponent* me = this->getEntity()->GET_CMP(PositionComponent);
	int xP = player->getX();
	int yP = player->getY();
	int xMe = me->getX();
	int yMe = me->getY();
	while (tmp != NULL)
	{
		tmp = tmp->getNext();
		nbr++;
	}
	if (pow((pow((xP - xMe), 2) + pow((yP - yMe), 2)), 0.5) <= 64 * nbr)
		setInRange(true);
	else
	{
		_inRange = false;
		_hasBeenReset = false;
	}


	getBoss()->getPlayer();
}
Esempio n. 2
0
void handleUpdatePacket(uint8* data, int len)
{

	UpdatePacketSelf update = *(UpdatePacketSelf*)&data[1];

	//if( player_x != update.positionX || player_y != update.positionY ) {
		//printf( "X/Y: %i, %i\n", update.positionX, update.positionY );
	//}
	player_x = update.positionX;
	player_y = update.positionY;
	player_health = update.currentHPPct;

	if( player_health <= 25 ) {
		printf( "[%s] Health (%i) < 25. Exiting!\n", currentDateTime().c_str(), player_health );
		logout( player_id );
		SLEEP( 100 );
		exit_bot       = true;
		finished_quest = true;
		missing_quest  = true;
	}

	/*for( int j = 0; j < len; j++ ) {
		fprintf( out, "%02X ", data[j] );
	}
	fprintf( out, "\n" );

	fprintf( out, "Update positionX: %i\n", update.positionX );
	fprintf( out, "Update positionY: %i\n", update.positionY );
	fprintf( out, "Update spellflags: %i\n", update.spellflags );
	fprintf( out, "Update colorbits: %i\n", update.colorbits );
	fprintf( out, "Update numInRangeDynamicObjects: %i\n", update.numInRangeDynamicObjects );
	fprintf( out, "Update numInRangeUnits: %i\n", update.numInRangeUnits );
	fprintf( out, "Update unklol: %i\n", update.unklol );
	fprintf( out, "Update flags: %i\n", update.flags );
	fprintf( out, "Update rotation: %i\n", update.rotation );
	fprintf( out, "Update animation: %i\n", update.animation );
	fprintf( out, "Update spellEffect: %i\n", update.spellEffect );
	fprintf( out, "Update numInRangeSpellEffects: %i\n", update.numInRangeSpellEffects );
	fprintf( out, "Update unklol2: %i\n", update.unklol2 );
	fprintf( out, "Update unklol3: %i\n", update.unklol3 );
	fprintf( out, "Update currentHPPct: %i\n", update.currentHPPct );
	fprintf( out, "Update currentMPPct: %i\n", update.currentMPPct );
	fprintf( out, "Update currentExpPct: %i\n", update.currentExpPct );
	fprintf( out, "\n\n" );*/

	int offset = 23;

	if( update.numInRangeDynamicObjects > 0 )
	{
		for( int i = 0; i < update.numInRangeDynamicObjects; i++ )
		{
			if( data[offset] == 0x01 ) offset += 8;
			else if( data[offset] == 0x02 ) offset += 12;
			else if( data[offset] == 0x03 ) offset += 6;
		}
	}

	if( update.numInRangeSpellEffects > 0 )
	{
		for( int x = 0; x < update.numInRangeSpellEffects; x++ )
		{
			if( data[offset] >= 240 ) offset += 12;
			else offset += 8;
		}
	}

	setAllOoR();

	if( update.numInRangeUnits > 0 )
	{
		for( int i = 0; i < update.numInRangeUnits; i++ )
		{
			uint16 id = ( data[offset+1] << 8 ) + data[offset];
			uint16 trueid = id & 0x7FFF;
			
			// Attempt to find unit in our unitmap
			setInRange( trueid );

			offset += 2;

			if( id & 0x8000 )
				continue;
			else
			{
				uint8 updateflag = data[offset];
				offset += 1;

				if(updateflag & 0x01)
				{
					UpdatePacketUnitMovement movement = *(UpdatePacketUnitMovement*)&data[offset];
					um_units.at( trueid ).movement = movement;
					//fprintf( out, "Player: %i | Movement | X/Y: %i, %i\n", trueid, movement.positionX, movement.positionY );
					//UnitMap::UpdateUnitsMovement(trueid, *(UpdatePacketUnitMovement*)&data[offset]); 
					offset += 5;
				}
				if(updateflag & 0x02)
				{
					UpdatePacketUnitAuras auras = *(UpdatePacketUnitAuras*)&data[offset];
					um_units.at( trueid ).auras = auras;
					//UnitMap::UpdateUnitsAuras(trueid, *(UpdatePacketUnitAuras*)&data[offset]);
					offset += 3;
				}
				if(updateflag & 0x04)
				{
					UpdatePacketUnitModels models = *(UpdatePacketUnitModels*)&data[offset];
					um_units.at( trueid ).models = models;
					//fprintf( out, "Player: %i | ModelInfo | Model: %i, Weapon: %i, Shield: %i, Helmet: %i\n", trueid, models.model, models.weapon, models.shield, models.helmet );
					//UnitMap::UpdateUnitsModel(trueid, *(UpdatePacketUnitModels*)&data[offset]);
					offset += 8;
				}
				if(updateflag & 0x08)
				{
					UpdatePacketUnitAnim anim = *(UpdatePacketUnitAnim*)&data[offset];
					//UnitMap::UpdateUnitsAnim(trueid, *(UpdatePacketUnitAnim*)&data[offset]);
					um_units.at( trueid ).anim = anim; 

					if( anim.anim == 21 || anim.anim == 45 )
					{
						um_units.at( trueid ).dead = true;
					} else {
						um_units.at( trueid ).dead = false;
					}

					offset += 1;
				}
				if(updateflag & 0x10)
				{
					UpdatePacketUnitSpellEffect spellfx = *(UpdatePacketUnitSpellEffect*)&data[offset];
					//UnitMap::UpdateUnitsSpellEffect(trueid, *(UpdatePacketUnitSpellEffect*)&data[offset]);
					um_units.at( trueid ).spelleffect = spellfx;
					offset += 1;
				}
				if(updateflag & 0x20)
				{
					offset += 1 + data[offset];
				}
			}
		}
	}

	clearOoR();

	if( update.flags & 0x01 ) {
		if( data[offset] == 0x31 && data[offset+1] == 0x30 && data[offset+2] == 0x30 ) {
			finished_quest = true;
		}
	}

	//fprintf( out, "\n\n" );
}