diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..d12ca2f --- /dev/null +++ b/changelog.md @@ -0,0 +1,30 @@ + + +# changelog 1.3.0 +* #### Established Versioning system +* #### moved the following fields + * `inventory_image_magless` -> `inventory.inventory_image_magless` + * `inventory_image_magless` -> `inventory.inventory_image_magless` + * `firemode_inventory_overlays` - > `inventory.firemode_inventory_overlays` + * `ammo_handler` -> `subclasses.ammo_handler` + * `sprite_scope` -> `subclasses.sprite_scope` + * `crosshair` -> `subclasses.crosshair` +* #### create the following classes + * `Part_handler` + * completed (expansion later) + * facilitates attachments + * `Physics_system` + * inactive + * future implementation for automatic translation + * `Reflector_sight` + * work in progress + * simulates a reflector sight with an entity +* #### added the following changes to the gun class + * made `consts` and `properties` proxy tables for protection of data (and reworked the LEEF class lib for this) + * created a system for property modification + * added `subclasses` property to replace hardcoded subclasses with modular system + * added `subclass_instances` field (see above). These will be automatically updated if their index is in the subclasses list. + * added `visuals.attached_objects` property to define attached entities + * added `attached_objects` field + * made `get_pos` capable of accounting for animation translations + diff --git a/classes/Gun-construct.lua b/classes/Gun-construct.lua index 466364f..16b28ff 100644 --- a/classes/Gun-construct.lua +++ b/classes/Gun-construct.lua @@ -296,25 +296,32 @@ local function reregister_item(self, props) end --accept a chain of indices where the value from old_index overrides new_index local function warn_deprecation(gun, field, new_field) - minetest.log("warning", "Guns4d: `"..gun.."` deprecated use of field `"..field.."` use `"..new_field.."` instead.") + minetest.log("warning", "Guns4d: `"..gun.."` deprecated use of field `"..field.."` in properties. Use `"..new_field.."` instead.") end -local function patch_old_gun(self, minor_version) +local function patch_deprecated(self, minor_version) local props = self.properties - --minor version 2 changes... - if minor_version==2 then - if props.firemode_inventory_overlays then - warn_deprecation(self.name, "firemode_inventory_overlays", "inventory.firemode_inventory_overlays") - for i, _ in pairs(props.firemode_inventory_overlays) do - props.inventory.firemode_inventory_overlays[i] = props.firemode_inventory_overlays[i] - end + --1.2->1.3 (probably missing some.) + if props.firemode_inventory_overlays then + warn_deprecation(self.name, "firemode_inventory_overlays", "inventory.firemode_inventory_overlays") + for i, _ in pairs(props.firemode_inventory_overlays) do + props.inventory.firemode_inventory_overlays[i] = props.firemode_inventory_overlays[i] end - for _, i in pairs {"ammo_handler", "part_handler", "crosshair", "sprite_scope"} do - if props[i] then - warn_deprecation(self.name, i, "subclasses."..i) - props.subclasses[i] = props[i] - end + end + for _, i in pairs {"ammo_handler", "part_handler", "crosshair", "sprite_scope"} do + if props[i] then + warn_deprecation(self.name, i, "subclasses."..i) + props.subclasses[i] = props[i] end end + if self.properties.inventory_image then + self.properties.inventory.inventory_image = self.properties.inventory_image + warn_deprecation(self.name, "inventory_image", "inventory.inventory_image") + end + if self.properties.inventory_image_magless then + self.properties.inventory.inventory_image_magless = self.properties.inventory_image_magless + warn_deprecation(self.name, "inventory_image_magless", "inventory.inventory_image_magless") + end + end --========================== MAIN CLASS CONSTRUCTOR =============================== @@ -352,7 +359,7 @@ function gun_default:construct_base_class() end if self.consts.VERSION[2] < 3 then minetest.log("error", "Guns4d: `"..self.name.."` had minor version before `1.3.0` indicating that this gun likely has no versioning. Attempting patches for `1.2.0`...") - patch_old_gun(self, 2) + patch_deprecated(self, 2) end self.properties = leef.class.proxy_table.new(self.properties) diff --git a/classes/Gun-methods.lua b/classes/Gun-methods.lua index 1f4d700..b8a46d9 100644 --- a/classes/Gun-methods.lua +++ b/classes/Gun-methods.lua @@ -194,13 +194,13 @@ function gun_default:update_image_and_text_meta(meta) end end --pick the image - local image = self.properties.inventory_image + local image = self.properties.inventory.inventory_image if (ammo.total_bullets > 0) and not ammo.magazine_psuedo_empty then - image = self.properties.inventory_image - elseif self.properties.inventory_image_magless and ( (ammo.loaded_mag == "empty") or (ammo.loaded_mag == "") or ammo.magazine_psuedo_empty) then - image = self.properties.inventory_image_magless - elseif self.properties.inventory_image_empty then - image = self.properties.inventory_image_empty + image = self.properties.inventory.inventory_image + elseif self.properties.inventory.inventory_image_magless and ( (ammo.loaded_mag == "empty") or (ammo.loaded_mag == "") or ammo.magazine_psuedo_empty) then + image = self.properties.inventory.inventory_image_magless + elseif self.properties.inventory.inventory_image_empty then + image = self.properties.inventory.inventory_image_empty end --add the firemode overlay to the image local firemodes = 0 diff --git a/classes/Gun.lua b/classes/Gun.lua index 173ddb4..31d17d8 100644 --- a/classes/Gun.lua +++ b/classes/Gun.lua @@ -1,8 +1,6 @@ ---- Gun class - local Vec = vector ---- Gun class fields +--- class fields -- -- ## Defining a gun: -- @@ -82,16 +80,17 @@ local gun_default = { -- @field hip `table` @{gun.properties.hip|hipfire properties} -- @field ads `table` @{gun.properties.ads|aiming ("aiming down sights") properties} -- @field firemodes `table` @{gun.properties.firemodes|list of firemodes} - -- @field firemode_inventory_overlays `table` @{gun.properties.firemode_inventory_overlays|list of corresponding images for firemodes} -- @field recoil `table` @{gun.properties.recoil|defines the guns recoil} -- @field sway `table` @{gun.properties.sway|defines the guns idle sway} -- @field wag `table` @{gun.properties.wag|defines the movement of the gun while walking} -- @field charging `table` @{gun.properties.charging|defines how rounds are chambered into the gun} -- @field ammo `table` @{gun.properties.ammo|defines what ammo the gun uses} -- @field visuals `table` @{gun.properties.visuals|defines visual attributes of the gun} + -- @field sounds `table` @{gun.properties.sounds|defines sounds to be used by functions of the gun} + -- @field inventory `table` @{gun.properties.inventory|inventory related attributes} -- @compact properties = { - --- starting vertical rotation of the gun + --- `float` starting vertical rotation of the gun initial_vertical_rotation = -60, --- `float`=.5 max angular deviation (vertical) from breathing breathing_scale = .5, @@ -99,10 +98,6 @@ local gun_default = { flash_offset = Vec.new(), --- `int`=600 The number of rounds (cartidges) this gun can throw per minute. Used by update(), fire() and default controls firerateRPM = 600, - --- `string` inventory image for when the gun has no magazine - inventory_image_magless = nil, - --- `string` inventory image for when the gun is loaded. This is added automatically during construction. - inventory_image = nil, --- an ordered list of reloading states used by @{default_controls}. -- -- the default reload states for a magazine operated weapon, copied from the m4. @@ -113,7 +108,7 @@ local gun_default = { -- {action="load", time=.5, anim="load", sounds = {sound="ar_mag_load", delay = .25}}, -- {action="charge", time=.5, anim="charge", sounds={sound="ar_charge", delay = .2}} reload = {}, - --- a table {x1,y1,z1,x2,y2,z2} specifying the bounding box of the model. The first 3 (x1,y1,z1) are the lower of their counterparts. This is autogenerated if not present. + --- `table` (optional) a table `{x1,y1,z1, x2,y2,z2}` specifying the bounding box of the model. The first 3 (x1,y1,z1) are the lower of their counterparts. This is autogenerated from the model when not present, reccomended that you leave nil. model_bounding_box = nil, --- `string` overlay on the item to use when infinite ammo is on infinite_inventory_overlay = "inventory_overlay_inf_ammo.png", @@ -137,19 +132,15 @@ local gun_default = { firemode = Guns4d.default_touch_controls.firemode, jump_cancel_ads = Guns4d.default_touch_controls.jump_cancel_ads }, + --- properties.inventory + -- + -- @table gun.properties.inventory + -- @see lvl1_fields.properties|properties + -- @compact inventory = { - --[[part_slots = { - underbarrel = { - formspec_inventory_location = {x=0, y=1} - slots = 2, - rail = "picatinny" --only attachments fit for this type will be usable. - allowed = { - "group:guns4d_underbarrel" - }, - bone = "" --the bone both to attach to and to display at on the menu. - } - },]] + --- the size in meters to render the gun in it's inventory opened with /guns4d_inv render_size = 2, --length (in meters) which is visible accross the z/forward axis at y/up=0, x=0. For orthographic this will be the scale of the orthographic camera. Default 2 + --- the image of the gun in it's inventory opened with /guns4d_inv render_image = "m4_ortho.png", --expects an image of the right side of the gun, where the gun is facing the right. Default "m4_ortho.png" --- table of firemodes and their overlays in the player's inventory when the gun is on that firemode firemode_inventory_overlays = { --#4 @@ -162,8 +153,23 @@ local gun_default = { --safe default: "inventory_overlay_safe.png" (unimplemented firemode) safe = "inventory_overlay_safe.png" }, + --- `string` (optional) inventory image for when the gun has no magazine + inventory_image_magless = nil, + --- `string` inventory image for when the gun is loaded. This is added automatically during construction. + inventory_image = nil, + --[[part_slots = { + underbarrel = { + formspec_inventory_location = {x=0, y=1} + slots = 2, + rail = "picatinny" --only attachments fit for this type will be usable. + allowed = { + "group:guns4d_underbarrel" + }, + bone = "" --the bone both to attach to and to display at on the menu. + } + },]] }, - --- `table` a list of subclasses to create on construct and update. Note special fields `ammo_handler` and `part_handler`. + --- properties.subclasses -- -- @table gun.properties.subclsses -- @see lvl1_fields.properties|properties @@ -394,8 +400,15 @@ local gun_default = { fire = {x=0,y=0}, }, }, - --- a table of @{guns4d_soundspec|soundspecs} to be referenced by other functions + --- properties.sounds + -- + -- other fields are defined by other properties such as @{gun.properties.charging.draw_sound|properties.charging.draw_sound} and @{lvl1_fields.properties.reload|properties.reload} + -- @table gun.properties.sounds + -- @see lvl1_fields.properties|properties + -- @see guns4d_soundspec|soundspec + -- @compact sounds = { --this does not contain reload sound effects. + --- sound player when firing the weapon fire = { { __replace_old_table=true, diff --git a/docs/class/Gun.html b/docs/class/Gun.html index 695fa32..86cd328 100644 --- a/docs/class/Gun.html +++ b/docs/class/Gun.html @@ -6,7 +6,7 @@ gun - Guns4d - +
@@ -16,6 +16,7 @@
+
@@ -29,14 +30,16 @@
  • Class gun
  • properties

  • +
  • properties.inventory

    +
  • +
  • properties.subclasses

    +
  • properties.ads

  • properties.hip

  • properties.firemodes

  • -
  • properties.firemode_inventory_overlays

    -
  • properties.recoil

  • properties.sway

    @@ -49,12 +52,20 @@
  • properties.visuals

  • +
  • properties.sounds

    +
  • offsets

  • consts

  • +
    +
    Manual
    + +
    Classes
    +
    +
    Manual
    + +
    Classes
    diff --git a/docs/module/Gun.html b/docs/module/Gun.html new file mode 100644 index 0000000..c5bce1c --- /dev/null +++ b/docs/module/Gun.html @@ -0,0 +1,70 @@ + + + + + + Gun - Guns4d + + + + + +
    +
    +
    Guns4d | The ultimate 3d gun mod.
    +
    +
    +
    +
    + +
    +
    + +
    +
    +

    Module Gun + +

    +
    +

    Gun

    + +
    +
    +
    + + + \ No newline at end of file diff --git a/docs/module/misc_helpers.html b/docs/module/misc_helpers.html index 26125dd..7ae795f 100644 --- a/docs/module/misc_helpers.html +++ b/docs/module/misc_helpers.html @@ -36,6 +36,12 @@ +
    +
    Manual
    + +
    Classes
    +
    +
    Manual
    + +
    Classes