This primitive is used to broadcast a "message" to objects of the specified type(s) in the specified location that are set up to listen for it.
Objects receive messages if they implement a "Message Handler" function BHAV and define it in their OBJf entry.
Messages have a unique ID and message specific parameters. Unfortunately there is no way to request a message ID so it is possible for mods to conflict over their allocation.
There is no SimPe wizard for this instruction, so the following table details the meaning of each of the operands.
Operand | Description | Operand Values |
---|---|---|
0 | Location of objects to receive the message relative to the sending object (see also bit 3 of Op4) | 0x00: In same room 0x01: On same level 0x02: On lot 0x03: Inside building 0x04: Outside building |
1 & 2 | Qualifiers on the variable in operand 15 | |
3 | Target objects to receive the message (see also bit 1 of Op4) | 0x00: Selectable sims0x01: Selectable sims & neighbours0x02: Selectable sims & NPCs0x03: Neighbours0x04: NPCs0x05: All Sims0x06: Objects0x07: Everything |
4 - bit 1 | Controls where Location is taken from | Off: Use value in Op0 On (and Op0 is 0x00): Variable in Op5 gives specific room |
4 - bit 2 | Unused | |
4 - bit 3 | Controls where Target is taken from | Off: Use value in Op3 On: Use value in variable in Op5 |
5 | Variable containing the value to use as the Target/Location (see Op4) | |
6 & 7 | Qualifiers on the variable in operand 5 | |
8 | Priority of the message. Values seem to range from 0x00 to 0x02, but meaning and order is unknown | |
9 | Variable containing the value to pass as User Data 1 | |
10 & 11 | Qualifiers on the variable in operand 9 | |
12 | Variable containing the value to pass as User Data 2 | |
13 & 14 | Qualifiers on the variable in operand 12 | |
15 | Variable containing the value to pass as the Message ID |
- 0x0000 to 0x000D - defined in BCON 0x010C
- 0x0037 - used by "Doorbell"
- 0x00E7 - used by "In Room"
- 0x03E9 to 0x0404 - defined in BCON 0x012B
- 0x07D1 to 0x07D3 - defined in BCON 0x012B
- 0x0BB8 - used by "Broadcast Memory"
- 0x3A99 - used by "Finished Common Entry"
The BHAV defined as the Message Handler function in the receiving object's OBJf entry will receive at least five and possibly eight parameters - Maxis code implies there are eight, I've only ever received five, so treat params 5, 6 and 7 with caution. The "Reaction Trigger Handler" object has a message handler defined.
- 0 - Message ID
- 1 - Stack Object at time of call
- 2 - Priority
- 3 - User Data 1
- 4 - User Data 2
- 5 - ? User Data 3
- 6 - ? Sender ID
- 7 - ? Receiver ID
WH_Broadcaster_AgeTransition.package - modifies the age transistion code and sends two messages. As a Sim gets a day older (modification to "Sub - Age Days Left - Text Notification Barrage" BHAV 0x1049), the message 0x000E, priority 0x00, with User Data 1 = My OID and User Data 2 = My NID is broadcast. As a Sim transistions from one life stage to another (eg child to teen) (modification to "Age Transition" BHAV 0x1009) , the message 0x000F, priority 0x00, with User Data 1 = My OID and User Data 2 = My NID is broadcast.
WH_Listener_AgeTransition - listens for both messages and uses the latter to change a child's school to private if they have elder siblings still at private school.
Sample Broadcaster and Listener Code - MessageSamples.zip
- Entering and Exiting a Room
- SimAntics
- Primitives
- Variables & Attributes
- Stack Object
- Temporary Variables
- Byte Order
// Decompiled with JetBrains decompiler // Type: pjse.BhavNameWizards.WizPrim0x0077 // Assembly: pjse.coder.plugin, Version=4.0.3349.37576, Culture=neutral, PublicKeyToken=null using SimPe; using SimPe.PackedFiles.Wrapper; using System; namespace pjse.BhavNameWizards { public class WizPrim0x0077 : BhavWizPrim { public WizPrim0x0077(Instruction i) : base(i) { } protected override string Operands(bool lng) { byte[] numArray = new byte[16]; ((byte[]) this.instruction.Operands).CopyTo((Array) numArray, 0); ((byte[]) this.instruction.Reserved1).CopyTo((Array) numArray, 8); string str1 = "" + (lng ? pjse.Localization.GetString("bwp_message") + ": " : "") + this.dataOwner(lng, numArray[15], numArray[1], numArray[2]) + ", " + (lng ? pjse.Localization.GetString("Target") + ": " : ""); string str2; if (((int) numArray[4] & 4) != 0) { str2 = str1 + this.dataOwner(lng, numArray[5], numArray[6], numArray[7]); } else { switch (numArray[3]) { case 0: str2 = str1 + pjse.Localization.GetString("bwp77_selectableSims"); break; case 1: str2 = str1 + pjse.Localization.GetString("bwp77_selectableSims") + " + " + pjse.Localization.GetString("bwp77_neighbors"); break; case 2: str2 = str1 + pjse.Localization.GetString("bwp77_selectableSims") + " + " + pjse.Localization.GetString("bwp77_npcs"); break; case 3: str2 = str1 + pjse.Localization.GetString("bwp77_neighbors"); break; case 4: str2 = str1 + pjse.Localization.GetString("bwp77_npcs"); break; case 5: str2 = str1 + pjse.Localization.GetString("bwp77_allSims"); break; case 6: str2 = str1 + pjse.Localization.GetString("bwp77_objects"); break; case 7: str2 = str1 + pjse.Localization.GetString("bwp77_everything"); break; default: str2 = str1 + pjse.Localization.GetString("unk") + ": 0x" + Helper.HexString(numArray[3]); break; } } if (lng) { string str3 = str2 + ", " + (lng ? pjse.Localization.GetString("bwp_Location") + ": " : ""); string str4; switch (numArray[0]) { case 0: str4 = str3 + pjse.Localization.GetString("bwp77_room") + ": " + (((int) numArray[4] & 1) == 0 ? pjse.Localization.GetString("bwp77_same") : this.dataOwner(numArray[5], numArray[6], numArray[7])); break; case 1: str4 = str3 + pjse.Localization.GetString("bwp77_onSameLevel"); break; case 2: str4 = str3 + pjse.Localization.GetString("bwp77_onLot"); break; case 3: str4 = str3 + pjse.Localization.GetString("bwp77_insideBuilding"); break; case 4: str4 = str3 + pjse.Localization.GetString("bwp77_outsideBuilding"); break; default: str4 = str3 + pjse.Localization.GetString("unk") + ": 0x" + Helper.HexString(numArray[0]); break; } str2 = str4 + ", " + pjse.Localization.GetString("bwp_priority") + ": 0x" + Helper.HexString(numArray[8]) + ", " + pjse.Localization.GetString("bwp77_userData") + ": (" + this.dataOwner(numArray[9], numArray[10], numArray[11]) + ", " + this.dataOwner(numArray[12], numArray[13], numArray[14]) + ")"; } return str2; } } }