Skip to content

Commit

Permalink
More efficient tree cut entity detection, released particle index in …
Browse files Browse the repository at this point in the history
…panorama, added OrderBuildingConstruction(builder, ability, position)
  • Loading branch information
MNoya committed Jul 7, 2016
1 parent 7f7849c commit 69675a4
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 138 deletions.
23 changes: 16 additions & 7 deletions panorama/scripts/building_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function StartBuildingHelper( params )
var entities = Entities.GetAllEntitiesByClassname('npc_dota_building')
var hero_entities = Entities.GetAllHeroEntities()
var creature_entities = Entities.GetAllEntitiesByClassname('npc_dota_creature')
var dummy_entities = Entities.GetAllEntitiesByName('npc_dota_thinker')
var dummy_entities = Entities.GetAllEntitiesByName('npc_dota_base')
var building_entities = Entities.GetAllBuildingEntities()
entities = entities.concat(hero_entities)
entities = entities.concat(building_entities)
Expand All @@ -173,9 +173,9 @@ function StartBuildingHelper( params )
else
{
// Put tree dummies on a separate table to skip trees
if (Entities.GetUnitName(entities[i]) == 'npc_dota_thinker')
if (Entities.GetUnitName(entities[i]) == 'npc_dota_units_base')
{
if (Entities.GetAbilityByName(entities[i], "dummy_tree") != -1)
if (HasModifier(entities[i], "modifier_tree_cut"))
cutTrees[entPos] = entities[i]
}
// Block 2x2 squares if its an enemy unit
Expand Down Expand Up @@ -617,11 +617,11 @@ function BlockGridInRadius (position, radius, gridType) {
boundingRect["topBorderY"] = position[1]+radius
boundingRect["bottomBorderY"] = position[1]-radius

for (var x=boundingRect["leftBorderX"]+32; x <= boundingRect["rightBorderX"]-32; x+=64)
for (var x=boundingRect["leftBorderX"]; x <= boundingRect["rightBorderX"]-32; x+=64)
{
for (var y=boundingRect["topBorderY"]-32; y >= boundingRect["bottomBorderY"]+32; y-=64)
for (var y=boundingRect["topBorderY"]-32; y >= boundingRect["bottomBorderY"]; y-=64)
{
if (Length2D(position, [x,y,0]) <= radius)
if (Length2D(position, [x,y]) <= radius)
{
BlockEntityGrid([x,y,0], gridType)
}
Expand Down Expand Up @@ -699,4 +699,13 @@ function Length2D(v1, v2) {

function PrintGridCoords(x,y) {
$.Msg('(',x,',',y,') = [',WorldToGridPosX(x),',',WorldToGridPosY(y),']')
}
}

function HasModifier(entIndex, modifierName) {
var nBuffs = Entities.GetNumBuffs(entIndex)
for (var i = 0; i < nBuffs; i++) {
if (Buffs.GetName(entIndex, Entities.GetBuff(entIndex, i)) == modifierName)
return true
};
return false
};
3 changes: 3 additions & 0 deletions scripts/kv/building_settings.kv
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
// Should we disable building turnrate by default? Defining a "DisableTurning" kv on the unit will still override the global setting
"DISABLE_BUILDING_TURNING" "true"

// Path of the builder callbacks, can be changed to somewhere else within vscripts
"BUILD_PATH" "builder"

// Should we try to tie allied building rightclick to a "RepairAbility" usage ?
"RIGHT_CLICK_REPAIR" "true"

Expand Down
26 changes: 0 additions & 26 deletions scripts/npc/abilities/dummy_tree.txt

This file was deleted.

Loading

0 comments on commit 69675a4

Please sign in to comment.