<commit_before>-- Testskript 1 fr Weiterentwicklung Druidenmagie
-- 2007 by Falk
-- 2009 by Nitram
-- 2011 by Merung
-- Trinken aus grner Flasche (331)
-- ------------------------------------------------

-- include base.common for additional functions
require("base.common")
require("base.character")
require("alchemy.item.id_165_blue_bottle")

module("alchemy.item.id_331_green_bottle", package.seeall)

-- UPDATE common SET com_script='alchemy.item.id_331_green_bottle' WHERE com_itemid = 331;


function UseItem( User, SourceItem, TargetItem, Counter, Param, ltstate )
    
	if SourceItem:getData("stockData") == "" then -- no stock, something else
	    return
	end	
	
	if base.common.GetFrontItemID(User) == 1008 then -- infront of a cauldron?
	    cauldron = base.common.GetFrontItem(User)
		
		-- is the char an alchemist?
	    if User:getMagicType() ~= 3 then
		  base.common.InformNLS( User,
				"Nur jene, die in die Kunst der Alchemie eingefhrt worden sind, knnen hier ihr Werk vollrichten.",
				"Only those who have been introduced to the art of alchemy are able to work here.")
		  return;
	    end
		
		if ( ltstate == Action.abort ) then
	        base.common.InformNLS(User, "Du brichst deine Arbeit ab.", "You abort your work.")
	       return
		end
		
		if ( ltstate == Action.none ) then
            if (cauldron:getData("essenceBrew") =="true") then
		        actionDuration = 40 -- when we combine a stock and an essence brew, it takes longer
            else
                actionDuration = 20
            end				
			User:startAction( actionDuration, 21, 5, 10, 45)
			return
		end	  

		-- water, stock or potion is in the cauldron; leads to a failure
		if cauldron:getData("cauldronFilledWith") == "water" then
			world:gfx(1,cauldron.pos)
		    base.common.InformNLS(User, "Du Inhalt des Kessels verpufft, als Du das Wasser hinzu tust.", 
		                                "The substance in the cauldron blows out, as you fill the water in.")
		
		elseif cauldron:getData("stockData") ~= "" then
			druid.base.alchemy.CauldronExplosion(User,cauldron,{4,5})
			
		elseif cauldron:getData("potionEffectId") ~= "" then
			if cauldron:getData("potionId") == "331" then -- support potion
			    druid.item.id_165_blue_bottle.SupportStock(User,support,stock)
			else
			    druid.base.alchemy.CauldronExplosion(User,cauldron,{4,36})
		    end
			
		elseif cauldron:getData("cauldronFilledWith") == "essenceBrew" then 
			druid.base.alchemy.CombineStockEssence( User, SourceItem, cauldron, Counter, Param, ltstate )
		
		else -- nothing in the cauldron, we just fill in the stock
            cauldron:setData("stockData",SourceItem:getData("stockData"))
		end
		
		world:changeItem(cauldron)
		SourceItem:setData("stockData","")
		SourceItem.id = 164
		SourceItem.quality = 333
	    if math.random(1,20) == 1 then
		    world:erase(SourceItem,1)	 -- bottle breaks
		    Uase.common.InformNLS(User, "Die Flasche zerbricht.", "The bottle breaks.")
        else	
		    world:changeItem(SourceItem)
        end
	
	else -- no cauldron, drink 
	    if User.attackmode then
		   base.common.InformNLS(User, "Du kannst nichts trinken, whrend Du kmpfst.", "You cannot drink while fighting.", Player.lowPriority)
		else
		    User:talkLanguage(Character.say, Player.german, "#me trinkt eine grne Flssigkeit.");
			User:talkLanguage(Character.say, Player.english, "#me drinks a green liquid.");
			base.common.InformNLS(User, "Du hast nicht das Gefhl, dass etwas passiert.", "You don't have the feeling that something happens.")
			SourceItem.id = 164
		    SourceItem.quality = 333
	        if math.random(1,20) == 1 then
		       User:eraseItem(SourceItem,1) -- bottle breaks
		       base.common.InformNLS(User, "Die Flasche zerbricht.", "The bottle breaks.", Player.lowPriority)
            else	
		        world:changeItem(SourceItem)
            end
	        User.movepoints=User.movepoints - 20
		end
	end
end
function LookAtItem(User,Item)
    world:itemInform(User, Item, base.lookat.GenerateLookAt(User, Item, 0))
end   <commit_msg>some changes<commit_after>-- Testskript 1 fr Weiterentwicklung Druidenmagie
-- 2007 by Falk
-- 2009 by Nitram
-- 2011 by Merung
-- Trinken aus grner Flasche (331)
-- ------------------------------------------------

-- include base.common for additional functions
require("base.common")
require("base.character")
require("alchemy.item.id_165_blue_bottle")

module("alchemy.item.id_331_green_bottle", package.seeall)

-- UPDATE common SET com_script='alchemy.item.id_331_green_bottle' WHERE com_itemid = 331;


function UseItem( User, SourceItem, TargetItem, Counter, Param, ltstate )
    
	if SourceItem:getData("bottleFilledWith") ~= "stock" then -- no stock, something else
	    return
	
	else
        -- infront of a cauldron?
		local cauldron = GetCauldronInfront(User)
        if cauldron then
	        
			-- is the char an alchemist?
	        local anAlchemist = alchemy.base.alchemy.CheckIfAlchemist(User,"<NAME>, die in die Kunst der Alchemie eingefhrt worden sind, knnen hier ihr Werk vollrichten.","Only those who have been introduced to the art of alchemy are able to work here.")
		    if not anAlchemist then
		        return
	        end
		
			if ( ltstate == Action.abort ) then
				base.common.InformNLS(User, "Du brichst deine Arbeit ab.", "You abort your work.")
			   return
			end
		
			if ( ltstate == Action.none ) then
				User:startAction( 40, 21, 5, 10, 45)
				return
			end	  

			FillStockIn(User,cauldron,SourceItem)
			alchemy.base.alchemy.EmptyBottle(User,SourceItem)
		else
		    DrinkIt(User, SourceItem)
		end
	end
end

function DrinkIt(User, SourceItem)
    if User.attackmode then
		base.common.InformNLS(User, "Du kannst nichts trinken, whrend Du kmpfst.", "You cannot drink while fighting.", Player.lowPriority)
	else
		User:talkLanguage(Character.say, Player.german, "#me trinkt eine grne Flssigkeit.")
		User:talkLanguage(Character.say, Player.english, "#me drinks a green liquid.")
		base.common.InformNLS(User, "Du hast nicht das Gefhl, dass etwas passiert.", "You don't have the feeling that something happens.")
		User.movepoints=User.movepoints - 20
		alchemy.base.alchemy.EmptyBottle(User,SourceItem)
    end
end

function FillStockIn(User,cauldron,SourceItem)
    -- water, stock or potion is in the cauldron; leads to a failure
	if cauldron:getData("cauldronFilledWith") == "water" then
		alchemy.base.alchemy.CauldronDestruction(User,cauldron,1)

	elseif cauldron:getData("cauldronFilledWith") ~= "stock" then
		alchemy.base.alchemy.CauldronDestruction(User,cauldron,2)
	
	elseif cauldron:getData("cauldronFilledWith") == "potion" then
		if cauldron.id == 1011 then -- support potion
			 alchemy.item.id_165_blue_bottle.SupportStock(User,cauldron,SourceItem)
		else
			alchemy.base.alchemy.CauldronExplosion(User,cauldron,2)
		end
	
	elseif cauldron:getData("cauldronFilledWith") == "essenceBrew" then 
		alchemy.base.alchemy.CombineStockEssence( User, SourceItem, cauldron)

	elseif cauldron.id == 1008 -- nothing in the cauldron, we just fill in the stock
		alchemy.base.alchemy.StockFromTo(SourceItem,cauldron)
		cauldron:setData("cauldronFilledWith","stock")
		cauldron.id = 1012
		world:changeItem(cauldron)
	end
end

function LookAtItem(User,Item)
    world:itemInform(User, Item, base.lookat.GenerateLookAt(User, Item, 0))
end 
{'fraction_non_alphanumeric': 0.11589855467684756, 'fraction_numerical': 0.018952822470684482, 'mean_word_length': 3.3660714285714284, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5813860', 'n_tokens_mistral': 2750, 'n_tokens_neox': 2393, 'n_words': 631}