Esempio n. 1
0
void mdefense::acidsplash( monster *const m, Creature *const source, projectile const *const proj )
{
    if( source == nullptr || m == nullptr ) {
        return;
    }
    if( proj != nullptr && rng( 0, 40 ) > m->def_chance ) {
        return; //Less likely for a projectile to deliver enough force
    }

    int dx = posp( source->posx() - m->posx() );
    int dy = posp( source->posy() - m->posy() );
    if( one_in( 2 ) ) {
        for( int i = 0; i < rng( 3, 5 ); i++ ) {
            const int mul = one_in( 2 ) ? 2 : 1;
            tripoint dest( m->posx() + ( dx * mul ) + rng( -1, 1 ),
                           m->posy() + ( dy * mul ) + rng( -1, 1 ),
                           m->posz() );
            g->m.add_field( dest, fd_acid, rng( 2, 3 ), 0 );
        }
    }
    if( g->u.sees( source->pos() ) ) {
        auto const msg_type = ( source == &g->u ) ? m_bad : m_info;
        add_msg( msg_type, _( "Acid sprays out of %s as it is hit!" ),
                 m->disp_name().c_str(), source->disp_name().c_str() );
    }
}
Esempio n. 2
0
 // show an example of a constraint: this method uses a point-to-point
 // constraint to connect one of the cube's corners to a corner of the
 // other cube.
 void ConnectTo(MyCube *cube){
   DL_point posm(1,1,1),posp(-1,-1,-1);
   link=new DL_ptp();
   if (cube) link->init(companion,&posm,cube->companion,&posp);
   else { // connect to the current position of the corner in the world.
     DL_point posw;
     companion->to_world(&posm,&posw);
     link->init(companion,&posm,NULL,&posw);
   }
 }