Skrypty & Kody TFS 1.2 - drugi amulet of loss

Pucek1993

Active User
Zarejestrowany
Dołączył
Luty 4, 2016
Posty
71
Liczba reakcji
1
Cze??, chce doda? do swojego silnika drugi Amulet of loss, lecz nie potrafi? zrobi? aby dzia?a? poprawnie. Jest dodany do items.xml oraz do movements (atrybuty dodatkowe dzia?aj?)

18:09 You see a god amulet of loss (protection all +10%).It weighs 4.2 oz.Item ID: 2218

Lecz nie wiem, jak zrobi? w creaturescripts ?eby dzia?a? poprawnie. Aol zakodowany jest jako ITEM_AMULETOFLOSS.

PHP:
function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
	if getPlayerFlagValue(player, PlayerFlag_NotGenerateLoot) then
		return true
	end

	local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
	local hasSkull = isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull())
	if amulet and amulet.itemid == ITEM_AMULETOFLOSS and not hasSkull then
		local isPlayer = false
		if killer then
			if killer:isPlayer() then
				isPlayer = true
			else
				local master = killer:getMaster()
				if master and master:isPlayer() then
					isPlayer = true
				end
			end
		end

		if not isPlayer or not player:hasBlessing(6) then
			player:removeItem(ITEM_AMULETOFLOSS, 1, -1, false)
		end
	else
		local lossPercent = player:getLossPercent()
		for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
			local item = player:getSlotItem(i)
			if item then
				if hasSkull or math.random(item:isContainer() and 100 or 1000) <= lossPercent then
					if not item:moveTo(corpse) then
						item:remove()
					end
				end
			end
		end
	end

	if not player:getSlotItem(CONST_SLOT_BACKPACK) then
		player:addItem(ITEM_BAG, 1, false, CONST_SLOT_BACKPACK)
	end

	return true
end

---------- Tre?? dodana o 20:11 ----------

Ogarni?te, temat do zamkni?cia. Wymagana ingerencja w source, pozdrawiam!
 
Odp: TFS 1.2 - drugi amulet of loss

Trudno by?oby Ci pom?c w tej sytuacji poniewa? nic tutaj nie wypisa?e? je?eli chcesz mie? 2 takie same aoly tylko jeden z inn? atrybucj? to jedynie ten sam wygl?d, ale z inn? nazw?.. I wtedy dublujesz.
 
Odp: TFS 1.2 - drugi amulet of loss

Napisa?em ?e zrobione. Wystarczy?o doda? dodatkowy amulet of loss w source, a p??niej uwzgl?dni? go w LUA i dzia?a.
 
Odp: TFS 1.2 - drugi amulet of loss

Witam! M?j skrypt wygl?da nast?puj?co - aole znikaj?, ale bez aol nie wypada eq. Po wklejeniu starego skryptu z jednym aolem, jest wszystko ok. Pomo?e kto? ogarn???

PHP:
function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
        if getPlayerFlagValue(player, PlayerFlag_NotGenerateLoot) then
                return true
        end
 
        local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
        local hasSkull = isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull())
        if amulet and amulet.itemid == ITEM_AMULETOFLOSS or ITEM_AMULETOFLOSS2 and not hasSkull then
                local isPlayer = false
                if killer then
                        if killer:isPlayer() then
                                isPlayer = true
                        else
                                local master = killer:getMaster()
                                if master and master:isPlayer() then
                                        isPlayer = true
                                end
                        end
                end
 
                if not isPlayer or not player:hasBlessing(6) then
                        player:removeItem(ITEM_AMULETOFLOSS, 1, -1, false)
                        player:removeItem(ITEM_AMULETOFLOSS2, 1, -1, false)
                end
        else
                local lossPercent = player:getLossPercent()
                for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
                        local item = player:getSlotItem(i)
                        if item then
                                if hasSkull or math.random(item:isContainer() and 100 or 1000) <= lossPercent then
                                        if not item:moveTo(corpse) then
                                                item:remove()
                                        end
                                end
                        end
                end
        end
 
        if not player:getSlotItem(CONST_SLOT_BACKPACK) then
                player:addItem(ITEM_BAG, 1, false, CONST_SLOT_BACKPACK)
        end
 
        return true
end
 
Back
Do góry