void WeaponUsageStatistic::On_Check_Respond(NET_Packet* P) { if (!P) return; u8 NumFalse = P->r_u8(); u8 NumTrue = P->r_u8(); u8 i; ABULLETS_it BulletIt; for (i=0; i<NumFalse; i++) { u32 BulletID = P->r_u32(); if (!FindBullet(BulletID, BulletIt)) { Msg("! Warning: No bullet found! ID[%d]", BulletID); continue; }; BulletIt->HitResponds++; RemoveBullet(BulletIt); } for (i=0; i<NumTrue; i++) { u32 BulletID = P->r_u32(); s16 BoneID = P->r_s16(); if (!FindBullet(BulletID, BulletIt)) { Msg("! Warning: No bullet found! ID[%d]", BulletID); continue; }; BulletIt->HitResponds++; //--------------------------------------------------------------- PLAYERS_STATS_it PlayerIt = FindPlayer(*(BulletIt->FirerName)); WEAPON_STATS_it WeaponIt = PlayerIt->FindPlayersWeapon(*(BulletIt->WeaponName)); (*WeaponIt).m_dwKillsScored++; (*WeaponIt).m_dwKillsScored_d++; HITS_VEC_it HitIt; if (WeaponIt->FindHit(BulletID, HitIt)) { HitData& HData = *HitIt; HData.Deadly = true; HData.BoneID = BoneID; CObject* pObj = Level().Objects.net_Find(HData.TargetID); if (pObj) HData.BoneName = smart_cast<CKinematics*>(pObj->Visual())->LL_BoneName_dbg(BoneID); } //--------------------------------------------------------------- RemoveBullet(BulletIt); } };
void WeaponUsageStatistic::OnBullet_Remove(SBullet* pBullet) { if (!pBullet || !pBullet->flags.allow_sendhit) return; ABULLETS_it BulletIt; if (!FindBullet(pBullet->m_dwID, BulletIt)) return; // Msg("! Bullet Removed ID[%d]", BulletIt->Bullet.m_dwID); BulletIt->Removed = true; RemoveBullet (BulletIt); }
void BulletList::Tick(DOUBLE2 PosCamera, double deltaTime, RECT2ARRAYSTRUCT targetRectStruct) { m_RussianBaseRectArr[0] = targetRectStruct.rect2struct1; m_RussianBaseRectArr[1] = targetRectStruct.rect2struct2; m_RussianBaseRectArr[2] = targetRectStruct.rect2struct3; m_RussianBaseRectArr[3] = targetRectStruct.rect2struct4; m_RussianBaseRectArr[4] = targetRectStruct.rect2struct5; //Calls the Tick method on each Bullet in the list for(int i=0;i<MAX_NR_OF_BULLETS;++i) if(m_BulletPtrArr[i]!=nullptr) { m_BulletPtrArr[i]->Tick(deltaTime); } //Calls the Tick method on each RussianBullet in the list for(int i=0;i<MAX_NR_OF_BULLETS;++i) if(m_RussianBaseBulletPtrArr[i]!=nullptr) { m_RussianBaseBulletPtrArr[i]->Tick(deltaTime); } //delete every bullet who leaves the camera's view for(int i=0;i<MAX_NR_OF_BULLETS;++i) if(m_BulletPtrArr[i]!=nullptr) { if(m_BulletPtrArr[i]->GetPos().x>PosCamera.x+GAME_ENGINE->GetWidth()) RemoveBullet(m_BulletPtrArr[i]); else if(m_BulletPtrArr[i]->GetPos().x<0) RemoveBullet(m_BulletPtrArr[i]); else if(m_BulletPtrArr[i]->GetPos().y<0) RemoveBullet(m_BulletPtrArr[i]); else if(m_BulletPtrArr[i]->GetPos().y>PosCamera.y+GAME_ENGINE->GetHeight()) RemoveBullet(m_BulletPtrArr[i]); } for(int i=0;i<MAX_NR_OF_BULLETS;++i) if(m_RussianBaseBulletPtrArr[i]!=nullptr) { if(m_RussianBaseBulletPtrArr[i]->GetPos().x>PosCamera.x+GAME_ENGINE->GetWidth()) RemoveRussianBaseBullet(m_RussianBaseBulletPtrArr[i]); else if(m_RussianBaseBulletPtrArr[i]->GetPos().x<0) RemoveRussianBaseBullet(m_RussianBaseBulletPtrArr[i]); else if(m_RussianBaseBulletPtrArr[i]->GetPos().y<0) RemoveRussianBaseBullet(m_RussianBaseBulletPtrArr[i]); else if(m_RussianBaseBulletPtrArr[i]->GetPos().y>PosCamera.y+GAME_ENGINE->GetHeight()) RemoveRussianBaseBullet(m_RussianBaseBulletPtrArr[i]); } }
void EditorScene::RemoveBullet(Entity * node) { if(NULL != node) { node->RemoveComponent(Component::BULLET_COMPONENT); int size = node->GetChildrenCount(); for (int i = 0; i < size; i++) { RemoveBullet(node->GetChild(i)); } } }
void DeleteAllBullets( ) { UINT32 uiCount; for ( uiCount = 0; uiCount < guiNumBullets; uiCount++ ) { if ( gBullets[ uiCount ].fAllocated) { // Remove from old position RemoveBullet( uiCount ); gBullets[ uiCount ].fAllocated = FALSE; } } RecountBullets( ); }
RECT2 BulletList::IsRussianBaseHit() { RECT2 russianbaserect(0,0,0,0); for (int i = 0; i < MAX_NR_OF_BULLETS ; i++) { if(m_BulletPtrArr[i]!=nullptr) { RECT2 bulletRect = m_BulletPtrArr[i]->GetRect(); for (int i = 0; i < NUMBER_OF_RUSSIANBASE ; i++) { if( RectIntersectTest(m_RussianBaseRectArr[i] , bulletRect) == true) { RemoveBullet(m_BulletPtrArr[i]); russianbaserect = m_RussianBaseRectArr[i]; } } } } return russianbaserect; }
void CEffectsGame::UpdateBullets( float frametime ) { for (int i=0; i<MAX_BULLETS; i++) { if (bullets[i] == NULL) continue;; CSprite3D *bullet = bullets[i]; Vector3 move = bullet->velocity * frametime; Vector3 start = bullet->GetPosition(); bullet->Move(move.x, move.y, move.z); bullet->velocity.y -= frametime * cv_bulletGravity.GetFloat(); bullet->lockedAxis = bullet->velocity; bullet->lockedAxis.Normalize(); Vector3 v = bullet->velocity; v.Normalize(); gRenderer.AddLine(bullet->GetPosition(), bullet->GetPosition() + v, SRGBA(255,230,180,180)); if (bullet->GetWorldPosition().y < 0) { RemoveBullet(i); } SMapTile *tileHit; Vector3 tileHitPos; Vector3 pos; bool hit = false; if (hit = pLevel->CastRay(start, bullet->GetPosition(), OUT tileHitPos, OUT &tileHit, OUT &pos)) { EnterCriticalSection(&renderCS); tileHit->type = 0; LeaveCriticalSection(&renderCS); // remove tile from the level and mark for update SMapChunk *chunk = pLevel->GetChunk( floor(tileHitPos.x/SMapChunk::Size), floor(tileHitPos.y/SMapChunk::Size), floor(tileHitPos.z/SMapChunk::Size) ); chunk->dirtyBody = true; chunk->dirty = true; // add a box to spawn list SSpawnTile s; s.pos = tileHitPos; s.vel = v * cv_bulletforce.GetFloat(); boxesToSpawn.push(s); // remove bullet RemoveBullet(i); float puffSpeed = 0.5; // add puff effect for (int i = 0; i<6; i++) { static CTexture *puffTex = new CTexture("particles/explosion4.dds"); CParticle *p = new CParticle(puffTex); p->size = Vector2(1.35, 1.35); p->position = pos; p->velocity = Vector3( frand(-puffSpeed,puffSpeed), frand(-puffSpeed,puffSpeed), frand(-puffSpeed,puffSpeed) ); p->lifetime = 1; //p->color = SRGBA(155,155,155,255); p->color = SRGB(clamp(pos.x*255.0f/32.0f,0,255)*0.9f, clamp(pos.y*255.0f/32.0f,0,255)*0.9f, clamp(pos.z*255.0f/32.0f,0,255)*0.9f); p->colorChange = p->color;// SRGBA(255,255,255,0); p->colorChange.a = 0; p->colorTime = 1; p->sizeVel = Vector2(0.85,0.85); particles->Add(p); } } } //PrintText("Bullets: %d", bulletsNum); }
void EditorScene::RemoveNode(Entity * node) { RemoveBullet(node); Scene::RemoveNode(node); }
void DeleteAniTile( ANITILE *pAniTile ) { ANITILE *pAniNode = NULL; ANITILE *pOldAniNode = NULL; TILE_ELEMENT *TileElem; pAniNode = pAniTileHead; while( pAniNode!= NULL ) { if ( pAniNode == pAniTile ) { // OK, set links // Check for head or tail if ( pOldAniNode == NULL ) { // It's the head pAniTileHead = pAniTile->pNext; } else { pOldAniNode->pNext = pAniNode->pNext; } if ( !(pAniNode->uiFlags & ANITILE_EXISTINGTILE ) ) { // Delete memory assosiated with item switch( pAniNode->ubLevelID ) { case ANI_STRUCT_LEVEL: RemoveStructFromLevelNode( pAniNode->sGridNo, pAniNode->pLevelNode ); break; case ANI_SHADOW_LEVEL: RemoveShadowFromLevelNode( pAniNode->sGridNo, pAniNode->pLevelNode ); break; case ANI_OBJECT_LEVEL: RemoveObject( pAniNode->sGridNo, pAniNode->usTileIndex ); break; case ANI_ROOF_LEVEL: RemoveRoof( pAniNode->sGridNo, pAniNode->usTileIndex ); break; case ANI_ONROOF_LEVEL: RemoveOnRoof( pAniNode->sGridNo, pAniNode->usTileIndex ); break; case ANI_TOPMOST_LEVEL: RemoveTopmostFromLevelNode( pAniNode->sGridNo, pAniNode->pLevelNode ); break; } if ( ( pAniNode->uiFlags & ANITILE_CACHEDTILE ) ) { RemoveCachedTile( pAniNode->sCachedTileID ); } if ( pAniNode->uiFlags & ANITILE_EXPLOSION ) { // Talk to the explosion data... RemoveExplosionData( pAniNode->uiUserData3 ); if ( !gfExplosionQueueActive ) { // turn on sighting again // the explosion queue handles all this at the end of the queue gTacticalStatus.uiFlags &= (~DISALLOW_SIGHT); } // Freeup attacker from explosion DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("@@@@@@@ Reducing attacker busy count..., EXPLOSION effect gone off") ); ReduceAttackBusyCount( (UINT8)pAniNode->ubUserData2, FALSE ); } if ( pAniNode->uiFlags & ANITILE_RELEASE_ATTACKER_WHEN_DONE ) { // First delete the bullet! RemoveBullet( pAniNode->uiUserData3 ); DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("@@@@@@@ Freeing up attacker - miss finished animation") ); FreeUpAttacker( (UINT8) pAniNode->ubAttackerMissed ); } } else { TileElem = &( gTileDatabase[ pAniNode->usTileIndex ] ); // OK, update existing tile usIndex.... Assert( TileElem->pAnimData != NULL ); pAniNode->pLevelNode->usIndex = TileElem->pAnimData->pusFrames[ pAniNode->pLevelNode->sCurrentFrame ]; // OK, set our frame data back to zero.... pAniNode->pLevelNode->sCurrentFrame = 0; // Set some flags to write to Z / update save buffer // pAniNode->pLevelNode->uiFlags |=( LEVELNODE_LASTDYNAMIC | LEVELNODE_UPDATESAVEBUFFERONCE ); pAniNode->pLevelNode->uiFlags &= ~( LEVELNODE_DYNAMIC | LEVELNODE_USEZ | LEVELNODE_ANIMATION ); if (pAniNode->uiFlags & ANITILE_DOOR) { // unset door busy! DOOR_STATUS * pDoorStatus; pDoorStatus = GetDoorStatus( pAniNode->sGridNo ); if (pDoorStatus) { pDoorStatus->ubFlags &= ~(DOOR_BUSY); } if ( GridNoOnScreen( pAniNode->sGridNo ) ) { SetRenderFlags(RENDER_FLAG_FULL); } } } MemFree( pAniNode ); return; } pOldAniNode = pAniNode; pAniNode = pAniNode->pNext; } }