Beispiel #1
0
int RGrunt::Process()
{
	double &the_time = ztime->ztime;
	int &x = loc.x;
	int &y = loc.y;

	Common_Process(the_time);

	if(this->CanThrowGrenades() || (attack_object && attack_object->AttackedOnlyByExplosives())) return 1;

	if(mode == R_ATTACKING && the_time >= next_attack_time)
	{
		action_i++;
		if(action_i>=5) action_i = 3;

		if(action_i >= 3)
			next_attack_time = the_time + 0.40 + ((rand() % 100) * 0.2 * 0.01);
		else
			next_attack_time = the_time + 0.02;

		//just switched to firing?
		if(action_i == 4 && attack_object)
		{
			int tx, ty;
			int w, h;

			attack_object->GetCords(tx, ty);
			attack_object->GetDimensionsPixel(w,h);

			tx += (rand() % w);
			ty += (rand() % h);

			if(effect_list) effect_list->push_back((ZEffect*)(new EBullet(ztime, owner, x+8, y+8, tx, ty)));
			ZSoundEngine::PlayWavRestricted(RIFLE_FIRE_SND, loc.x, loc.y, width_pix, height_pix);
		}
	}

	return 1;
}
Beispiel #2
0
int RLaser::Process()
{
	double &the_time = ztime->ztime;
	int &x = loc.x;
	int &y = loc.y;

	Common_Process(the_time);

	if(this->CanThrowGrenades() || (m_attacked_object && m_attacked_object->AttackedOnlyByExplosives())) return 1;

	if(mode == R_ATTACKING && the_time >= next_attack_time)
	{
		action_i++;
		if(action_i>=3) action_i = 0;

		switch(action_i)
		{
			case 0:
				next_attack_time = the_time + 0.30 + ((rand() % 100) * 0.2 * 0.01);
				break;
			case 1:
			case 2:
				next_attack_time = the_time + 0.05 + ((rand() % 100) * 0.03 * 0.01);
				break;
		}

		//just switched to firing?
		if(action_i == 2 && m_attacked_object)
		{
			int tx, ty;
			int sx, sy;
			int w, h;

			m_attacked_object->GetCords(tx, ty);
			m_attacked_object->GetDimensionsPixel(w,h);

			tx += (rand() % w);
			ty += (rand() % h);

			switch(direction)
			{
			case 0:
				sx = 8;
				sy = 0;
				break;
			case 1:
				sx = 8;
				sy = -8;
				break;
			case 2:
				sx = 0;
				sy = -8;
				break;
			case 3:
				sx = -8;
				sy = -8;
				break;
			case 4:
				sx = -8;
				sy = 0;
				break;
			case 5:
				sx = -8;
				sy = 8;
				break;
			case 6:
				sx = 0;
				sy = 8;
				break;
			case 7:
				sx = 8;
				sy = 8;
				break;
			}

			if(effect_list) effect_list->push_back((ZEffect*)(new ELaser(ztime, x+8+sx, y+8+sy, tx, ty)));
			ZSoundEngine::PlayWavRestricted(LASER_FIRE_SND, loc.x, loc.y, width_pix, height_pix);
		}
	}

	return 1;
}