-+-+-+-+-+-+-+-+ START OF PART 39 -+-+-+-+-+-+-+-+
X`09          curse`5E.next := from_ptr`5E.next;
X`09          inven_temp`5E.data := from_ptr`5E.data;
X`09          old_ctr := inven_ctr;
X`09          inven_carry;
X`09          `7Bchange to next line by Dean; used to begin with
X                           if (inven_ctr=old_ctr) then`7D
X`09`09  inven_ctr := inven_ctr - 1;
X`09`09  msg_print('You remove the item');
X`09`09end
X`09      else
X`09`09msg_print('You make several attempts, but cannot seem to get a grip on
V it.');
X`09    cur_inven := inventory_list;
X`09    end
X`09  else
X`09    msg_print('You have nothing to remove.');
X`09end;
X
X`09`7B Inventory of selective items, picked by character`09-DMF-`09`7D
X      procedure selective_inven;
X`09var
X`09`09ptr`09`09: treas_ptr;
X`09`09out`09`09: string;
X`09`09exit_flag`09: boolean;
X`09`09command`09`09: char;
X`09begin
X`09  ptr := inventory_list;
X`09  out := ' ';
X`09  while (ptr <> nil) do
X`09    begin
X`09      if (index(out,ptr`5E.data.tchar) = 0) then
X`09`09out := ptr`5E.data.tchar + out;
X`09      ptr := ptr`5E.next;
X`09    end;
X`09  out := substr(out,1,length(out)-1);
X`09  exit_flag := false;
X`09  repeat
X`09    prt('What type of items to inventory? ('+out+') ',1,1);
X`09    if not(get_com('',command)) then
X`09      exit_flag := true;
X`09  until (exit_flag) or (index(out,command) <> 0);
X`09  if not(exit_flag) then
X`09    begin
X`09      change_all_ok_stats(false,false);
X`09      ptr := inventory_list;
X`09      while (ptr <> nil) do
X`09`09begin
X`09`09  if (ptr`5E.data.tchar = command) then
X`09`09    ptr`5E.ok := true;
X`09`09  ptr := ptr`5E.next;
X`09`09end;
X`09      clear_display;
X`09      clear(1,1);
X`09      prompt := 'You are currently carrying: space for next page';
X`09      show_inven(ptr,false,false);
X`09    end;
X`09end;
X
X`09`7B Switch primary and secondary weapons`09`09-RAK-`09`7D
X      procedure switch_weapon;
X`09var
X`09  prt1,prt2                             : vtype;
X`09  tmp_obj                               : treasure_type;
X`09begin
X`09  if (uand(cursed_worn_bit,equipment`5BEquipment_primary`5D.flags) <> 0)
V then
X`09    begin
X`09      inven_temp`5E.data := equipment`5BEquipment_primary`5D;
X`09      objdes(prt1,inven_temp,false);
X`09      msg_print('The ' + prt1 +
X`09`09`09' you are wielding appears to be cursed.');
X`09    end
X`09  else
X`09    begin
X`09`09`7B Switch weapons        `7D
X`09      reset_flag := false;
X`09      tmp_obj := equipment`5BEquipment_secondary`5D;
X`09      equipment`5BEquipment_secondary`5D := equipment`5BEquipment_primary
V`5D;
X`09      equipment`5BEquipment_primary`5D := tmp_obj;
X     `7B Subtract bonuses      `7D
X`09      py_bonuses(equipment`5BEquipment_secondary`5D,-1);
X     `7B Add bonuses           `7D
X`09      py_bonuses(equipment`5BEquipment_primary`5D,1);
X`09      if (equipment`5BEquipment_primary`5D.tval > 0) then
X`09`09begin
X`09`09  prt1 := 'Primary weapon   : ';
X`09`09  inven_temp`5E.data := equipment`5BEquipment_primary`5D;
X`09`09  objdes(prt2,inven_temp,true);
X`09`09  msg_print(prt1 + prt2);
X`09`09end;
X`09      if (equipment`5BEquipment_secondary`5D.tval > 0) then
X`09`09begin
X`09`09  prt1 := 'Secondary weapon : ';
X`09`09  inven_temp`5E.data := equipment`5BEquipment_secondary`5D;
X`09`09  objdes(prt2,inven_temp,true);
X`09`09  msg_print(prt1 + prt2);
X`09`09end;
X`09    end;
X`09  if (scr_state <> 0) then
X`09    begin
X`09      msg_print('');
X`09      clear(1,1);
X`09      prt('You are currently using -',1,1);
X`09      show_equip(1);
X`09    end;
X`09end;
X
X`09`7B Main logic for INVEN_COMMAND`09`09`09-RAK-`09`7D
X      begin
X`09inven_command := false;
X`09exit_flag := false;
X`09scr_state := 0;
X`09cur_inven := inventory_list;
X`09repeat
X`09  case command of
X`09    'i' : begin         `7B Inventory     `7D
X`09`09    if (inven_ctr = 0) then
X`09`09      msg_print('You are not carrying anything.')
X`09`09    else
X`09`09      begin
X`09`09`09clear(1,1);
X`09`09        prompt := 'You are currently carrying: space for next page';
X`09`09        clear_display;
X`09`09        change_all_ok_stats(true,true);
X`09`09        show_inven(item_ptr,false,false);
X`09`09      end;`09
X`09`09  end;
X`09    'c' : begin
X`09`09    if (inven_ctr = 0) then
X`09`09      msg_print('You are not carrying anything.')
X`09`09    else
X`09`09      begin
X`09`09`09clear(1,1);
X`09`09`09prompt := 'Warning: a-t/A-T DESTROYS that item: space for next page
V';
X`09`09`09clear_display;
X`09`09`09change_all_ok_stats(true,true);
X`09`09`09show_inven(item_ptr,true,true);
X`09`09      end;
X`09`09   end;
X`09    'e' : begin         `7B Equipment     `7D
X`09`09    if (equip_ctr = 0) then
X`09`09      msg_print('You are not using any equipment.')
X`09`09    else if (scr_state <> 2) then
X`09`09      begin     `7B Sets scr_state to 2           `7D
X`09`09`09clear(1,1);
X`09`09`09prt('You are currently using -',1,1);
X`09`09`09show_equip(1);
X`09`09      end;
X`09`09  end;
X`09    's' : begin`09`09`7B Statistics of an item`09`7D
X`09`09    clear_display;
X`09`09    if not(wizard1) and not(wizard2)
X`09`09      then msg_print('You *wish*, you sleazy scum-bag!')
X`09`09      else
X`09`09`09begin
X`09        `09    if (inven_ctr = 0) then
X`09`09                msg_print('You are not carrying anything.')
X`09`09            else
X`09`09                stats;
X`09`09        end;
X`09`09  end;
X`09    't' : begin         `7B Take off      `7D
X`09`09    if (equip_ctr = 0) then
X`09`09      msg_print('You are not using any equipment.')
X`09`09    else
X`09`09      unwear;   `7B May set scr_state to 2        `7D
X`09`09  end;
X`09    'w' : begin         `7B Wear/wield    `7D
X`09`09    if (inven_ctr = 0) then
X`09`09      msg_print('You are not carrying anything.')
X`09`09    else
X`09`09      wear;     `7B May set scr_state to 1        `7D
X`09`09  end;
X`09    'x' : begin
X`09`09    if (equipment`5BEquipment_primary`5D.tval <> 0) then
X`09`09      switch_weapon
X`09`09    else if (equipment`5BEquipment_secondary`5D.tval <> 0) then
X`09`09      switch_weapon
X`09`09    else
X`09`09      msg_print('But you are wielding no weapons.');
X`09`09  end;
X`09    'M' : begin
X`09`09    if (scr_state <> 4) then
X`09`09      begin
X`09`09`09show_money;
X`09`09`09scr_state := 4;
X`09`09      end;
X`09`09  end;
X`09    'p' : begin
X`09`09    if (inven_ctr = 0) then
X`09`09      msg_print('You are not carrying anything.')
X`09`09    else
X`09`09      put_inside;
X`09`09  end;
X`09    'r' : begin
X`09`09    if (inven_ctr = 0) then
X`09`09      msg_print('You are not carrying anything.')
X`09`09    else
X`09`09      take_out;
X`09`09  end;
X`09    'I' : begin
X`09`09    if (inven_ctr = 0) then
X`09`09      msg_print('You are not carrying anything.')
X`09`09    else
X`09`09      selective_inven;
X`09`09  end;
X`09`7B Special function for other routines                   `7D
X`09    '?' : begin `7B Displays part inven, returns  `7D
X`09`09    cur_inven := inventory_list;
X`09`09    clear_display;
X`09`09    inven_command := show_inven(item_ptr,true,false);
X`09`09    scr_state := 0;     `7B Clear screen state    `7D
X`09`09  end;
X`09`7B Nonsense command                                      `7D
X`09    otherwise ;
X`09  end;
X`09  if (scr_state > 0) then
X`09    begin
X`09      prt('<e>quip, <i>inven, <t>ake-off, <w>ear/wield, e<x>change, <M>on
Vey, <c>lean.',23,2);
X`09      if (wizard2) then
X`09`09prt('<p>ut item into, <r>emove item from, <s> stats of item, <I>inven
V selective.',24,2)
X`09      else
X`09`09prt('<p>ut item into, <r>emove item from, <I>inven selective, or `5EZ
V to exit.',24,2);
X`09      test_flag := false;
X`09      repeat
X`09`09inkey(command);
X`09`09com_val := ord(command);
X`09`09case com_val of
X`09`09  0,3,25,26,27,32 : begin       `7B Exit from module      `7D
X`09`09`09`09    exit_flag := true;
X`09`09`09`09    test_flag := true;
X`09`09`09`09  end;
X`09`09  otherwise if (command in `5B'e','i','c','s','t','w','x','M',
X`09`09`09`09'p','r','I','W'`5D) then`09 `7B Module commands `7D
X`09`09`09  test_flag := true
X`09`09`09else if (command='?') then ;
X`09`09end;
X`09      until (test_flag);
X`09      prt('',23,1);
X`09      prt('',24,1);
X`09    end
X`09  else
X`09    exit_flag := true;
X`09until(exit_flag);
X`09if (scr_state > 0) then         `7B If true, must redraw screen   `7D
X`09  inven_command := true;
X      end;
X
X`09`7B Remove an item from inventory_list`09`09`09-DMF-`09`7D
X`5Bglobal,psect(inven$code)`5D procedure delete_inven_item(ptr : treas_ptr);
X      var
X`09`09temp_ptr,curse`09: treas_ptr;
X      begin
X`09if (cur_inven = ptr) then
X`09  cur_inven := cur_inven`5E.next;
X`09if (ptr = inventory_list) then
X`09  begin
X`09    temp_ptr := inventory_list;
X`09    inventory_list := ptr`5E.next;
X`09    dispose(temp_ptr);
X`09    inven_ctr := inven_ctr - 1;
X`09  end
X`09else
X`09  begin
X`09    if (cur_inven = nil) then
X`09      cur_inven := inventory_list;
X`09    curse := inventory_list;
X`09    while (curse`5E.next <> ptr) do
X`09      curse := curse`5E.next;
X`09    temp_ptr := ptr;
X`09    curse`5E.next := ptr`5E.next;
X`09    dispose(temp_ptr);
X`09    inven_ctr := inven_ctr - 1;
X`09  end;
X      end;
X
X`09`7B Destroy an item in the inventory`09`09`09-RAK-`09`7D
X`5Bglobal,psect(inven$code)`5D procedure inven_destroy(item_ptr : treas_ptr)
V;
X      begin
X`09inven_temp`5E.data := item_ptr`5E.data;
X`09with item_ptr`5E.data do
X`09  begin
X`09    if ((number > 1) and (subval < 512))  then
X`09      begin
X`09`09number := number - 1;
X`09`09inven_weight := inven_weight - weight;
X`09`09inven_temp`5E.data.number := 1;
X`09      end
X`09    else
X`09      begin
X`09`09inven_weight := inven_weight - weight*number;
X`09`09delete_inven_item(item_ptr);
X`09      end;
X`09  end
X      end;
X
X`09`7B Drops an item from inventory to given location`09-RAK-`09`7D
X`5Bglobal,psect(inven$code)`5D procedure inven_drop(
X`09`09`09`09item_ptr`09: treas_ptr;
X`09`09`09`09y,x`09`09: integer;
X`09`09`09`09mon`09`09: boolean);
X
X      var
X`09i1`09`09`09`09: integer;
X`09temp_ptr`09`09`09: treas_ptr;
X
X      begin
X`09with cave`5By,x`5D do
X`09  begin
X`09    if (tptr > 0) then pusht(tptr);
X`09    new(temp_ptr);
X`09    temp_ptr`5E.data := item_ptr`5E.data;
X`09    if (mon) then
X`09      inven_temp`5E.data := item_ptr`5E.data
X`09    else
X`09      inven_destroy(item_ptr);
X`09    popt(i1);
X`09    t_list`5Bi1`5D := inven_temp`5E.data;
X`09    tptr := i1;
X`09    dispose(temp_ptr);
X`09  end;
X      end;
X
X`09`7B Destroys a type of item on a given percent chance`09-RAK-`09`7D
X`5Bglobal,psect(inven$code)`5D function inven_damage(
X`09`09`09typ`09`09:`09obj_set;
X`09`09`09perc`09`09:`09integer
X`09`09`09`09`09) : integer;
X      var
X`09`09i1,i2`09`09: integer;
X`09`09curse`09`09: treas_ptr;
X      begin
X`09i2 := 0;
X`09curse := inventory_list;
X`09while (curse <> nil) do
X`09  begin
X`09    with curse`5E.data do
X`09      if (tval in typ) then
X`09        if ((randint(100) < perc) and (curse`5E.is_in = false)) then
X`09`09  if ((uand(curse`5E.data.flags2,holding_bit) <> 0) and
X`09`09      (curse`5E.insides = 0)) or
X`09`09     (uand(curse`5E.data.flags2,holding_bit) = 0) then
X`09`09    begin
X`09`09      inven_destroy(curse);
X`09`09      i2 := i2 + 1;
X`09`09    end;
X`09    curse := curse`5E.next;
X`09  end;
X`09inven_damage := i2;
X      end;
X
X`09`7B Check inventory for too much weight`09`09`09-RAK-`09`7D
X`5Bglobal,psect(inven$code)`5D function inven_check_weight : boolean;
X      var
X`09item_wgt`09: integer;
X      begin
X`09with inven_temp`5E.data do
X`09  item_wgt := number*weight;
X`09`09`7B Current stuff + weight <= max weight `7D
X`09inven_check_weight := inven_weight + item_wgt <= (weight_limit*100);
X      end;
X
X`09`7B Check to see if he will be carrying too many objects`09-RAK-`09`7D
X`5Bglobal,psect(inven$code)`5D function inven_check_num : boolean;
X      begin
X`09inven_check_num := true;
X      end;
X
X`09`7B Add item to inventory_list`09`09`09`09-DMF-`09`7D
X`5Bglobal,psect(inven$code)`5D function add_inven_item(item : treasure_type)
V : treas_ptr;
X      var
X`09`09item_num,wgt,typ,subt,count`09: integer;
X`09`09flag`09`09`09`09: boolean;
X`09`09curse,new_item`09`09`09: treas_ptr;
X      procedure insert(ptr : treas_ptr; wgt : integer);
X`09var
X`09`09cur`09: treas_ptr;
X`09begin
X`09  if (ptr = inventory_list) then
X`09    begin
X`09      new_item`5E.next := inventory_list;
X`09      inventory_list := new_item;
X`09    end
X`09  else
X`09    begin
X`09      cur := inventory_list;
X`09      while (cur`5E.next <> ptr) do
X`09        cur := cur`5E.next;
X`09      new_item`5E.next := ptr;
X`09      cur`5E.next := new_item;
X`09    end;
X`09end;
X      begin
X`09if (inventory_list = nil) then
X`09  begin
X`09    new(inventory_list);
X`09    inventory_list`5E.data := item;
X`09    inventory_list`5E.ok := false;
X`09    inventory_list`5E.insides := 0;
X`09    inventory_list`5E.is_in := false;
X`09    inventory_list`5E.next := nil;
X`09    inven_weight := inven_weight + item.number * item.weight;
X`09    add_inven_item := inventory_list;
X`09    inven_ctr := inven_ctr + 1;
X`09  end
X`09else
X`09  begin
X`09    with item do
X`09      begin
X`09`09item_num := number;
X`09`09typ := tval;
X`09`09subt := subval;
X`09`09wgt := number * weight;
X`09      end;
X`09    new(new_item);
X`09    new_item`5E.data := item;
X`09    new_item`5E.ok := false;
X`09    new_item`5E.insides := 0;
X`09    new_item`5E.is_in := false;
X`09    new_item`5E.next := nil;
X`09    curse := inventory_list;
X`09    repeat
X`09      with curse`5E.data do
X`09`09if (typ = tval) then
X`09`09  begin
X`09`09    if (subt = subval) then
X`09`09      if (subt > 255) then
X`09`09`09begin
X`09`09`09  number := number + item_num;
X`09`09`09  inven_weight := inven_weight + wgt;
X`09`09`09  add_inven_item := curse;
X`09`09`09  flag := true;
X`09`09`09end;
X`09`09  end
X`09`09else if (tval < typ) then
X`09`09  begin
X`09`09    insert(curse,wgt);
X`09`09    inven_ctr := inven_ctr + 1;
X`09`09    inven_weight := inven_weight + wgt;
X`09`09    add_inven_item := new_item;
X`09`09    flag := true;
X`09`09  end;
X`09      curse := curse`5E.next;
X`09      if (curse <> nil) and (curse`5E.is_in) then
X`09`09while (curse <> nil) and (curse`5E.is_in) do
+-+-+-+-+-+-+-+-  END  OF PART 39 +-+-+-+-+-+-+-+-
