void actWallBuster(Entity *my) { int c; if( !my->skill[28] ) return; // received on signal if( my->skill[28] == 2) { Uint16 x = std::min<Uint16>(std::max(0.0,my->x/16),map.width-1); Uint16 y = std::min<Uint16>(std::max(0.0,my->y/16),map.height-1); map.tiles[OBSTACLELAYER+y*MAPLAYERS+x*MAPLAYERS*map.height] = 0; map.tiles[(MAPLAYERS-1)+y*MAPLAYERS+x*MAPLAYERS*map.height] = 0; spawnExplosion(my->x,my->y,my->z-8); if( multiplayer==SERVER ) { for( c=0; c<MAXPLAYERS; c++ ) { if( client_disconnected[c]==TRUE ) continue; strcpy((char *)net_packet->data,"WACD"); SDLNet_Write16(x,&net_packet->data[4]); SDLNet_Write16(y,&net_packet->data[6]); net_packet->address.host = net_clients[c-1].host; net_packet->address.port = net_clients[c-1].port; net_packet->len = 8; sendPacketSafe(net_sock, -1, net_packet, c-1); } } list_RemoveNode(my->mynode); } }
void enemy3Think(entity *self) { if(self->cooldown > 0)self->cooldown--; if(self->s.y > 40.0f) { self->shown = 0; self->solid = 0; }else { self->shown = 1; self->solid = 1; } if(self->s.y > 30.0f) { self->s.y -= 1; }else self->s.y -= enemy3speed; if( self->cooldown <= 0) { self->cooldown = 35; spawnenemyBullet(self->s.x,self->s.y+15,self->s.z,-2.3f); spawnenemyBullet(self->s.x,self->s.y+15,self->s.z,-2.5f); spawnenemyBullet(self->s.x,self->s.y+15,self->s.z,-2.7f); spawnenemyBullet(self->s.x,self->s.y+15,self->s.z,-2.1f); spawnenemyBullet(self->s.x,self->s.y+15,self->s.z,-2.9f); } if( self->cooldown == 15) { spawnenemyBullet(self->s.x,self->s.y+13,self->s.z,-0.3f); spawnenemyBullet(self->s.x,self->s.y+13,self->s.z,-0.5f); spawnenemyBullet(self->s.x,self->s.y+13,self->s.z,-0.7f); spawnenemyBullet(self->s.x,self->s.y+13,self->s.z,-0.1f); spawnenemyBullet(self->s.x,self->s.y+13,self->s.z,-0.9f); } if(self->bigcooldown > 0)self->bigcooldown--; if(self->state == HIT) { self->bigcooldown = 3; self->state = -1; self->modelColor[0] = 1.0f; self->modelColor[1] = 0.0f; self->modelColor[2] = 0.0f; self->modelColor[3] = 1.0f; } if(self->bigcooldown <= 0) { self->state = -1; self->modelColor[0] = enemy3Color.x; self->modelColor[1] = enemy3Color.y; self->modelColor[2] = enemy3Color.z; self->modelColor[3] = 1.0f; } if(self->health <= 0 || self->s.y <= -80.0f) { spawnExplosion(self->s.x,self->s.y,self->s.z, 1.0f); if(self->health <= 0) score += 180; freeEntity(self); } }
void enemy1Think(entity *self) { float dy,dx; if(self->s.y > 40.0f) { self->shown = 0; self->solid = 0; }else { self->shown = 1; self->solid = 1; } if(self->cooldown > 0)self->cooldown--; if(self->state2 == 1 && self->cooldown <= 0) { self->s.x += (float)(cos(self->v.y)*enemy1speed); self->s.y += (float)(sin(self->v.y)*enemy1speed); self->rotation.y+=30; }else if(self->cooldown <= 0) { self->s.y -= 1; self->rotation.y+=10; } if(self->state2 == 1 && self->cooldown > 0)self->rotation.y+=10; if(self->s.y < 20.0f && self->state2 == 0) { dy=playerPos.y-self->s.y; dx=playerPos.x-self->s.x; self->v.y=(float)atan2(dy,dx); self->state2 = 1; self->cooldown = 10; } if(self->bigcooldown > 0)self->bigcooldown--; if(self->state == HIT) { self->bigcooldown = 3; self->state = -1; self->modelColor[0] = 1.0f; self->modelColor[1] = 0.0f; self->modelColor[2] = 0.0f; self->modelColor[3] = 1.0f; } if(self->bigcooldown <= 0) { self->state = -1; self->modelColor[0] = enemy1Color.x; self->modelColor[1] = enemy1Color.y; self->modelColor[2] = enemy1Color.z; self->modelColor[3] = 1.0f; } if(((self->s.y < -50.0f || self->s.y > 50.0f || self->s.x < -50.0f || self->s.x > 50.0f) && self->state2 == 1) || self->health <= 0) { spawnExplosion(self->s.x,self->s.y,self->s.z, 0.2f); if(self->health <= 0) score += 30; freeEntity(self); } }
//-------------------------------------------------------------------------- // OnAdd //-------------------------------------------------------------------------- bool Splash::onAdd() { // first check if we have a server connection, if we dont then this is on the server // and we should exit, then check if the parent fails to add the object NetConnection* conn = NetConnection::getConnectionToServer(); if(!conn || !Parent::onAdd()) return false; if( !mDataBlock ) { Con::errorf("Splash::onAdd - Fail - No datablock"); return false; } mDelayMS = mDataBlock->delayMS + sgRandom.randI( -mDataBlock->delayVariance, mDataBlock->delayVariance ); mEndingMS = mDataBlock->lifetimeMS + sgRandom.randI( -mDataBlock->lifetimeVariance, mDataBlock->lifetimeVariance ); mVelocity = mDataBlock->velocity; mHeight = mDataBlock->height; mTimeSinceLastRing = 1.0 / mDataBlock->ejectionFreq; for( U32 i=0; i<SplashData::NUM_EMITTERS; i++ ) { if( mDataBlock->emitterList[i] != NULL ) { ParticleEmitter * pEmitter = new ParticleEmitter; pEmitter->onNewDataBlock( mDataBlock->emitterList[i], false ); if( !pEmitter->registerObject() ) { Con::warnf( ConsoleLogEntry::General, "Could not register emitter for particle of class: %s", mDataBlock->getName() ); delete pEmitter; pEmitter = NULL; } mEmitterList[i] = pEmitter; } } spawnExplosion(); mObjBox.minExtents = Point3F( -1, -1, -1 ); mObjBox.maxExtents = Point3F( 1, 1, 1 ); resetWorldBox(); gClientSceneGraph->addObjectToScene(this); removeFromProcessList(); ClientProcessList::get()->addObject(this); conn->addObject(this); return true; }
/** * check if a cube's bounding sphre intersects the bullet's */ void collision(evil& cube) { float v[3]; v[0] = cube.x - _blt.x; v[1] = cube.y - _blt.y; v[2] = cube.z - _blt.z; float m = 0; for(int i = 0; i < 3; ++i) m += v[i] * v[i]; if(m < 10.0f * sqrtf(3.0f) + sbullet_size) { _score += 2u + _bonus++; // acorda scor si bonus jucatorului daca a nimerit ceva cube.dead = true; spawnExplosion(cube); } }
void playerupdate(entity *self) { playerPos=self->s; playerlife=self->lives; if(self->deadcool > 0) { self->solid=0; if(self->deadcool%5) { self->modelColor[0] = 1.0f; self->modelColor[1] = 1.0f; self->modelColor[2] = 1.0f; self->modelColor[3] = 0.1f; }else { self->modelColor[0] = playerColor.x; self->modelColor[1] = playerColor.y; self->modelColor[2] = playerColor.z; self->modelColor[3] = 1.0f; } }else { self->solid=1; self->modelColor[0] = playerColor.x; self->modelColor[1] = playerColor.y; self->modelColor[2] = playerColor.z; self->modelColor[3] = 1.0f; } if(self->health <= 0) { spawnExplosion(self->s.x,self->s.y,self->s.z, 1.0f); self->deadcool= 60; self->lives--; if(self->lives < 0) { freeEntity(self); inMenu = 1; return; } self->health = 1; self->s.y = -20; self->s.x = 0; } }
void BossThink(entity *self) { float dy,dx; if(self->s.y > 20.0f) { self->shown = 0; self->solid = 0; self->s.y -= 1; }else { self->shown = 1; self->solid = 1; DrawHealth(self->health*0.15f, self->maxHealth, 1, 0, 0); if(self->cooldown > 0)self->cooldown--; if(self->state2 ==1) { self->s.x-= 0.5f; if(self->s.x <= -20.0f) { self->s.x = -20.0f; self->state2=2; } } if(self->state2 ==2) { self->s.x+= 0.5f; if(self->s.x >= 20.0f) { self->s.x = 20.0f; self->state2=1; } } if(self->cooldown%5==0 && self->cooldown <= 40) { dy=playerPos.y-self->s.y; dx=playerPos.x-self->s.x; self->v.y=(float)atan2(dy,dx); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y+0.8f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y-0.8f); } if( self->cooldown <= 200 && self->cooldown>= 115 && self->cooldown%8==0) { dy=playerPos.y-self->s.y; dx=playerPos.x-self->s.x; self->v.y=(float)atan2(dy,dx); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y-0.2f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y+0.2f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y-0.4f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y+0.4f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y-0.5f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y+0.5f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y-0.6f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y+0.6f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y-0.8f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y+0.8f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y-1.0f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y+1.0f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y-1.2f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y+1.2f); } if( self->cooldown <= 0) { self->cooldown = 195; spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.3f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.5f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.7f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.1f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.9f); } if( self->cooldown == 15) { spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.3f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.5f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.7f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.1f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.9f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.3f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.5f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.7f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.1f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.9f); } if( self->cooldown == 100) { spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.3f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.5f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.7f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.1f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.9f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.3f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.5f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.7f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.1f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.9f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.3f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.5f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.7f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.1f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.9f); } if( self->cooldown == 50) { spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.3f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.5f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.7f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.1f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.9f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.3f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.5f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.7f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.1f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.9f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.3f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.5f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.7f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.1f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.9f); } if( self->cooldown == 90) { spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.2f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.3f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.8f); spawnenemyBullet(self->s.x,self->s.y,self->s.z, 0.0f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.8f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.2f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.4f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.6f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.0f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.8f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.2f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.4f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.6f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.0f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.8f); } if( self->cooldown == 80) { spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.4f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.6f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.8f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.2f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.0f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.4f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.6f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.8f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.2f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-3.0f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.4f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.6f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.8f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.2f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.0f); } if( self->cooldown == 70) { spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.3f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.5f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.7f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.1f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.9f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.3f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.5f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.7f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.1f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.9f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.3f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.5f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.7f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.1f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.9f); } if( self->cooldown == 60) { spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.4f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.6f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.8f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-0.2f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.0f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.4f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.6f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.8f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.2f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-3.0f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.4f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.6f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.8f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-1.2f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,-2.0f); } if(self->bigcooldown > 0)self->bigcooldown--; if(self->state == HIT) { self->bigcooldown = 3; self->state = -1; self->modelColor[0] = 1.0f; self->modelColor[1] = 0.0f; self->modelColor[2] = 0.0f; self->modelColor[3] = 1.0f; } if(self->bigcooldown <= 0) { self->state = -1; self->modelColor[0] = bossColor.x; self->modelColor[1] = bossColor.y; self->modelColor[2] = bossColor.z; self->modelColor[3] = 1.0f; } if(self->health <= 0 || self->s.y <= -40.0f) { spawnExplosion(self->s.x,self->s.y,self->s.z, 1.0f); if(self->health <= 0) score += 5000; freeEntity(self); } } }
void enemy2Think(entity *self) { float dy,dx; if(self->cooldown > 0)self->cooldown--; if(self->s.y > 40.0f) { self->shown = 0; self->solid = 0; }else { self->shown = 1; self->solid = 1; } if(self->s.y < 20.0f) { dy=playerPos.y-self->s.y; dx=playerPos.x-self->s.x; self->v.y=(float)atan2(dy,dx); self->rotation.z=(self->v.y*(RadToDeg))-90; self->s.y -= enemy2speed; if( self->cooldown <= 0) { self->cooldown = 55; spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y-0.1f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y+0.1f); } if( self->cooldown == 15) { spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y-0.5f); spawnenemyBullet(self->s.x,self->s.y,self->s.z,self->v.y+0.5f); } }else self->s.y -= 1; if(self->frame < self->totalframes) { self->frame++; }else { self->frame=0; if(self->keyframe == 0) { self->totalframes=10; self->keyframe=1; self->nextkeyframe=0; }else { self->totalframes=20; self->keyframe=0; self->nextkeyframe=1; } } if(self->bigcooldown > 0)self->bigcooldown--; if(self->state == HIT) { self->bigcooldown = 3; self->state = -1; self->modelColor[0] = 1.0f; self->modelColor[1] = 0.0f; self->modelColor[2] = 0.0f; self->modelColor[3] = 1.0f; } if(self->bigcooldown <= 0) { self->state = -1; self->modelColor[0] = enemy2Color.x; self->modelColor[1] = enemy2Color.y; self->modelColor[2] = enemy2Color.z; self->modelColor[3] = 1.0f; } if(self->health <= 0 || self->s.y <= -40.0f) { spawnExplosion(self->s.x,self->s.y,self->s.z, 0.2f); if(self->health <= 0) score += 80; freeEntity(self); } }
void Rocket::onLifetimeOver() { spawnExplosion(); }