Переменная в npc_units_custom

mrlikelot

Продвинутый
24 Июл 2015
168
1
Возможно ли создать дополнительную переменную, например, так:
Код:
"npc_ghost_pugna_security1"
 {
  // General
  //
  "BaseClass"     "npc_dota_creature" // Class of entity of link to.
  "Model"      "models/creeps/lane_creeps/creep_radiant_melee/radiant_melee_mega.vmdl" // Model.
  "SoundSet"     "Creep_Good_Range"     // Name of sound set.
  "Level"      "7"
  "UnitLabel"     "Pugna Guard"

  "Ability1"     "respawn"   // Ability 1.
  "RespawnTime"			"60"
RespawnTime в данном случае. Если да, то как её получить в Lua?
Нужно потому что для всех мобов одна способность, но значение должно быть разным. Если невозможно, то как ещё реализовать можно?
 
Последнее редактирование модератором:
Код:
GameRules.UnitKV = LoadKeyValues("scripts/npc/npc_units_custom.txt")

function CDOTA_BaseNPC:GetRespawnTime_Custom()
	return GameRules.UnitKV[self:GetUnitName()]["RespawnTime"] or -1
end
 
Последнее редактирование модератором:
[quote author=ZLOY link=topic=1401.msg8978#msg8978 date=1490600088]
Код:
GameRules.UnitKV = LoadKeyValues("scripts/npc/npc_units_custom.txt")

function CDOTA_BaseNPC:GetRespawnTime_Custom()
	return GameRules.UnitKV[self:GetUnitName()]["RespawnTime"] or -1
end
[/quote]

А можно именно получить эту переменную,а не задать правило? Я ж правильно понял :-[?
На моддоте написано:
Doesn't work on non-custom units. You need to load & merge the base files for those.
Don't name units the same as heroes or it will fail.

А у меня получается, что юнит появляется, я его убиваю, абилка активирует таймер и через некоторое время юнит опять появляется.

Lua
Код:
function respawn( keys )
	local caster = keys.caster
	local ability = keys.ability
	local time = 
	print(time)
	Timers:CreateTimer(time, function()
    local point = Entities:FindByName( nil, caster):GetAbsOrigin() 
 		local unit = CreateUnitByName(caster, point + RandomVector( RandomFloat( 0, 200 )), true, nil, nil, DOTA_TEAM_BADGUYS )
  end)
end
Не знаю, что вставить в time

UPD. Или создавать таблицу по типу этой и будет работать?
Код:
GameRules.UnitKV = LoadKeyValues("scripts/npc/npc_units_custom.txt")

 --Load HeroKV into UnitKV
MergeTables(GameRules.UnitKV, LoadKeyValues("scripts/npc/npc_heroes_custom.txt"))
Код:
function MergeTables( t1, t2 )
  for name,info in pairs(t2) do
    t1[name] = info
  end
end
 
Последнее редактирование модератором:
Код:
local time = caster:GetRespawnTime_Custom()
 
[quote author=ZLOY link=topic=1401.msg8980#msg8980 date=1490603604]
Код:
local time = caster:GetRespawnTime_Custom()
[/quote]
Спасибо, прекрасно работает.
Код:

Код:
"npc_ghost_pugna_boss"
 {
  // General
  //
  "BaseClass"     "npc_dota_creature" // Class of entity of link to.
  "Model"      "models/creeps/neutral_creeps/n_creep_ghost_b/n_creep_ghost_frost.vmdl" // Model.
  "SoundSet"     "Creep_Good_Range"     // Name of sound set.
  "Level"      "10"
  "UnitLabel"     "Pugna"


  "Ability1"     "respawn"   // Ability 1.
  // Armor
  "ArmorPhysical"    "0"   // Physical protection.
  "MagicalResistance"    "0"   // Magical protection.
  "RespawnTime"			"60"
  // Attack
  "AttackCapabilities"  "DOTA_UNIT_CAP_MELEE_ATTACK"   // Type of attack - melee, ranged, etc.
  "AttackDamageMin"   "210"   // Damage range min.
  "AttackDamageMax"   "240"   // Damage range max.
  "AttackDamageType"   "DAMAGE_TYPE_ArmorPhysical"
  "AttackRate"    "0.8"   // Speed of attack.
  "AttackAnimationPoint"  "0.5"  // Normalized time in animation cycle to attack.
  "AttackAcquisitionRange" "300"  // Range within a target can be acquired.
  "AttackRange"    "150"  // Range within a target can be attacked.
  "ProjectileModel"   "" // Particle system model for projectile.
  "ProjectileSpeed"   "900"  // Speed of projectile.

  // Attributes
  "AttributePrimary"   "DOTA_ATTRIBUTE_STRENGTH"
  "AttributeBaseStrength"  "0"   // Base strength
  "AttributeStrengthGain"  "0"   // Strength bonus per level.
  "AttributeBaseIntelligence" "0"   // Base intelligence
  "AttributeIntelligenceGain" "0"   // Intelligence bonus per level.
  "AttributeBaseAgility"  "0"   // Base agility
  "AttributeAgilityGain"  "0"   // Agility bonus per level.

  // Bounty
  "BountyXP"     "450"   // Experience earn.
  "BountyGoldMin"    "350"   // Gold earned min.
  "BountyGoldMax"    "450"   // Gold earned max.

  // Bounds
  "BoundsHullName"   "DOTA_HULL_SIZE_SMALL"   // Hull type used for navigation/locomotion.

  // Movement
  "MovementCapabilities"  "DOTA_UNIT_CAP_MOVE_GROUND"   // Type of locomotion - ground, air
  "MovementSpeed"    "200"  // Speed
  "MovementTurnRate"   "1.0"  // Turning rate.
  "FollowRange"    "250"  // Distance to keep when following

  // Status
  "StatusHealth"    "1200"   // Base health.
  "StatusHealthRegen"   "0"   // Health regeneration rate.
  "StatusMana"    "0"   // Base mana.
  "StatusManaRegen"   "0"   // Mana regeneration rate.

  // Team
  "TeamName"     "DOTA_TEAM_BADGUYS"   // Team name.
  
  // Vision
  "VisionDaytimeRange"  "0"  // Range of vision during day light.
  "VisionNighttimeRange"  "0"  // Range of vision at night time.
 }

Код:
"respawn"
 {
  // General
  //"ID"       "5343"              // unique ID number for this ability. Do not change this once established or it will invalidate collected stats.
  "AbilityBehavior"    "DOTA_ABILITY_BEHAVIOR_PASSIVE | DOTA_ABILITY_BEHAVIOR_NOT_LEARNABLE"
  "MaxLevel"      "1"
  "BaseClass"      "ability_datadriven"
  "AbilityTextureName"      "rubick_empty1"
  "Modifiers"
  {
    "modifier_respawn"
    {
      "Passive"      "1"
      "IsHidden"     "1"
      "IsDebuff"     "0"
  
      "OnDeath"
      {
        "RunScript"
        {
          "ScriptFile"  "heroes/respawn.lua"
          "Function"   "respawn"
        }
      }
    }
  }
 }
Код:
GameRules.UnitKV = LoadKeyValues("scripts/npc/npc_units_custom.txt")

function CDOTA_BaseNPC:GetRespawnTime_Custom()
	return GameRules.UnitKV[self:GetUnitName()]["RespawnTime"] or -1
end

function respawn( keys )
	local caster = keys.caster
	local ability = keys.ability
	local time = caster:GetRespawnTime_Custom()
	local name = caster:GetUnitName()
	print(time)
	print(name)
	print(caster)
	Timers:CreateTimer(time, function()
    local point = Entities:FindByName( nil, name):GetAbsOrigin() 
 		local unit = CreateUnitByName(name, point + RandomVector( RandomFloat( 0, 200 )), true, nil, nil, DOTA_TEAM_BADGUYS )
  end)
end
 
Последнее редактирование модератором:
Реклама: