- if (*s != 's')
- continue;
- if (sp->shp_mobil < (s_char)0)
- continue;
- gun = getvar(V_GUN,(s_char *)sp,EF_SHIP);
- if (gun < 1)
- continue;
- shell = getvar(V_SHELL,(s_char *)sp,EF_SHIP);
- if (shell < 3)
- shell += supply_commod(sp->shp_own,
- sp->shp_x,sp->shp_y,I_SHELL,
- 3-shell);
- if (shell < 3)
- continue;
-
- range = sp->shp_effic* techfact(sp->shp_tech,
- ((double)sp->shp_frnge)) / 100.0;
-
- range2 = (double)roundrange(range);
- if (md > range)
- continue;
-
- if (!line_of_sight((s_char **)0, x, y,
- gp->x, gp->y))
- continue;
- putvar(V_SHELL,shell-3,(s_char *)sp,EF_SHIP);
- mobcost = sp->shp_effic * 0.01 * sp->shp_speed;
- mobcost = (480.0/(mobcost +
- techfact(sp->shp_tech, mobcost)));
- sp->shp_mobil -= mobcost;
- putship(sp->shp_uid,sp);
- hitchance = DTORP_HITCHANCE(md, sp->shp_visib);
-
- wu(0,sp->shp_own,
- "%s locking on %s %s in %s\n",
- prship(sp),cname(victim),s,
- xyas(x,y,sp->shp_own));
- wu(0,sp->shp_own,
- "\tEffective torpedo range is %.1f\n", range);
- wu(0,sp->shp_own,
- "\tWhooosh... Hitchance = %d%%\n",
- (int)(hitchance*100));
-
- if (hitchance < 1.0 && !chance(hitchance)) {
- wu(0,sp->shp_own,
- "\tMissed\n");
- mpr(victim, "Incoming torpedo sighted @ %s missed (whew)!\n",
- xyas(x,y,victim));
- continue;
- }
- wu(0,sp->shp_own,
- "\tBOOM!...\n");
- dam2 = TORP_DAMAGE();
-
- dam += dam2;
- nreport(victim,N_TORP_SHIP,sp->shp_own,1);
- wu(0,sp->shp_own,
- "\tTorpedo hit %s %s for %d damage\n",
- cname(victim),s,dam2);
-
- mpr(victim,
- "Incoming torpedo sighted @ %s hits and does %d damage!\n",
- xyas(x,y,victim), dam2);
- }else{
- range = techfact(sp->shp_tech,
- (double)mcp->m_frnge/2.0);
- range2 = (double)roundrange(range);
- if (md > range2)
- continue;
- gun = getvar(V_GUN, (s_char *)sp, EF_SHIP);
- gun = min(gun, sp->shp_glim);
- shell = getvar(V_SHELL, (s_char *)sp, EF_SHIP);
- if (shell < gun)
- shell += supply_commod(sp->shp_own,
- sp->shp_x,sp->shp_y,I_SHELL,
- gun-shell);
- gun = min(gun, shell);
- gun = min(gun,(int)((float)getvar(V_MILIT,
- (s_char *)sp,EF_SHIP)/2.0));
- if (gun ==0)
- continue;
- gun = max(gun,1);
- dam2 = seagun(sp->shp_effic,gun);
- if ( range2 == 0.0 )
- prb = 1.0;
- else
- prb = ((double)md) / range2;
- prb *= prb;
- if (chance(prb))
- dam2 = (int)((float)dam2/2.0);
- dam += dam2;
- if (sect.sct_type == SCT_WATER)
- nreport(sp->shp_own,N_SHP_SHELL,victim,1);
- else
- nreport(sp->shp_own,N_SCT_SHELL,victim,1);
- wu(0,sp->shp_own,
- "%s fires at %s %s at %s\n",
- prship(sp),
- cname(victim), s,
- xyas(x,y,sp->shp_own));
-
- mpr(victim, "%s fires at you at %s\n",
- cname(sp->shp_own), prship(sp),
- xyas(x,y,victim));
-
- putvar(V_SHELL,shell-gun,(s_char *)sp, EF_SHIP);
- putship(sp->shp_uid,sp);
- }
- }else if (glp->type == EF_PLANE) {
- pcp = (struct plchrstr *)glp->cp;
- if (pcp->pl_flags & P_M)
- /* units have their own missile interdiction */
- if (hardtarget != SECT_HARDTARGET ||
- pcp->pl_flags & P_MAR)
- continue;
-
- /* save planes for later */
- plp = (struct plist *)malloc(sizeof(struct plist));
-
- bzero((s_char *)plp,sizeof(struct plist));
- plp->pcp = pcp;
- bcopy(glp->thing, (s_char *)&plp->plane,
- sizeof(struct plnstr));
- if (plp->pcp->pl_flags & P_M)
- emp_insque(&plp->queue, &missiles);
- else
- emp_insque(&plp->queue, &bombers);
- plane_owner = plp->plane.pln_own;
- }
- }
- if (!QEMPTY(&missiles)) {
- /* I arbitrarily chose 100 mindam -KHS */
- dam += msl_launch_mindam(&missiles, x, y, hardtarget, EF_SECTOR, 100, "sector", victim, mission);
- qp=missiles.q_forw;
- while(qp != (&missiles)){
- qp=qp->q_forw;
- free(qp);
- }
- }
-
- if (QEMPTY(&bombers)) {
- qp=list->q_forw;
- while(qp != list){
- glp = (struct genlist *)qp;
- qp=qp->q_forw;
-
- free(glp->thing);
- free((s_char *)glp);
- }
- return dam;
- }
- /*
- * If there are planes performing an
- * interdict or support mission, find
- * some escorts for them, if possible.
- * Up to 2 per bomber, if possible.
- */
- find_escorts(x,y,plane_owner,&escorts);
-
- if (mission == MI_SINTERDICT)
- mission_pln_sel(&bombers,P_T|P_A,0,hardtarget);
- else
- mission_pln_sel(&bombers,P_T,P_A,SECT_HARDTARGET);
-
- mission_pln_sel(&escorts,P_ESC|P_F,0,SECT_HARDTARGET);
-
- for(qp = bombers.q_forw; qp != (&bombers); qp = qp->q_forw){
- plp = (struct plist *)qp;
- if (!find_airport(&airp,plp->plane.pln_x,plp->plane.pln_y))
- add_airport(&airp,plp->plane.pln_x,
- plp->plane.pln_y);
- }
-
- for(qp = airp.q_forw; qp != (&airp); qp = qp->q_forw){
- struct airport *air;
- s_char pp[512];
-
- air = (struct airport *)qp;
- md = mapdist(x,y,air->x,air->y);
-
- emp_initque(&b);
- emp_initque(&e);
-
- /* Split off the bombers at this base into b */
- divide(&bombers,&b,air->x,air->y);
-
- /* Split off the escorts at this base into e */
- divide(&escorts,&e,air->x,air->y);
-
- tech = 0;
- mission_flags = 0;
- mission_flags |= P_X; /* stealth (shhh) */
- mission_flags |= P_H; /* gets turned off if not all choppers */
-
- mission_flags = mission_pln_arm(&b,air->x,air->y,2*md,'p',0,
- 0,mission_flags,&tech);
-
- if (QEMPTY(&b)){
- continue;
- }
-
- mission_flags = mission_pln_arm(&e,air->x,air->y,2*md,'p',0,
- P_F|P_ESC,mission_flags,&tech);
-
- BestAirPath(pp, air->x, air->y, x, y);
- wu(0, plane_owner, "Flying %s mission from %s\n",
- mission_name(mission), xyas(air->x, air->y, plane_owner));
- if (air->own && (air->own != plane_owner)) {
- wu(0, air->own, "%s is flying %s mission from %s\n",
- cname(plane_owner), mission_name(mission),
- xyas(air->x, air->y, air->own));
+ if (*s != 's')
+ continue;
+ if (sp->shp_mobil < (s_char)0)
+ continue;
+ gun = getvar(V_GUN, (s_char *)sp, EF_SHIP);
+ if (gun < 1)
+ continue;
+ shell = getvar(V_SHELL, (s_char *)sp, EF_SHIP);
+ if (shell < 3)
+ shell += supply_commod(sp->shp_own,
+ sp->shp_x, sp->shp_y, I_SHELL,
+ 3 - shell);
+ if (shell < 3)
+ continue;
+
+ range = sp->shp_effic * techfact(sp->shp_tech,
+ ((double)sp->shp_frnge)) /
+ 100.0;
+
+ range2 = (double)roundrange(range);
+ if (md > range)
+ continue;
+
+ if (!line_of_sight((s_char **)0, x, y, gp->x, gp->y))
+ continue;
+ putvar(V_SHELL, shell - 3, (s_char *)sp, EF_SHIP);
+ mobcost = sp->shp_effic * 0.01 * sp->shp_speed;
+ mobcost = (480.0 / (mobcost +
+ techfact(sp->shp_tech, mobcost)));
+ sp->shp_mobil -= mobcost;
+ putship(sp->shp_uid, sp);
+ hitchance = DTORP_HITCHANCE(md, sp->shp_visib);
+
+ wu(0, sp->shp_own,
+ "%s locking on %s %s in %s\n",
+ prship(sp), cname(victim), s, xyas(x, y, sp->shp_own));
+ wu(0, sp->shp_own,
+ "\tEffective torpedo range is %.1f\n", range);
+ wu(0, sp->shp_own,
+ "\tWhooosh... Hitchance = %d%%\n",
+ (int)(hitchance * 100));
+
+ if (hitchance < 1.0 && !chance(hitchance)) {
+ wu(0, sp->shp_own, "\tMissed\n");
+ mpr(victim,
+ "Incoming torpedo sighted @ %s missed (whew)!\n",
+ xyas(x, y, victim));
+ continue;