Ejemplo n.º 1
0
void GhostTrap::act(Pointer<Entity> target)
{
	if (target->inherits<Ghost>()) {
		//BOOM
		detonate();
	}
}
Ejemplo n.º 2
0
void Fireball::timepass()
{
    Shot::timepass();
    travelDistance -= position.getVelocityMagnitude() * getDt();
    if(travelDistance < 0)
        detonate();
}
Ejemplo n.º 3
0
void detonate_if(const entity_id& id, const transformr& where, const logic_step& step) {
	step.get_cosmos()[id].dispatch_on_having_all<invariants::explosive>([&](const auto typed_handle) {
		detonate({
			step, id, typed_handle.template get<invariants::explosive>(), where
		});
	});
}
Ejemplo n.º 4
0
void Mine::timepass() {

	if (isArmed) {
		detonateTime -= getDt();
		if (detonateTime < 0) detonate();
	}
	Entity::timepass();
}
Ejemplo n.º 5
0
void Mine::collideWith(Entity *ent)
{
	if(((ent->getPosition().positionVector() - position.positionVector()).getMagnitude() <= coreRadius+ent->getRadius())
		 && canDestroy(ent)) 
	{
		detonate();
	}
	else if (canDetonate(ent)) {
		isArmed = true;
		detonateTime = mineDelay;
		radius = 1;
	}
}
Ejemplo n.º 6
0
/*
===============
FireWeapon2
===============
*/
void FireWeapon2( gentity_t *ent )
{
  if( ent->client )
  {
    // set aiming directions
    AngleVectors( ent->client->ps.viewangles, forward, right, up );
    CalcMuzzlePoint( ent, forward, right, up, muzzle );
  }
  else
  {
    AngleVectors( ent->s.angles2, forward, right, up );
    VectorCopy( ent->s.pos.trBase, muzzle );
  }

  // fire the specific weapon
  switch( ent->s.weapon )
  {
		/*case WP_ALEVEL1:
			//Blaster_ball( ent, 0);
			break;*/
			
    case WP_ALEVEL0:
        explodedretch( ent );
        break;
    case WP_ALEVEL1_UPG:
      poisonCloud( ent );
      break;
    case WP_ALEVEL2_UPG:
      areaZapFire( ent );
      break;

    case WP_LUCIFER_CANNON:
      LCChargeFire( ent, qtrue );
      break;

    case WP_ABUILD:
    case WP_ABUILD2:
    case WP_HBUILD:
    case WP_HBUILD2:
      cancelBuildFire( ent );
      break;
      
      case WP_BLASTER:
          detonate( ent );
          break;

    default:
      break;
  }
}
Ejemplo n.º 7
0
/**
 * sets off all the bombs in the field
 */
void doBombs() {
	Uint8 x, y;

	for(y=0; y<level->fieldHeight; y++) {
		for(x=0; x<level->fieldWidth; x++) {
			if(level->field[x][y] == BT_ABOMB)
				detonate(x, y);
		}
	}

	/* don't let blocks get eaten mid-step */
	/* this doesn't work very well */
	/* if(frame % 32 < 2 || frame % 32 > 28) eatBlocks(); */
}
Ejemplo n.º 8
0
/**
 * Includes most routines that define where a bullet or projectile is located during a specified frame.
 */
void Bullet::move()
{
    int j;
    REAL zK;
    static int cx, cy, cz;
    bool new_check = false;

    switch (state) {
        case READY:
            break;
        case FLY:
            for (j = 0; j < 8; j++) {
                i++;

                x = (int)(x0 + i * cos(te) * sin(fi));
                y = (int)(y0 + i * sin(te) * sin(fi));
                z = (int)(z0 + i * cos(fi));
                //text_mode(0);
                //textprintf(screen, font, 0, SCREEN2H+20, 1, "(%f,%f,%f)", z, x, y);
                
                if (cz != z / 12) { cz = z / 12; new_check = true; }
                if (cx != x / 16) { cx = x / 16; new_check = true; }
                if (cy != y / 16) { cy = y / 16; new_check = true; }

                if (new_check)
                    affect_morale(cz, cx, cy);

                if ((!map->inside(z, x, y)) ||
                        (!map->pass_lof_cell(z, x, y)) ||
                        platoon_remote->check_for_hit(z, x, y) ||
                        platoon_local->check_for_hit(z, x, y)
                   ) {
                    explodes = map->inside(z, x, y);
                    hitcell();
                    state = HIT;
                    
                    Item::obdata_play_sound_sample(type);
                    break;
                }
            }
            break;
        case BEAM:
            i++;
            if (i > 8) {
                hitcell();
                state = HIT;
                break;
            }
            break;
        case THROWN:
            zK = 4 * zA / ro / ro;
            for (j = 0; j < 3; j++) {
                i++;

                x = (int)(x0 + i * cos(te) * sin(fi));
                y = (int)(y0 + i * sin(te) * sin(fi));
                z = (int)(z0 + i * cos(fi) - zK * (i - ro / 2.0) * (i - ro / 2.0) + zA);

                if ((!map->inside(z, x, y)) ||
                        (!map->pass_lof_cell(z, x, y))) {
                    i -= 1;      //prevent fall over wall
                    x = (int)(x0 + i * cos(te) * sin(fi));
                    y = (int)(y0 + i * sin(te) * sin(fi));
                    z = (int)(z0 + i * cos(fi) - zK * (i - ro / 2.0) * (i - ro / 2.0) + zA);

                    hitcell();      //lev = 0; //!!!!
                    lev = map->find_ground(lev, col, row);
                    map->place(lev, col, row)->put(item);
                    elist->check_for_detonation(0, item);
                    item = NULL;
                    state = READY;
                    break;
                }
            }
            break;
        case ST_AIMEDTHROW:
            for (j = 0; j < 3; j++) {
                i++;

                x = (int)(x0 + i * cos(te) * sin(fi));
                y = (int)(y0 + i * sin(te) * sin(fi));
                z = (int)(z0 + i * cos(fi));

                if ((!map->inside(z, x, y)) || (i > 16 * 5) ||
                        (!map->pass_lof_cell(z, x, y)) ||
                        platoon_remote->check_for_hit(z, x, y) ||
                        platoon_local->check_for_hit(z, x, y)
                   ) {
                    //i -= 1; //prevent fall over wall
                    x = (int)(x0 + i * cos(te) * sin(fi));
                    y = (int)(y0 + i * sin(te) * sin(fi));
                    z = (int)(z0 + i * cos(fi));

                    hitcell();      //lev = 0; //!!!!
                    hitman();
                    lev = map->find_ground(lev, col, row);
                    map->place(lev, col, row)->put(item);
                    item  = NULL;
                    state = READY;
                    break;
                }
            }
            break;
        case ST_PUNCH:
            i++;
            if (i > 8) {
                hitcell();
                state = HIT;
                break;
            }
            break;
        case HIT:
            if (phase == 0) {
                if (explodable() && explodes) {
                    detonate();
                    item  = NULL;
                    state = READY;
                    break;
                }
            }
            if (incendiary() && explodes) {
                detonate();
                item  = NULL;
                state = READY;
                break;
            }
            phase++;
            if (phase == 2 * PHASE)
                hitman();

            if (phase > 9 * PHASE) {
                phase = 0;
                item  = NULL;
                state = READY;
            }
    }
}