PDA

View Full Version : Hiding a pie menu function


Gwenke33
9th Nov 2011, 01:26 PM
I would like to influence the probability that a certain interacttion is chosen by sims with various traits.
I thought to put the various checks and calculations in the guardian BHAV, which would then allow the sims that meet the criteria to use the object about 50% of the time.

How do I hide this whole interaction in the pie menu from the player? I tried including the Hide Menu global in the guard, but I'm afraid it killed the autonomy.

Maybe I should approach my goal entirely differently?

xiaoyun
9th Nov 2011, 04:28 PM
Returning false from guardian bhav of pie menu item will hide this menu item while
returning true will ofcourse let it to be displayed / used.

Unfortunately there are more than one way to create pie menus,
therefore parameters received by guardian bhav's may differ for each type.

If pie menu is static (defined in TTAB) then param 0 send to its guardian bhav
will tell you who is trying to access this menu item.

If pie menu is created dynamically with Add/change action string,
then you will probably use CT - Object Menu BHAV
where param 1 will define who is trying to access your menu.

But for both examples value send through this param will be 0 = player / 1 = sim

What you have to do then, is define guardian BHAV arg count to 0x02 (to be able read these parameters)
then in guardian BHAV check param 0 (or param 1 (look above explanation)),
if its 0 (player) then exit with false (hide item from player)
or if its 1 (sim) then exit with true (let it to be visible to sim).

Gwenke33
9th Nov 2011, 10:38 PM
Wow. Thank you very much. This looks exactly what I wanted.

My object has a TTAB-based menu. So, is it enough to insert a check for param 0 as the last line, set it up as you described, and whatever the result of the earlier checks is, that interaction will never appear for the player, but sims can use it autonomously? (Autonomy is set to 0x00000032).
So far I've managed to make it disappear from the menu, this way but my test sims do not ever use the interaction.
Could you perhaps suggest an object where it is used this way, so that I can check?

Edit:
It works! It was just my sims being very uncooperative. I'd still be interested in an in-game example, though.
Thank you again!
(For the record, I think 'Hide Menu' would also work, as I now saw it in the flamingo.)

xiaoyun
10th Nov 2011, 03:05 PM
The problem here is that we let sims decide by them self if they want to use your object,
and ofcourse as you noticed, more objects on lot you have, less often sims will want to use it.

What defines item attractivity to sims here is TTAB options / motives.
It "announce" to sims what object have to offer then sims chose it or not depending on own need's.
Manipulating it would lure sims to chose your item more often but they would use it over and over expecting to satisfy these needs
(but instead they would be just checked for something and droped), ignoring at the same time objects which really would satisfy them.
So we will not only not alter TTAB's motives settings to not "lie" to sims, but additionally we will block them completly from autonomously chosing our object by setting TTAB's autonomy to 0x64. :blink:

Ok, so what now if they cant chose it and player also cant ? :cry:

There is Function - Main in our object, which is running all the time in loop, why not use it to browse all sims on lot from time to time
and if any sim meets our conditions, make him chose our menu option ?
Thats what we will do :bunny:

TTAB
; autonomy is set to 0x64 so no sim can chose our menu item by himself.

Function - Option 1 TEST () (menu item guardian BHAV)
; hide menu so player cant chose it.
0. [global 0x0109] Hide Menu (no args) [true][true] ; menu will not become displayed (but still can be chosed by sim)

Function - Option 1 () (menu item BHAV)
; Here we can put anything we want our chosed sim to do (My is sim object ID)
; For test i put here Dialog so we can see our sim really chosed this menu item.
0. [prim 0x0002] Expression (Stack Object ID 0x0000 := My person data 0x001F (neighbor id)) [go1][error] ; neighbor ID for Dialog icon
1. [prim 0x0024] Dialog (Text Notification,"$Me has chosed example option 1" ...) [true][error] ; show text message - so we see it works !

Test - ShouldThisSimChoseOption1 ? (obSim: P0) return flags
; (here we check our conditions (param 0 = object sim) then return false or true)
; For test i put here example condition which generate random number in range
; from 0 to 100 and if number is less than 30 then it return true (30% chance for sim to be chosed))
0. [prim 0x0008] Random Number (Local 0x0000 := 0 .. < Literal 0x0064) [go1][error] ; get random number from range 0 to 100 into Local(0)
1. [prim 0x0002] Expression (Local 0x0000 < Literal 0x001E) [true][false] ; if local(0) is < than 30 then exit with true, else exit with false

Function - Main ()
; Here in defined time intervals we browse for every sim on lot
; then check if he meets our condition and if yes then we make him chose our menu item :bunny:
0. [global 0x016F] Idle - Minutes (1 arg: Minutes=Literal 0x0001) [go1][error] ; browse every 1 sim minute (better less often, its fast here as example)
1. [prim 0x0002] Expression (Stack Object ID 0x0000 := Literal 0x0000) [go2][error] ; we start with "no sim"
2. [prim 0x001F] Set to Next (Stack Object ID 0x0000, person) [found go3][notmoresims go0] ; lets find next sim and put him to stack object ID
3. [private 0x1004] Test - ShouldThisSimChoseOption1 ? (1 arg: Stack Object ID 0x0000)[yesgo4][nogo2] ; we want this sim ?
4. [prim 0x0002] Expression (Local 0x0000 := My 0x000B (object id)) [go5][error] ; Local(0) is our object sim have to chose
5. [prim 0x000D] Push Interaction (Target: Stack Obj, Obj: Local 0x0000, Interaction: Literal 0x0001, max priority) [nextgo2][nextgo2] ; he chose it

Working example of painting which perform above alghoritm is attached as download at bottom of this post.

:!!: Warning :!!:
This item is a tutorial example and contain random GUID in OBJD file (0x12312312)
If you plan to modify this item and release to public, please remember to change OBJD's file GUID to valid one.
(You may obtain your own unique GUID by chosing getGUID link in SimPE's OBJD file editor)

:new: You can ofcourse add more options and various tests for each menu item.
To do this, add new menu items in TTAB / TTAs, then clone Test - ShouldThisSimChoseOption1 ? for each menu item.
In Function - Main for each menu item add line 3-4-5, change line 3 to Test - ShouldThisSimChoseOption2 ?
In line 5 Interaction: Literal 0x000X is number of menu item.

It may look like this for 3 menu items, where each menu item may have different requirements to be chosen :

Function - Main ()
0. [global 0x016F] Idle - Minutes (1 arg: Minutes=Literal 0x0001) [go1][error] ; browse every 1 sim minute (better less often, its fast here as example)
1. [prim 0x0002] Expression (Stack Object ID 0x0000 := Literal 0x0000) [go2][error] ; we start with "no sim"
2. [prim 0x001F] Set to Next (Stack Object ID 0x0000, person) [found go3][notmoresims go0] ; lets find next sim and put him to stack object ID
3. [private 0x1004] Test - ShouldThisSimChoseOption1 ? (1 arg: Stack Object ID 0x0000)[yesgo4][nogo6] ; should chose option 1 ?
4. [prim 0x0002] Expression (Local 0x0000 := My 0x000B (object id)) [go5][error] ; Local(0) is our object sim have to chose
5. [prim 0x000D] Push Interaction (Target: Stack Obj, Obj: Local 0x0000, Interaction: Literal 0x0001, max priority) [nextgo2][nextgo2] ; he chose it, lets check next sim
6. [private 0x1004] Test - ShouldThisSimChoseOption2 ? (1 arg: Stack Object ID 0x0000)[yesgo7][nogo9] ; should chose option 2 ?
7. [prim 0x0002] Expression (Local 0x0000 := My 0x000B (object id)) [go8][error] ; Local(0) is our object sim have to chose
8. [prim 0x000D] Push Interaction (Target: Stack Obj, Obj: Local 0x0000, Interaction: Literal 0x0002, max priority) [nextgo2][nextgo2] ; he chose it, lets check next sim
9. [private 0x1004] Test - ShouldThisSimChoseOption3 ? (1 arg: Stack Object ID 0x0000)[yesgoA][nogo2] ; should chose option 3 ?
A. [prim 0x0002] Expression (Local 0x0000 := My 0x000B (object id)) [goB][error] ; Local(0) is our object sim have to chose
B. [prim 0x000D] Push Interaction (Target: Stack Obj, Obj: Local 0x0000, Interaction: Literal 0x0003, max priority) [nextgo2][nextgo2] ; he chose it, lets check next sim
ect...

Take note line 0. cause our checks to run every sim minute (Minutes=Literal 0x0001)
I have made it that rapid only for testing purpose to "see fast, that it works".
In real, nothing changes "that fast" in sims world so its unnecessary to check so often.
It would be good to change it to some higher value like 5 or 10 sim minutes ? or even more.

:new: In previous version i forgot to include line 3 in Function - Main () which is very important >,<
Missing this line will cause every sim to be "chosed" always, no matter of our criteria. Im very sorry for this. Bug is allready fixed
Please redownload.

Gwenke33
12th Nov 2011, 08:10 PM
Wow.
That was extremely helpful. A mini-tutorial in itself on creating a funtioning object.
The clarification on attractiveness was especially helpful.

I am sure that I will use this for some object where sims HAVE to do something, as this methods seems suited to those types of situations rather than fun objects, where the frequency of use should really be affacted by what other objects are offerig fun to sims.

Thank you again, this will be a very useful resource for others as well.