Class MMOItem

  • All Implemented Interfaces:
    IMMOItem

    public class MMOItem
    extends BaseMMOItem
    An MMOItem represents a non-player entity inside an MMORoom. MMOItems can be used as bonuses, triggers, bullets etc... or any other non-player entity that will be handled using the MMORoom's rules of visibility.

    This means that whenever one or more MMOItem falls within the AoI of a Player it will be notified to the User with a client side PROXIMITY_LIST_UPDATE. MMOItems are identified by unique ID and by all of their custom variables.

    MMOItems also have Variables that behave just like User Variables, that can be used to attach any custom property to each Item.

    Example of use:

     // Prepare the variables
     List<IMMOItemVariables> vars = new LinkedList<IMMOItemVariables>();
     vars.add(new MMOItemVariable("type", "1");  // identifies the type of bonus based on our game rules
     vars.add(new MMOitemVariable("val", 100);   // the value of the bonus
     
     // Create the item
     MMOItem bonus = new MMOItem(vars);
     
     // Access the MMO API
     ISFSMMOApi mmoApi = SmartfoxServer.getInstance().getAPIManager().getMMOApi;
     
     // Set the Item in the room at specific coordinates 
     mmoApi.setMMOItemPosition(bonus, new Vec3D(10, 20, 5), theMMORoom);
      
     

    The final line of code assumes we already have an MMORoom object where the Item will be added. It might be an existing room or one that has just been created. After the Item is placed in the MMORoom a PROXIMITY_LIST_UPDATE will be sent to Users that are within range of the object.

    Tutorial

    To learn more see also this introductory tutorial.
    Since:
    2.8.x
    See Also:
    MMOItemVariable, MMORoom, SFSMMOApi