예제 #1
0
DBOOL FlagStand::SpawnFlag()
{
	// Sanity checks...

	if (m_nTeamID < 1) return(DFALSE);
	if (m_nTeamID > 2) return(DFALSE);


	// Get the position and rotation for the flag...

	DVector vPos;
	g_pServerDE->GetObjectPos(m_hObject, &vPos);
	vPos.x -= 16;
	vPos.y += 32;

	DRotation rRot;
	g_pServerDE->GetObjectRotation(m_hObject, &rRot);


	// Spawn the flag object for the team..

	if (!m_hFlagObject)
	{
		char sSpawnString[128];
		sprintf(sSpawnString, "FlagObject TeamID %i", GetTeamID());

		m_hFlagObject = SpawnObject(sSpawnString, &vPos, &rRot, NULL);
		if (!m_hFlagObject) return(DFALSE);
	}


	// All done...

	return(DTRUE);
}
예제 #2
0
파일: World.cpp 프로젝트: Aishiro/ATools
void CWorld::UpdateSpawns()
{
	int i;
	CSpawnObject* obj;
	CPtrArray<CObject> spawnObjects;

	for (i = 0; i < m_objects[OT_CTRL].GetSize(); i++)
	{
		obj = (CSpawnObject*)m_objects[OT_CTRL].GetAt(i);
		if (obj->m_world && obj->m_isReal && obj->m_isRespawn)
			spawnObjects.Append(obj);
	}

	for (i = 0; i < m_objects[OT_ITEM].GetSize(); i++)
	{
		obj = (CSpawnObject*)m_objects[OT_ITEM].GetAt(i);
		if (obj->m_world && obj->m_isReal && obj->m_isRespawn)
			spawnObjects.Append(obj);
	}

	for (i = 0; i < m_objects[OT_MOVER].GetSize(); i++)
	{
		obj = (CSpawnObject*)m_objects[OT_MOVER].GetAt(i);
		if (obj->m_world && obj->m_isReal && obj->m_isRespawn)
			spawnObjects.Append(obj);
	}

	for (i = 0; i < spawnObjects.GetSize(); i++)
		SpawnObject(spawnObjects[i], g_global3D.spawnAllMovers);
}
예제 #3
0
파일: maps.cpp 프로젝트: nmakoto/Epsilon5
void TMaps::LoadObjects(const QString& fileName) {
    QFile file(fileName);
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        throw UException("Error opening " + fileName);
    }
    QTextStream in(&file);
    QString line = "";
    while (!line.isNull()) {
        line = in.readLine();
        if (line.isEmpty() || line[0] == '#') {
            continue;
        }
        QStringList objectParams = line.split(":");
        if (objectParams.size() != 4) {
            throw UException("Error parsing " + fileName);
        }

        int id = utils::FromString(objectParams[3]);
        int x = utils::FromString(objectParams[0]);
        int y = utils::FromString(objectParams[1]);
        double angle = utils::FromString(objectParams[2]);

        emit SpawnObject(id, x, y, angle);
    }
}
예제 #4
0
파일: World.cpp 프로젝트: Aishiro/ATools
void CWorld::AddObject(CObject* obj)
{
	if (!obj)
		return;

	if (!obj->m_ID)
	{
		obj->m_ID = m_nextObjectID;
		m_nextObjectID++;
	}

	m_objects[obj->m_type].Append(obj);

	CLandscape* land = GetLand(obj->m_pos);
	if (land)
	{
		obj->m_world = this;
		land->m_objects[obj->m_type].Append(obj);

		if (g_global3D.spawnAllMovers
			&& (obj->m_type == OT_MOVER || obj->m_type == OT_ITEM || obj->m_type == OT_CTRL)
			&& ((CSpawnObject*)obj)->m_isRespawn)
			SpawnObject(obj, true);
	}
}
예제 #5
0
void CCoin::RotateToRest()
{
	if ( !m_bRotatedToRest )
	{
		char szSpawn[1024];
		sprintf(szSpawn, "WeaponItem Gravity 0;AmmoAmount 1;WeaponType Coin;AmmoType Coin");

		LTVector vPos;
		g_pLTServer->GetObjectPos(m_hObject, &vPos);
		vPos.y += 2.0f; // This offsets us from the floor a bit so we don't pop through when WeaponItem sets its dims.

		LTRotation rRot;
		rRot.Init();

		BaseClass* pObj = SpawnObject(szSpawn, vPos, rRot);

		if ( pObj && pObj->m_hObject )
		{
			g_pLTServer->SetAcceleration(pObj->m_hObject, &LTVector(0,0,0));
			g_pLTServer->SetVelocity(pObj->m_hObject, &LTVector(0,0,0));
		}

		g_pLTServer->SetObjectFlags(m_hObject, g_pLTServer->GetObjectFlags(m_hObject)&~FLAG_VISIBLE);
	}

	CGrenade::RotateToRest();

	if ( IsCharacter(m_hFiredFrom) )
	{
		LTVector vPosition;
        g_pLTServer->GetObjectPos(m_hObject, &vPosition);

        CCharacter* pCharacter = (CCharacter*)g_pLTServer->HandleToObject(m_hFiredFrom);

		CharCoinInfo cinfo;
        cinfo.fTime = g_pLTServer->GetTime();
		cinfo.eSurfaceType = m_eLastHitSurface;
		cinfo.vPosition = vPosition;

		SURFACE* pSurf = g_pSurfaceMgr->GetSurface(m_eLastHitSurface);
		_ASSERT(pSurf);
		if (pSurf)
		{
			cinfo.fVolume = pSurf->fMovementNoiseModifier;
		}
		else
		{
			cinfo.fVolume = 1.0f;
		}

		pCharacter->SetLastCoinInfo(&cinfo);
	}
}
예제 #6
0
void Ragdolls::MoveCamera(float timeStep)
{
    // Do not move if the UI has a focused element (the console)
    if (GetContext()->m_UISystem.get()->GetFocusElement())
        return;

    Input* input = GetContext()->m_InputSystem.get();

    // Movement speed as world units per second
    const float MOVE_SPEED = 20.0f;
    // Mouse sensitivity as degrees per pixel
    const float MOUSE_SENSITIVITY = 0.1f;

    // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
    IntVector2 mouseMove = input->GetMouseMove();
    yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
    pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
    pitch_ = Clamp(pitch_, -90.0f, 90.0f);

    // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
    cameraNode_->SetRotation(Quaternion(pitch_, yaw_, 0.0f));

    // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
    if (input->GetKeyDown(KEY_W))
        cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
    if (input->GetKeyDown(KEY_S))
        cameraNode_->Translate(Vector3::BACK * MOVE_SPEED * timeStep);
    if (input->GetKeyDown(KEY_A))
        cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
    if (input->GetKeyDown(KEY_D))
        cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);

    // "Shoot" a physics object with left mousebutton
    if (input->GetMouseButtonPress(MOUSEB_LEFT))
        SpawnObject();

    // Check for loading / saving the scene
    if (input->GetKeyPress(KEY_F5))
    {
        File saveFile(GetContext(), GetContext()->m_FileSystem->GetProgramDir() + "Data/Scenes/Ragdolls.xml", FILE_WRITE);
        scene_->SaveXML(saveFile);
    }
    if (input->GetKeyPress(KEY_F7))
    {
        File loadFile(GetContext(), GetContext()->m_FileSystem->GetProgramDir() + "Data/Scenes/Ragdolls.xml", FILE_READ);
        scene_->LoadXML(loadFile);
    }

    // Toggle physics debug geometry with space
    if (input->GetKeyPress(KEY_SPACE))
        drawDebug_ = !drawDebug_;
}
예제 #7
0
void CDestructibleModel::SpawnItem()
{
	if (!m_hstrSpawn) return;

	LTVector vPos;
	LTRotation rRot;
	char szSpawn[256];

	g_pLTServer->GetObjectPos(m_hObject, &vPos);
	g_pLTServer->GetObjectRotation(m_hObject, &rRot);

	strncpy(szSpawn, g_pLTServer->GetStringData(m_hstrSpawn), ARRAY_LEN(szSpawn));
	szSpawn[255] = '\0';
	SpawnObject(szSpawn, vPos, rRot);
}
update_status ModuleObjects::PreUpdate()
{
	// check camera position to decide what to spawn
	for (uint i = 0; i < MAX_OBJECTS; ++i)
	{
		if (object[i].type != OBJECTS_TYPES::NO_OBJECT_TYPE)
		{
			if ((object[i].y) * SCREEN_SIZE > (-1 * (App->render->camera.y) - 200))
			{
				SpawnObject(object[i]);
				object[i].type = OBJECTS_TYPES::NO_OBJECT_TYPE;
				LOG("Spawning object at %d", object[i].y * SCREEN_SIZE);
			}
		}
	}
	return UPDATE_CONTINUE;
}
void Breakable::CreateImpactFX()
{
	STEAMCREATESTRUCT sc;

	sc.fRange			= 75.0f;
	sc.fCreateDelta		= 10.0f;
	sc.fEndAlpha		= 0.0f;
	sc.fEndScale		= 3.0f;
	sc.fParticleRadius	= 20000.0f;
	sc.fStartAlpha		= 0.5f;
	sc.fStartScale		= 1.0f;
	sc.fVel				= 25.0f;
    sc.hstrParticle     = g_pLTServer->CreateString("SFX\\Impact\\Spr\\Smoke.spr");
	sc.vMinDriftVel.Init(-35, 5, -35);
	sc.vMinDriftVel.Init(35, 50, 35);
	sc.vColor1.Init(255, 255, 255);
	sc.vColor2.Init(255, 255, 255);

    LTVector vDims;
    g_pLTServer->GetObjectDims(m_hObject, &vDims);
	sc.fVolumeRadius = Max(vDims.x, vDims.y);
	sc.fVolumeRadius = Max(sc.fVolumeRadius, vDims.z);

	sc.nNumParticles = int(sc.fVolumeRadius / 10.0f);
	sc.nNumParticles = sc.nNumParticles < 1 ? 1 : sc.nNumParticles;

    LTRotation rRot;
    g_pLTServer->GetObjectRotation(m_hObject, &rRot);

    LTVector vDown(0, 1, 0);
    g_pLTServer->AlignRotation(&rRot, &vDown, LTNULL);

    LTVector vPos;
    g_pLTServer->GetObjectPos(m_hObject, &vPos);

	Steam* pSteam = (Steam*)SpawnObject("Steam", vPos, rRot);
	if (pSteam)
	{
        pSteam->Setup(&sc, 3.0f, LTTRUE);
	}

	// Clear this so we don't try and delete it twice...

    sc.hstrParticle = LTNULL;
}
예제 #10
0
update_status ModuleObjects::PreUpdate()
{
	// check camera position to decide what to spawn
	for (uint i = 0; i < MAX_OBJECTS; ++i)
	{
		if (queue[i].type != OBJECT_TYPES::UNKNOWN)
		{
			if (queue[i].y * (-SCREEN_SIZE) < App->render->camera.y + (App->render->camera.h * SCREEN_SIZE) + SPAWN_MARGIN)
			{
				SpawnObject(queue[i]);
				queue[i].type = OBJECT_TYPES::UNKNOWN;
				LOG("Spawning object at %d", queue[i].x * SCREEN_SIZE);
			}
		}
	}

	return UPDATE_CONTINUE;
}
예제 #11
0
파일: World.cpp 프로젝트: Aishiro/ATools
bool CWorld::_loadLndFile(int i, int j)
{
	CLandscape* land = new CLandscape(m_device, this, j * MAP_SIZE, i * MAP_SIZE);
	if (!land->Load(m_filename % string().sprintf("%02d-%02d.lnd", j, i)))
	{
		Delete(land);
		return false;
	}

	m_lands[i * m_width + j] = land;

	const float minX = j * MAP_SIZE * MPU;
	const float maxX = (j + 1) * MAP_SIZE * MPU;
	const float minZ = i * MAP_SIZE * MPU;
	const float maxZ = (i + 1) * MAP_SIZE * MPU;

	int k, l;
	CObject* obj;
	for (k = 0; k < MAX_OBJTYPE; k++)
	{
		for (l = 0; l < m_objects[k].GetSize(); l++)
		{
			obj = m_objects[k].GetAt(l);

			if (!obj->m_world
				&& obj->m_pos.x >= minX
				&& obj->m_pos.x < maxX
				&& obj->m_pos.z >= minZ
				&& obj->m_pos.z < maxZ)
			{
				obj->m_world = this;
				land->m_objects[k].Append(obj);

				if (g_global3D.spawnAllMovers
					&& (obj->m_type == OT_MOVER || obj->m_type == OT_ITEM || obj->m_type == OT_CTRL)
					&& ((CSpawnObject*)obj)->m_isRespawn)
					SpawnObject(obj, true);
			}
		}
	}

	return true;
}
예제 #12
0
void CServerMissionMgr::Update( )
{
	// Update the playertracker.
	m_PlayerTracker.Update( );

	// Since all the players dropped out, we can just finish what we
	// were doing.
	if( m_bPlayerTrackerAborted )
	{
		// Clear the abort signal.
		m_bPlayerTrackerAborted = false;
		FinishExitLevel( );
	}

	// Check to see if the time limit was reached...
	if( m_ServerSettings.m_nTimeLimit > 0 && m_fStartTime >= 0.0f )
	{
		float fElapsedTime = g_pLTServer->GetTime() - m_fStartTime;

		// Convert timelimit to seconds and see how much we have left.
		float fTimeLeft = ((float)m_ServerSettings.m_nTimeLimit * 60.0f ) - fElapsedTime;

		// If we ran out of time, then go to the next round.
		if( fTimeLeft <= 0 )
		{
			g_pLTServer->CPrint( "TimeLimit reached." );
			NextRound();
		}
		// Check if we should show a countdown timer.
		else if( fTimeLeft < 30.0f && m_hDisplayTimer == NULL )
		{
			LTVector vPos;
			LTRotation rRot;
			DisplayTimer* pDisplayTimer = ( DisplayTimer* )SpawnObject( "DisplayTimer", vPos, rRot );
			if( pDisplayTimer )
			{
				m_hDisplayTimer = pDisplayTimer->m_hObject;
				pDisplayTimer->Start( fTimeLeft );
			}
		}
	}
}
예제 #13
0
void DoomsDayDevice::InitialUpdate( )
{
	// Create the "target" objects...
	
	char szSpawn[256];
		
	LTVector vPos;
	g_pLTServer->GetObjectPos( m_hObject, &vPos );

	LTRotation rRot;
	g_pLTServer->GetObjectRotation( m_hObject, &rRot );

	// The PropTypes to use as targets are the normal PropTypes with _target appended...
	
	char szType[64] = {0};

	for( uint32 i = 0; i < kDoomsDay_MAXTYPES; ++i )
	{
		sprintf( szType, c_aDDPieceTypes[i].m_pszPropType );
		sprintf( szSpawn, "PropType Type %s_target", szType );

		BaseClass* pObj = SpawnObject( szSpawn, vPos, rRot );
		
		if( pObj && pObj->m_hObject )
		{
			m_lsthTargets.push_back( pObj->m_hObject );

			g_pCommonLT->SetObjectFlags( m_lsthTargets[i], OFT_Flags2, FLAG2_FORCETRANSLUCENT, FLAG2_FORCETRANSLUCENT );

			// Attach the target to the base...

			char *pszDoomsday = strtok( szType, "_" );
			char *pszSocket = strtok( NULL, "\0" );

			HATTACHMENT hAttachment;
			g_pLTServer->CreateAttachment( m_hObject, pObj->m_hObject, pszSocket, &LTVector(0,0,0), &LTRotation(), &hAttachment );
	
		}
	}

	BeginIdle( );
}
예제 #14
0
파일: World.cpp 프로젝트: Aishiro/ATools
void CWorld::DeleteObject(CObject* obj)
{
	if (!obj || obj->m_type >= MAX_OBJTYPE)
		return;

	int find = m_objects[obj->m_type].Find(obj);
	if (find != -1)
		m_objects[obj->m_type].RemoveAt(find);

	CLandscape* land = GetLand(obj->m_pos);
	if (land)
	{
		find = land->m_objects[obj->m_type].Find(obj);
		if (find != -1)
			land->m_objects[obj->m_type].RemoveAt(find);
	}

	if (g_global3D.spawnAllMovers
		&& (obj->m_type == OT_MOVER || obj->m_type == OT_ITEM || obj->m_type == OT_CTRL)
		&& ((CSpawnObject*)obj)->m_isRespawn)
		SpawnObject(obj, false);

	if (obj->m_type == OT_PATH)
	{
		CPath* path = (CPath*)obj;
		for (auto it = m_paths.begin(); it != m_paths.end(); it++)
		{
			find = it.value()->Find(path);
			if (find != -1)
			{
				for (int i = find + 1; i < it.value()->GetSize(); i++)
					it.value()->GetAt(i)->m_index--;
				it.value()->RemoveAt(find);
			}
		}
	}

	Delete(obj);
}
uint32 Spawner::ObjectMessageFn( HOBJECT hSender, uint32 messageID, HMESSAGEREAD hRead )
{
    LTVector vPos;
    LTRotation rRot;
	char szSpawn[501];

	switch( messageID )
	{
		case MID_TRIGGER:
		{
			const char* szMsg = (const char*)g_pLTServer->ReadFromMessageDWord(hRead);

			if (_stricmp(szMsg, "default") == 0)
			{
                szMsg = g_pLTServer->GetStringData(m_hstrDefaultSpawn);
			}

			strncpy( szSpawn, szMsg, 500 );

            g_pLTServer->GetObjectPos( m_hObject, &vPos );
            g_pLTServer->GetObjectRotation( m_hObject, &rRot );

			// Play spawn sound...
			if ( m_hstrSpawnSound )
			{
                char* pSound = g_pLTServer->GetStringData(m_hstrSpawnSound);
                g_pServerSoundMgr->PlaySoundFromPos(vPos, pSound, m_fSoundRadius, SOUNDPRIORITY_MISC_LOW);
            }

			SpawnObject( szSpawn, vPos, rRot );
			break;
		}

		default : break;
	}

	return BaseClass::ObjectMessageFn(hSender, messageID, hRead);
}
예제 #16
0
void CDestructable::HandleDestruction()
{
	CServerDE* pServerDE = BaseClass::GetServerDE();
	if (!pServerDE) return;

	if (m_hstrDeathTriggerTarget)
	{
		LPBASECLASS pD = pServerDE->HandleToObject(m_hObject);
		SendTriggerMsgToObjects(pD, m_hstrDeathTriggerTarget, m_hstrDeathTriggerMessage);
	}

	// See if we need to spawn anything
	if (m_hstrSpawnObject)
	{
		DVector vPos;
		DRotation rRot;

		pServerDE->GetObjectPos(m_hObject, &vPos);
		pServerDE->GetObjectRotation(m_hObject, &rRot);

		SpawnObject(pServerDE->GetStringData(m_hstrSpawnObject), &vPos, &rRot, &m_vSpawnObjectVel);
	}
}
예제 #17
0
 static GameObject* GetClosestGObjectID(Player* player, GameObject* obj)
 {
     if(!player)
         return NULL;
     uint32 closestID = 0;
     for(std::set<uint32>::const_iterator it = GObjects.begin(); it != GObjects.end();)
     {
         if(obj && obj->GetGUIDHigh() == (*it))
         {
             ++it;
             continue;
         }
         GameObject* temp = player->GetGameObject(*it);
         if (!temp)
         {
             GObjects.erase(*it++);
             continue;
         }
         if(obj && temp->GetDistance(player) > obj->GetDistance(player))
         {
             ++it;
             continue;
         }
         closestID = (*it);
         obj = temp;
         ++it;
     }
     if (obj && !closestID && obj->GetGUIDLow() && !obj->GetDBTableGUIDLow()) // obj is .gob add temp, respawn and return
     {
         float x,y,z,o;
         obj->GetPosition(x,y,z,o);
         GameObject* obj2 = SpawnObject(player,x,y,z,o,obj->GetPhaseMask(),false,obj->GetEntry(),false);
         DeleteObject(obj);
         obj = obj2;
     }
     return obj;
 }
예제 #18
0
void UTerrainManager::CollapseTile(ATile* t) {
	SpawnRubble(t);
	//RubbleSpawned ? .Invoke(this, new TileEventArgs(t));
	for (int x = t->X - 1; x < t->X + 2; ++x)
	{
		for (int y = t->Y - 1; y < t->Y + 2; ++y)
		{
			if (IsOutOfBounds(x, y) || (x == t->X && y == t->Y))
				continue;
			if (!GetTile(x, y)->IsVisible)
			{
				DiscoverCave(x, y);
				OnCaveDiscovered.Broadcast();
			}
			if (UpdateWallAtTile(x, y))
			{
				CollapseTile(x, y);
			}
		}
	}
	int spiders = 2;
	for (int i = 5; i < spiders; ++i)
	{
		SpawnObject(t->X, t->Y, FString("SmallSpider"));
	}
	int numberOfCrystals = 0;
	int numberOfOre = 0;
	switch (t->Cror)
	{
		//crystals
	case 1:
	case 3:
		numberOfCrystals = 1;
		break;

	case 5:
	case 7:
		numberOfCrystals = 3;
		break;

	case 9:
	case 0xB:
		numberOfCrystals = 5;
		break;

	case 0xD:
	case 0x13:
		numberOfCrystals = 11;
		break;

	case 0x11:
	case 0x17:
		numberOfCrystals = 25;
		break;

		//Ore
	case 2:
	case 4:
		numberOfOre = 1;
		break;
	case 6:
	case 8:
		numberOfOre = 3;
		break;
	case 0xA:
	case 0xC:
	case 0x10:
		numberOfOre = 5;
		break;
	case 0xE:
	case 0x14:
		numberOfOre = 11;
		break;
	case 0x12:
	case 0x18:
		numberOfOre = 25;
		break;
	}
	for (int i = 0; i < numberOfCrystals; ++i)
		SpawnObject(t->X, t->Y, FString("PowerCrystal"));
	for (int i = 0; i < numberOfOre; ++i)
		SpawnObject(t->X, t->Y, FString("Ore"));
	OnWallColapsed.Broadcast(t);
}
예제 #19
0
void CSpear::HandleImpact(HOBJECT hObj)
{
	if (!g_vtSpearStickPercentage.IsInitted())
	{
        g_vtSpearStickPercentage.Init(g_pLTServer, "SpearStickPercent", LTNULL, 0.9f);
	}

	if (!m_pAmmoData || !m_pAmmoData->pProjectileFX)
	{
		CProjectile::HandleImpact(hObj);
		return;
	}


	CollisionInfo info;
    g_pLTServer->GetLastCollision(&info);

    LTVector vPos, vVel, vCurVel, vP0, vP1;
    g_pLTServer->GetObjectPos(m_hObject, &vPos);

    LTRotation rRot;
    g_pLTServer->GetObjectRotation(m_hObject, &rRot);


	// Should we break the spear?

	enum SpearAction
	{
		eSpearActionBreak,
		eSpearActionStickWorld,
		eSpearActionStickAI,
		eSpearActionStickPlayer,
		eSpearActionStickBody
	};

	SpearAction eSpearAction = eSpearActionBreak;

	// Randomly break even if we could sometimes stick...

	if (GetRandom(0.0, 1.0f) > g_vtSpearStickPercentage.GetFloat())
	{
		eSpearAction = eSpearActionBreak;
	}
	else if (IsMainWorld(hObj))
	{
 		// Calculate where we really hit the world...

		g_pLTServer->GetVelocity(m_hObject, &vVel);

		vP1 = vPos;
        vCurVel = vVel * g_pLTServer->GetFrameTime();
		vP0 = vP1 - vCurVel;
		vP1 += vCurVel;

        LTFLOAT fDot1 = VEC_DOT(info.m_Plane.m_Normal, vP0) - info.m_Plane.m_Dist;
        LTFLOAT fDot2 = VEC_DOT(info.m_Plane.m_Normal, vP1) - info.m_Plane.m_Dist;

		if (fDot1 < 0.0f && fDot2 < 0.0f || fDot1 > 0.0f && fDot2 > 0.0f)
		{
			vPos = vP1;
		}
		else
		{
            LTFLOAT fPercent = -fDot1 / (fDot2 - fDot1);
			VEC_LERP(vPos, vP0, vP1, fPercent);
		}

		// Set our new "real" pos...

        g_pLTServer->SetObjectPos(m_hObject, &vPos);

		eSpearAction = eSpearActionStickWorld;
	}
	else if (IsMoveable(hObj))
	{
		if (IsAI(hObj))
		{
			// Attach to a AI
			eSpearAction = eSpearActionStickAI;
		}
		else if (IsPlayer(hObj))
		{
			// Attach to a Player
			eSpearAction = eSpearActionStickPlayer;
		}
		else if (IsBody(hObj))
		{
			// Attach to a body
 			eSpearAction = eSpearActionStickBody;
		}
		else
		{
			// Could probably come up with a way to attach to moveable
			// non-character objects (like doors), but it is much easier
			// to just break it ;)...

            eSpearAction = eSpearActionBreak;
		}
	}

	// If the surface is too hard, the spear will just break when
	// it hits it...

	SurfaceType eSurf = GetSurfaceType(info);
	SURFACE* pSurf = g_pSurfaceMgr->GetSurface(eSurf);
	if ((eSpearActionBreak == eSpearAction) || ((eSpearActionStickWorld == eSpearAction) && pSurf && pSurf->fHardness > 0.5))
	{
		// Create spear debris...

		DEBRIS* pDebris = g_pDebrisMgr->GetDebris(m_pAmmoData->szName);
		if (pDebris)
		{
			vVel.Norm();
            LTVector vNegVel = -vVel;
            CreatePropDebris(vPos, vNegVel, pDebris->nId);
		}

		CProjectile::HandleImpact(hObj);
		return;
	}

	// Create the Spear powerup...

	char szSpawn[512];
	sprintf(szSpawn, "AmmoBox AmmoType1 %s;AmmoCount1 1;Filename %s;Skin %s",
		m_pAmmoData->szName, m_pAmmoData->pProjectileFX->szModel,
		m_pAmmoData->pProjectileFX->szSkin);

	LTVector vScale = m_pAmmoData->pProjectileFX->vModelScale;

	// Make sure the spear sticks out a little ways...

	vVel.Norm();
	vPos -= (vVel * vScale.z/2.0f);

	if (eSpearActionStickWorld == eSpearAction)
	{
		g_pLTServer->AlignRotation(&rRot, &vVel, LTNULL);
	}

	BaseClass* pClass = SpawnObject(szSpawn, LTVector(-10000,-10000,-10000), rRot);

	if (pClass)
	{
		g_pLTServer->ScaleObject(pClass->m_hObject, &vScale);

		LTVector vDims;
		g_pLTServer->GetObjectDims(pClass->m_hObject, &vDims);
		vDims.x *= vScale.x;
		vDims.y *= vScale.y;
		vDims.z *= vScale.z;

		g_pLTServer->SetObjectDims(pClass->m_hObject, &vDims);

		// We don't want other projectiles to impact on us...

		//uint32 dwUsrFlags = g_pLTServer->GetObjectUserFlags(pClass->m_hObject);
		//dwUsrFlags |= USRFLG_IGNORE_PROJECTILES;
		//g_pLTServer->SetObjectUserFlags(pClass->m_hObject, dwUsrFlags);


		if ( eSpearActionStickAI == eSpearAction || eSpearActionStickPlayer == eSpearAction )
		{
			g_pLTServer->SetObjectUserFlags(pClass->m_hObject, g_pLTServer->GetObjectUserFlags(pClass->m_hObject) & ~USRFLG_GLOW);
			g_pLTServer->SetObjectFlags(pClass->m_hObject, g_pLTServer->GetObjectFlags(pClass->m_hObject) & ~FLAG_TOUCH_NOTIFY);

			if ( eSpearActionStickPlayer == eSpearAction )
			{
				g_pLTServer->SetObjectUserFlags(pClass->m_hObject, g_pLTServer->GetObjectUserFlags(pClass->m_hObject) | USRFLG_ATTACH_HIDE1SHOW3);
			}

			// Attach it to the character

			CCharacter* pCharacter = (CCharacter*)g_pLTServer->HandleToObject(hObj);
			pCharacter->AddSpear(pClass->m_hObject, pCharacter->GetModelNodeLastHit(), rRot);
		}
		else if ( eSpearActionStickBody == eSpearAction )
		{
			g_pLTServer->SetObjectUserFlags(pClass->m_hObject, g_pLTServer->GetObjectUserFlags(pClass->m_hObject) & ~USRFLG_GLOW);
			g_pLTServer->SetObjectFlags(pClass->m_hObject, g_pLTServer->GetObjectFlags(pClass->m_hObject) & ~FLAG_TOUCH_NOTIFY);

			// Attach it to the body

			Body* pBody = (Body*)g_pLTServer->HandleToObject(hObj);
			pBody->AddSpear(pClass->m_hObject, rRot);
		}
		else // ( eSpearActionStickWorld == eSpearAction )
		{
			// Move it to the right position in the world
			g_pLTServer->SetObjectPos(pClass->m_hObject, &vPos);
		}
	}

	CProjectile::HandleImpact(hObj);
}
예제 #20
0
void CServerPage::PerformCommand(int command,DWORD p1,int p2)
{
	switch(command)
	{
	case 1:Close(0);
		break;

	case 2:SpawnObject(IDChicken,NULL);
		break;
	case 3:RemoveObject(IDChicken);
		break;

	case 16:SpawnObject(IDBauer,NULL);
		break;
	case 17:RemoveObject(IDBauer);
		break;

	case 4:SpawnObject(IDStall,NULL);
		break;
	case 5:RemoveObject(IDStall);
		break;

	case 6:SpawnObject(IDTree,NULL);
		break;
	case 7:RemoveObject(IDTree);
		break;

	case 8:SpawnObject(IDGartenkralle,NULL);
		break;
	case 9:RemoveObject(IDGartenkralle);
		break;

	case 10:SpawnObject(IDGolfer,NULL);
		break;
	case 11:RemoveObject(IDGolfer);
		break;

	case 12:SpawnObject(IDDrescher,NULL);
		break;
	case 13:RemoveObject(IDDrescher);
		break;

	case 14:SpawnObject(IDPlasmaCannon,NULL);
		break;
	case 15:RemoveObject(IDPlasmaCannon);
		break;


	case 20:game->aircontrol=LongToFloat(p2);
		mustsend=TRUE;
		break;
	case 21:game->damage=LongToFloat(p2);
		mustsend=TRUE;
		break;
	case 22:game->gravity=LongToFloat(p2);
		mustsend=TRUE;
		break;
	case 23:game->jumpspeed=LongToFloat(p2);
		mustsend=TRUE;
		break;
	case 24:game->plasmarate=LongToFloat(p2);
		mustsend=TRUE;
		break;
	case 25:game->plasmaregeneration=LongToFloat(p2);
		mustsend=TRUE;
		break;
	case 26:game->replenishpower=LongToFloat(p2);
		mustsend=TRUE;
		break;
	case 27:game->sittime=LongToFloat(p2);
		mustsend=TRUE;
		break;
	case 28:game->takepower=LongToFloat(p2);
		mustsend=TRUE;
		break;
	case 29:game->throwtime=LongToFloat(p2);
		mustsend=TRUE;
		break;
	case 30:game->respawntime=LongToFloat(p2);
		mustsend=TRUE;
		break;

	case 50:Config.KI=p2;
		mustsend=TRUE;
		break;
	case 51:game->PlasmaBallPressure=p2;
		mustsend=TRUE;
		break;
	}
	InvalidateAll();
}
예제 #21
0
    static bool GOMove_Command(ChatHandler* handler, const char* args)
    {
        if (!args)
            return false;

        char* ID_t = strtok((char*)args, " ");
        if (!ID_t)
            return false;
        uint32 ID = (uint32)atol(ID_t);

        char* GObjectID_C = strtok(NULL, " ");
        uint32 GObjectID = 0;
        bool isHex = false;
        if (GObjectID_C)
        {
            GObjectID = strtoul(GObjectID_C, NULL, 0); // can take in hex as well as dec
            isHex = (std::string(GObjectID_C).find("0x") != std::string::npos);
        }

        char* ARG_t = strtok(NULL, " ");
        uint32 ARG = 0;
        if (ARG_t)
            ARG = (uint32)atol(ARG_t);

        WorldSession* session = handler->GetSession();
        Player* player = session->GetPlayer();
        uint64 playerGUID = player->GetGUID();

        if (ID < SPAWN) // no args
        {
            if (ID >= DELET && ID <= GOTO) // has target (needs retrieve gameobject)
            {
                GameObject* target = GetObjectByGObjectID(player, GObjectID, isHex);
                if (!target)
                    ChatHandler(player->GetSession()).PSendSysMessage("Object GUID: %u not found. Temp(%u)", GObjectID, isHex ? 1 : 0);
                else
                {
                    float x,y,z,o;
                    target->GetPosition(x,y,z,o);
                    uint32 p = target->GetPhaseMask();
                    switch(ID)
                    {
                    case DELET: DeleteObject(target/*, isHex ? GObjectID : 0*/); SendSelectionInfo(player, GObjectID, isHex, false); break;
                    case X: SpawnObject(player,player->GetPositionX(),y,z,o,p,true,GObjectID, isHex);      break;
                    case Y: SpawnObject(player,x,player->GetPositionY(),z,o,p,true,GObjectID, isHex);      break;
                    case Z: SpawnObject(player,x,y,player->GetPositionZ(),o,p,true,GObjectID, isHex);      break;
                    case O: SpawnObject(player,x,y,z,player->GetOrientation(),p,true,GObjectID, isHex);    break;
                    case GOTO: player->TeleportTo(target->GetMapId(), x,y,z,o);                     break;
                    case RESPAWN: SpawnObject(player,x,y,z,o,p,false,target->GetEntry(), isHex);           break;
                    case GROUND:
                        {
                            float ground = target->GetMap()->GetHeight(target->GetPhaseMask(), x, y, MAX_HEIGHT);
                            if(ground != INVALID_HEIGHT)
                                SpawnObject(player,x,y,ground,o,p,true,GObjectID, isHex);
                        } break;
                    }
                }
            }
            else
            {
                switch(ID)
                {
                case TEST: session->SendAreaTriggerMessage(player->GetName().c_str());      break;
                case FACE: { float piper2 = M_PI/2; float multi = player->GetOrientation()/piper2; float multi_int = floor(multi); float new_ori = (multi-multi_int > 0.5f) ? (multi_int+1)*piper2 : multi_int*piper2; player->SetFacingTo(new_ori); } break;
                case SAVE: SaveObject(player, GObjectID, isHex);                                   break;
                case SELECTNEAR:
                    {
                        GameObject* object = handler->GetNearbyGameObject();
                        object = GetClosestGObjectID(player, object);
                        if (!object)
                            ChatHandler(player->GetSession()).PSendSysMessage("No objects found");
                        else
                        {
                            bool isHex = (object->GetGUIDHigh() != HIGHGUID_GAMEOBJECT);
                            SendSelectionInfo(player, isHex ? object->GetGUIDHigh() : object->GetDBTableGUIDLow() ? object->GetDBTableGUIDLow() : object->GetGUIDLow(), isHex, true);
                            session->SendAreaTriggerMessage("Selected %s", object->GetName().c_str());
                        }
                    } break;
                }
            }
        }
        else if (ARG && ID >= SPAWN)
        {
            if (ID >= NORTH && ID <= PHASE)
            {
                GameObject* target = GetObjectByGObjectID(player, GObjectID, isHex);
                if (!target)
                    ChatHandler(player->GetSession()).PSendSysMessage("Object GUID: %u not found. Temporary: %s", GObjectID, isHex ? "true" : "false");
                else
                {
                    float x,y,z,o;
                    target->GetPosition(x,y,z,o);
                    uint32 p = target->GetPhaseMask();
                    switch(ID)
                    {
                    case NORTH: SpawnObject(player,x+((float)ARG/100),y,z,o,p,true,GObjectID, isHex);                        break;
                    case EAST: SpawnObject(player,x,y-((float)ARG/100),z,o,p,true,GObjectID, isHex);                         break;
                    case SOUTH: SpawnObject(player,x-((float)ARG/100),y,z,o,p,true,GObjectID, isHex);                        break;
                    case WEST: SpawnObject(player,x,y+((float)ARG/100),z,o,p,true,GObjectID, isHex);                         break;
                    case NORTHEAST: SpawnObject(player,x+((float)ARG/100),y-((float)ARG/100),z,o,p,true,GObjectID, isHex);   break;
                    case SOUTHEAST: SpawnObject(player,x-((float)ARG/100),y-((float)ARG/100),z,o,p,true,GObjectID, isHex);   break;
                    case SOUTHWEST: SpawnObject(player,x-((float)ARG/100),y+((float)ARG/100),z,o,p,true,GObjectID, isHex);   break;
                    case NORTHWEST: SpawnObject(player,x+((float)ARG/100),y+((float)ARG/100),z,o,p,true,GObjectID, isHex);   break;
                    case UP: SpawnObject(player,x,y,z+((float)ARG/100),o,p,true,GObjectID, isHex);                           break;
                    case DOWN: SpawnObject(player,x,y,z-((float)ARG/100),o,p,true,GObjectID, isHex);                         break;
                    case RIGHT: SpawnObject(player,x,y,z,o-((float)ARG/100),p,true,GObjectID, isHex);                        break;
                    case LEFT: SpawnObject(player,x,y,z,o+((float)ARG/100),p,true,GObjectID, isHex);                         break;
                    case PHASE: SpawnObject(player,x,y,z,o,ARG,true,GObjectID, isHex);                                       break;
                    }
                }
            }
            else
            {
                switch(ID)
                {
                case SPAWN:
                    {
                        if (SpawnObject(player, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(),  player->GetOrientation(), player->GetPhaseMaskForSpawn(), false, ARG, false, true))
                            SpawnQue[player->GetGUID()] = ARG;
                    } break;
                case SPAWNSPELL:
                    {
                        SpawnQue[player->GetGUID()] = ARG;
                    } break;
                case SELECTALLNEAR:
                    { 
                        if (ARG > 5000)
                            ARG = 5000;

                        QueryResult result = WorldDatabase.PQuery("SELECT guid, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE map = '%u' AND position_x BETWEEN '%f'-'%u' AND '%f'+'%u' AND position_y BETWEEN '%f'-'%u' AND '%f'+'%u' AND position_z BETWEEN '%f'-'%u' AND '%f'+'%u' ORDER BY order_ ASC LIMIT 100",
                            player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetPositionX(), ARG, player->GetPositionX(), ARG, player->GetPositionY(), ARG, player->GetPositionY(), ARG, player->GetPositionZ(), ARG, player->GetPositionZ(), ARG);

                        if (result)
                        {
                            do
                            {
                                Field* fields   = result->Fetch();
                                uint32 guidLow  = fields[0].GetUInt32();

                                if (GameObject* object = GetObjectByGObjectID(player, guidLow, false))
                                    SendSelectionInfo(player, guidLow, false, true);
                            }
                            while (result->NextRow());
                        }
                        for(std::set<uint32>::const_iterator it = GObjects.begin(); it != GObjects.end();)
                        {
                            GameObject* temp = player->GetGameObject(*it);
                            if(!temp)
                            {
                                GObjects.erase(*it++);
                                continue;
                            }
                            if(temp->IsWithinDistInMap(player, ARG))
                                SendSelectionInfo(player, (*it), true, true);
                            ++it;
                        }
                    } break;
                }
            }
        }
        else
            return false;
        return true;
    }