void Physics_UpdateAttachPoint(Physics_AttachPoint* attachPoint, f32 mass, const vec3* gravity, f32 DTSq, f32 DTOverPreviousDT) { //Time-Corrected Verlet integration //http://archive.gamedev.net/archive/reference/articles/article2200.html vec3 xNeg1; CopyVec3(&xNeg1,&attachPoint->lastPosition); //Acceleration vec3 acceleration; ScaleVec3(&acceleration,&attachPoint->force,1.0f/mass); AddVec3_Self(&acceleration,gravity); vec3 x0; CopyVec3(&x0,&attachPoint->position); //Save current position into last position before updating new position CopyVec3(&attachPoint->lastPosition,&attachPoint->position); SubVec3(&attachPoint->position,&x0,&xNeg1); ScaleVec3_Self(&attachPoint->position,DTOverPreviousDT); AddVec3_Self(&attachPoint->position,&x0); AddScaledVec3_Self(&attachPoint->position,&acceleration,DTSq); }
bool Spawner::SpawnInit(void* pSpawnStruct) { m_hSpawnObject = CoreObjectHandle(); m_spawnTimer = -1.0f; m_spawnTimeMin = 5.0f; m_spawnTimeMax = 5.0f; m_requiresTrigger = false; m_launchSpeed = 0.0f; SpawnableEntity* pSpawnableEnt = (SpawnableEntity*)pSpawnStruct; if(pSpawnableEnt == NULL) { return false; } CopyVec3(&m_position,&pSpawnableEnt->position); for (pugi::xml_node property = pSpawnableEnt->pProperties.child("property"); property; property = property.next_sibling("property")) { const char* propNameString = property.attribute("name").value(); const char* valueString = property.attribute("value").value(); if(strcmp(propNameString, "SpawnObject") == 0) { const u32 uniqueID = atoi(valueString); m_pEntityToSpawn = GAME->GetSpawnableEntityByTiledUniqueID(uniqueID); } else if(strcmp(propNameString, "SpawnTimeMin") == 0) { m_spawnTimeMin = atof(valueString); } else if(strcmp(propNameString, "SpawnTimeMax") == 0) { m_spawnTimeMax = atof(valueString); } else if(strcmp(propNameString, "LaunchSpeed") == 0) { m_launchSpeed = atof(valueString); } else if(strcmp(propNameString, "RequiresTrigger") == 0) { if(strcmp(valueString, "true") == 0) { m_requiresTrigger = true; } } } m_spawnTimer = rand_FloatRange(m_spawnTimeMin, m_spawnTimeMax); return false; }
void SampleGame2D::LoadLevel() { Reset(); /*std::string levelPath("ArtResources/TestLevel/"); //std::string levelFile("TestMap.tmx"); std::string levelFile("TestMapTurningCamera.tmx"); LoadTiledLevelFromTMX(levelPath,levelFile,64,1.0f); Array_InsertionSort(m_spawnableEntities,m_numSpawnableEntities,Compare_SpawnableEntities_X); */ GAME->Box2D_TogglePhysicsDebug(true); /*std::string uiPath("ArtResources/UI/"); std::string titleScreenFile("TitleScreenView.xml"); CoreUIView* pTitleView = LoadCoreUIFromXML(uiPath, titleScreenFile); m_hTitleScreen = pTitleView->GetHandle();*/ CopyVec3(&m_lastCamPos,&vec3_zero); CopyVec3(&m_camPos, &vec3_zero); m_camState = CamState_Normal; if(g_MUSIC_Enabled) { //PlaySongByID(g_SongID_Normal, 0.5f, true); } m_titleScreenState = TitleScreenState_WaitingToFadeOut; m_timeScreenTimer = 0.0f; if(m_pauseSoundSource == 0) { /*OPENALAUDIO->SwitchContext(GameAudioContext_UI); OPENALAUDIO->CreateSoundBufferFromFile(g_SoundAsset_Pause.soundFileName,&g_SoundAsset_Pause.soundBufferID); m_pauseSoundSource = OPENALAUDIO->CreateSoundSourceFromBuffer(g_SoundAsset_Pause.soundBufferID); OPENALAUDIO->SwitchContext(GameAudioContext_Normal);*/ } }
void Esp() { if (!Targets.empty()) { vec4_t clEnemyVIS = { cFuncESPEnemyVISR.iValue/255.0f, cFuncESPEnemyVISG.iValue/255.0f, cFuncESPEnemyVISB.iValue/255.0f, 1.0f }; vec4_t clEnemyINVIS = { cFuncESPEnemyUNVISR.iValue/255.0f, cFuncESPEnemyUNVISG.iValue/255.0f, cFuncESPEnemyUNVISB.iValue/255.0f, 1.0f }; vec4_t clFriendyVIS = { cFuncESPFriendVISR.iValue/255.0f, cFuncESPFriendVISG.iValue/255.0f, cFuncESPFriendVISB.iValue/255.0f, 1.0f }; vec4_t clFriendINVIS = { cFuncESPFriendUNVISR.iValue/255.0f, cFuncESPFriendUNVISG.iValue/255.0f, cFuncESPFriendUNVISB.iValue/255.0f, 1.0f }; for (int i = 0; i < Targets.size(); i++) { if (!Targets[i].alive || (Targets[i].enemy && cFuncESPFilter.iValue == FILTR_ESPFRIENDS) || (!Targets[i].enemy && cFuncESPFilter.iValue == FILTR_ESPENEMY) || (bot.cg->snap->ps.clientNum == Targets[i].ci->clientNum)) continue; vec4_t colour; if (Targets[i].enemy) { if (Targets[i].visible) CopyVec4(colour, clEnemyVIS); else CopyVec4(colour, clEnemyINVIS); } else { if (Targets[i].visible) CopyVec4(colour, clFriendyVIS); else CopyVec4(colour, clFriendINVIS); } float fov_x = *(float*)((DWORD)GetModuleHandleA("gfx_d3d_mp_x86_s.dll") + bot.Fov_x); if (cFuncESP3Dbox.bValue) { Draw3DBox(Targets[i], colour); } if (cFuncESP2Dbox.bValue) { vec3_t orgUP, orgDown; vec2_t crdUP, crdDown; GetBoneOriginID(Targets[i].cent, "j_helmet", orgUP); CopyVec3(orgDown, Targets[i].cent->lerpOrigin); if (WorldToScreen(orgUP, crdUP) && WorldToScreen(orgDown, crdDown)) { float width = 400.0f; float x = crdDown[0]-((width / Targets[i].distance * fov_x)/2); float y = crdUP[1]; float w = (width / Targets[i].distance * fov_x); float h = crdDown[1] - crdUP[1]; Draw.Border(x, y, w, h, 2, colour); } } if (cFuncESPSkeleton.bValue) { DrawBone(Targets[i].cent, "j_head_end", "j_head", colour); DrawBone(Targets[i].cent, "j_head", "j_neck", colour); DrawBone(Targets[i].cent, "j_neck", "j_clavicle_le", colour); DrawBone(Targets[i].cent, "j_neck", "j_clavicle_ri", colour); DrawBone(Targets[i].cent, "j_clavicle_le", "j_shoulder_le", colour); DrawBone(Targets[i].cent, "j_shoulder_le", "j_elbow_le", colour); DrawBone(Targets[i].cent, "j_elbow_le", "j_wrist_le", colour); DrawBone(Targets[i].cent, "j_clavicle_ri", "j_shoulder_ri", colour); DrawBone(Targets[i].cent, "j_shoulder_ri", "j_elbow_ri", colour); DrawBone(Targets[i].cent, "j_elbow_ri", "j_wrist_ri", colour); DrawBone(Targets[i].cent, "j_neck", "j_spine4", colour); DrawBone(Targets[i].cent, "j_spine4", "j_spine3", colour); DrawBone(Targets[i].cent, "j_spine3", "j_spine2", colour); DrawBone(Targets[i].cent, "j_spine2", "j_spine1", colour); DrawBone(Targets[i].cent, "j_spine1", "torso_stabilizer", colour); DrawBone(Targets[i].cent, "torso_stabilizer", "j_hiptwist_le", colour); DrawBone(Targets[i].cent, "j_hiptwist_le", "j_knee_le", colour); DrawBone(Targets[i].cent, "j_knee_le", "j_ankle_le", colour); DrawBone(Targets[i].cent, "j_ankle_le", "j_ball_le", colour); DrawBone(Targets[i].cent, "torso_stabilizer", "j_hiptwist_ri", colour); DrawBone(Targets[i].cent, "j_hiptwist_ri", "j_knee_ri", colour); DrawBone(Targets[i].cent, "j_knee_ri", "j_ankle_ri", colour); DrawBone(Targets[i].cent, "j_ankle_ri", "j_ball_ri", colour); } if (cFuncESPLines.bValue) { vec2_t screen; vec3_t org; GetBoneOriginID(Targets[i].cent, "j_spine1", org); if(WorldToScreen(org, screen)) { float x = bot.cg->refdef.width/2; float y = bot.cg->refdef.height; Draw.Line(x, y, screen[0], screen[1], colour, 1); } } LPSTR font; switch (cFuncESPFont.iValue) { case FILTR_BIG: font = bot.fonts.Big; break; case FILTR_NORMAL: font = bot.fonts.Normal; break; case FILTR_SMALL: font = bot.fonts.Small; break; case FILTR_BOLD: font = bot.fonts.Bold; default: font = bot.fonts.Big; break; } vec3_t org_helmet; vec2_t screen1, screen2; GetBoneOriginID(Targets[i].cent, "j_helmet", org_helmet); if(WorldToScreen(org_helmet, screen1) && WorldToScreen(Targets[i].cent->lerpOrigin, screen2)) { string name = strip_color(string(Targets[i].ci->name)); name = strip_color(name); if (cFuncESPNames.bValue) Draw.Text(screen1[0], screen1[1], 0.8, colour, F_CENTER, font, "%s", name.c_str()); if (cFuncESPDistance.bValue) Draw.Text(screen2[0], screen2[1], 0.9, colour, F_CENTER, font, "%im", (int)Targets[i].distance); } } } }