diff --git a/artifacts/scripting/headers/define_extra.h b/artifacts/scripting/headers/define_extra.h index 722f2b3c2..2c2c74f62 100644 --- a/artifacts/scripting/headers/define_extra.h +++ b/artifacts/scripting/headers/define_extra.h @@ -306,6 +306,22 @@ #define PROTO_CR_AI_PACKET (408) #define PROTO_CR_TEAM_NUM (412) +// scenery +#define PROTO_SC_MATERIAL (44) + +// walls +#define PROTO_WL_MATERIAL (32) + +// material types +#define MATERIAL_TYPE_GLASS (0) +#define MATERIAL_TYPE_METAL (1) +#define MATERIAL_TYPE_PLASTIC (2) +#define MATERIAL_TYPE_WOOD (3) +#define MATERIAL_TYPE_DIRT (4) +#define MATERIAL_TYPE_STONE (5) +#define MATERIAL_TYPE_CEMENT (6) +#define MATERIAL_TYPE_LEATHER (7) + // weapon calibers #define CALIBER_NONE (0) #define CALIBER_ROCKET (1) diff --git a/artifacts/scripting/headers/lib.arrays.h b/artifacts/scripting/headers/lib.arrays.h index 37e0a58a0..e99e14f9f 100644 --- a/artifacts/scripting/headers/lib.arrays.h +++ b/artifacts/scripting/headers/lib.arrays.h @@ -554,14 +554,14 @@ procedure array_transform_kv(variable arr, variable keyFunc, variable valueFunc) end /** - * Converts given array into a new map where keys are array values and all values are 1. + * Converts given array into a new map where keys are array values and all values are set to specified value. * @arg {array} arr * @ret {array} */ -procedure array_to_set(variable arr) begin +procedure array_to_set(variable arr, variable value := 1) begin variable v, retArr := temp_array_map; foreach (v in arr) begin - retArr[v] := 1; + retArr[v] := value; end return retArr; end @@ -641,7 +641,7 @@ procedure array_fill(variable arr, variable pos, variable count, variable value) end /** - * Adds all the values of the second array to the first array. + * Adds all the values of the second array to the first array. If arr1 is a map then for values with same keys, values from arr2 will take priority. * @arg {array} arr1 * @arg {array} arr2 * @ret {array} - the first array after modification @@ -661,6 +661,14 @@ procedure array_append(variable arr1, variable arr2) begin return arr1; end +/** + * Creates a new temp array with all values from arr1 and arr2. If arr1 is a map then for values with same keys, values from arr2 will take priority. + * @arg {array} arr1 + * @arg {array} arr2 + * @ret {array} - the created temp array + */ +#define array_concat(arr1, arr2) array_append(clone_array(arr1), arr2) + /** * Loads a "saved" array. If it doesn't exist, creates it (with a given size). * @arg {string} name - saved array name/key diff --git a/artifacts/scripting/headers/lib.inven.h b/artifacts/scripting/headers/lib.inven.h index 23a585521..cdffd7d2d 100644 --- a/artifacts/scripting/headers/lib.inven.h +++ b/artifacts/scripting/headers/lib.inven.h @@ -65,6 +65,21 @@ procedure unwield_armor(variable critter) begin end end +/** + * Makes critter put away given item if it's in armor or any item/weapon slot. + * @arg {ObjectPtr} critter + * @arg {ObjectPtr} item + */ +procedure inven_unwield_item(variable critter, variable item) begin + if (obj_type(critter) != OBJ_TYPE_CRITTER) then return; + + if (critter_inven_obj(critter, INVEN_TYPE_WORN) == item) then begin + call unwield_armor(critter); + end else if ((critter_inven_obj(critter, INVEN_TYPE_LEFT_HAND) == item) or (critter_inven_obj(critter, INVEN_TYPE_RIGHT_HAND) == item)) then begin + inven_unwield(critter); + end +end + /** * Removes items of given pid from given object's inventory. Returns number of actually removed items. * @arg {ObjectPtr} invenObj - obj to remove items from @@ -86,13 +101,7 @@ procedure remove_items_pid(variable invenObj, variable itemPid, variable quantit toRemoveQty := quantity; while (quantity > 0) do begin item := obj_carrying_pid_obj(invenObj, itemPid); - if (obj_type(invenObj) == OBJ_TYPE_CRITTER) then begin - if (critter_inven_obj(invenObj, INVEN_TYPE_WORN) == item) then begin - call unwield_armor(invenObj); - end else if ((critter_inven_obj(invenObj, INVEN_TYPE_LEFT_HAND) == item) or (critter_inven_obj(invenObj, INVEN_TYPE_RIGHT_HAND) == item)) then begin - inven_unwield(invenObj); - end - end + call inven_unwield_item(invenObj, item); quantity -= rm_mult_objs_from_inven(invenObj, item, quantity); destroy_object(item); end @@ -100,19 +109,14 @@ procedure remove_items_pid(variable invenObj, variable itemPid, variable quantit end /** - * Remove the whole stack of a given *item* object from *invenObj* inventory. + * Remove one item from a given *item* stack object from *invenObj* inventory. * For a critter, this will correctly remove item from armor/hand slot, if it is equipped. + * Note that *item* pointer will be invalid after this. * @arg {ObjectPtr} invenObj - obj to remove from * @arg {ObjectPtr} item - item (stack) object to remove */ procedure remove_item_obj(variable invenObj, variable item) begin - if (obj_type(invenObj) == OBJ_TYPE_CRITTER) then begin - if (critter_inven_obj(invenObj,INVEN_TYPE_WORN) == item) then begin - call unwield_armor(invenObj); - end else if ((critter_inven_obj(invenObj, INVEN_TYPE_LEFT_HAND) == item) or (critter_inven_obj(invenObj, INVEN_TYPE_RIGHT_HAND) == item)) then begin - inven_unwield(invenObj); - end - end + call inven_unwield_item(invenObj, item); rm_obj_from_inven(invenObj, item); destroy_object(item); end @@ -136,7 +140,7 @@ end /** * Ensures a given *quantity* of *itemPid* in *invenObj* inventory, adding or removing items as necessary. * @arg {ObjectPtr} invenObj - obj to add/remove items to/from - * @arg {int} itemPid - PID of item to remove + * @arg {int} itemPid - PID of item to add/remove * @arg {int} quantity */ procedure set_items_qty_pid(variable invenObj, variable itemPid, variable quantity) @@ -154,42 +158,6 @@ begin end end -/** - * Removes money and items from a *critter*'s inventory, using provided probabilities (applied to whole stacks, not individual items). - * Useful for reducing loot of merchants after death. - * @arg {ObjectPtr} critter - * @arg {int} moneyPercent - Percent of money to remove. - * @arg {int} probArmor - % probability to remove armor. - * @arg {int} probDrugs - % probability to remove drugs. - * @arg {int} probWeapons - % probability to remove weapons. - * @arg {int} probAmmo - % probability to remove ammo. - * @arg {int} probMisc - % probability to remove misc item. - */ -procedure reduce_merchant_loot(variable critter, variable moneyPercent, variable probArmor, variable probDrugs, variable probWeapons, variable probAmmo, variable probMisc) begin - variable inv, item, it, prob, tmp; - inv := inven_as_array(critter); - item_caps_adjust(critter, -(item_caps_total(critter) * moneyPercent / 100)); - //display_msg("total items "+len_array(inv)); - foreach item in inv begin - if (obj_pid(item) != PID_BOTTLE_CAPS) then begin - it := obj_item_subtype(item); - if (it == item_type_armor) then - prob := probArmor; - else if (it == item_type_drug) then - prob := probDrugs; - else if (it == item_type_weapon) then - prob := probWeapons; - else if (it == item_type_ammo) then - prob := probAmmo; - else - prob := probMisc; - if (random(0, 99) < prob) then begin - //display_msg("remove "+obj_name(item)); - call remove_all_items_pid(critter, obj_pid(item)); - end - end - end -end /** * Returns item in one of *critter*'s hand slots using given attack type. diff --git a/docs/Gemfile b/docs/Gemfile index a519f28cf..365fbb453 100644 --- a/docs/Gemfile +++ b/docs/Gemfile @@ -11,7 +11,7 @@ source "https://rubygems.org" # If you want to use GitHub Pages, remove the "gem "jekyll"" above and # uncomment the line below. To upgrade, run `bundle update github-pages`. -gem "github-pages", "~> 231", group: :jekyll_plugins +gem "github-pages", "~> 225", group: :jekyll_plugins gem "jekyll-remote-theme" # If you have any plugins, put them here! @@ -26,4 +26,5 @@ gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby] # Performance-booster for watching directories on Windows gem "wdm", "~> 0.1.0" if Gem.win_platform? -gem "webrick", "~> 1.8" +# Fix build error +gem "logger", "~> 1.5.3" diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock index e07f6e073..c9c4bb5c4 100644 --- a/docs/Gemfile.lock +++ b/docs/Gemfile.lock @@ -1,54 +1,36 @@ GEM remote: https://rubygems.org/ specs: - activesupport (6.1.7.5) + activesupport (6.0.6.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) zeitwerk (~> 2.2, >= 2.2.2) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.11.1) colorator (1.1.0) commonmarker (0.23.10) - concurrent-ruby (1.1.9) - dnsruby (1.61.9) - simpleidn (~> 0.1) + concurrent-ruby (1.3.3) + dnsruby (1.72.2) + simpleidn (~> 0.2.1) em-websocket (0.5.3) eventmachine (>= 0.12.9) http_parser.rb (~> 0) - ethon (0.15.0) + ethon (0.16.0) ffi (>= 1.15.0) eventmachine (1.2.7) - execjs (2.8.1) - faraday (1.10.0) - faraday-em_http (~> 1.0) - faraday-em_synchrony (~> 1.0) - faraday-excon (~> 1.1) - faraday-httpclient (~> 1.0) - faraday-multipart (~> 1.0) - faraday-net_http (~> 1.0) - faraday-net_http_persistent (~> 1.0) - faraday-patron (~> 1.0) - faraday-rack (~> 1.0) - faraday-retry (~> 1.0) - ruby2_keywords (>= 0.0.4) - faraday-em_http (1.0.0) - faraday-em_synchrony (1.0.0) - faraday-excon (1.1.0) - faraday-httpclient (1.0.1) - faraday-multipart (1.0.3) - multipart-post (>= 1.2, < 3) - faraday-net_http (1.0.1) - faraday-net_http_persistent (1.2.0) - faraday-patron (1.0.0) - faraday-rack (1.0.0) - faraday-retry (1.0.3) - ffi (1.15.5) + execjs (2.9.1) + faraday (2.10.0) + faraday-net_http (>= 2.0, < 3.2) + logger + faraday-net_http (3.1.0) + net-http + ffi (1.17.0) forwardable-extended (2.6.0) gemoji (3.0.1) github-pages (225) @@ -222,34 +204,33 @@ GEM kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) liquid (4.0.3) - listen (3.7.1) + listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) + logger (1.5.3) mercenary (0.3.6) - mini_portile2 (2.8.6) minima (2.5.1) jekyll (>= 3.5, < 5.0) jekyll-feed (~> 0.9) jekyll-seo-tag (~> 2.1) - minitest (5.15.0) - multipart-post (2.1.1) - nokogiri (1.16.5) - mini_portile2 (~> 2.8.2) + minitest (5.24.1) + net-http (0.4.1) + uri + nokogiri (1.16.6-x86_64-linux) racc (~> 1.4) - octokit (4.22.0) - faraday (>= 0.9) - sawyer (~> 0.8.0, >= 0.5.3) + octokit (4.25.1) + faraday (>= 1, < 3) + sawyer (~> 0.9) pathutil (0.16.2) forwardable-extended (~> 2.6) - public_suffix (4.0.6) - racc (1.7.3) - rb-fsevent (0.11.1) - rb-inotify (0.10.1) + public_suffix (4.0.7) + racc (1.8.0) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) ffi (~> 1.0) - rexml (3.2.8) - strscan (>= 3.0.9) + rexml (3.3.2) + strscan rouge (3.26.0) - ruby2_keywords (0.0.5) rubyzip (2.3.2) safe_yaml (1.0.5) sass (3.7.4) @@ -257,34 +238,32 @@ GEM sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - sawyer (0.8.2) + sawyer (0.9.2) addressable (>= 2.3.5) - faraday (> 0.8, < 2.0) - simpleidn (0.2.1) - unf (~> 0.1.4) + faraday (>= 0.17.3, < 3) + simpleidn (0.2.3) strscan (3.1.0) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) thread_safe (0.3.6) - typhoeus (1.4.0) + typhoeus (1.4.1) ethon (>= 0.9.0) - tzinfo (1.2.10) + tzinfo (1.2.11) thread_safe (~> 0.1) - unf (0.1.4) - unf_ext - unf_ext (0.0.8) unicode-display_width (1.8.0) - zeitwerk (2.5.4) + uri (0.13.0) + zeitwerk (2.6.16) PLATFORMS - ruby + x86_64-linux DEPENDENCIES github-pages (~> 225) jekyll-analytics jekyll-feed (~> 0.6) jekyll-remote-theme + logger (~> 1.5.3) tzinfo-data BUNDLED WITH - 2.1.4 + 2.3.5