├── materials ├── grid_overlay.vtex_c └── range_overlay.vtex_c ├── panorama ├── layout │ └── custom_game │ │ ├── selection.xml │ │ └── building_helper.xml └── scripts │ ├── clicks.js │ ├── selection │ ├── selection.js │ └── selection_filter.js │ └── building_helper.js ├── scripts ├── custom_net_tables.txt ├── vscripts │ ├── libraries │ │ ├── modifiers │ │ │ ├── repair_modifiers.lua │ │ │ ├── grid_modifiers.lua │ │ │ ├── modifier_tree_cut.lua │ │ │ ├── modifier_builder_hidden.lua │ │ │ ├── modifier_out_of_world.lua │ │ │ └── modifier_building.lua │ │ ├── selection.lua │ │ └── keyvalues.lua │ ├── repair.lua │ └── builder.lua ├── npc │ └── items │ │ └── item_building_cancel.txt └── kv │ └── building_settings.kv ├── README.md ├── particles └── buildinghelper │ ├── square_sprite.vpcf │ ├── square_overlay.vpcf │ ├── range_overlay.vpcf │ ├── ghost_model.vpcf │ └── square_projected.vpcf └── LICENSE.txt /materials/grid_overlay.vtex_c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MNoya/BuildingHelper/HEAD/materials/grid_overlay.vtex_c -------------------------------------------------------------------------------- /materials/range_overlay.vtex_c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MNoya/BuildingHelper/HEAD/materials/range_overlay.vtex_c -------------------------------------------------------------------------------- /panorama/layout/custom_game/selection.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /scripts/custom_net_tables.txt: -------------------------------------------------------------------------------- 1 | 2 | { 3 | custom_net_tables = 4 | [ 5 | "builders", 6 | "selection", 7 | "construction_size", 8 | "building_settings", 9 | ] 10 | } -------------------------------------------------------------------------------- /scripts/vscripts/libraries/modifiers/repair_modifiers.lua: -------------------------------------------------------------------------------- 1 | modifier_repairing = class({}) -- Stackable modifier on the target being repaired 2 | modifier_builder_repairing = class({}) -- Tooltip builder repairing 3 | 4 | function modifier_repairing:IsPurgable() return false end 5 | function modifier_builder_repairing:IsPurgable() return false end -------------------------------------------------------------------------------- /panorama/layout/custom_game/building_helper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /scripts/vscripts/libraries/modifiers/grid_modifiers.lua: -------------------------------------------------------------------------------- 1 | modifier_grid_blight = class({}) 2 | 3 | function modifier_grid_blight:IsHidden() return true end 4 | function modifier_grid_blight:IsPurgable() return false end 5 | function modifier_grid_blight:GetAttributes() return MODIFIER_ATTRIBUTE_PERMANENT end 6 | 7 | LinkLuaModifier("modifier_grid_blight", "libraries/modifiers/grid_modifiers", LUA_MODIFIER_MOTION_NONE) -------------------------------------------------------------------------------- /scripts/npc/items/item_building_cancel.txt: -------------------------------------------------------------------------------- 1 | "item_building_cancel" 2 | { 3 | "BaseClass" "item_datadriven" 4 | "AbilityTextureName" "item_cancel" 5 | "AbilityBehavior" "DOTA_ABILITY_BEHAVIOR_NO_TARGET | DOTA_ABILITY_BEHAVIOR_IMMEDIATE | DOTA_ABILITY_BEHAVIOR_IGNORE_CHANNEL | DOTA_ABILITY_BEHAVIOR_IGNORE_PSEUDO_QUEUE" 6 | "AbilityCastPoint" "0" 7 | 8 | "ItemDroppable" "0" 9 | "ItemPurchasable" "0" 10 | "ItemSellable" "0" 11 | 12 | "OnSpellStart" 13 | { 14 | "RunScript" 15 | { 16 | "ScriptFile" "builder.lua" 17 | "Function" "CancelBuilding" 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /scripts/vscripts/libraries/modifiers/modifier_tree_cut.lua: -------------------------------------------------------------------------------- 1 | modifier_tree_cut = class({}) 2 | 3 | function modifier_tree_cut:CheckState() 4 | local state = { 5 | [MODIFIER_STATE_NO_UNIT_COLLISION] = true, 6 | [MODIFIER_STATE_NO_TEAM_MOVE_TO] = true, 7 | [MODIFIER_STATE_NO_TEAM_SELECT] = true, 8 | [MODIFIER_STATE_COMMAND_RESTRICTED] = true, 9 | [MODIFIER_STATE_ATTACK_IMMUNE] = true, 10 | [MODIFIER_STATE_INVULNERABLE] = true, 11 | [MODIFIER_STATE_NOT_ON_MINIMAP] = true, 12 | [MODIFIER_STATE_UNSELECTABLE] = true, 13 | [MODIFIER_STATE_NO_HEALTH_BAR] = true, 14 | } 15 | return state 16 | end 17 | 18 | function modifier_tree_cut:IsPurgable() return false end -------------------------------------------------------------------------------- /scripts/vscripts/libraries/modifiers/modifier_builder_hidden.lua: -------------------------------------------------------------------------------- 1 | modifier_builder_hidden = class({}) 2 | 3 | -- Builder can send build orders while inside the building 4 | -- Builder is selectable while inside the building 5 | if IsServer() then 6 | function modifier_builder_hidden:CheckState() 7 | local state = { 8 | [MODIFIER_STATE_NO_UNIT_COLLISION] = true, 9 | [MODIFIER_STATE_INVULNERABLE] = true, 10 | [MODIFIER_STATE_ROOTED] = true, 11 | [MODIFIER_STATE_DISARMED] = true, 12 | [MODIFIER_STATE_NOT_ON_MINIMAP] = true, 13 | [MODIFIER_STATE_NO_HEALTH_BAR] = true, 14 | [MODIFIER_STATE_BLIND] = true, 15 | } 16 | 17 | return state 18 | end 19 | end 20 | 21 | function modifier_builder_hidden:IsHidden() 22 | return true 23 | end 24 | 25 | function modifier_builder_hidden:IsPurgable() 26 | return false 27 | end -------------------------------------------------------------------------------- /scripts/vscripts/libraries/modifiers/modifier_out_of_world.lua: -------------------------------------------------------------------------------- 1 | modifier_out_of_world = class({}) 2 | 3 | if IsServer() then 4 | function modifier_out_of_world:CheckState() 5 | local state = { 6 | [MODIFIER_STATE_OUT_OF_GAME] = self.serverside, 7 | [MODIFIER_STATE_PASSIVES_DISABLED] = true, 8 | [MODIFIER_STATE_PROVIDES_VISION] = false, 9 | [MODIFIER_STATE_NO_UNIT_COLLISION] = true, 10 | [MODIFIER_STATE_NOT_ON_MINIMAP] = true, 11 | [MODIFIER_STATE_NO_HEALTH_BAR] = true, 12 | [MODIFIER_STATE_UNSELECTABLE] = true, 13 | [MODIFIER_STATE_INVULNERABLE] = true, 14 | [MODIFIER_STATE_NO_TEAM_MOVE_TO] = true, 15 | [MODIFIER_STATE_NO_TEAM_SELECT] = true, 16 | [MODIFIER_STATE_STUNNED] = true, 17 | [MODIFIER_STATE_BLIND] = true, 18 | [MODIFIER_STATE_COMMAND_RESTRICTED] = true, 19 | } 20 | 21 | return state 22 | end 23 | 24 | function modifier_out_of_world:OnCreated( params ) 25 | local unit = self:GetParent() 26 | self.serverside = params.clientside ~= 1 27 | end 28 | 29 | function modifier_out_of_world:IsPurgable() 30 | return false 31 | end 32 | end -------------------------------------------------------------------------------- /scripts/vscripts/libraries/modifiers/modifier_building.lua: -------------------------------------------------------------------------------- 1 | modifier_building = class({}) 2 | 3 | function modifier_building:OnCreated(event) 4 | self.disable_turning = event.disable_turning == 1 and 1 or 0 5 | self.magic_immune = event.magic_immune == 1 6 | self.deniable = event.deniable == 1 7 | end 8 | 9 | function modifier_building:GetModifierDisableTurning() 10 | return self.disable_turning 11 | end 12 | 13 | function modifier_building:GetModifierIgnoreCastAngle() 14 | return self.disable_turning or 1 15 | end 16 | 17 | function modifier_building:CheckState() 18 | return { [MODIFIER_STATE_MAGIC_IMMUNE] = self.magic_immune or true, 19 | [MODIFIER_STATE_SPECIALLY_DENIABLE] = self.deniable or true, 20 | [MODIFIER_STATE_ROOTED] = true, 21 | [MODIFIER_STATE_LOW_ATTACK_PRIORITY] = true, 22 | [MODIFIER_STATE_NO_UNIT_COLLISION] = true, } 23 | end 24 | 25 | function modifier_building:DeclareFunctions() 26 | return { MODIFIER_PROPERTY_DISABLE_TURNING, 27 | MODIFIER_PROPERTY_IGNORE_CAST_ANGLE, 28 | MODIFIER_PROPERTY_MOVESPEED_LIMIT, } 29 | end 30 | 31 | function modifier_building:GetAttributes() 32 | return MODIFIER_ATTRIBUTE_PERMANENT 33 | end 34 | 35 | function modifier_building:GetModifierMoveSpeed_Limit() 36 | return 0 37 | end 38 | 39 | function modifier_building:IsHidden() 40 | return true 41 | end 42 | 43 | function modifier_building:IsPurgable() 44 | return false 45 | end -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dota 2 Building Helper 2 | 3 | After months of improvements accomplished in various gamemodes, the library has been refined and its ready for a wonderful year of strategy mods! 4 | 5 | For installation steps and documentation, [head over the wiki](https://github.com/MNoya/BuildingHelper/wiki) and check various of the current implementations of this codebase. There will be updates to the docs and the scripts, so do Watch/Star the repo to get the latest news and progress being done. 6 | 7 | ## Help, Bug Reports and Feature Requests 8 | 9 | We can be reached through various ways: 10 | 11 | * [Create an issue on GitHub](https://github.com/Myll/Dota-2-Building-Helper/issues/new) 12 | * At `irc.gamesurge.net` [#dota2mods & #dota2modhelpdesk](https://kiwiirc.com/client/irc.gamesurge.net/?#dota2mods,#dota2modhelpdesk) 13 | * At [moddota.com](https://moddota.com/forums/), throught the dedicated [Tools subforum](https://moddota.com/forums/categories/tools) 14 | 15 | ## Contributing 16 | 17 | Contributing to this repo is absolutely welcomed. Building Helper's goal is to make Dota 2 a fully compatible platform to create RTS-style and Tower Defense mods. It will take a community effort to achieve this goal. 18 | 19 | If you implement any fix or feature you'd like to see it included in this library, make a pull request or make an issue with the necessary script changes. 20 | 21 | ## Credits 22 | 23 | * [Noya](https://github.com/MNoya), release, updates and maintenance 24 | * [BMD](https://github.com/bmddota), made the encoding grid system and ton of previous work 25 | * [Myll](https://github.com/stephenfournier), original dev 26 | * [Perry](https://github.com/perryvw), contributed to the old scaleform version 27 | * [snipplets](https://github.com/snipplets/), first panorama implementation and queue system 28 | 29 | ## Notes 30 | 31 | If you're a new modder we highly recommend forking a new starter addon using [D2ModKit](https://github.com/Myll/Dota-2-ModKit) program. 32 | 33 | ## License 34 | 35 | Building Helper is licensed under the GNU General Public license. If you use Building Helper in your mod, please state so in your credits. -------------------------------------------------------------------------------- /particles/buildinghelper/square_sprite.vpcf: -------------------------------------------------------------------------------- 1 | 2 | { 3 | _class = "CParticleSystemDefinition" 4 | m_flCullRadius = -1.000000 5 | m_flConstantRadius = 64.000000 6 | m_nMaxParticles = 4 7 | m_Operators = 8 | [ 9 | { 10 | _class = "C_OP_Decay" 11 | m_bDisableOperator = true 12 | }, 13 | { 14 | _class = "C_OP_PositionLock" 15 | }, 16 | { 17 | _class = "C_OP_RemapCPtoVector" 18 | m_nCPInput = 2 19 | m_nFieldOutput = 6 20 | m_vInputMax = 21 | [ 22 | 255.000000, 23 | 255.000000, 24 | 255.000000, 25 | ] 26 | m_vOutputMax = 27 | [ 28 | 1.000000, 29 | 1.000000, 30 | 1.000000, 31 | ] 32 | }, 33 | ] 34 | m_Renderers = 35 | [ 36 | { 37 | _class = "C_OP_RenderSprites" 38 | m_nOrientationType = 2 39 | m_hTexture = resource:"materials/particle/particle_whitebox.vtex" 40 | }, 41 | { 42 | _class = "C_OP_RenderProjected" 43 | m_hProjectedMaterial = resource:"materials/particle/particle_whitebox_projected.vmat" 44 | m_bDisableOperator = true 45 | }, 46 | ] 47 | m_Initializers = 48 | [ 49 | { 50 | _class = "C_INIT_RemapCPtoScalar" 51 | m_nCPInput = 1 52 | m_flInputMax = 128.000000 53 | m_flOutputMax = 128.000000 54 | }, 55 | { 56 | _class = "C_INIT_CreateWithinSphere" 57 | }, 58 | { 59 | _class = "C_INIT_RandomLifeTime" 60 | m_fLifetimeMin = 1.000000 61 | m_fLifetimeMax = 1.000000 62 | m_bDisableOperator = true 63 | }, 64 | { 65 | _class = "C_INIT_RemapCPtoVector" 66 | m_nCPInput = 2 67 | m_nFieldOutput = 6 68 | m_vInputMax = 69 | [ 70 | 255.000000, 71 | 255.000000, 72 | 255.000000, 73 | ] 74 | m_vOutputMax = 75 | [ 76 | 1.000000, 77 | 1.000000, 78 | 1.000000, 79 | ] 80 | m_bDisableOperator = true 81 | }, 82 | { 83 | _class = "C_INIT_PositionPlaceOnGround" 84 | m_flOffset = 5.000000 85 | m_bDisableOperator = true 86 | }, 87 | { 88 | _class = "C_INIT_RemapCPtoScalar" 89 | m_nCPInput = 3 90 | m_nFieldOutput = 7 91 | m_flInputMax = 100.000000 92 | }, 93 | { 94 | _class = "C_INIT_PositionOffset" 95 | m_OffsetMin = 96 | [ 97 | 0.000000, 98 | 0.000000, 99 | 6.000000, 100 | ] 101 | m_OffsetMax = 102 | [ 103 | 0.000000, 104 | 0.000000, 105 | 6.000000, 106 | ] 107 | }, 108 | ] 109 | m_Emitters = 110 | [ 111 | { 112 | _class = "C_OP_InstantaneousEmitter" 113 | m_nParticlesToEmit = 1 114 | }, 115 | ] 116 | } -------------------------------------------------------------------------------- /particles/buildinghelper/square_overlay.vpcf: -------------------------------------------------------------------------------- 1 | 2 | { 3 | _class = "CParticleSystemDefinition" 4 | m_flCullRadius = -1.000000 5 | m_flConstantRadius = 64.000000 6 | m_nMaxParticles = 4 7 | m_Operators = 8 | [ 9 | { 10 | _class = "C_OP_Decay" 11 | m_bDisableOperator = true 12 | }, 13 | { 14 | _class = "C_OP_PositionLock" 15 | }, 16 | { 17 | _class = "C_OP_RemapCPtoVector" 18 | m_nCPInput = 2 19 | m_nFieldOutput = 6 20 | m_vInputMax = 21 | [ 22 | 255.000000, 23 | 255.000000, 24 | 255.000000, 25 | ] 26 | m_vOutputMax = 27 | [ 28 | 1.000000, 29 | 1.000000, 30 | 1.000000, 31 | ] 32 | }, 33 | { 34 | _class = "C_OP_RemapCPtoScalar" 35 | m_nCPInput = 3 36 | m_nFieldOutput = 7 37 | m_flInputMax = 100.000000 38 | }, 39 | ] 40 | m_Renderers = 41 | [ 42 | { 43 | _class = "C_OP_RenderSprites" 44 | m_nOrientationType = 2 45 | m_hTexture = resource:"materials/grid_overlay.vtex" 46 | }, 47 | { 48 | _class = "C_OP_RenderProjected" 49 | m_hProjectedMaterial = resource:"materials/particle/particle_whitebox_projected.vmat" 50 | m_bDisableOperator = true 51 | }, 52 | ] 53 | m_Initializers = 54 | [ 55 | { 56 | _class = "C_INIT_RemapCPtoScalar" 57 | m_nCPInput = 1 58 | m_flInputMax = 128.000000 59 | m_flOutputMax = 128.000000 60 | }, 61 | { 62 | _class = "C_INIT_CreateWithinSphere" 63 | }, 64 | { 65 | _class = "C_INIT_RandomLifeTime" 66 | m_fLifetimeMin = 1.000000 67 | m_fLifetimeMax = 1.000000 68 | m_bDisableOperator = true 69 | }, 70 | { 71 | _class = "C_INIT_RemapCPtoVector" 72 | m_nCPInput = 2 73 | m_nFieldOutput = 6 74 | m_vInputMax = 75 | [ 76 | 255.000000, 77 | 255.000000, 78 | 255.000000, 79 | ] 80 | m_vOutputMax = 81 | [ 82 | 1.000000, 83 | 1.000000, 84 | 1.000000, 85 | ] 86 | m_bDisableOperator = true 87 | }, 88 | { 89 | _class = "C_INIT_PositionPlaceOnGround" 90 | m_flOffset = 4.000000 91 | m_bDisableOperator = true 92 | }, 93 | { 94 | _class = "C_INIT_RemapCPtoScalar" 95 | m_nCPInput = 3 96 | m_nFieldOutput = 7 97 | m_flInputMax = 100.000000 98 | }, 99 | { 100 | _class = "C_INIT_PositionOffset" 101 | m_OffsetMin = 102 | [ 103 | 0.000000, 104 | 0.000000, 105 | 5.000000, 106 | ] 107 | m_OffsetMax = 108 | [ 109 | 0.000000, 110 | 0.000000, 111 | 5.000000, 112 | ] 113 | }, 114 | ] 115 | m_Emitters = 116 | [ 117 | { 118 | _class = "C_OP_InstantaneousEmitter" 119 | m_nParticlesToEmit = 1 120 | }, 121 | ] 122 | } -------------------------------------------------------------------------------- /particles/buildinghelper/range_overlay.vpcf: -------------------------------------------------------------------------------- 1 | 2 | { 3 | _class = "CParticleSystemDefinition" 4 | m_flCullRadius = -1.000000 5 | m_flConstantRadius = 64.000000 6 | m_nMaxParticles = 4 7 | m_Operators = 8 | [ 9 | { 10 | _class = "C_OP_Decay" 11 | m_bDisableOperator = true 12 | }, 13 | { 14 | _class = "C_OP_PositionLock" 15 | }, 16 | { 17 | _class = "C_OP_RemapCPtoVector" 18 | m_nCPInput = 2 19 | m_nFieldOutput = 6 20 | m_vInputMax = 21 | [ 22 | 255.000000, 23 | 255.000000, 24 | 255.000000, 25 | ] 26 | m_vOutputMax = 27 | [ 28 | 1.000000, 29 | 1.000000, 30 | 1.000000, 31 | ] 32 | }, 33 | { 34 | _class = "C_OP_RemapCPtoScalar" 35 | m_nCPInput = 3 36 | m_nFieldOutput = 7 37 | m_flInputMax = 100.000000 38 | }, 39 | ] 40 | m_Renderers = 41 | [ 42 | { 43 | _class = "C_OP_RenderSprites" 44 | m_nOrientationType = 2 45 | m_hTexture = resource:"materials/range_overlay.vtex" 46 | }, 47 | { 48 | _class = "C_OP_RenderProjected" 49 | m_hProjectedMaterial = resource:"materials/particle/particle_whitebox_projected.vmat" 50 | m_bDisableOperator = true 51 | }, 52 | ] 53 | m_Initializers = 54 | [ 55 | { 56 | _class = "C_INIT_RemapCPtoScalar" 57 | m_nCPInput = 1 58 | m_flInputMax = 2000.000000 59 | m_flOutputMax = 2000.000000 60 | }, 61 | { 62 | _class = "C_INIT_CreateWithinSphere" 63 | }, 64 | { 65 | _class = "C_INIT_RandomLifeTime" 66 | m_fLifetimeMin = 1.000000 67 | m_fLifetimeMax = 1.000000 68 | m_bDisableOperator = true 69 | }, 70 | { 71 | _class = "C_INIT_RemapCPtoVector" 72 | m_nCPInput = 2 73 | m_nFieldOutput = 6 74 | m_vInputMax = 75 | [ 76 | 255.000000, 77 | 255.000000, 78 | 255.000000, 79 | ] 80 | m_vOutputMax = 81 | [ 82 | 1.000000, 83 | 1.000000, 84 | 1.000000, 85 | ] 86 | m_bDisableOperator = true 87 | }, 88 | { 89 | _class = "C_INIT_PositionPlaceOnGround" 90 | m_flOffset = 4.000000 91 | m_bDisableOperator = true 92 | }, 93 | { 94 | _class = "C_INIT_RemapCPtoScalar" 95 | m_nCPInput = 3 96 | m_nFieldOutput = 7 97 | m_flInputMax = 100.000000 98 | }, 99 | { 100 | _class = "C_INIT_PositionOffset" 101 | m_OffsetMin = 102 | [ 103 | 0.000000, 104 | 0.000000, 105 | 5.000000, 106 | ] 107 | m_OffsetMax = 108 | [ 109 | 0.000000, 110 | 0.000000, 111 | 5.000000, 112 | ] 113 | }, 114 | ] 115 | m_Emitters = 116 | [ 117 | { 118 | _class = "C_OP_InstantaneousEmitter" 119 | m_nParticlesToEmit = 1 120 | }, 121 | ] 122 | } -------------------------------------------------------------------------------- /panorama/scripts/clicks.js: -------------------------------------------------------------------------------- 1 | "use strict" 2 | var right_click_repair = CustomNetTables.GetTableValue("building_settings", "right_click_repair").value; 3 | 4 | function GetMouseTarget() 5 | { 6 | var mouseEntities = GameUI.FindScreenEntities( GameUI.GetCursorPosition() ) 7 | var localHeroIndex = Players.GetPlayerHeroEntityIndex( Players.GetLocalPlayer() ) 8 | 9 | for ( var e of mouseEntities ) 10 | { 11 | if ( !e.accurateCollision ) 12 | continue 13 | return e.entityIndex 14 | } 15 | 16 | for ( var e of mouseEntities ) 17 | { 18 | return e.entityIndex 19 | } 20 | 21 | return 0 22 | } 23 | 24 | // Handle Right Button events 25 | function OnRightButtonPressed() 26 | { 27 | var iPlayerID = Players.GetLocalPlayer() 28 | var selectedEntities = Players.GetSelectedEntities( iPlayerID ) 29 | var mainSelected = Players.GetLocalPlayerPortraitUnit() 30 | var targetIndex = GetMouseTarget() 31 | var pressedShift = GameUI.IsShiftDown() 32 | 33 | // Builder Right Click 34 | if ( IsBuilder( mainSelected ) ) 35 | { 36 | // Cancel BH 37 | if (!pressedShift) SendCancelCommand() 38 | 39 | // Repair rightclick 40 | if (right_click_repair && IsCustomBuilding(targetIndex) && Entities.GetHealthPercent(targetIndex) < 100 && IsAlliedUnit(targetIndex, mainSelected)) { 41 | GameEvents.SendCustomGameEventToServer( "building_helper_repair_command", {targetIndex: targetIndex, queue: pressedShift}) 42 | return true 43 | } 44 | } 45 | 46 | return false 47 | } 48 | 49 | // Handle Left Button events 50 | function OnLeftButtonPressed() { 51 | return false 52 | } 53 | 54 | function IsCustomBuilding(entIndex) { 55 | return (Entities.GetAbilityByName( entIndex, "ability_building") != -1) 56 | } 57 | 58 | function IsBuilder(entIndex) { 59 | var tableValue = CustomNetTables.GetTableValue( "builders", entIndex.toString()) 60 | return (tableValue !== undefined) && (tableValue.IsBuilder == 1) 61 | } 62 | 63 | function IsAlliedUnit(entIndex, targetIndex) { 64 | return (Entities.GetTeamNumber(entIndex) == Entities.GetTeamNumber(targetIndex)) 65 | } 66 | 67 | // Main mouse event callback 68 | GameUI.SetMouseCallback( function( eventName, arg ) { 69 | var CONSUME_EVENT = true 70 | var CONTINUE_PROCESSING_EVENT = false 71 | var LEFT_CLICK = (arg === 0) 72 | var RIGHT_CLICK = (arg === 1) 73 | 74 | if ( GameUI.GetClickBehaviors() !== CLICK_BEHAVIORS.DOTA_CLICK_BEHAVIOR_NONE ) 75 | return CONTINUE_PROCESSING_EVENT 76 | 77 | var mainSelected = Players.GetLocalPlayerPortraitUnit() 78 | 79 | if ( eventName === "pressed" || eventName === "doublepressed") 80 | { 81 | // Builder Clicks 82 | if (IsBuilder(mainSelected)) 83 | if (LEFT_CLICK) 84 | return (state == "active") ? SendBuildCommand() : OnLeftButtonPressed() 85 | else if (RIGHT_CLICK) 86 | return OnRightButtonPressed() 87 | 88 | if (LEFT_CLICK) 89 | return OnLeftButtonPressed() 90 | else if (RIGHT_CLICK) 91 | return OnRightButtonPressed() 92 | 93 | } 94 | return CONTINUE_PROCESSING_EVENT 95 | } ) -------------------------------------------------------------------------------- /scripts/kv/building_settings.kv: -------------------------------------------------------------------------------- 1 | "BH_Settings" 2 | { 3 | // Particle settings 4 | "GRID_ALPHA" "30" //Defines the transparency of the base green/red squares in Panorama 5 | "ALT_GRID_ALPHA" "90" //Defines the transparency of the alt grid white/red squares in Panorama 6 | "ALT_GRID_SQUARES" "4" //Defines how many small squares to create to each side of the building construction size 7 | "RANGE_OVERLAY_ALPHA" "30" //Defines the transparency of the range overlay showed when placing a building with attack capabilities 8 | "MODEL_ALPHA" "100" //Defines the transparency of both the ghost model in Panorama and Building Placed in Lua 9 | "RECOLOR_GHOST_MODEL" "false" //Recolor the ghost model green when valid or just default color 10 | "RED_MODEL_WHEN_INVALID" "true" //Recolor red when ghosting over an invalid position 11 | "RECOLOR_BUILDING_PLACED" "true" //Recolor green the queue of buildings placed in Lua 12 | "PERMANENT_ALT_GRID" "false" 13 | 14 | // Does this game have tree cutting methods and allows for building on them? 15 | "UPDATE_TREES" "true" 16 | 17 | // Percentage health that buildings should start at 18 | "INITIAL_HEALTH_FACTOR" "0.1" 19 | 20 | // Percentage health at which buildings should play their FireEffect 21 | "FIRE_EFFECT_FACTOR" "0.5" 22 | 23 | // Min Height buildings are able to be placed, leave it empty for none. If a value is defined, all building placements strictly below this number will be invalid 24 | "HEIGHT_RESTRICTION" "" 25 | 26 | // Should buildings be immune to magic damage? Should also be careful with healing abilities targeting them. 27 | "MAGIC_IMMUNE_BUILDINGS" "true" 28 | 29 | // Should buildings be deniable from 100% HP? 30 | "DENIABLE_BUILDINGS" "true" 31 | 32 | // Should we disable building turnrate by default? Defining a "DisableTurning" kv on the unit will still override the global setting 33 | "DISABLE_BUILDING_TURNING" "true" 34 | 35 | // Path of the builder callbacks, can be changed to somewhere else within vscripts 36 | "BUILD_PATH" "builder" 37 | 38 | // Should we try to tie allied building rightclick to a "RepairAbility" usage ? 39 | "RIGHT_CLICK_REPAIR" "true" 40 | 41 | // Path of the repair callbacks, can be changed to somewhere else within vscripts 42 | "REPAIR_PATH" "repair" 43 | 44 | // The following can be overriden in each ability KV if different ratios are necessary 45 | "REPAIR_SETTINGS" 46 | { 47 | "RepairCostRatio" "0.35" //Resource cost needed to heal the buildings HP based on the original cost 48 | "RepairTimeRatio" "1.5" //Time needed to heal the buildings HP based on the original time 49 | 50 | // Powerbuild is applied for every extra builder working on the same building 51 | "PowerbuildCost" "0.15" //Cost Ratio = RepairCostRatio + PowerbuildCost*(Builders-1) 52 | "PowerbuildRate" "0.6" //Time Ratio = RepairTimeRatio * PowerbuildRate^(Builders-1) 53 | } 54 | 55 | // Turn this off to hide the console print messages 56 | "TESTING" "true" 57 | } -------------------------------------------------------------------------------- /particles/buildinghelper/ghost_model.vpcf: -------------------------------------------------------------------------------- 1 | 2 | { 3 | _class = "CParticleSystemDefinition" 4 | m_bShouldHitboxesFallbackToRenderBounds = false 5 | m_nMaxParticles = 1 6 | m_flConstantRadius = 1.000000 7 | m_ConstantColor = 8 | [ 9 | 0, 10 | 0, 11 | 0, 12 | 255, 13 | ] 14 | m_nConstantSequenceNumber1 = 18 15 | m_bShouldSort = false 16 | m_Renderers = 17 | [ 18 | { 19 | _class = "C_OP_RenderModels" 20 | m_nManualFrameField = 18 21 | m_nSubModelField = 19 22 | m_nBodyGroupField = 19 23 | m_bManualAnimFrame = true 24 | m_bOrientZ = true 25 | m_nSkin = 1 26 | m_nModelCP = 1 27 | m_ModelList = 28 | [ 29 | { 30 | m_model = resource:"models/heroes/storm_spirit/storm_spirit.vmdl" 31 | }, 32 | ] 33 | m_nLOD = 1 34 | }, 35 | ] 36 | m_Operators = 37 | [ 38 | { 39 | _class = "C_OP_Orient2DRelToCP" 40 | m_nFieldOutput = 12 41 | m_flRotOffset = 90.000000 42 | m_flOpStartFadeOutTime = 0.100000 43 | m_flOpEndFadeOutTime = 0.100000 44 | m_bDisableOperator = true 45 | }, 46 | { 47 | _class = "C_OP_RemapCPtoScalar" 48 | m_flOutputMax = 10.100000 49 | m_flInputMax = 10.000000 50 | m_nCPInput = 2 51 | m_nField = 1 52 | m_bDisableOperator = true 53 | }, 54 | { 55 | _class = "C_OP_SequenceFromModel" 56 | m_flOpEndFadeOutTime = 0.250000 57 | m_flOpStartFadeOutTime = 0.250000 58 | m_flOutputMax = 1000.000000 59 | m_nFieldOutput = 13 60 | m_flInputMax = 1000.000000 61 | m_nControlPointNumber = 1 62 | }, 63 | { 64 | _class = "C_OP_EndCapTimedDecay" 65 | }, 66 | { 67 | _class = "C_OP_RampScalarLinearSimple" 68 | m_flEndTime = 0.500000 69 | m_Rate = 30.000000 70 | m_nField = 18 71 | }, 72 | { 73 | _class = "C_OP_RemapCPtoVector" 74 | m_nCPInput = 2 75 | m_nFieldOutput = 6 76 | m_vInputMax = 77 | [ 78 | 255.000000, 79 | 255.000000, 80 | 255.000000, 81 | ] 82 | m_vOutputMax = 83 | [ 84 | 1.000000, 85 | 1.000000, 86 | 1.000000, 87 | ] 88 | }, 89 | { 90 | _class = "C_OP_PositionLock" 91 | }, 92 | ] 93 | m_Initializers = 94 | [ 95 | { 96 | _class = "C_INIT_RemapInitialCPDirectionToRotation" 97 | m_nCP = 1 98 | m_nFieldOutput = 12 99 | m_flOffsetRot = 90.000000 100 | }, 101 | { 102 | _class = "C_INIT_RandomLifeTime" 103 | m_fLifetimeMin = 1.000000 104 | m_fLifetimeMax = 1.000000 105 | }, 106 | { 107 | _class = "C_INIT_CreateWithinSphere" 108 | }, 109 | { 110 | _class = "C_INIT_PositionOffset" 111 | m_OffsetMin = 112 | [ 113 | 2.000000, 114 | 0.000000, 115 | 0.000000, 116 | ] 117 | m_OffsetMax = 118 | [ 119 | 2.000000, 120 | 0.000000, 121 | 0.000000, 122 | ] 123 | m_bLocalCoords = true 124 | }, 125 | { 126 | _class = "C_INIT_RandomAlphaWindowThreshold" 127 | m_flMin = 18.000000 128 | m_flMax = 18.000000 129 | }, 130 | { 131 | _class = "C_INIT_RemapCPtoScalar" 132 | m_nCPInput = 3 133 | m_nFieldOutput = 7 134 | m_flInputMax = 100.000000 135 | }, 136 | { 137 | _class = "C_INIT_RemapCPtoScalar" 138 | m_nCPInput = 4 139 | m_flInputMax = 1000.000000 140 | m_flOutputMax = 1000.000000 141 | }, 142 | ] 143 | m_Emitters = 144 | [ 145 | { 146 | _class = "C_OP_InstantaneousEmitter" 147 | m_nParticlesToEmit = 1 148 | }, 149 | ] 150 | m_flCullRadius = -1.000000 151 | } -------------------------------------------------------------------------------- /panorama/scripts/selection/selection.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var skip = false 4 | 5 | // Recieves a list of entities to replace the current selection 6 | function Selection_New(msg) 7 | { 8 | var entities = msg.entities 9 | //$.Msg("Selection_New ", entities) 10 | for (var i in entities) { 11 | if (i==1) 12 | GameUI.SelectUnit(entities[i], false) //New 13 | else 14 | GameUI.SelectUnit(entities[i], true) //Add 15 | }; 16 | OnUpdateSelectedUnit() 17 | } 18 | 19 | // Recieves a list of entities to add to the current selection 20 | function Selection_Add(msg) 21 | { 22 | var entities = msg.entities 23 | //$.Msg("Selection_Add ", entities) 24 | for (var i in entities) { 25 | GameUI.SelectUnit(entities[i], true) 26 | }; 27 | OnUpdateSelectedUnit() 28 | } 29 | 30 | // Removes a list of entities from the current selection 31 | function Selection_Remove(msg) 32 | { 33 | var remove_entities = msg.entities 34 | //$.Msg("Selection_Remove ", remove_entities) 35 | var selected_entities = GetSelectedEntities(); 36 | for (var i in remove_entities) { 37 | var index = selected_entities.indexOf(remove_entities[i]) 38 | if (index > -1) 39 | selected_entities.splice(index, 1) 40 | }; 41 | 42 | if (selected_entities.length == 0) 43 | { 44 | Selection_Reset() 45 | return 46 | } 47 | 48 | for (var i in selected_entities) { 49 | if (i==0) 50 | GameUI.SelectUnit(selected_entities[i], false) //New 51 | else 52 | GameUI.SelectUnit(selected_entities[i], true) //Add 53 | }; 54 | OnUpdateSelectedUnit() 55 | } 56 | 57 | // Fall back to the default selection 58 | function Selection_Reset(msg) 59 | { 60 | var playerID = Players.GetLocalPlayer() 61 | var heroIndex = Players.GetPlayerHeroEntityIndex(playerID) 62 | GameUI.SelectUnit(heroIndex, false) 63 | OnUpdateSelectedUnit() 64 | } 65 | 66 | // Filter & Sending 67 | function OnUpdateSelectedUnit() 68 | { 69 | //$.Msg( "OnUpdateSelectedUnit ", Players.GetLocalPlayerPortraitUnit() ); 70 | if (skip == true){ 71 | skip = false; 72 | return 73 | } 74 | 75 | // Skips units from the selected group 76 | SelectionFilter(GetSelectedEntities()) 77 | 78 | $.Schedule(0.03, SendSelectedEntities); 79 | } 80 | 81 | // Updates the list of selected entities on server for this player 82 | function SendSelectedEntities() { 83 | GameEvents.SendCustomGameEventToServer("selection_update", {entities: GetSelectedEntities()}) 84 | } 85 | 86 | // Local player shortcut 87 | function GetSelectedEntities() { 88 | return Players.GetSelectedEntities(Players.GetLocalPlayer()); 89 | } 90 | 91 | // Returns an index of an override defined on lua with npcHandle:SetSelectionOverride(reselect_unit) 92 | function GetSelectionOverride(entityIndex) { 93 | var table = CustomNetTables.GetTableValue("selection", entityIndex) 94 | return table ? table.entity : -1 95 | } 96 | 97 | function OnUpdateQueryUnit() 98 | { 99 | //$.Msg( "OnUpdateQueryUnit ", Players.GetQueryUnit(Players.GetLocalPlayer())); 100 | } 101 | 102 | (function () { 103 | // Custom event listeners 104 | GameEvents.Subscribe( "selection_new", Selection_New); 105 | GameEvents.Subscribe( "selection_add", Selection_Add); 106 | GameEvents.Subscribe( "selection_remove", Selection_Remove); 107 | GameEvents.Subscribe( "selection_reset", Selection_Reset); 108 | 109 | // Built-In Dota client events 110 | GameEvents.Subscribe( "dota_player_update_selected_unit", OnUpdateSelectedUnit ); 111 | GameEvents.Subscribe( "dota_player_update_query_unit", OnUpdateQueryUnit ); 112 | })(); -------------------------------------------------------------------------------- /scripts/vscripts/repair.lua: -------------------------------------------------------------------------------- 1 | -------------------------------- 2 | -- Repair Scripts -- 3 | -------------------------------- 4 | 5 | function Repair(event) 6 | local caster = event.caster 7 | local target = event.target 8 | 9 | BuildingHelper:AddRepairToQueue(caster, target, false) 10 | end 11 | 12 | -- Right before starting to move towards the target 13 | function BuildingHelper:OnPreRepair(builder, target) 14 | -- Custom repair target rules 15 | local bValidRepair = target:GetClassname() == "npc_dota_creature" and IsCustomBuilding(target) and target:GetHealthPercent() < 100 16 | 17 | -- Return false to stop the repair process 18 | return bValidRepair 19 | end 20 | 21 | -- As soon as the builder reaches the building 22 | function BuildingHelper:OnRepairStarted(builder, building) 23 | self:print("OnRepairStarted "..builder:GetUnitName().." "..builder:GetEntityIndex().." -> "..building:GetUnitName().." "..building:GetEntityIndex()) 24 | 25 | local repair_ability = self:GetRepairAbility(builder) 26 | if repair_ability and repair_ability:GetToggleState() == false then 27 | repair_ability:ToggleAbility() -- Fake toggle the ability 28 | end 29 | 30 | builder:StartGesture(ACT_DOTA_ATTACK) 31 | builder.repair_animation_timer = Timers:CreateTimer(function() 32 | if builder.state == "repairing" then 33 | builder:StartGesture(ACT_DOTA_ATTACK) 34 | end 35 | return 1 36 | end) 37 | end 38 | 39 | function BuildingHelper:OnRepairTick(building, hpGain, costFactor) 40 | local playerID = building:GetPlayerOwnerID() 41 | local goldCost = building:GetKeyValue("GoldCost") 42 | local buildTime = building:GetKeyValue("BuildTime") 43 | building.GoldAdjustment = building.GoldAdjustment or 0 44 | building.gold_used = 0 45 | 46 | -- Keep adding the floating point values every tick 47 | local pct_healed = hpGain / building:GetMaxHealth() 48 | local gold_tick = pct_healed * goldCost * costFactor 49 | local gold_float = gold_tick - math.floor(gold_tick) 50 | gold_tick = math.floor(gold_tick) 51 | 52 | if PlayerResource:GetGold(playerID) >= gold_tick then 53 | building.GoldAdjustment = building.GoldAdjustment + gold_float 54 | if building.GoldAdjustment > 1 then 55 | PlayerResource:ModifyGold(playerID, -gold_tick, false, 0) 56 | building.GoldAdjustment = building.GoldAdjustment - 1 57 | building.gold_used = building.gold_used + gold_tick + 1 58 | else 59 | PlayerResource:ModifyGold(playerID, -gold_tick, false, 0) 60 | building.gold_used = building.gold_used + gold_tick 61 | end 62 | else 63 | building.gold_used = nil 64 | return false -- cancels the repair on all builders 65 | end 66 | end 67 | 68 | -- After an ongoing move-to-building or repair process is cancelled 69 | function BuildingHelper:OnRepairCancelled(builder, building) 70 | self:print("OnRepairCancelled "..builder:GetUnitName().." "..builder:GetEntityIndex().." -> "..building:GetUnitName().." "..building:GetEntityIndex()) 71 | 72 | if builder.repair_animation_timer then 73 | builder:RemoveGesture(ACT_DOTA_ATTACK) 74 | Timers:RemoveTimer(builder.repair_animation_timer) 75 | end 76 | end 77 | 78 | -- After a building is fully constructed via repair ("RequiresRepair" buildings), or is fully repaired 79 | function BuildingHelper:OnRepairFinished(builder, building) 80 | self:print("OnRepairFinished "..builder:GetUnitName().." "..builder:GetEntityIndex().." -> "..building:GetUnitName().." "..building:GetEntityIndex()) 81 | 82 | if builder.repair_animation_timer then 83 | builder:RemoveGesture(ACT_DOTA_ATTACK) 84 | Timers:RemoveTimer(builder.repair_animation_timer) 85 | end 86 | end -------------------------------------------------------------------------------- /panorama/scripts/selection/selection_filter.js: -------------------------------------------------------------------------------- 1 | // Defines scripts to set selection redirects 2 | 3 | var DESELECT_BUILDINGS = false; // Get only the units when units&buildings are on the same list 4 | var SELECT_ONLY_BUILDINGS = false; // Get only the buildings when units&buildings are on the same list 5 | var DISPLAY_RANGE_PARTICLE = false; // Uses the main selected entity to update a particle showing attack range 6 | var rangedParticle 7 | 8 | function SelectionFilter( entityList ) { 9 | 10 | if (DESELECT_BUILDINGS) { 11 | if (entityList.length > 1 && IsMixedBuildingSelectionGroup(entityList) ){ 12 | $.Schedule(1/60, DeselectBuildings) 13 | } 14 | } 15 | 16 | else if (SELECT_ONLY_BUILDINGS) { 17 | if (entityList.length > 1 && IsMixedBuildingSelectionGroup(entityList) ){ 18 | $.Schedule(1/60, SelectOnlyBuildings) 19 | } 20 | } 21 | 22 | if (DISPLAY_RANGE_PARTICLE) { 23 | var mainSelected = Players.GetLocalPlayerPortraitUnit(); 24 | 25 | // Remove old particle 26 | if (rangedParticle) 27 | Particles.DestroyParticleEffect(rangedParticle, true) 28 | 29 | // Create range display on the selected ranged attacker 30 | if (IsCustomBuilding(mainSelected) && Entities.HasAttackCapability(mainSelected)) 31 | { 32 | var range = Entities.GetAttackRange(mainSelected) 33 | rangedParticle = Particles.CreateParticle("particles/ui_mouseactions/range_display.vpcf", ParticleAttachment_t.PATTACH_CUSTOMORIGIN, mainSelected) 34 | var position = Entities.GetAbsOrigin(mainSelected) 35 | position[2] = 380 //Offset 36 | Particles.SetParticleControl(rangedParticle, 0, position) 37 | Particles.SetParticleControl(rangedParticle, 1, [range, 0, 0]) 38 | } 39 | } 40 | 41 | for (var i = 0; i < entityList.length; i++) { 42 | var overrideEntityIndex = GetSelectionOverride(entityList[i]) 43 | if (overrideEntityIndex != -1) { 44 | GameUI.SelectUnit(overrideEntityIndex, false); 45 | } 46 | }; 47 | } 48 | 49 | function DeselectBuildings() { 50 | var iPlayerID = Players.GetLocalPlayer(); 51 | var selectedEntities = Players.GetSelectedEntities( iPlayerID ); 52 | 53 | skip = true; 54 | var first = FirstNonBuildingEntityFromSelection(selectedEntities) 55 | GameUI.SelectUnit(first, false); // Overrides the selection group 56 | 57 | for (var unit of selectedEntities) { 58 | skip = true; // Makes it skip an update 59 | if (!IsCustomBuilding(unit) && unit != first){ 60 | GameUI.SelectUnit(unit, true); 61 | } 62 | } 63 | } 64 | 65 | function FirstNonBuildingEntityFromSelection( entityList ){ 66 | for (var i = 0; i < entityList.length; i++) { 67 | if (!IsCustomBuilding(entityList[i])){ 68 | return entityList[i] 69 | } 70 | } 71 | return 0 72 | } 73 | 74 | function GetFirstUnitFromSelectionSkipUnit ( entityList, entIndex ) { 75 | for (var i = 0; i < entityList.length; i++) { 76 | if ((entityList[i]) != entIndex){ 77 | return entityList[i] 78 | } 79 | } 80 | return 0 81 | } 82 | 83 | // Returns whether the selection group contains both buildings and non-building units 84 | function IsMixedBuildingSelectionGroup ( entityList ) { 85 | var buildings = 0 86 | var nonBuildings = 0 87 | for (var i = 0; i < entityList.length; i++) { 88 | if (IsCustomBuilding(entityList[i])){ 89 | buildings++ 90 | } 91 | else { 92 | nonBuildings++ 93 | } 94 | } 95 | return (buildings>0 && nonBuildings>0) 96 | } 97 | 98 | function SelectOnlyBuildings() { 99 | var iPlayerID = Players.GetLocalPlayer(); 100 | var selectedEntities = Players.GetSelectedEntities( iPlayerID ); 101 | 102 | skip = true; 103 | var first = FirstBuildingEntityFromSelection(selectedEntities) 104 | GameUI.SelectUnit(first, false); // Overrides the selection group 105 | 106 | for (var unit of selectedEntities) { 107 | skip = true; // Makes it skip an update 108 | if (IsCustomBuilding(unit) && unit != first){ 109 | GameUI.SelectUnit(unit, true); 110 | } 111 | } 112 | } 113 | 114 | function FirstBuildingEntityFromSelection( entityList ){ 115 | for (var i = 0; i < entityList.length; i++) { 116 | if (IsCustomBuilding(entityList[i])){ 117 | return entityList[i] 118 | } 119 | } 120 | return 0 121 | } 122 | 123 | function IsCustomBuilding( entityIndex ){ 124 | var ability_building = Entities.GetAbilityByName( entityIndex, "ability_building") 125 | var ability_tower = Entities.GetAbilityByName( entityIndex, "ability_tower") 126 | return (ability_building != -1 || ability_tower != -1) 127 | } 128 | 129 | function IsMechanical( entityIndex ) { 130 | var ability_siege = Entities.GetAbilityByName( entityIndex, "ability_siege") 131 | return (ability_siege != -1) 132 | } 133 | 134 | function IsCityCenter( entityIndex ){ 135 | return (Entities.GetUnitLabel( entityIndex ) == "city_center") 136 | } 137 | -------------------------------------------------------------------------------- /scripts/vscripts/builder.lua: -------------------------------------------------------------------------------- 1 | -- A build ability is used (not yet confirmed) 2 | function Build( event ) 3 | local caster = event.caster 4 | local ability = event.ability 5 | local ability_name = ability:GetAbilityName() 6 | local building_name = ability:GetAbilityKeyValues()['UnitName'] 7 | local gold_cost = ability:GetGoldCost(1) 8 | local hero = caster:IsRealHero() and caster or caster:GetOwner() 9 | local playerID = hero:GetPlayerID() 10 | 11 | -- If the ability has an AbilityGoldCost, it's impossible to not have enough gold the first time it's cast 12 | -- Always refund the gold here, as the building hasn't been placed yet 13 | hero:ModifyGold(gold_cost, false, 0) 14 | 15 | -- Makes a building dummy and starts panorama ghosting 16 | BuildingHelper:AddBuilding(event) 17 | 18 | -- Additional checks to confirm a valid building position can be performed here 19 | event:OnPreConstruction(function(vPos) 20 | 21 | -- Check for minimum height if defined 22 | if not BuildingHelper:MeetsHeightCondition(vPos) then 23 | BuildingHelper:print("Failed placement of " .. building_name .." - Placement is below the min height required") 24 | SendErrorMessage(playerID, "#error_invalid_build_position") 25 | return false 26 | end 27 | 28 | -- If not enough resources to queue, stop 29 | if PlayerResource:GetGold(playerID) < gold_cost then 30 | BuildingHelper:print("Failed placement of " .. building_name .." - Not enough gold!") 31 | SendErrorMessage(playerID, "#error_not_enough_gold") 32 | return false 33 | end 34 | 35 | return true 36 | end) 37 | 38 | -- Position for a building was confirmed and valid 39 | event:OnBuildingPosChosen(function(vPos) 40 | -- Spend resources 41 | hero:ModifyGold(-gold_cost, false, 0) 42 | 43 | -- Play a sound 44 | EmitSoundOnClient("DOTA_Item.ObserverWard.Activate", PlayerResource:GetPlayer(playerID)) 45 | end) 46 | 47 | -- The construction failed and was never confirmed due to the gridnav being blocked in the attempted area 48 | event:OnConstructionFailed(function() 49 | local playerTable = BuildingHelper:GetPlayerTable(playerID) 50 | local building_name = playerTable.activeBuilding 51 | 52 | BuildingHelper:print("Failed placement of " .. building_name) 53 | end) 54 | 55 | -- Cancelled due to ClearQueue 56 | event:OnConstructionCancelled(function(work) 57 | local building_name = work.name 58 | BuildingHelper:print("Cancelled construction of " .. building_name) 59 | 60 | -- Refund resources for this cancelled work 61 | if work.refund then 62 | hero:ModifyGold(gold_cost, false, 0) 63 | end 64 | end) 65 | 66 | -- A building unit was created 67 | event:OnConstructionStarted(function(unit) 68 | BuildingHelper:print("Started construction of " .. unit:GetUnitName() .. " " .. unit:GetEntityIndex()) 69 | -- Play construction sound 70 | 71 | -- If it's an item-ability and has charges, remove a charge or remove the item if no charges left 72 | if ability.GetCurrentCharges and not ability:IsPermanent() then 73 | local charges = ability:GetCurrentCharges() 74 | charges = charges-1 75 | if charges == 0 then 76 | ability:RemoveSelf() 77 | else 78 | ability:SetCurrentCharges(charges) 79 | end 80 | end 81 | 82 | -- Units can't attack while building 83 | unit.original_attack = unit:GetAttackCapability() 84 | unit:SetAttackCapability(DOTA_UNIT_CAP_NO_ATTACK) 85 | 86 | -- Give item to cancel 87 | unit.item_building_cancel = CreateItem("item_building_cancel", hero, hero) 88 | if unit.item_building_cancel then 89 | unit:AddItem(unit.item_building_cancel) 90 | unit.gold_cost = gold_cost 91 | end 92 | 93 | -- FindClearSpace for the builder 94 | FindClearSpaceForUnit(caster, caster:GetAbsOrigin(), true) 95 | caster:AddNewModifier(caster, nil, "modifier_phased", {duration=0.03}) 96 | 97 | -- Remove invulnerability on npc_dota_building baseclass 98 | unit:RemoveModifierByName("modifier_invulnerable") 99 | end) 100 | 101 | -- A building finished construction 102 | event:OnConstructionCompleted(function(unit) 103 | BuildingHelper:print("Completed construction of " .. unit:GetUnitName() .. " " .. unit:GetEntityIndex()) 104 | 105 | -- Play construction complete sound 106 | 107 | -- Remove the item 108 | if unit.item_building_cancel then 109 | UTIL_Remove(unit.item_building_cancel) 110 | end 111 | 112 | -- Give the unit their original attack capability 113 | unit:SetAttackCapability(unit.original_attack) 114 | 115 | end) 116 | 117 | -- These callbacks will only fire when the state between below half health/above half health changes. 118 | -- i.e. it won't fire multiple times unnecessarily. 119 | event:OnBelowHalfHealth(function(unit) 120 | BuildingHelper:print(unit:GetUnitName() .. " is below half health.") 121 | end) 122 | 123 | event:OnAboveHalfHealth(function(unit) 124 | BuildingHelper:print(unit:GetUnitName().. " is above half health.") 125 | end) 126 | end 127 | 128 | -- Called when the Cancel ability-item is used 129 | function CancelBuilding( keys ) 130 | local building = keys.unit 131 | local hero = building:GetOwner() 132 | local playerID = building:GetPlayerOwnerID() 133 | 134 | BuildingHelper:print("CancelBuilding "..building:GetUnitName().." "..building:GetEntityIndex()) 135 | 136 | -- Refund here 137 | if building.gold_cost then 138 | hero:ModifyGold(building.gold_cost, false, 0) 139 | end 140 | 141 | -- Eject builder 142 | local builder = building.builder_inside 143 | if builder then 144 | BuildingHelper:ShowBuilder(builder) 145 | end 146 | 147 | building:ForceKill(true) --This will call RemoveBuilding 148 | end 149 | 150 | -- Requires notifications library from bmddota/barebones 151 | function SendErrorMessage( pID, string ) 152 | Notifications:ClearBottom(pID) 153 | Notifications:Bottom(pID, {text=string, style={color='#E62020'}, duration=2}) 154 | EmitSoundOnClient("General.Cancel", PlayerResource:GetPlayer(pID)) 155 | end 156 | -------------------------------------------------------------------------------- /scripts/vscripts/libraries/selection.lua: -------------------------------------------------------------------------------- 1 | SELECTION_VERSION = "1.00" 2 | 3 | --[[ 4 | Lua-controlled Selection Library by Noya 5 | 6 | Installation: 7 | - "require" this file inside your code in order to add the new API functions to the PlayerResource global 8 | - Additionally, ensure your game scripts custom_net_tables.txt has a "selection" entry 9 | - Finally, ensure that you have the following files correctly added and included in your panorama content folder 10 | selection.xml, and include line on custom_ui_manifest.xml, on layout/custom_game/ folder 11 | selection folder containing selection.js and selection_filter.js, on /scripts/ folder 12 | 13 | Usage: 14 | - Functions with unit_args can recieve an Entity Index, a NPC Handle, or a table of each type. 15 | - Functions with unit can recieve an Entity Index or NPC Handle 16 | 17 | * Create a new selection for the player 18 | PlayerResource:NewSelection(playerID, unit_args) 19 | 20 | * Add units to the current selection of the player 21 | PlayerResource:AddToSelection(playerID, unit_args) 22 | 23 | * Remove units by index from the player selection group 24 | PlayerResource:RemoveFromSelection(playerID, unit_args) 25 | 26 | * Returns the list of units by entity index that are selected by the player 27 | PlayerResource:GetSelectedEntities(playerID) 28 | 29 | * Deselect everything, selecting the main hero (which can be redirected to another entity) 30 | PlayerResource:ResetSelection(playerID) 31 | 32 | * Get the index of the first selected unit of the player 33 | PlayerResource:GetMainSelectedEntity(playerID) 34 | 35 | * Check if a unit is selected or not by a player, returns bool 36 | PlayerResource:IsUnitSelected(playerID, unit_args) 37 | 38 | * Force a refresh of the current selection on all players, useful after abilities are removed 39 | PlayerResource:RefreshSelection() 40 | 41 | * Redirects the selection of the main hero to another entity of choice 42 | PlayerResource:SetDefaultSelectionEntity(playerID, unit) 43 | 44 | * Redirects the selection of any entity to another entity of choice 45 | hero:SetSelectionOverride(unit) 46 | 47 | * Use -1 to reset to default 48 | PlayerResource:SetDefaultSelectionEntity(playerID, -1) 49 | hero:SetSelectionOverride(-1) 50 | 51 | Notes: 52 | - Enemy units that you don't control can't be added to the selection group of a player 53 | - This library requires "libraries/timers.lua" to be present in your vscripts directory. 54 | 55 | --]] 56 | 57 | function CDOTA_PlayerResource:NewSelection(playerID, unit_args) 58 | local player = self:GetPlayer(playerID) 59 | if player then 60 | local entities = Selection:GetEntIndexListFromTable(unit_args) 61 | CustomGameEventManager:Send_ServerToPlayer(player, "selection_new", {entities = entities}) 62 | end 63 | end 64 | 65 | function CDOTA_PlayerResource:AddToSelection(playerID, unit_args) 66 | local player = self:GetPlayer(playerID) 67 | if player then 68 | local entities = Selection:GetEntIndexListFromTable(unit_args) 69 | CustomGameEventManager:Send_ServerToPlayer(player, "selection_add", {entities = entities}) 70 | end 71 | end 72 | 73 | function CDOTA_PlayerResource:RemoveFromSelection(playerID, unit_args) 74 | local player = self:GetPlayer(playerID) 75 | if player then 76 | local entities = Selection:GetEntIndexListFromTable(unit_args) 77 | CustomGameEventManager:Send_ServerToPlayer(player, "selection_remove", {entities = entities}) 78 | end 79 | end 80 | 81 | function CDOTA_PlayerResource:ResetSelection(playerID) 82 | local player = self:GetPlayer(playerID) 83 | if player then 84 | CustomGameEventManager:Send_ServerToPlayer(player, "selection_reset", {}) 85 | end 86 | end 87 | 88 | function CDOTA_PlayerResource:GetSelectedEntities(playerID) 89 | return Selection.entities[playerID] or {} 90 | end 91 | 92 | function CDOTA_PlayerResource:GetMainSelectedEntity(playerID) 93 | local selectedEntities = self:GetSelectedEntities(playerID) 94 | return selectedEntities and selectedEntities["0"] 95 | end 96 | 97 | function CDOTA_PlayerResource:IsUnitSelected(playerID, unit) 98 | if not unit then return false end 99 | local entIndex = type(unit)=="number" and unit or IsValidEntity(unit) and unit:GetEntityIndex() 100 | if not entIndex then return false end 101 | 102 | local selectedEntities = self:GetSelectedEntities(playerID) 103 | for _,v in pairs(selectedEntities) do 104 | if v==entIndex then 105 | return true 106 | end 107 | end 108 | return false 109 | end 110 | 111 | function CDOTA_PlayerResource:RefreshSelection() 112 | Timers:CreateTimer(0.03, function() 113 | FireGameEvent("dota_player_update_selected_unit", {}) 114 | end) 115 | end 116 | 117 | function CDOTA_PlayerResource:SetDefaultSelectionEntity(playerID, unit) 118 | if not unit then unit = -1 end 119 | local entIndex = type(unit)=="number" and unit or unit:GetEntityIndex() 120 | local hero = self:GetSelectedHeroEntity(playerID) 121 | if hero then 122 | hero:SetSelectionOverride(unit) 123 | end 124 | end 125 | 126 | function CDOTA_BaseNPC:SetSelectionOverride(reselect_unit) 127 | local unit = self 128 | local reselectIndex = type(reselect_unit)=="number" and reselect_unit or reselect_unit:GetEntityIndex() 129 | 130 | CustomNetTables:SetTableValue("selection", tostring(unit:GetEntityIndex()), {entity = reselectIndex}) 131 | end 132 | 133 | ------------------------------------------------------------------------ 134 | -- Internal 135 | ------------------------------------------------------------------------ 136 | 137 | require('libraries/timers') 138 | 139 | if not Selection then 140 | Selection = class({}) 141 | end 142 | 143 | function Selection:Init() 144 | Selection.entities = {} --Stores the selected entities of each playerID 145 | CustomGameEventManager:RegisterListener("selection_update", Dynamic_Wrap(Selection, 'OnUpdate')) 146 | end 147 | 148 | function Selection:OnUpdate(event) 149 | local playerID = event.PlayerID 150 | Selection.entities[playerID] = event.entities 151 | end 152 | 153 | -- Internal function to build an entity index list out of various inputs 154 | function Selection:GetEntIndexListFromTable(unit_args) 155 | local entities = {} 156 | if type(unit_args)=="number" then 157 | table.insert(entities, unit_args) -- Entity Index 158 | -- Check contents of the table 159 | elseif type(unit_args)=="table" then 160 | if unit_args.IsCreature then 161 | table.insert(entities, unit_args:GetEntityIndex()) -- NPC Handle 162 | else 163 | for _,arg in pairs(unit_args) do 164 | -- Table of entity index values 165 | if type(arg)=="number" then 166 | table.insert(entities, arg) 167 | -- Table of npc handles 168 | elseif type(arg)=="table" then 169 | if arg.IsCreature then 170 | table.insert(entities, arg:GetEntityIndex()) 171 | end 172 | end 173 | end 174 | end 175 | end 176 | return entities 177 | end 178 | 179 | if not Selection.entities then Selection:Init() end -------------------------------------------------------------------------------- /scripts/vscripts/libraries/keyvalues.lua: -------------------------------------------------------------------------------- 1 | KEYVALUES_VERSION = "1.00" 2 | 3 | -- Change to false to skip loading the base files 4 | LOAD_BASE_FILES = false 5 | 6 | --[[ 7 | Simple Lua KeyValues library 8 | Author: Martin Noya // github.com/MNoya 9 | 10 | Installation: 11 | - require this file inside your code 12 | 13 | Usage: 14 | - Your npc custom files will be validated on require, error will occur if one is missing or has faulty syntax. 15 | - This allows to safely grab key-value definitions in npc custom abilities/items/units/heroes 16 | 17 | "some_custom_entry" 18 | { 19 | "CustomName" "Barbarian" 20 | "CustomKey" "1" 21 | "CustomStat" "100 200" 22 | } 23 | 24 | With a handle: 25 | handle:GetKeyValue() -- returns the whole table based on the handles baseclass 26 | handle:GetKeyValue("CustomName") -- returns "Barbarian" 27 | handle:GetKeyValue("CustomKey") -- returns 1 (number) 28 | handle:GetKeyValue("CustomStat") -- returns "100 200" (string) 29 | handle:GetKeyValue("CustomStat", 2) -- returns 200 (number) 30 | 31 | Same results with strings: 32 | GetKeyValue("some_custom_entry") 33 | GetKeyValue("some_custom_entry", "CustomName") 34 | GetKeyValue("some_custom_entry", "CustomStat") 35 | GetKeyValue("some_custom_entry", "CustomStat", 2) 36 | 37 | - Ability Special value grabbing: 38 | 39 | "some_custom_ability" 40 | { 41 | "AbilitySpecial" 42 | { 43 | "01" 44 | { 45 | "var_type" "FIELD_INTEGER" 46 | "some_key" "-3 -4 -5" 47 | } 48 | } 49 | } 50 | 51 | With a handle: 52 | ability:GetAbilitySpecial("some_key") -- returns based on the level of the ability/item 53 | 54 | With string: 55 | GetAbilitySpecial("some_custom_ability", "some_key") -- returns "-3 -4 -5" (string) 56 | GetAbilitySpecial("some_custom_ability", "some_key", 2) -- returns -4 (number) 57 | 58 | Notes: 59 | - In case a key can't be matched, the returned value will be nil 60 | - Don't identify your custom units/heroes with the same name or it will only grab one of them. 61 | ]] 62 | 63 | if not KeyValues then 64 | KeyValues = {} 65 | end 66 | 67 | local split = function(inputstr, sep) 68 | if sep == nil then sep = "%s" end 69 | local t={} ; i=1 70 | for str in string.gmatch(inputstr, "([^"..sep.."]+)") do 71 | t[i] = str 72 | i = i + 1 73 | end 74 | return t 75 | end 76 | 77 | -- Load all the necessary key value files 78 | function LoadGameKeyValues() 79 | local scriptPath ="scripts/npc/" 80 | local override = LoadKeyValues(scriptPath.."npc_abilities_override.txt") 81 | local files = { AbilityKV = {base="npc_abilities",custom="npc_abilities_custom"}, 82 | ItemKV = {base="items",custom="npc_items_custom"}, 83 | UnitKV = {base="npc_units",custom="npc_units_custom"}, 84 | HeroKV = {base="npc_heroes",custom="npc_heroes_custom"} 85 | } 86 | 87 | -- Load and validate the files 88 | for k,v in pairs(files) do 89 | local file = {} 90 | if LOAD_BASE_FILES then 91 | file = LoadKeyValues(scriptPath..v.base..".txt") 92 | end 93 | 94 | -- Replace main game keys by any match on the override file 95 | for k,v in pairs(override) do 96 | if file[k] then 97 | file[k] = v 98 | end 99 | end 100 | 101 | local custom_file = LoadKeyValues(scriptPath..v.custom..".txt") 102 | if custom_file then 103 | for k,v in pairs(custom_file) do 104 | file[k] = v 105 | end 106 | else 107 | print("[KeyValues] Critical Error on "..v.custom..".txt") 108 | return 109 | end 110 | 111 | GameRules[k] = file --backwards compatibility 112 | KeyValues[k] = file 113 | end 114 | 115 | -- Merge All KVs 116 | KeyValues.All = {} 117 | for name,path in pairs(files) do 118 | for key,value in pairs(KeyValues[name]) do 119 | if not KeyValues.All[key] then 120 | KeyValues.All[key] = value 121 | end 122 | end 123 | end 124 | 125 | -- Merge units and heroes (due to them sharing the same class CDOTA_BaseNPC) 126 | for key,value in pairs(KeyValues.HeroKV) do 127 | if not KeyValues.UnitKV[key] then 128 | KeyValues.UnitKV[key] = value 129 | else 130 | if type(KeyValues.All[key]) == "table" then 131 | print("[KeyValues] Warning: Duplicated unit/hero entry for "..key) 132 | end 133 | end 134 | end 135 | end 136 | 137 | -- Works for heroes and units on the same table due to merging both tables on game init 138 | function CDOTA_BaseNPC:GetKeyValue(key, level) 139 | if level then return GetUnitKV(self:GetUnitName(), key, level) 140 | else return GetUnitKV(self:GetUnitName(), key) end 141 | end 142 | 143 | -- Dynamic version of CDOTABaseAbility:GetAbilityKeyValues() 144 | function CDOTABaseAbility:GetKeyValue(key, level) 145 | if level then return GetAbilityKV(self:GetAbilityName(), key, level) 146 | else return GetAbilityKV(self:GetAbilityName(), key) end 147 | end 148 | 149 | -- Item version 150 | function CDOTA_Item:GetKeyValue(key, level) 151 | if level then return GetItemKV(self:GetAbilityName(), key, level) 152 | else return GetItemKV(self:GetAbilityName(), key) end 153 | end 154 | 155 | function CDOTABaseAbility:GetAbilitySpecial(key) 156 | return GetAbilitySpecial(self:GetAbilityName(), key, self:GetLevel()) 157 | end 158 | 159 | -- Global functions 160 | -- Key is optional, returns the whole table by omission 161 | -- Level is optional, returns the whole value by omission 162 | function GetKeyValue(name, key, level, tbl) 163 | local t = tbl or KeyValues.All[name] 164 | if key and t then 165 | if t[key] and level then 166 | local s = split(t[key]) 167 | if s[level] then return tonumber(s[level]) or s[level] -- Try to cast to number 168 | else return tonumber(s[#s]) or s[#s] end 169 | else return t[key] end 170 | else return t end 171 | end 172 | 173 | function GetUnitKV(unitName, key, level) 174 | return GetKeyValue(unitName, key, level, KeyValues.UnitKV[unitName]) 175 | end 176 | 177 | function GetAbilityKV(abilityName, key, level) 178 | return GetKeyValue(abilityName, key, level, KeyValues.AbilityKV[abilityName]) 179 | end 180 | 181 | function GetItemKV(itemName, key, level) 182 | return GetKeyValue(itemName, key, level, KeyValues.ItemKV[itemName]) 183 | end 184 | 185 | function GetAbilitySpecial(name, key, level) 186 | local t = KeyValues.All[name] 187 | if key and t then 188 | local tspecial = t["AbilitySpecial"] 189 | if tspecial then 190 | -- Find the key we are looking for 191 | for _,values in pairs(tspecial) do 192 | if values[key] then 193 | if not level then return values[key] 194 | else 195 | local s = split(values[key]) 196 | if s[level] then return tonumber(s[level]) -- If we match the level, return that one 197 | else return tonumber(s[#s]) end -- Otherwise, return the max 198 | end 199 | break 200 | end 201 | end 202 | end 203 | else return t end 204 | end 205 | 206 | if not KeyValues.All then LoadGameKeyValues() end -------------------------------------------------------------------------------- /particles/buildinghelper/square_projected.vpcf: -------------------------------------------------------------------------------- 1 | 2 | CParticleSystemDefinition CParticleSystemDefinition_0 3 | { 4 | int m_nInitialParticles = 0 5 | float(3) m_BoundingBoxMin = ( -10.000000, -10.000000, -10.000000 ) 6 | float(3) m_BoundingBoxMax = ( 10.000000, 10.000000, 10.000000 ) 7 | int m_nSnapshotControlPoint = 0 8 | string m_pszSnapshotName = "" 9 | string m_pszTargetLayerID = "" 10 | string m_hReferenceReplacement = "" 11 | string m_pszCullReplacementName = "" 12 | float m_flCullRadius = -1.000000 13 | float m_flCullFillCost = 1.000000 14 | int m_nCullControlPoint = 0 15 | float m_flMaxRecreationTime = 0.000000 16 | string m_hFallback = "" 17 | int m_nFallbackMaxCount = -1 18 | string m_hLowViolenceDef = "" 19 | uint(4) m_ConstantColor = ( 255, 255, 255, 255 ) 20 | float(3) m_ConstantNormal = ( 0.000000, 0.000000, 1.000000 ) 21 | float m_flConstantRadius = 64.000000 22 | float m_flConstantRotation = 0.000000 23 | float m_flConstantRotationSpeed = 0.000000 24 | float m_flConstantLifespan = 1.000000 25 | int m_nConstantSequenceNumber = 0 26 | int m_nConstantSequenceNumber1 = 0 27 | int m_nGroupID = 0 28 | float m_flMaximumTimeStep = 0.100000 29 | float m_flMaximumSimTime = 0.000000 30 | float m_flMinimumSimTime = 0.000000 31 | float m_flMinimumTimeStep = 0.000000 32 | int m_nMinimumFrames = 0 33 | int m_nMinCPULevel = 0 34 | int m_nMinGPULevel = 0 35 | bool m_bViewModelEffect = false 36 | bool m_bScreenSpaceEffect = false 37 | float m_flMaxDrawDistance = 100000.000000 38 | float m_flStartFadeDistance = 200000.000000 39 | float m_flNoDrawTimeToGoToSleep = 8.000000 40 | int m_nMaxParticles = 4 41 | int m_nSkipRenderControlPoint = -1 42 | int m_nAllowRenderControlPoint = -1 43 | int m_nAggregationMinAvailableParticles = 0 44 | float m_flAggregateRadius = 0.000000 45 | float m_flStopSimulationAfterTime = 1000000000.000000 46 | float(3) m_vControlPoint1DefaultOffsetRelativeToControlPoint0 = ( 0.000000, 0.000000, 0.000000 ) 47 | string m_Name = "" 48 | ParticleChildrenInfo_t[] m_Children = 49 | [ 50 | 51 | ] 52 | bool m_bShouldSort = true 53 | bool m_bShouldBatch = false 54 | float m_flDepthSortBias = 0.000000 55 | bool m_bShouldHitboxesFallbackToRenderBounds = true 56 | CParticleOperatorInstance*[] m_Operators = 57 | [ 58 | &C_OP_Decay_0, 59 | &C_OP_PositionLock_0, 60 | &C_OP_RemapCPtoVector_0 61 | ] 62 | CParticleOperatorInstance*[] m_Renderers = 63 | [ 64 | &C_OP_RenderSprites_0, 65 | &C_OP_RenderProjected_0 66 | ] 67 | CParticleOperatorInstance*[] m_Initializers = 68 | [ 69 | &C_INIT_RemapCPtoScalar_0, 70 | &C_INIT_CreateWithinSphere_0, 71 | &C_INIT_RandomLifeTime_0, 72 | &C_INIT_RemapCPtoVector_0, 73 | &C_INIT_PositionPlaceOnGround_0, 74 | &C_INIT_RemapCPtoScalar_6 75 | ] 76 | CParticleOperatorInstance*[] m_Emitters = 77 | [ 78 | &C_OP_InstantaneousEmitter_0 79 | ] 80 | CParticleOperatorInstance*[] m_ForceGenerators = 81 | [ 82 | 83 | ] 84 | CParticleOperatorInstance*[] m_Constraints = 85 | [ 86 | 87 | ] 88 | } 89 | 90 | C_OP_Decay C_OP_Decay_0 91 | { 92 | float m_flOpStartFadeInTime = 0.000000 93 | float m_flOpEndFadeInTime = 0.000000 94 | float m_flOpStartFadeOutTime = 0.000000 95 | float m_flOpEndFadeOutTime = 0.000000 96 | float m_flOpFadeOscillatePeriod = 0.000000 97 | float m_flOpTimeOffsetMin = 0.000000 98 | float m_flOpTimeOffsetMax = 0.000000 99 | int m_nOpTimeOffsetSeed = 0 100 | int m_nOpStrengthScaleSeed = 0 101 | float m_flOpStrengthMinScale = 1.000000 102 | float m_flOpStrengthMaxScale = 1.000000 103 | int m_nOpTimeScaleSeed = 0 104 | float m_flOpTimeScaleMin = 1.000000 105 | float m_flOpTimeScaleMax = 1.000000 106 | bool m_bDisableOperator = true 107 | int m_nOpEndCapState = -1 108 | int m_nOpScaleCP = -1 109 | string m_Notes = "" 110 | } 111 | 112 | C_OP_PositionLock C_OP_PositionLock_0 113 | { 114 | int m_nControlPointNumber = 0 115 | float m_flStartTime_min = 1.000000 116 | float m_flStartTime_max = 1.000000 117 | float m_flStartTime_exp = 1.000000 118 | float m_flEndTime_min = 1.000000 119 | float m_flEndTime_max = 1.000000 120 | float m_flEndTime_exp = 1.000000 121 | float m_flRange = 0.000000 122 | float m_flJumpThreshold = 512.000000 123 | float m_flPrevPosScale = 1.000000 124 | bool m_bLockRot = false 125 | float m_flOpStartFadeInTime = 0.000000 126 | float m_flOpEndFadeInTime = 0.000000 127 | float m_flOpStartFadeOutTime = 0.000000 128 | float m_flOpEndFadeOutTime = 0.000000 129 | float m_flOpFadeOscillatePeriod = 0.000000 130 | float m_flOpTimeOffsetMin = 0.000000 131 | float m_flOpTimeOffsetMax = 0.000000 132 | int m_nOpTimeOffsetSeed = 0 133 | int m_nOpStrengthScaleSeed = 0 134 | float m_flOpStrengthMinScale = 1.000000 135 | float m_flOpStrengthMaxScale = 1.000000 136 | int m_nOpTimeScaleSeed = 0 137 | float m_flOpTimeScaleMin = 1.000000 138 | float m_flOpTimeScaleMax = 1.000000 139 | bool m_bDisableOperator = false 140 | int m_nOpEndCapState = -1 141 | int m_nOpScaleCP = -1 142 | string m_Notes = "" 143 | } 144 | 145 | C_OP_RemapCPtoVector C_OP_RemapCPtoVector_0 146 | { 147 | int m_nCPInput = 2 148 | int m_nFieldOutput = 6 149 | int m_nLocalSpaceCP = -1 150 | float(3) m_vInputMin = ( 0.000000, 0.000000, 0.000000 ) 151 | float(3) m_vInputMax = ( 255.000000, 255.000000, 255.000000 ) 152 | float(3) m_vOutputMin = ( 0.000000, 0.000000, 0.000000 ) 153 | float(3) m_vOutputMax = ( 1.000000, 1.000000, 1.000000 ) 154 | float m_flStartTime = -1.000000 155 | float m_flEndTime = -1.000000 156 | float m_flInterpRate = 0.000000 157 | bool m_bScaleInitialRange = false 158 | bool m_bScaleCurrent = false 159 | bool m_bOffset = false 160 | bool m_bAccelerate = false 161 | float m_flOpStartFadeInTime = 0.000000 162 | float m_flOpEndFadeInTime = 0.000000 163 | float m_flOpStartFadeOutTime = 0.000000 164 | float m_flOpEndFadeOutTime = 0.000000 165 | float m_flOpFadeOscillatePeriod = 0.000000 166 | float m_flOpTimeOffsetMin = 0.000000 167 | float m_flOpTimeOffsetMax = 0.000000 168 | int m_nOpTimeOffsetSeed = 0 169 | int m_nOpStrengthScaleSeed = 0 170 | float m_flOpStrengthMinScale = 1.000000 171 | float m_flOpStrengthMaxScale = 1.000000 172 | int m_nOpTimeScaleSeed = 0 173 | float m_flOpTimeScaleMin = 1.000000 174 | float m_flOpTimeScaleMax = 1.000000 175 | bool m_bDisableOperator = false 176 | int m_nOpEndCapState = -1 177 | int m_nOpScaleCP = -1 178 | string m_Notes = "" 179 | } 180 | 181 | C_OP_RenderSprites C_OP_RenderSprites_0 182 | { 183 | int m_nSequenceOverride = -1 184 | int m_nOrientationType = 2 185 | int m_nOrientationControlPoint = -1 186 | float m_flMinSize = 0.000000 187 | float m_flMaxSize = 5000.000000 188 | float m_flStartFadeSize = 100000000.000000 189 | float m_flEndFadeSize = 200000000.000000 190 | float m_flStartFadeDot = 1.000000 191 | float m_flEndFadeDot = 2.000000 192 | float m_flDepthBias = 0.000000 193 | float m_flFinalTextureScaleU = 1.000000 194 | float m_flFinalTextureScaleV = 1.000000 195 | float m_flFinalTextureOffsetU = 0.000000 196 | float m_flFinalTextureOffsetV = 0.000000 197 | float m_flCenterXOffset = 0.000000 198 | float m_flCenterYOffset = 0.000000 199 | float m_flZoomAmount0 = 1.000000 200 | float m_flZoomAmount1 = 1.000000 201 | bool m_bDistanceAlpha = false 202 | bool m_bSoftEdges = false 203 | float m_flEdgeSoftnessStart = 0.600000 204 | float m_flEdgeSoftnessEnd = 0.500000 205 | bool m_bOutline = false 206 | uint(4) m_OutlineColor = ( 255, 255, 255, 255 ) 207 | int m_nOutlineAlpha = 255 208 | float m_flOutlineStart0 = 0.500000 209 | float m_flOutlineStart1 = 0.600000 210 | float m_flOutlineEnd0 = 0.700000 211 | float m_flOutlineEnd1 = 0.800000 212 | float m_flAnimationRate = 0.100000 213 | bool m_bFitCycleToLifetime = false 214 | bool m_bAnimateInFPS = false 215 | bool m_bPerVertexLighting = false 216 | float m_flSelfIllumAmount = 0.000000 217 | float m_flDiffuseAmount = 1.000000 218 | float m_flSourceAlphaValueToMapToZero = 0.000000 219 | float m_flSourceAlphaValueToMapToOne = 1.000000 220 | bool m_bGammaCorrectVertexColors = true 221 | bool m_bSaturateColorPreAlphaBlend = true 222 | symbol m_nSequenceCombineMode = 0 223 | float m_flAnimationRate2 = 0.000000 224 | float m_flSequence0RGBWeight = 0.500000 225 | float m_flSequence0AlphaWeight = 0.500000 226 | float m_flSequence1RGBWeight = 0.500000 227 | float m_flSequence1AlphaWeight = 0.500000 228 | float m_flAddSelfAmount = 0.000000 229 | bool m_bAdditive = false 230 | bool m_bMod2X = false 231 | bool m_bMaxLuminanceBlendingSequence0 = false 232 | bool m_bMaxLuminanceBlendingSequence1 = false 233 | bool m_bRefract = false 234 | float m_flRefractAmount = 1.000000 235 | int m_nRefractBlurRadius = 0 236 | symbol m_nRefractBlurType = 0 237 | string m_stencilTestID = "" 238 | string m_stencilWriteID = "" 239 | bool m_bWriteStencilOnDepthPass = true 240 | bool m_bWriteStencilOnDepthFail = false 241 | bool m_bReverseZBuffering = false 242 | bool m_bDisableZBuffering = false 243 | bool m_bParticleFeathering = false 244 | float m_flFeatheringMinDist = 0.000000 245 | float m_flFeatheringMaxDist = 15.000000 246 | float m_flOverbrightFactor = 1.000000 247 | string m_hTexture = "materials/particle/particle_whitebox.vtex" 248 | CParticleVisibilityInputs VisibilityInputs = CParticleVisibilityInputs 249 | { 250 | float m_flCameraBias = 0.000000 251 | float m_flInputMin = 0.000000 252 | float m_flInputMax = 0.000000 253 | float m_flAlphaScaleMin = 0.000000 254 | float m_flAlphaScaleMax = 1.000000 255 | float m_flRadiusScaleMin = 1.000000 256 | float m_flRadiusScaleMax = 1.000000 257 | float m_flRadiusScaleFOVBase = 0.000000 258 | float m_flProxyRadius = 1.000000 259 | float m_flDistanceInputMin = 0.000000 260 | float m_flDistanceInputMax = 0.000000 261 | float m_flDotInputMin = 0.000000 262 | float m_flDotInputMax = 0.000000 263 | float m_flNoPixelVisibilityFallback = 1.000000 264 | int m_nCPin = -1 265 | } 266 | float m_flOpStartFadeInTime = 0.000000 267 | float m_flOpEndFadeInTime = 0.000000 268 | float m_flOpStartFadeOutTime = 0.000000 269 | float m_flOpEndFadeOutTime = 0.000000 270 | float m_flOpFadeOscillatePeriod = 0.000000 271 | float m_flOpTimeOffsetMin = 0.000000 272 | float m_flOpTimeOffsetMax = 0.000000 273 | int m_nOpTimeOffsetSeed = 0 274 | int m_nOpStrengthScaleSeed = 0 275 | float m_flOpStrengthMinScale = 1.000000 276 | float m_flOpStrengthMaxScale = 1.000000 277 | int m_nOpTimeScaleSeed = 0 278 | float m_flOpTimeScaleMin = 1.000000 279 | float m_flOpTimeScaleMax = 1.000000 280 | bool m_bDisableOperator = true 281 | int m_nOpEndCapState = -1 282 | int m_nOpScaleCP = -1 283 | string m_Notes = "" 284 | } 285 | 286 | C_OP_RenderProjected C_OP_RenderProjected_0 287 | { 288 | bool m_bProjectCharacter = false 289 | bool m_bProjectWorld = true 290 | bool m_bProjectWater = true 291 | string m_hProjectedMaterial = "materials/particle/particle_whitebox_projected.vmat" 292 | CParticleVisibilityInputs VisibilityInputs = CParticleVisibilityInputs 293 | { 294 | float m_flCameraBias = 0.000000 295 | float m_flInputMin = 0.000000 296 | float m_flInputMax = 0.000000 297 | float m_flAlphaScaleMin = 0.000000 298 | float m_flAlphaScaleMax = 1.000000 299 | float m_flRadiusScaleMin = 1.000000 300 | float m_flRadiusScaleMax = 1.000000 301 | float m_flRadiusScaleFOVBase = 0.000000 302 | float m_flProxyRadius = 1.000000 303 | float m_flDistanceInputMin = 0.000000 304 | float m_flDistanceInputMax = 0.000000 305 | float m_flDotInputMin = 0.000000 306 | float m_flDotInputMax = 0.000000 307 | float m_flNoPixelVisibilityFallback = 1.000000 308 | int m_nCPin = -1 309 | } 310 | float m_flOpStartFadeInTime = 0.000000 311 | float m_flOpEndFadeInTime = 0.000000 312 | float m_flOpStartFadeOutTime = 0.000000 313 | float m_flOpEndFadeOutTime = 0.000000 314 | float m_flOpFadeOscillatePeriod = 0.000000 315 | float m_flOpTimeOffsetMin = 0.000000 316 | float m_flOpTimeOffsetMax = 0.000000 317 | int m_nOpTimeOffsetSeed = 0 318 | int m_nOpStrengthScaleSeed = 0 319 | float m_flOpStrengthMinScale = 1.000000 320 | float m_flOpStrengthMaxScale = 1.000000 321 | int m_nOpTimeScaleSeed = 0 322 | float m_flOpTimeScaleMin = 1.000000 323 | float m_flOpTimeScaleMax = 1.000000 324 | bool m_bDisableOperator = false 325 | int m_nOpEndCapState = -1 326 | int m_nOpScaleCP = -1 327 | string m_Notes = "" 328 | } 329 | 330 | C_INIT_RemapCPtoScalar C_INIT_RemapCPtoScalar_0 331 | { 332 | int m_nCPInput = 1 333 | int m_nFieldOutput = 3 334 | int m_nField = 0 335 | float m_flInputMin = 0.000000 336 | float m_flInputMax = 128.000000 337 | float m_flOutputMin = 0.000000 338 | float m_flOutputMax = 128.000000 339 | float m_flStartTime = -1.000000 340 | float m_flEndTime = -1.000000 341 | bool m_bScaleInitialRange = false 342 | bool m_bRunForParentApplyKillList = true 343 | float m_flOpStartFadeInTime = 0.000000 344 | float m_flOpEndFadeInTime = 0.000000 345 | float m_flOpStartFadeOutTime = 0.000000 346 | float m_flOpEndFadeOutTime = 0.000000 347 | float m_flOpFadeOscillatePeriod = 0.000000 348 | float m_flOpTimeOffsetMin = 0.000000 349 | float m_flOpTimeOffsetMax = 0.000000 350 | int m_nOpTimeOffsetSeed = 0 351 | int m_nOpStrengthScaleSeed = 0 352 | float m_flOpStrengthMinScale = 1.000000 353 | float m_flOpStrengthMaxScale = 1.000000 354 | int m_nOpTimeScaleSeed = 0 355 | float m_flOpTimeScaleMin = 1.000000 356 | float m_flOpTimeScaleMax = 1.000000 357 | bool m_bDisableOperator = false 358 | int m_nOpEndCapState = -1 359 | int m_nOpScaleCP = -1 360 | string m_Notes = "" 361 | } 362 | 363 | C_INIT_CreateWithinSphere C_INIT_CreateWithinSphere_0 364 | { 365 | float m_fRadiusMin = 0.000000 366 | float m_fRadiusMax = 0.000000 367 | float(3) m_vecDistanceBias = ( 1.000000, 1.000000, 1.000000 ) 368 | float(3) m_vecDistanceBiasAbs = ( 0.000000, 0.000000, 0.000000 ) 369 | int m_nControlPointNumber = 0 370 | int m_nScaleCP = -1 371 | float m_fSpeedMin = 0.000000 372 | float m_fSpeedMax = 0.000000 373 | float m_fSpeedRandExp = 1.000000 374 | bool m_bLocalCoords = false 375 | bool m_bUseHighestEndCP = false 376 | float m_flEndCPGrowthTime = 0.000000 377 | float(3) m_LocalCoordinateSystemSpeedMin = ( 0.000000, 0.000000, 0.000000 ) 378 | float(3) m_LocalCoordinateSystemSpeedMax = ( 0.000000, 0.000000, 0.000000 ) 379 | bool m_bRunForParentApplyKillList = true 380 | float m_flOpStartFadeInTime = 0.000000 381 | float m_flOpEndFadeInTime = 0.000000 382 | float m_flOpStartFadeOutTime = 0.000000 383 | float m_flOpEndFadeOutTime = 0.000000 384 | float m_flOpFadeOscillatePeriod = 0.000000 385 | float m_flOpTimeOffsetMin = 0.000000 386 | float m_flOpTimeOffsetMax = 0.000000 387 | int m_nOpTimeOffsetSeed = 0 388 | int m_nOpStrengthScaleSeed = 0 389 | float m_flOpStrengthMinScale = 1.000000 390 | float m_flOpStrengthMaxScale = 1.000000 391 | int m_nOpTimeScaleSeed = 0 392 | float m_flOpTimeScaleMin = 1.000000 393 | float m_flOpTimeScaleMax = 1.000000 394 | bool m_bDisableOperator = false 395 | int m_nOpEndCapState = -1 396 | int m_nOpScaleCP = -1 397 | string m_Notes = "" 398 | } 399 | 400 | C_INIT_RandomLifeTime C_INIT_RandomLifeTime_0 401 | { 402 | float m_fLifetimeMin = 1.000000 403 | float m_fLifetimeMax = 1.000000 404 | float m_fLifetimeRandExponent = 1.000000 405 | bool m_bRunForParentApplyKillList = true 406 | float m_flOpStartFadeInTime = 0.000000 407 | float m_flOpEndFadeInTime = 0.000000 408 | float m_flOpStartFadeOutTime = 0.000000 409 | float m_flOpEndFadeOutTime = 0.000000 410 | float m_flOpFadeOscillatePeriod = 0.000000 411 | float m_flOpTimeOffsetMin = 0.000000 412 | float m_flOpTimeOffsetMax = 0.000000 413 | int m_nOpTimeOffsetSeed = 0 414 | int m_nOpStrengthScaleSeed = 0 415 | float m_flOpStrengthMinScale = 1.000000 416 | float m_flOpStrengthMaxScale = 1.000000 417 | int m_nOpTimeScaleSeed = 0 418 | float m_flOpTimeScaleMin = 1.000000 419 | float m_flOpTimeScaleMax = 1.000000 420 | bool m_bDisableOperator = true 421 | int m_nOpEndCapState = -1 422 | int m_nOpScaleCP = -1 423 | string m_Notes = "" 424 | } 425 | 426 | C_INIT_RemapCPtoVector C_INIT_RemapCPtoVector_0 427 | { 428 | int m_nCPInput = 2 429 | int m_nFieldOutput = 6 430 | float(3) m_vInputMin = ( 0.000000, 0.000000, 0.000000 ) 431 | float(3) m_vInputMax = ( 255.000000, 255.000000, 255.000000 ) 432 | float(3) m_vOutputMin = ( 0.000000, 0.000000, 0.000000 ) 433 | float(3) m_vOutputMax = ( 1.000000, 1.000000, 1.000000 ) 434 | float m_flStartTime = -1.000000 435 | float m_flEndTime = -1.000000 436 | bool m_bScaleInitialRange = false 437 | bool m_bOffset = false 438 | bool m_bAccelerate = false 439 | int m_nLocalSpaceCP = -1 440 | bool m_bRunForParentApplyKillList = true 441 | float m_flOpStartFadeInTime = 0.000000 442 | float m_flOpEndFadeInTime = 0.000000 443 | float m_flOpStartFadeOutTime = 0.000000 444 | float m_flOpEndFadeOutTime = 0.000000 445 | float m_flOpFadeOscillatePeriod = 0.000000 446 | float m_flOpTimeOffsetMin = 0.000000 447 | float m_flOpTimeOffsetMax = 0.000000 448 | int m_nOpTimeOffsetSeed = 0 449 | int m_nOpStrengthScaleSeed = 0 450 | float m_flOpStrengthMinScale = 1.000000 451 | float m_flOpStrengthMaxScale = 1.000000 452 | int m_nOpTimeScaleSeed = 0 453 | float m_flOpTimeScaleMin = 1.000000 454 | float m_flOpTimeScaleMax = 1.000000 455 | bool m_bDisableOperator = false 456 | int m_nOpEndCapState = -1 457 | int m_nOpScaleCP = -1 458 | string m_Notes = "" 459 | } 460 | 461 | C_INIT_PositionPlaceOnGround C_INIT_PositionPlaceOnGround_0 462 | { 463 | float m_flOffset = 5.000000 464 | float m_flMaxTraceLength = 128.000000 465 | string m_CollisionGroupName = "NONE" 466 | bool m_bKill = false 467 | bool m_bIncludeWater = false 468 | bool m_bSetNormal = false 469 | bool m_bSetPXYZOnly = false 470 | float m_flOffsetByRadiusFactor = 0.000000 471 | bool m_bRunForParentApplyKillList = true 472 | float m_flOpStartFadeInTime = 0.000000 473 | float m_flOpEndFadeInTime = 0.000000 474 | float m_flOpStartFadeOutTime = 0.000000 475 | float m_flOpEndFadeOutTime = 0.000000 476 | float m_flOpFadeOscillatePeriod = 0.000000 477 | float m_flOpTimeOffsetMin = 0.000000 478 | float m_flOpTimeOffsetMax = 0.000000 479 | int m_nOpTimeOffsetSeed = 0 480 | int m_nOpStrengthScaleSeed = 0 481 | float m_flOpStrengthMinScale = 1.000000 482 | float m_flOpStrengthMaxScale = 1.000000 483 | int m_nOpTimeScaleSeed = 0 484 | float m_flOpTimeScaleMin = 1.000000 485 | float m_flOpTimeScaleMax = 1.000000 486 | bool m_bDisableOperator = true 487 | int m_nOpEndCapState = -1 488 | int m_nOpScaleCP = -1 489 | string m_Notes = "" 490 | } 491 | 492 | C_INIT_RemapCPtoScalar C_INIT_RemapCPtoScalar_6 493 | { 494 | int m_nCPInput = 3 495 | int m_nFieldOutput = 7 496 | int m_nField = 0 497 | float m_flInputMin = 0.000000 498 | float m_flInputMax = 100.000000 499 | float m_flOutputMin = 0.000000 500 | float m_flOutputMax = 1.000000 501 | float m_flStartTime = -1.000000 502 | float m_flEndTime = -1.000000 503 | bool m_bScaleInitialRange = false 504 | bool m_bRunForParentApplyKillList = true 505 | float m_flOpStartFadeInTime = 0.000000 506 | float m_flOpEndFadeInTime = 0.000000 507 | float m_flOpStartFadeOutTime = 0.000000 508 | float m_flOpEndFadeOutTime = 0.000000 509 | float m_flOpFadeOscillatePeriod = 0.000000 510 | float m_flOpTimeOffsetMin = 0.000000 511 | float m_flOpTimeOffsetMax = 0.000000 512 | int m_nOpTimeOffsetSeed = 0 513 | int m_nOpStrengthScaleSeed = 0 514 | float m_flOpStrengthMinScale = 1.000000 515 | float m_flOpStrengthMaxScale = 1.000000 516 | int m_nOpTimeScaleSeed = 0 517 | float m_flOpTimeScaleMin = 1.000000 518 | float m_flOpTimeScaleMax = 1.000000 519 | bool m_bDisableOperator = false 520 | int m_nOpEndCapState = -1 521 | int m_nOpScaleCP = -1 522 | string m_Notes = "" 523 | } 524 | 525 | C_OP_InstantaneousEmitter C_OP_InstantaneousEmitter_0 526 | { 527 | int m_nParticlesToEmit = 1 528 | int m_nMinParticlesToEmit = -1 529 | float m_flStartTime = 0.000000 530 | float m_flStartTimeMax = -1.000000 531 | float m_flInitFromKilledParentParticles = 0.000000 532 | int m_nMaxEmittedPerFrame = -1 533 | int m_nScaleControlPoint = -1 534 | int m_nScaleControlPointField = 0 535 | int m_nSnapshotControlPoint = -1 536 | float m_flOpStartFadeInTime = 0.000000 537 | float m_flOpEndFadeInTime = 0.000000 538 | float m_flOpStartFadeOutTime = 0.000000 539 | float m_flOpEndFadeOutTime = 0.000000 540 | float m_flOpFadeOscillatePeriod = 0.000000 541 | float m_flOpTimeOffsetMin = 0.000000 542 | float m_flOpTimeOffsetMax = 0.000000 543 | int m_nOpTimeOffsetSeed = 0 544 | int m_nOpStrengthScaleSeed = 0 545 | float m_flOpStrengthMinScale = 1.000000 546 | float m_flOpStrengthMaxScale = 1.000000 547 | int m_nOpTimeScaleSeed = 0 548 | float m_flOpTimeScaleMin = 1.000000 549 | float m_flOpTimeScaleMax = 1.000000 550 | bool m_bDisableOperator = false 551 | int m_nOpEndCapState = -1 552 | int m_nOpScaleCP = -1 553 | string m_Notes = "" 554 | } -------------------------------------------------------------------------------- /panorama/scripts/building_helper.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | GameUI.SetRenderBottomInsetOverride( 0 ); 4 | 5 | var state = 'disabled'; 6 | var frame_rate = 1/30; 7 | var tree_update_interval = 1; 8 | var size = 0; 9 | var overlay_size = 0; 10 | var range = 0; 11 | var pressedShift = false; 12 | var altDown = false; 13 | var invalid = false; 14 | var requires; 15 | var modelParticle; 16 | var propParticle; 17 | var propScale; 18 | var offsetZ; 19 | var modelOffset; 20 | var gridParticles; 21 | var overlayParticles; 22 | var rangeOverlay; 23 | var rangeOverlayActive; 24 | var builderIndex; 25 | var entityGrid = []; 26 | var tree_entities = []; 27 | var distance_to_gold_mine; 28 | var last_tree_update = Game.GetGameTime(); 29 | var treeGrid = []; 30 | var cutTrees = []; 31 | 32 | // building_settings.kv options 33 | var grid_alpha = CustomNetTables.GetTableValue( "building_settings", "grid_alpha").value 34 | var alt_grid_alpha = CustomNetTables.GetTableValue( "building_settings", "alt_grid_alpha").value 35 | var alt_grid_squares = CustomNetTables.GetTableValue( "building_settings", "alt_grid_squares").value; 36 | var range_overlay_alpha = CustomNetTables.GetTableValue( "building_settings", "range_overlay_alpha").value 37 | var model_alpha = CustomNetTables.GetTableValue( "building_settings", "model_alpha").value 38 | var recolor_ghost = CustomNetTables.GetTableValue( "building_settings", "recolor_ghost").value; 39 | var turn_red = CustomNetTables.GetTableValue( "building_settings", "turn_red").value; 40 | var permanent_alt_grid = CustomNetTables.GetTableValue( "building_settings", "permanent_alt_grid").value; 41 | var update_trees = CustomNetTables.GetTableValue( "building_settings", "update_trees").value; 42 | 43 | var height_restriction 44 | if (CustomNetTables.GetTableValue( "building_settings", "height_restriction") !== undefined) 45 | height_restriction = CustomNetTables.GetTableValue( "building_settings", "height_restriction").value; 46 | 47 | var GRID_TYPES = CustomNetTables.GetTableValue( "building_settings", "grid_types") 48 | CustomNetTables.SubscribeNetTableListener( "building_settings", function() { 49 | GRID_TYPES = CustomNetTables.GetTableValue( "building_settings", "grid_types") 50 | }) 51 | 52 | var Root = $.GetContextPanel() 53 | var localHeroIndex 54 | 55 | if (! Root.loaded) 56 | { 57 | Root.GridNav = []; 58 | Root.squareX = 0; 59 | Root.squareY = 0; 60 | Root.loaded = true; 61 | } 62 | 63 | function StartBuildingHelper( params ) 64 | { 65 | if (params !== undefined) 66 | { 67 | // Set the parameters passed by AddBuilding 68 | localHeroIndex = Players.GetPlayerHeroEntityIndex( Players.GetLocalPlayer() ); 69 | state = params.state; 70 | size = params.size; 71 | range = params.range; 72 | overlay_size = size + alt_grid_squares * 2; 73 | builderIndex = params.builderIndex; 74 | var scale = params.scale; 75 | var entindex = params.entindex; 76 | var propScale = params.propScale; 77 | offsetZ = params.offsetZ; 78 | modelOffset = params.modelOffset; 79 | 80 | requires = GetRequiredGridType(entindex) 81 | distance_to_gold_mine = HasGoldMineDistanceRestriction(entindex) 82 | 83 | // If we chose to not recolor the ghost model, set it white 84 | var ghost_color = [0, 255, 0] 85 | if (!recolor_ghost) 86 | ghost_color = [255,255,255] 87 | 88 | pressedShift = GameUI.IsShiftDown(); 89 | 90 | if (modelParticle !== undefined) { 91 | Particles.DestroyParticleEffect(modelParticle, true) 92 | Particles.ReleaseParticleIndex(modelParticle) 93 | } 94 | if (propParticle !== undefined) { 95 | Particles.DestroyParticleEffect(propParticle, true) 96 | Particles.ReleaseParticleIndex(propParticle) 97 | } 98 | if (gridParticles !== undefined) { 99 | for (var i in gridParticles) { 100 | Particles.DestroyParticleEffect(gridParticles[i], true) 101 | Particles.ReleaseParticleIndex(gridParticles[i]) 102 | } 103 | } 104 | if (overlayParticles !== undefined) { 105 | for (var i in overlayParticles) { 106 | Particles.DestroyParticleEffect(overlayParticles[i], true) 107 | Particles.ReleaseParticleIndex(overlayParticles[i]) 108 | } 109 | } 110 | if (rangeOverlay !== undefined) { 111 | Particles.DestroyParticleEffect(rangeOverlay, true) 112 | Particles.ReleaseParticleIndex(rangeOverlay) 113 | } 114 | 115 | // Building Ghost 116 | modelParticle = Particles.CreateParticle("particles/buildinghelper/ghost_model.vpcf", ParticleAttachment_t.PATTACH_CUSTOMORIGIN, 0); 117 | Particles.SetParticleControlEnt(modelParticle, 1, entindex, ParticleAttachment_t.PATTACH_ABSORIGIN_FOLLOW, "follow_origin", Entities.GetAbsOrigin(entindex), true) 118 | Particles.SetParticleControl(modelParticle, 2, ghost_color) 119 | Particles.SetParticleControl(modelParticle, 3, [model_alpha,0,0]) 120 | Particles.SetParticleControl(modelParticle, 4, [scale,0,0]) 121 | 122 | // Grid squares 123 | gridParticles = []; 124 | for (var x=0; x < size*size; x++) 125 | { 126 | var particle = Particles.CreateParticle("particles/buildinghelper/square_sprite.vpcf", ParticleAttachment_t.PATTACH_CUSTOMORIGIN, 0) 127 | Particles.SetParticleControl(particle, 1, [32,0,0]) 128 | Particles.SetParticleControl(particle, 3, [grid_alpha,0,0]) 129 | gridParticles.push(particle) 130 | } 131 | 132 | // Prop particle attachment 133 | if (params.propIndex !== undefined) 134 | { 135 | propParticle = Particles.CreateParticle("particles/buildinghelper/ghost_model.vpcf", ParticleAttachment_t.PATTACH_CUSTOMORIGIN, 0); 136 | Particles.SetParticleControlEnt(propParticle, 1, params.propIndex, ParticleAttachment_t.PATTACH_ABSORIGIN_FOLLOW, "attach_hitloc", Entities.GetAbsOrigin(params.propIndex), true) 137 | Particles.SetParticleControl(propParticle, 2, ghost_color) 138 | Particles.SetParticleControl(propParticle, 3, [model_alpha,0,0]) 139 | Particles.SetParticleControl(propParticle, 4, [propScale,0,0]) 140 | } 141 | 142 | rangeOverlayActive = false; 143 | overlayParticles = []; 144 | } 145 | 146 | if (state == 'active') 147 | { 148 | $.Schedule(frame_rate, StartBuildingHelper); 149 | 150 | // Get all the visible entities 151 | var entities = Entities.GetAllEntitiesByClassname('npc_dota_building') 152 | var hero_entities = Entities.GetAllHeroEntities() 153 | var creature_entities = Entities.GetAllEntitiesByClassname('npc_dota_creature') 154 | var dummy_entities = Entities.GetAllEntitiesByName('npc_dota_base') 155 | var building_entities = Entities.GetAllBuildingEntities() 156 | entities = entities.concat(hero_entities) 157 | entities = entities.concat(building_entities) 158 | entities = entities.concat(creature_entities) 159 | entities = entities.concat(dummy_entities) 160 | 161 | // Build the entity grid with the construction sizes and entity origins 162 | entityGrid = [] 163 | for (var i = 0; i < entities.length; i++) 164 | { 165 | if (!Entities.IsAlive(entities[i]) || Entities.IsOutOfGame(entities[i]) || !HasModifier(entities[i], "modifier_building")) continue 166 | var entPos = Entities.GetAbsOrigin( entities[i] ) 167 | var squares = GetConstructionSize(entities[i]) 168 | 169 | if (squares > 0) 170 | { 171 | // Block squares centered on the origin 172 | BlockGridSquares(entPos, squares, GRID_TYPES["BLOCKED"]) 173 | } 174 | else 175 | { 176 | // Put tree dummies on a separate table to skip trees 177 | if (Entities.GetUnitName(entities[i]) == 'npc_dota_units_base') 178 | { 179 | if (HasModifier(entities[i], "modifier_tree_cut")) 180 | cutTrees[entPos] = entities[i] 181 | } 182 | // Block 2x2 squares if its an enemy unit 183 | else if (Entities.GetTeamNumber(entities[i]) != Entities.GetTeamNumber(builderIndex) && !HasModifier(entities[i], "modifier_out_of_world")) 184 | { 185 | BlockGridSquares(entPos, 2, GRID_TYPES["BLOCKED"]) 186 | } 187 | } 188 | 189 | var specialGrid = GetCustomGrid(entities[i]) 190 | if (specialGrid) 191 | { 192 | for (var gridType in specialGrid) 193 | { 194 | if (specialGrid[gridType].Square) 195 | { 196 | //$.Msg("Setting ",specialGrid[gridType].Square," grid squares with ",gridType.toUpperCase()," [",GRID_TYPES[gridType.toUpperCase()],"]") 197 | BlockGridSquares(entPos, Number(specialGrid[gridType].Square), GRID_TYPES[gridType.toUpperCase()]) 198 | } 199 | else if (specialGrid[gridType].Radius) 200 | { 201 | //$.Msg("Setting ",specialGrid[gridType].Radius," grid radius with ",gridType.toUpperCase()," [",GRID_TYPES[gridType.toUpperCase()],"]") 202 | BlockGridInRadius(entPos, Number(specialGrid[gridType].Radius), GRID_TYPES[gridType.toUpperCase()]) 203 | } 204 | } 205 | } 206 | } 207 | 208 | // Update treeGrid (slowly, as its the most expensive) 209 | if (update_trees) 210 | { 211 | var time = Game.GetGameTime() 212 | var time_since_last_tree_update = time - last_tree_update 213 | if (time_since_last_tree_update > tree_update_interval) 214 | { 215 | last_tree_update = time 216 | tree_entities = Entities.GetAllEntitiesByClassname('ent_dota_tree') 217 | treeGrid = []; 218 | for (var i = 0; i < tree_entities.length; i++) 219 | { 220 | var treePos = Entities.GetAbsOrigin(tree_entities[i]) 221 | // Block the grid if the tree isn't chopped 222 | if (cutTrees[treePos] === undefined) 223 | BlockGridSquares(treePos, 2, "TREE") 224 | } 225 | } 226 | } 227 | 228 | var mPos = GameUI.GetCursorPosition(); 229 | var GamePos = Game.ScreenXYToWorld(mPos[0], mPos[1]); 230 | if ( GamePos !== null ) 231 | { 232 | SnapToGrid(GamePos, size) 233 | 234 | invalid = false 235 | var color = [0,255,0] 236 | var part = 0 237 | var halfSide = (size/2)*64 238 | var boundingRect = {} 239 | boundingRect["leftBorderX"] = GamePos[0]-halfSide 240 | boundingRect["rightBorderX"] = GamePos[0]+halfSide 241 | boundingRect["topBorderY"] = GamePos[1]+halfSide 242 | boundingRect["bottomBorderY"] = GamePos[1]-halfSide 243 | 244 | if (GamePos[0] > 10000000) return 245 | 246 | var closeToGoldMine = TooCloseToGoldmine(GamePos) 247 | 248 | // Building Base Grid 249 | for (var x=boundingRect["leftBorderX"]+32; x <= boundingRect["rightBorderX"]-32; x+=64) 250 | { 251 | for (var y=boundingRect["topBorderY"]-32; y >= boundingRect["bottomBorderY"]+32; y-=64) 252 | { 253 | var pos = SnapHeight(x,y,GamePos[2]) 254 | if (part>size*size) 255 | return 256 | 257 | var gridParticle = gridParticles[part] 258 | Particles.SetParticleControl(gridParticle, 0, pos) 259 | part++; 260 | 261 | // Grid color turns red when over invalid position 262 | color = [0,255,0] 263 | if (IsBlocked(pos) || closeToGoldMine) 264 | { 265 | color = [255,0,0] 266 | invalid = true 267 | } 268 | 269 | Particles.SetParticleControl(gridParticle, 2, color) 270 | } 271 | } 272 | 273 | // Overlay Grid, visible with Alt pressed 274 | altDown = permanent_alt_grid || GameUI.IsAltDown(); 275 | if (altDown) 276 | { 277 | // Create the particles 278 | if (overlayParticles && overlayParticles.length == 0) 279 | { 280 | for (var y=0; y < overlay_size*overlay_size; y++) 281 | { 282 | var particle = Particles.CreateParticle("particles/buildinghelper/square_overlay.vpcf", ParticleAttachment_t.PATTACH_CUSTOMORIGIN, 0) 283 | Particles.SetParticleControl(particle, 1, [32,0,0]) 284 | Particles.SetParticleControl(particle, 3, [alt_grid_alpha,0,0]) 285 | overlayParticles.push(particle) 286 | } 287 | } 288 | 289 | color = [255,255,255] 290 | var part2 = 0 291 | var halfSide2 = (overlay_size/2)*64 292 | var boundingRect2 = {} 293 | boundingRect2["leftBorderX"] = GamePos[0]-halfSide2 294 | boundingRect2["rightBorderX"] = GamePos[0]+halfSide2 295 | boundingRect2["topBorderY"] = GamePos[1]+halfSide2 296 | boundingRect2["bottomBorderY"] = GamePos[1]-halfSide2 297 | 298 | for (var x2=boundingRect2["leftBorderX"]+32; x2 <= boundingRect2["rightBorderX"]-32; x2+=64) 299 | { 300 | for (var y2=boundingRect2["topBorderY"]-32; y2 >= boundingRect2["bottomBorderY"]+32; y2-=64) 301 | { 302 | var pos2 = SnapHeight(x2,y2,GamePos[2]) 303 | if (part2>=overlay_size*overlay_size) 304 | return 305 | 306 | color = [255,255,255] //White on empty positions 307 | var overlayParticle = overlayParticles[part2] 308 | Particles.SetParticleControl(overlayParticle, 0, pos2) 309 | part2++; 310 | 311 | if (IsBlocked(pos2) || TooCloseToGoldmine(pos2)) 312 | color = [255,0,0] 313 | 314 | Particles.SetParticleControl(overlayParticle, 2, color) 315 | } 316 | } 317 | } 318 | else 319 | { 320 | // Destroy the particles, only once 321 | if (overlayParticles && overlayParticles.length != 0) 322 | { 323 | for (var i in overlayParticles) { 324 | Particles.DestroyParticleEffect(overlayParticles[i], true) 325 | Particles.ReleaseParticleIndex(overlayParticles[i]) 326 | } 327 | overlayParticles = []; 328 | } 329 | } 330 | 331 | var modelPos = SnapHeight(GamePos[0],GamePos[1],GamePos[2]) 332 | 333 | // Destroy the range overlay if its not a valid building location 334 | if (invalid) 335 | { 336 | if (rangeOverlayActive && rangeOverlay !== undefined) 337 | { 338 | Particles.DestroyParticleEffect(rangeOverlay, true) 339 | Particles.ReleaseParticleIndex(rangeOverlay) 340 | rangeOverlayActive = false 341 | } 342 | } 343 | else 344 | { 345 | if (!rangeOverlayActive) 346 | { 347 | rangeOverlay = Particles.CreateParticle("particles/buildinghelper/range_overlay.vpcf", ParticleAttachment_t.PATTACH_CUSTOMORIGIN, localHeroIndex) 348 | Particles.SetParticleControl(rangeOverlay, 1, [range,0,0]) 349 | Particles.SetParticleControl(rangeOverlay, 2, [255,255,255]) 350 | Particles.SetParticleControl(rangeOverlay, 3, [range_overlay_alpha,0,0]) 351 | rangeOverlayActive = true 352 | } 353 | } 354 | 355 | if (rangeOverlay !== undefined) 356 | Particles.SetParticleControl(rangeOverlay, 0, modelPos) 357 | 358 | // Update the model particle 359 | modelPos[2]+=modelOffset 360 | Particles.SetParticleControl(modelParticle, 0, modelPos) 361 | 362 | if (propParticle !== undefined) 363 | { 364 | var pedestalPos = SnapHeight(GamePos[0],GamePos[1],GamePos[2]) 365 | pedestalPos[2]+=offsetZ 366 | Particles.SetParticleControl(propParticle, 0, pedestalPos) 367 | } 368 | 369 | // Turn the model red if we can't build there 370 | if (turn_red){ 371 | invalid ? Particles.SetParticleControl(modelParticle, 2, [255,0,0]) : Particles.SetParticleControl(modelParticle, 2, [255,255,255]) 372 | if (propParticle !== undefined) 373 | invalid ? Particles.SetParticleControl(propParticle, 2, [255,0,0]) : Particles.SetParticleControl(propParticle, 2, [255,255,255]) 374 | } 375 | } 376 | 377 | if ( (!GameUI.IsShiftDown() && pressedShift) || !Entities.IsAlive( builderIndex ) ) 378 | { 379 | EndBuildingHelper(); 380 | } 381 | } 382 | } 383 | 384 | function EndBuildingHelper() 385 | { 386 | state = 'disabled' 387 | if (modelParticle !== undefined){ 388 | Particles.DestroyParticleEffect(modelParticle, true) 389 | Particles.ReleaseParticleIndex(modelParticle) 390 | } 391 | if (propParticle !== undefined){ 392 | Particles.DestroyParticleEffect(propParticle, true) 393 | Particles.ReleaseParticleIndex(propParticle) 394 | } 395 | if (rangeOverlay !== undefined){ 396 | Particles.DestroyParticleEffect(rangeOverlay, true) 397 | Particles.ReleaseParticleIndex(rangeOverlay) 398 | } 399 | for (var i in gridParticles) { 400 | Particles.DestroyParticleEffect(gridParticles[i], true) 401 | Particles.ReleaseParticleIndex(gridParticles[i]) 402 | } 403 | for (var i in overlayParticles) { 404 | Particles.DestroyParticleEffect(overlayParticles[i], true) 405 | Particles.ReleaseParticleIndex(overlayParticles[i]) 406 | } 407 | } 408 | 409 | function SendBuildCommand( params ) 410 | { 411 | if (invalid) 412 | { 413 | CreateErrorMessage({message:"#error_invalid_build_position"}) 414 | return true 415 | } 416 | 417 | pressedShift = GameUI.IsShiftDown(); 418 | var mainSelected = Players.GetLocalPlayerPortraitUnit(); 419 | 420 | var mPos = GameUI.GetCursorPosition(); 421 | var GamePos = Game.ScreenXYToWorld(mPos[0], mPos[1]); 422 | 423 | GameEvents.SendCustomGameEventToServer( "building_helper_build_command", { "builder": mainSelected, "X" : GamePos[0], "Y" : GamePos[1], "Z" : GamePos[2] , "Queue" : pressedShift } ); 424 | 425 | // Cancel unless the player is holding shift 426 | if (!GameUI.IsShiftDown()) 427 | { 428 | EndBuildingHelper(params); 429 | return true; 430 | } 431 | return true; 432 | } 433 | 434 | function SendCancelCommand( params ) 435 | { 436 | EndBuildingHelper(); 437 | GameEvents.SendCustomGameEventToServer( "building_helper_cancel_command", {} ); 438 | } 439 | 440 | function CreateErrorMessage(msg) 441 | { 442 | var reason = msg.reason || 80; 443 | if (msg.message){ 444 | GameEvents.SendEventClientSide("dota_hud_error_message", {"splitscreenplayer":0,"reason":reason ,"message":msg.message} ); 445 | } 446 | else{ 447 | GameEvents.SendEventClientSide("dota_hud_error_message", {"splitscreenplayer":0,"reason":reason} ); 448 | } 449 | } 450 | 451 | function RegisterGNV(msg){ 452 | var GridNav = []; 453 | var squareX = msg.squareX 454 | var squareY = msg.squareY 455 | var boundX = msg.boundX 456 | var boundY = msg.boundY 457 | $.Msg("Registering GNV ["+squareX+","+squareY+"] ","Min Bounds: X="+boundX+", Y="+boundY) 458 | 459 | var arr = []; 460 | // Thanks to BMD for this method 461 | for (var i=0; i=0; j-=2){ 464 | var g = (code & (3 << j)) >> j; 465 | if (g != 0) 466 | arr.push(g); 467 | } 468 | } 469 | 470 | // Load the GridNav 471 | var x = 0; 472 | for (var i = 0; i < squareY; i++) { 473 | GridNav[i] = [] 474 | for (var j = 0; j < squareX; j++) { 475 | GridNav[i][j] = (arr[x] == 1) ? GRID_TYPES["BUILDABLE"] : GRID_TYPES["BLOCKED"] 476 | x++ 477 | } 478 | } 479 | 480 | Root.GridNav = GridNav 481 | Root.squareX = squareX 482 | Root.squareY = squareY 483 | Root.boundX = boundX 484 | Root.boundY = boundY 485 | 486 | // ASCII Art 487 | /* 488 | for (var i = 0; i= boundingRect["bottomBorderY"]+32; y-=64) 614 | { 615 | BlockTreeGrid([x,y,0]) 616 | } 617 | } 618 | } 619 | else 620 | { 621 | for (var x=boundingRect["leftBorderX"]+32; x <= boundingRect["rightBorderX"]-32; x+=64) 622 | { 623 | for (var y=boundingRect["topBorderY"]-32; y >= boundingRect["bottomBorderY"]+32; y-=64) 624 | { 625 | BlockEntityGrid([x,y,0], gridType) 626 | } 627 | } 628 | } 629 | } 630 | 631 | function BlockGridInRadius (position, radius, gridType) { 632 | var boundingRect = {} 633 | boundingRect["leftBorderX"] = position[0]-radius 634 | boundingRect["rightBorderX"] = position[0]+radius 635 | boundingRect["topBorderY"] = position[1]+radius 636 | boundingRect["bottomBorderY"] = position[1]-radius 637 | 638 | for (var x=boundingRect["leftBorderX"]+32; x <= boundingRect["rightBorderX"]+32; x+=64) 639 | { 640 | for (var y=boundingRect["topBorderY"]+32; y >= boundingRect["bottomBorderY"]+32; y-=64) 641 | { 642 | if (Length2D(position, [x,y]) <= radius) 643 | { 644 | BlockEntityGrid([x,y,0], gridType) 645 | } 646 | } 647 | } 648 | } 649 | 650 | function WorldToGridPosX(x){ 651 | return Math.floor(x/64) 652 | } 653 | 654 | function WorldToGridPosY(y){ 655 | return Math.floor(y/64) 656 | } 657 | 658 | function GetConstructionSize(entIndex) { 659 | var entName = Entities.GetUnitName(entIndex) 660 | var table = CustomNetTables.GetTableValue("construction_size", entName) 661 | return table ? table.size : 0 662 | } 663 | 664 | function GetRequiredGridType(entIndex) { 665 | var entName = Entities.GetUnitName(entIndex) 666 | var table = CustomNetTables.GetTableValue("construction_size", entName) 667 | if (table && table.requires !== undefined) 668 | { 669 | var types = table.requires.split(" ") 670 | var value = 0 671 | for (var i = 0; i < types.length; i++) 672 | { 673 | value+=GRID_TYPES[types[i]] 674 | } 675 | return value 676 | } 677 | else 678 | return GRID_TYPES["BUILDABLE"] 679 | } 680 | 681 | function GetCustomGrid(entIndex) { 682 | var entName = Entities.GetUnitName(entIndex) 683 | var table = CustomNetTables.GetTableValue("construction_size", entName) 684 | if (table && table.grid !== undefined) 685 | { 686 | var gridType = table.grid 687 | for (var type in gridType) 688 | if (HasModifier(entIndex, "modifier_grid_"+type.toLowerCase())) 689 | return table.grid 690 | } 691 | } 692 | 693 | function HasGoldMineDistanceRestriction(entIndex) { 694 | var entName = Entities.GetUnitName(entIndex) 695 | var table = CustomNetTables.GetTableValue("construction_size", entName) 696 | return table ? table.distance_to_gold_mine : 0 697 | } 698 | 699 | function GetClosestDistanceToGoldMine(position) { 700 | var building_entities = Entities.GetAllEntitiesByClassname('npc_dota_building') 701 | 702 | var minDistance = 99999 703 | for (var i = 0; i < building_entities.length; i++) 704 | { 705 | if (Entities.GetUnitName(building_entities[i]) == "gold_mine") 706 | { 707 | var distance_to_this_mine = Length2D(position, Entities.GetAbsOrigin(building_entities[i])) 708 | if (distance_to_this_mine < minDistance) 709 | minDistance = distance_to_this_mine 710 | } 711 | } 712 | return minDistance 713 | } 714 | 715 | function TooCloseToGoldmine(position) { 716 | return (distance_to_gold_mine > 0 && GetClosestDistanceToGoldMine(position) < distance_to_gold_mine) 717 | } 718 | 719 | function Length2D(v1, v2) { 720 | return Math.sqrt( (v2[0]-v1[0])*(v2[0]-v1[0]) + (v2[1]-v1[1])*(v2[1]-v1[1]) ) 721 | } 722 | 723 | function PrintGridCoords(x,y) { 724 | $.Msg('(',x,',',y,') = [',WorldToGridPosX(x),',',WorldToGridPosY(y),']') 725 | } 726 | 727 | function HasModifier(entIndex, modifierName) { 728 | var nBuffs = Entities.GetNumBuffs(entIndex) 729 | for (var i = 0; i < nBuffs; i++) { 730 | if (Buffs.GetName(entIndex, Entities.GetBuff(entIndex, i)) == modifierName) 731 | return true 732 | }; 733 | return false 734 | }; 735 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . --------------------------------------------------------------------------------