Приручение крипа

  • Автор темы Автор темы Danis
  • Дата начала Дата начала

Danis

Продвинутый
12 Июн 2016
285
0
Проект
Custom Hero Arena
Пытаюсь приручить крипа, но он отказывается выполнять "приказы", контрол сделал, не понимаю, чего не хватает?

Код:
	local caster = self:GetCaster()
	local target = self:GetCursorTarget()
	local health = self:GetSpecialValueFor("health")
	local speed = self:GetSpecialValueFor("speed")
	if not self.dominated_units then
			self.dominated_units = {}
		end

		for k,v in pairs(self.dominated_units) do
			if v and IsValidEntity(v) then 
				v:ForceKill(false)
			end
		end

		self.dominated_units = {}

		table.insert(self.dominated_units, target)

		target:AddNewModifier(caster, self, "modifier_kill", {duration = self:GetSpecialValueFor("duration")})
		target:SetControllableByPlayer(caster:GetEntityIndex(),true)
		--[[target:SetOwner(caster)]]--
		target:SetTeam(caster:GetTeamNumber())

		if target:GetMaxHealth() < health then
			print("Set Health to "..health)
			target:SetMaxHealth(health)
		end

		if target:GetBaseMoveSpeed() < speed then
			print("Set Movespeed to "..speed)
			target:SetBaseMoveSpeed(speed)
		end
 
Последнее редактирование модератором:
[quote author=Danis link=topic=1142.msg6734#msg6734 date=1478020546]
Пытаюсь приручить крипа, но он отказывается выполнять "приказы", контрол сделал, не понимаю, чего не хватает?

Код:
	local caster = self:GetCaster()
	local target = self:GetCursorTarget()
	local health = self:GetSpecialValueFor("health")
	local speed = self:GetSpecialValueFor("speed")
	if not self.dominated_units then
			self.dominated_units = {}
		end

		for k,v in pairs(self.dominated_units) do
			if v and IsValidEntity(v) then 
				v:ForceKill(false)
			end
		end

		self.dominated_units = {}

		table.insert(self.dominated_units, target)

		target:AddNewModifier(caster, self, "modifier_kill", {duration = self:GetSpecialValueFor("duration")})
		target:SetControllableByPlayer(caster:GetEntityIndex(),true)
		--[[target:SetOwner(caster)]]--
		target:SetTeam(caster:GetTeamNumber())

		if target:GetMaxHealth() < health then
			print("Set Health to "..health)
			target:SetMaxHealth(health)
		end

		if target:GetBaseMoveSpeed() < speed then
			print("Set Movespeed to "..speed)
			target:SetBaseMoveSpeed(speed)
		end
[/quote]
caster:GetEntityIndex
замени на
caster:GetPlayerOwnerID

И в следующий раз не путай ID игрока и Entity Index игрока.
 
Последнее редактирование модератором:
[quote author=CryDeS link=topic=1142.msg6735#msg6735 date=1478022715]
caster:GetEntityIndex
замени на
caster:GetPlayerOwnerID

И в следующий раз не путай ID игрока и Entity Index игрока.
[/quote]И так тоже делал. не работало.

Код:
target:SetControllableByPlayer(caster:GetPlayerOwnerID(),true)
 
Собственно получается сам спросил, сам ответил.
Вот код, может кому пригодится.
Код:
	local caster = self:GetCaster()
	local target = self:GetCursorTarget()
	local health = self:GetSpecialValueFor("health")
	local speed = self:GetSpecialValueFor("speed")
	if not target:IsAncient() or not target:IsMagicImmune() or not IsBoss(target) or not target.dominated then

		if not self.dominated_units then
			self.dominated_units = {}
		end

		for k,v in pairs(self.dominated_units) do
			if v and IsValidEntity(v) then 
				v.disable_drop = true
				v:ForceKill(false)
			end
		end

		self.dominated_units = {}

		local t_health = target:GetHealth()
		local t_max_health = target:GetMaxHealth()
		local t_speed = target:GetBaseMoveSpeed()
		target.disable_drop = true
		target:ForceKill(false)
		local unit = CreateUnitByName(target:GetUnitName(), target:GetAbsOrigin(), false, caster, caster, caster:GetTeamNumber() )
		unit:SetHealth(t_health)
		unit:AddNewModifier(caster, self, "modifier_kill", {duration = self:GetSpecialValueFor("duration")})
		unit:SetControllableByPlayer(caster:GetPlayerOwnerID(),true)
		unit:SetOwner(caster)

		if t_max_health < health then
			print("Set Health to "..health)
			unit:SetMaxHealth(health)
		end

		if t_speed < speed then
			print("Set Movespeed to "..speed)
			unit:SetBaseMoveSpeed(speed)
		end

		table.insert(self.dominated_units, unit)

		target.dominated = true
	end
 
Последнее редактирование модератором:
Реклама: