SphereCommunity
Pet Hunger - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: Pet Hunger (/Thread-Pet-Hunger)



Pet Hunger - Van Glan Bloom - 05-11-2015 10:30 AM

Good night people. I need your help in a script.

I inserted a hunger system in pets, so that the player have to feed the animals periodically. However I can not achieve my goal. I wanted when the animal had less than 2 food he left the player and stay ownerless.

Until now I have this

Code:
[function isfood]
IF (<type>==t_fruit) || (<type>==t_grain) || (<type>==t_meat_raw) || (<type>==t_food_raw) || (<type>==t_food)
return 1
else
return 0
ENDIF

[EVENTS e_pet_food]

ON=@ReceiveItem
if (<food> >= 64)
    emote is full
return 1
elseif (<argo.isfood>)
    food=<food> +2
        emote eats <argo.name>
            argo.remove
endif


ON=@npclostteleport
return 1

ON=@Hunger
if (<food> <= 30 )
emote are hungry
endif

ON=@Spelleffect
ref1=<tag0.dono>
    if (!(<ref1>))
        ref1=<owner>
            endif
if (<ref1> == <src>)
    if (<serv.spell.<argn1>.flags>&spellflag_harm)
        return 1
    endif
endif



RE: Pet Hunger - XuN - 05-11-2015 05:27 PM

http://wiki.sphere.torfo.org/index.php/@Hunger

Right now the only check you have related is 'if (<food> <= 30)' which is far away from '2', then you can do something like 'damage 0,01,<owner>', this will make pet think owner damaged it ... so it will desert and do all default checks (unmount, update PetSlots,remove memories, etc).


RE: Pet Hunger - Van Glan Bloom - 05-11-2015 10:55 PM

Like this ??

Code:
[ITEMDEF i_mem_pet_desert]
ID=i_memory
TYPE=t_eq_script

ON=@EQUIP
TIMER=1
ATTR=attr_decay

ON=@TIMER
if (<food> <= 2 )
    damage=0.01,<owner>
return 1
endif

Code:
ON=@Hunger
ser.newitem=i_mem_pet_desert



RE: Pet Hunger - XuN - 05-12-2015 02:36 AM

No.
First: @Hunger does not exists anymore, click the link I gave you.
Second: serv.newitem=xxx doesn't place the item, you must equip it
Third: <food> in @Timer will refer to the item, items doesn't have food, you must use <cont.food> and cont.damage
Fourth: You don't need anything from serv.newitem or @timers, you only have to check in the @RegenStat trigger if <food> < 2 when argn1=3


RE: Pet Hunger - Van Glan Bloom - 05-12-2015 09:47 AM

Thx Xun with your help i got it the script. =)

One more question is possibly in @regenstat use some timer for the say something like :

Exemple
Code:
on=@regenstat
....
emote Say something
Time=30...



RE: Pet Hunger - XuN - 05-12-2015 05:00 PM

timerf 30, emote something


RE: Pet Hunger - Van Glan Bloom - 05-14-2015 10:57 PM

It is possible to add an event to the player so that the animal stay with 0 food?
Anything like that :

Code:
on=@RegenStat
if (<food> = 0 )
    src.newitem i_system_pet_rabbit_removed
        act.cont=<owner.findlayer.layer_pack.uid>
            src.events -e_money_collect
                src.events +e_no_money_collect
            remove
        return 1
    endif



RE: Pet Hunger - XuN - 05-15-2015 04:49 AM

http://wiki.sphere.torfo.org/index.php/@RegenStat Please read it...


Food doesn't increase ... it decreases. You have 2 ways to achieve that with this trigger.