if (planet->import[CARGO_LOMMITE] > 0)
cost += planet->import[CARGO_LOMMITE] + planet->import[CARGO_LOMMITE] / 2;
else if (planet->export[CARGO_LOMMITE] > 0)
cost += planet->export[CARGO_LOMMITE];
else
cost += 10;
cost *= lommite + steel;
fee = cost * ((class +1) * 10);
cost += fee;
if (ch->gold < cost)
{
send_to_char("&RYou can't afford the materials....Stop that THIEF!!!\r\n", ch);
return;
}
ch->gold -= cost;
planet->resource[CARGO_STEEL] -= steel;
planet->resource[CARGO_LOMMITE] -= lommite;
checktool = FALSE;
checkdura = FALSE;
checkcir = FALSE;
checksuper = FALSE;
for ( obj = ch->last_carrying; obj; obj = obj->prev_content )
{
if (obj->item_type == ITEM_TOOLKIT)
checktool = TRUE;
if (obj->item_type == ITEM_DURASTEEL && checkdura == FALSE)
{
checkdura = TRUE;
separate_obj( obj );
obj_from_char( obj );
}
if (obj->item_type == ITEM_CIRCUIT && checkcir == FALSE)
{
checkcir = TRUE;
separate_obj( obj );
obj_from_char( obj );
}
if (obj->item_type == ITEM_SUPERCONDUCTOR && checksuper == FALSE)
{
checksuper = TRUE;
separate_obj( obj );
obj_from_char( obj );
}
}
/* ok so far so good...everything is cool...try to build the ship */
vnum = find_pvnum_block(numrooms);
if (vnum < 0)
{
bug ( "player ship area out of vnums",0);
send_to_char("Not enough vnums report to a coder.\r\n",ch);
return;
}
if (reserve_rooms(vnum, numrooms) < 0)
{
bug("do_designship: reserve_rooms failed",0);
send_to_char("Couldn't build your rooms report to coder.\r\n",ch);
return;
}
sprintf( filename, "%d.pship",vnum);
CREATE( ship, SHIP_DATA, 1 );
LINK( ship, first_ship, last_ship, next, prev );
ship->filename = STRALLOC( filename );
ship->name = STRALLOC ( arg1 );
ship->owner = STRALLOC (ch->name);
ship->copilot = STRALLOC( "" );
ship->pilot = STRALLOC( "" );
ship->home = STRALLOC( "" );
ship->type = PLAYER_SHIP;
/* you may want to adjust these to balance ships with your imm built ones
I use an array of maximum ship stats for the different classes of ships
that's another project though */
ship->maxenergy = (class + 1) * 50 * ch->pcdata->learned[gsn_shipdesign] ;
ship->energy = ship->maxenergy;
ship->maxhull = (class + 1) * 10 * ch->pcdata->learned[gsn_shipdesign] ;
ship->maxshield = (class + 1) * 5 * ch->pcdata->learned[gsn_shipdesign];
ship->realspeed = 2 * ch->pcdata->learned[gsn_shipdesign] / (class + 1);
ship->hyperspeed = ch->pcdata->learned[gsn_shipdesign] + (class +1) * 20;
ship->lasers = (class + 1) * (ch->pcdata->learned[gsn_shipdesign] / 20);
ship->manuever = ch->pcdata->learned[gsn_shipdesign] * 2 / (class + 1);
ship->comm = ch->pcdata->learned[gsn_shipdesign] * 2 / (class + 1);
ship->sensor = ch->pcdata->learned[gsn_shipdesign] * 2 / (class + 1);
ship->maxcargo = ch->pcdata->learned[gsn_shipdesign];
ship->upgrades = 0;
ship->upgradeslots = ch->pcdata->learned[gsn_shipdesign]/5;
ship->hull = ship->maxhull;
ship->in_room=NULL;
ship->currjump=NULL;
ship->target0=NULL;
ship->target1=NULL;
ship->target2=NULL;
ship->class=class;
ship->firstroom = vnum;
ship->lastroom = vnum + numrooms -1;
ship->entrance = vnum;
ship->lastbuilt = vnum;
if (numrooms == 1)
{
ship->cockpit = vnum;
ship->navseat = vnum;
ship->gunseat = vnum;
ship->pilotseat = vnum;
ship->engineroom = vnum;
ship->coseat = vnum;
}
gain_exp(ch, 10000, ENGINEERING_ABILITY);
/* I added this fee to balance the cost of building ships with that of selling them so as to
keep engis from making too much money too fast from just building and selling ships
*/
ch_printf( ch, "The planet's Government has assesed a Licence Fee of %d credits.\r\n", fee);
ch_printf( ch , "&WYou gain 10000 engineering experience.\r\n" );
learn_from_success(ch, gsn_shipdesign);
transship(ship, ch->in_room->vnum);
act( AT_PLAIN, "$n finishes building new ship, and climbs inside.", ch,
NULL, argument , TO_ROOM );
room = get_room_index(vnum);
if (!room)
{
bug ("designship..no such room",0);
return;
}
if (room->name)
STRFREE( room->name );
if (numrooms > 1)
room->name = STRALLOC( "Entrance Ramp" );
else
room->name = STRALLOC( "Cockpit" );
fold_area (room->area, room->area->filename, TRUE);
save_ship(ship);
write_ship_list();
char_from_room( ch );
char_to_room(ch, get_room_index(vnum));
}
|