void RocketProjectile::Tick(World & world){
	if(yv < 0 && xv == 0){ // up
		res_index = 4;
	}
	if(yv < 0 && xv > 0){ // up right
		res_index = 3;
		mirrored = false;
	}
	if(yv == 0 && xv > 0){ // right
		res_index = 0;
		mirrored = false;
	}
	if(yv > 0 && xv > 0){ // down right
		res_index = 1;
		mirrored = false;
	}
	if(yv > 0 && xv == 0){ // down
		res_index = 2;
	}
	if(yv > 0 && xv < 0){ // down left
		res_index = 1;
		mirrored = true;
	}
	if(yv == 0 && xv < 0){ // left
		res_index = 0;
		mirrored = true;
	}
	if(yv < 0 && xv < 0){ // up left
		res_index = 3;
		mirrored = true;
	}
	if(state_i == 100){
		oldxv = xv;
		oldyv = yv;
		xv = ceil(float(xv) * 0.3);
		yv = ceil(float(yv) * 0.3);
		soundchannel = EmitSound(world, world.resources.soundbank["rocket4.wav"], 128);
		state_i = 11;
		res_bank = 87;
	}
	if(state_i == 0){
		oldxv = xv;
		oldyv = yv;
		xv = ceil(float(xv) * 0.2);
		yv = ceil(float(yv) * 0.2);
		soundchannel = EmitSound(world, world.resources.soundbank["rocket9.wav"], 128);
	}
	if(state_i == 3){
		res_bank = 87;
	}
	if(state_i == 11){
		if(xv > 0){
			xv++;
		}else{
			xv--;
		}
		if(yv > 0){
			yv++;
		}else{
			yv--;
		}
		if(abs(xv) > abs(oldxv)){
			xv = oldxv;
		}
		if(abs(yv) > abs(oldyv)){
			yv = oldyv;
		}
		Platform * platform = 0;
		Object * object = 0;
		Sint16 oldx = x;
		Sint16 oldy = y;
		if(TestCollision(*this, world, &platform, &object)){
			float xn = 0, yn = 0;
			if(platform){
				platform->GetNormal(x, y, &xn, &yn);
			}
			int numplumes = 6;
			float anglen = (rand() % 100) / float(100);
			for(int i = 0; i < numplumes; i++){
				Plume * plume = (Plume *)world.CreateObject(ObjectTypes::PLUME);
				if(plume){
					plume->type = 4;
					/*plume->xv = (rand() % 17) - 8;
					plume->yv = (rand() % 17) - 8;
					plume->xv = (xn * abs(plume->xv)) + (rand() % 33) - 16;
					plume->yv = (yn * abs(plume->yv)) + (rand() % 33) - 16;*/
					float angle = (i / float(numplumes)) * (2 * 3.14);
					angle += anglen;
					plume->xv = (sin(angle)) * 15;
					plume->yv = (cos(angle)) * 15;
					if(xn || yn){
						plume->xv = (xn * abs(plume->xv)) + (rand() % 17) - 8;
						plume->yv = (yn * abs(plume->yv)) + (rand() % 17) - 8;
					}
					plume->SetPosition(x, y);
					
					Plume * plume2 = (Plume *)world.CreateObject(ObjectTypes::PLUME);
					if(plume2){
						plume2->type = 4;
						plume2->xv = plume->xv + (rand() % 7) - 3;
						plume2->yv = plume->yv + (rand() % 7) - 3;
						plume2->SetPosition(x, y);
					}
				}
			}
			std::vector<Uint8> types;
			types.push_back(ObjectTypes::PLAYER);
			types.push_back(ObjectTypes::GUARD);
			types.push_back(ObjectTypes::ROBOT);
			types.push_back(ObjectTypes::CIVILIAN);
			types.push_back(ObjectTypes::FIXEDCANNON);
			types.push_back(ObjectTypes::WALLDEFENSE);
			types.push_back(ObjectTypes::TECHSTATION);
			Object * owner = world.GetObjectFromId(ownerid);
			Uint16 teamid = 0;
			bool issecurity = false;
			if(owner){
				switch(owner->type){
					case ObjectTypes::PLAYER:{
						Player * player = static_cast<Player *>(owner);
						Team * team = player->GetTeam(world);
						if(team){
							teamid = team->id;
						}
					}break;
					case ObjectTypes::ROBOT:{
						Robot * robot = static_cast<Robot *>(owner);
						teamid = robot->virusplanter;
						issecurity = world.IsSecurity(*robot);
					}break;
					case ObjectTypes::GUARD:{
						issecurity = true;
					}break;
				}
			}
			std::vector<Object *> objects = world.TestAABB(x - 30, y - 30, x + 30, y + 30, types, ownerid, teamid);
			for(std::vector<Object *>::iterator it = objects.begin(); it != objects.end(); it++){
				if(!object || (object && (*it)->id != object->id)){
					if(!issecurity || (issecurity && !world.IsSecurity(*(*it)))){ // prevents robots/rocket guards from doing slash damage to other security
						Object damageprojectile(ObjectTypes::ROCKETPROJECTILE);
						damageprojectile.healthdamage = healthdamage;
						damageprojectile.shielddamage = shielddamage;
						damageprojectile.ownerid = ownerid;
						(*it)->HandleHit(world, 50, 50, damageprojectile);
					}
				}
			}
			xv = 0;
			yv = 0;
			res_bank = 0xFF;
			if(soundchannel){
				Audio::GetInstance().Stop(soundchannel, 100);
			}
			EmitSound(world, world.resources.soundbank["seekexp1.wav"], 128);
		}
		for(int i = 0; i < 2; i++){
			int xv2 = (signed(oldx) - x) * (1.25 * i);
			int yv2 = (signed(oldy) - y) * (1.25 * i);
			Plume * plume = (Plume *)world.CreateObject(ObjectTypes::PLUME);
			if(plume){
				plume->type = 3;
				plume->xv = rand() % 7 - 3;
				plume->yv = rand() % 7 - 3;
				plume->SetPosition(x + xv2, y + yv2);
			}
		}
	}
	if(state_i < 11 || (state_i >= 11 && xv == 0 && yv == 0)){
		state_i++;
	}
	if(state_i >= 25){
		world.MarkDestroyObject(id);
	}else{
		Player * localplayer = world.GetPeerPlayer(world.localpeerid);
		if(localplayer && ownerid == localplayer->id){
			//if(!world.systemcameraactive[0]){
				world.SetSystemCamera(0, id, 0, 20);
			//}
		}
	}
}