The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pet Hunger
Author Message
Van Glan Bloom
Journeyman
*

Posts: 104
Likes Given: 2
Likes Received: 3 in 3 posts
Joined: Jun 2013
Reputation: 0



Post: #1
Pet Hunger
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
(This post was last modified: 05-11-2015 10:31 AM by Van Glan Bloom.)
05-11-2015 10:30 AM
Find all posts by this user Like Post Quote this message in a reply
XuN
Sphere Developer
*****

Posts: 852
Likes Given: 102
Likes Received: 156 in 119 posts
Joined: Jul 2013
Reputation: 30



Post: #2
RE: Pet Hunger
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).
05-11-2015 05:27 PM
Find all posts by this user Like Post Quote this message in a reply
Van Glan Bloom
Journeyman
*

Posts: 104
Likes Given: 2
Likes Received: 3 in 3 posts
Joined: Jun 2013
Reputation: 0



Post: #3
RE: Pet Hunger
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
05-11-2015 10:55 PM
Find all posts by this user Like Post Quote this message in a reply
XuN
Sphere Developer
*****

Posts: 852
Likes Given: 102
Likes Received: 156 in 119 posts
Joined: Jul 2013
Reputation: 30



Post: #4
RE: Pet Hunger
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
05-12-2015 02:36 AM
Find all posts by this user Like Post Quote this message in a reply
Van Glan Bloom
Journeyman
*

Posts: 104
Likes Given: 2
Likes Received: 3 in 3 posts
Joined: Jun 2013
Reputation: 0



Post: #5
RE: Pet Hunger
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...
05-12-2015 09:47 AM
Find all posts by this user Like Post Quote this message in a reply
XuN
Sphere Developer
*****

Posts: 852
Likes Given: 102
Likes Received: 156 in 119 posts
Joined: Jul 2013
Reputation: 30



Post: #6
RE: Pet Hunger
timerf 30, emote something
05-12-2015 05:00 PM
Find all posts by this user Like Post Quote this message in a reply
Van Glan Bloom
Journeyman
*

Posts: 104
Likes Given: 2
Likes Received: 3 in 3 posts
Joined: Jun 2013
Reputation: 0



Post: #7
RE: Pet Hunger
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
05-14-2015 10:57 PM
Find all posts by this user Like Post Quote this message in a reply
XuN
Sphere Developer
*****

Posts: 852
Likes Given: 102
Likes Received: 156 in 119 posts
Joined: Jul 2013
Reputation: 30



Post: #8
RE: Pet Hunger
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.
05-15-2015 04:49 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 4 Guest(s)