Ejemplo n.º 1
0
bool bolt_vs_monster(MagicBolt* bolt, Monster* monster, Monster**victim)
{
    bool hit = false;

    Coord pos = monster->position();
    //todo: test code removal
    //if (monster->has_tile_beneath())
    //    monster->reload_tile_beneath();

    if (!save_throw(VS_MAGIC, monster) || bolt->is_frost())
    {
        hit = true;
        if (bolt->is_flame() && monster->immune_to_fire())
            msg("the flame bounces off the %s", monster->get_name().c_str());
        else
        {
            *victim = projectile_hit(pos, bolt); //todo: look into this hack, monster projectiles treated as hero's weapon
        }
    }
    else if (!monster->is_disguised())
    {
        if (bolt->from_player)
            monster->start_run();
        msg("the %s whizzes past the %s", bolt->name().c_str(), monster->get_name().c_str());
    }

    return hit;
}
Ejemplo n.º 2
0
bool MagicMissileStick::Zap(Coord dir)
{
    discover(false);

    Item* missile = new MagicMissile;
    do_motion(missile, dir);

    Agent* monster;
    if ((monster = game->level().monster_at(missile->position())) != NULL && !save_throw(VS_MAGIC, monster))
        projectile_hit(missile->position(), missile);
    else
        msg("the missile vanishes with a puff of smoke");

    return true;
}
Ejemplo n.º 3
0
void run_projectiles_slice(int tick)
{
	int				n;
	proj_type		*proj;
	
	for (n=0;n!=server.count.proj;n++) {
		proj=&server.projs[n];

		object_clear_contact(&proj->contact);
	   
			// projectile counts
			
		proj->count++;
		if (proj->parent_grace>0) proj->parent_grace--;

			// moving projectiles
			
		if (!proj->stick) {
			projectile_speed(proj);

			if (projectile_move(proj)) {
				projectile_mark_dispose(proj);
				continue;
			}
			
			projectile_gravity(proj);
		}
		
			// stuck projectiles
			
		else {
			projectile_stick(proj);
		}
		
		projectile_collision(proj);
		
		if (projectile_hit(tick,proj,FALSE)) {
			projectile_mark_dispose(proj);
		}
	}
		
	projectile_dispose();
}
Ejemplo n.º 4
0
bool weapon_add_projectile(int tick,obj_type *obj,weapon_type *weap,proj_setup_type *proj_setup,d3pnt *pt,d3ang *ang)
{
	d3pnt					spt,ept,hpt;
	proj_type				*proj;
	ray_trace_contact_type	contact;
	
		// create new projectile
		
	proj=projectile_create(tick,obj,weap,proj_setup);
	if (proj==NULL) return(FALSE);

	projectile_spawn_position(proj,pt,ang,obj);
	
		// call spawn
		
	scripts_post_event_console(&proj->attach,sd_event_spawn,0,0);
	
		// if this object is the player object, then spawn projectile in remotes
		
	if (net_setup.client.joined) {
		if ((obj->uid==server.player_obj_uid) || (obj->bot)) {
			net_client_send_projectile_add(obj->remote.uid,weap->name,proj_setup->name,pt,ang);
		}
	}

		// add in object motion

	proj->force.vct.x=obj->motion.vct.x*proj_setup->inherit_motion_factor;
	proj->force.vct.y=obj->motion.vct.y*proj_setup->inherit_motion_factor;
	proj->force.vct.z=obj->motion.vct.z*proj_setup->inherit_motion_factor;

		// detect weapons being fired into walls
		// if so, destroy projectile

	spt.x=obj->pnt.x;
	spt.y=obj->pnt.y-(obj->size.y>>1);
	spt.z=obj->pnt.z;

	ept.x=proj->pnt.x;
	ept.y=proj->pnt.y;
	ept.z=proj->pnt.z;
	
	contact.obj.on=TRUE;
	contact.proj.on=FALSE;
	contact.obj.ignore_uid=obj->uid;

	contact.hit_mode=poly_ray_trace_hit_mode_all;
	contact.origin=poly_ray_trace_origin_projectile;
	
	if (ray_trace_map_by_point(&spt,&ept,&hpt,&contact)) {

		proj->pnt.x=hpt.x;
		proj->pnt.y=hpt.y;
		proj->pnt.z=hpt.z;

		proj->contact.hit_poly.mesh_idx=contact.poly.mesh_idx;
		proj->contact.hit_poly.poly_idx=contact.poly.poly_idx;
		proj->contact.obj_uid=contact.obj.uid;
		proj->contact.proj_uid=-1;

		projectile_hit(tick,proj,FALSE);
	}

	return(TRUE);
}
Ejemplo n.º 5
0
/*
 * Perform the actual attack on a victim			-Thoric
 */
ch_ret ranged_got_target( char_data * ch, char_data * victim, obj_data * weapon, obj_data * projectile, short dist, short dt, const char *stxt, short color )
{
   /*
    * added wtype for check to determine skill used for ranged attacks - Grimm 
    */
   short wtype = 0;

   if( ch->in_room->flags.test( ROOM_SAFE ) )
   {
      /*
       * safe room, bubye projectile 
       */
      if( projectile )
      {
         ch->printf( "Your %s is blasted from existance by a godly presense.", projectile->myobj(  ).c_str(  ) );
         act( color, "A godly presence smites $p!", ch, projectile, nullptr, TO_ROOM );
         projectile->extract(  );
      }
      else
      {
         ch->printf( "Your %s is blasted from existance by a godly presense.", stxt );
         act( color, "A godly presence smites $t!", ch, aoran( stxt ), nullptr, TO_ROOM );
      }
      return rNONE;
   }

/*
   if( victim->has_actflag( ACT_SENTINEL ) && ch->in_room != victim->in_room )
   {
	*
	 * letsee, if they're high enough.. attack back with fireballs
	 * long distance or maybe some minions... go herne! heh..
	 *
	 * For now, just always miss if not in same room  -Thoric
	 *

      if( projectile )
      {
           * check dam type of projectile to determine skill to use - Grimm *
	   switch( projectile->value[4] )
	   {
		case PROJ_BOLT:
		case PROJ_ARROW:
               ch->learn_from_failure( gsn_archery );
		   break;
		 
		case PROJ_DART:
               ch->learn_from_failure( gsn_blowguns );
		   break;

		case PROJ_STONE:
               ch->learn_from_failure( gsn_slings );
		   break;
	   }
            
          * 50% chance of projectile getting lost *
         if( number_percent() < 50 )
            projectile->extract();
         else
         {
            if( projectile->in_obj )
               projectile->from_obj();
            if( projectile->carried_by )
               projectile->from_char();
            projectile->to_room( victim->in_room, victim );
         }
      }
	return damage( ch, victim, 0, dt );
   }
*/

   /*
    * check type of projectile to determine value of wtype 
    * * wtype points to same "short" as the skill assigned to that
    * * range by the code and as such the proper skill will be used. 
    * * Grimm
    *
    * Bugfix: Projectile could be nullptr here - Samson
    */
   if( projectile )
   {
      switch ( projectile->value[4] )
      {
         default:
         case PROJ_BOLT:
         case PROJ_ARROW:
            wtype = gsn_archery;
            break;

         case PROJ_DART:
            wtype = gsn_blowguns;
            break;

         case PROJ_STONE:
            wtype = gsn_slings;
            break;
      }
   }

   if( number_percent(  ) > 50 || ( projectile && weapon && can_use_skill( ch, number_percent(  ), wtype ) ) )
   {
      if( victim->isnpc(  ) ) /* This way the poor sap can hunt its attacker */
         victim->unset_actflag( ACT_SENTINEL );
      if( projectile )
         global_retcode = projectile_hit( ch, victim, weapon, projectile, dist );
      else
         global_retcode = spell_attack( dt, ch->level, ch, victim );
   }
   else
   {
      // Bugfix: Projectile could be nullptr here - Samson
      if( projectile )
      {
         switch ( projectile->value[4] )
         {
            default:
            case PROJ_BOLT:
            case PROJ_ARROW:
               ch->learn_from_failure( gsn_archery );
               break;

            case PROJ_DART:
               ch->learn_from_failure( gsn_blowguns );
               break;

            case PROJ_STONE:
               ch->learn_from_failure( gsn_slings );
               break;
         }
      }
      global_retcode = damage( ch, victim, 0, dt );

      if( projectile )
      {
         /*
          * 50% chance of getting lost 
          */
         if( number_percent(  ) < 50 )
            projectile->extract(  );
         else
         {
            if( projectile->carried_by )
               projectile->from_char(  );
            projectile->to_room( victim->in_room, victim );
         }
      }
   }
   return global_retcode;
}