@name Cactus
@persist Timer Water Fertilizer Died Checked FertObj:array [E O]:entity Status:string
@model models/props_junk/terracotta01.mdl
runOnTick(1)

if (first()|duped())
{
    O = owner()
    E = entity()
    
    Fertilizer = 0
        
    holoCreate(1)
    holoModel(1, "hq_sphere")
    holoScale(1, vec(1.25,1.25,0))
    holoPos(1, E:pos() + vec(-0.75,0,10))
    holoMaterial(1, "models/props/CS_militia/boulder01")
    holoParent(1, E)
    
    holoCreate(2)
    holoModel(2, "models/props_foliage/cactus01.mdl")
    holoPos(2, E:pos() + vec(-0.6,0,10))
    holoParent(2, E)
    holoScale(2, vec(0,0,0))
    holoShadow(2,1)
    
    concmd("say Cactus by KaMiKaZeee! has spawned! :D")
}
#Firs time in water checker
if (E:isUnderWater() & Checked == 0){Checked = 1}

#Fertilizant
findInSphere(E:pos(), 25)
findIncludeModel("models/props_lab/jar01a.mdl") 
findIncludeModel("models/props_lab/jar01b.mdl") 
FertObj = findToArray()

for (I = 1, FertObj:count())
{
    if (FertObj[I, entity]:model() == "models/props_lab/jar01a.mdl" & Fertilizer < 100)
    {Fertilizer += 12.5
        FertObj[I, entity]:propDelete()}
    if (FertObj[I, entity]:model() == "models/props_lab/jar01b.mdl" & Fertilizer < 100)
    {Fertilizer += 5
        FertObj[I, entity]:propDelete()}
}

if (Fertilizer > 100){Fertilizer = 100}

if (Fertilizer > 1){Fertilizer-= 0.05}

#Water
if (Water > 50 & Water < 150){Timer += 0.0001}

if (Fertilizer > 50 & Water < 75){Timer *= 2}

if (Timer < 1){holoScale(2, vec(Timer,Timer,Timer))} 

if (E:isUnderWater() & Water < 151) {Water+= 0.05
    Status = "Drinking Some Water"}elseif
(E:isUnderWater() == 0 & Water > 0 & Water < 150){Water -= 0.005}

if (Water < 50) {holoColor(2, vec(Water*5,Water*4,Water*4))}else
{holoColor(2,vec(255,255,255))
    Status = "Happy Cactus :D"}
    
if (Water < 50 & !E:isUnderWater() & Died == 0){Status = "Need Water!"}
    
if (Water > 100) 
{
    Status = "Dying :S So Many Water"
}

if (Water > 150) 
{
    holoColor(2,vec(20,20,20)) 
    Status = "Died D:" 
    if (Died == 0)
    {
        concmd("say [CACTUS] Died because too much water D:")
        Died = 1
    } 
}

if (Checked & Water == 0)
{
    holoColor(2,vec(20,20,20)) 
    Status = "Died D:" 
    if (Died == 0)
    {
        concmd("say [CACTUS] Died because no water D:")
        Died = 1
    } 
}

#Display
setName("--KaMiKaZeee Cactus-- 
----o----
Water [" + floor(Water):toString() + "%]
Fertilizer [" + floor(Fertilizer):toString() + "%]
Status [" + Status + "]
----o----")
