Jump to content

michaelbolland

Registered
  • Posts

    0
  • Joined

  • Last visited

Posts posted by michaelbolland

  1. thanks that would be really great, can you possibly put it in the wiki for others too?

     

    i know you have a lot of work to do for the roadmap and instead of you coding in changes for us to do what we want to achieve if you can go into detail on how it works currently we can do the changes ourselves and then if you are happy we can submit our changes to you for future releases

     

    that way the community can work in harmony with you instead of being a burden, sure we will have technical questions but if you believe it is possible for us to make the changes now then all that needs to be addressed is the documentation really

     

    thanks again!

  2. Hi Sooms,

     

    Thank you for the reply, this is really helpful

     

    So as for moving this over to the ClassAbility plugin i am wondering how i should handle my current hook

     

    At the moment the event will fire based on right clicking the item in my inventory

     

    So for example I have added a new effecttype into ItemDatabase.java

     

    Here is the code

     

    } else if (effectType.equals("BuildingMaterial")) {
    // Used to turn an item into a Building Resource when acquired
    //String value = rs.getString("effect" + i + "value");
    //int resourceID = Integer.parseInt(value);
    tmpl.put(InventoryClient.ITEM_NAMESPACE, AgisItem.TEMPL_ACQUIRE_HOOK, new BuildingResourceAcquireHook(rs.getInt("id")));
    } else if (effectType.equals("Blueprint")) {
    // Used to turn an item into a recipe when acquired
    String value = rs.getString("effect" + i + "value");
    int recipeID = Integer.parseInt(value);
    tmpl.put(InventoryClient.ITEM_NAMESPACE, InventoryClient.TEMPL_ACTIVATE_HOOK, new RecipeItemActivateHook(recipeID));
    } else if (effectType.equals("ConsumeAbility")) {
    // Mixxit - Used to turn an item into an ability when acquired
    String value = rs.getString("effect" + i + "value");
    int abilityID = Integer.parseInt(value);
    tmpl.put(InventoryClient.ITEM_NAMESPACE, InventoryClient.TEMPL_ACTIVATE_HOOK, new ConsumeAbilityActivateHook(abilityID));
    }

     

    At the point here, where I am putting the hook into the Item Namespace, are you saying I need to instead put this into the ClassAbility namespace?

     

    If so how will the event fire for the right click of the item?

  3. Hey Shooms,

     

    I dont want auto learning abilities, i am wanting to have clicky items that grant them

     

    So I modified the recipe hook script and made a new one from it to allow items to be consumed to give abilities

     

    But for some reason I don't see the ability on my action bar - I do however get a message saying I can't consume the ability if i try to use it a second time (it states i already know it)

     

    So it seems like I am getting the ability but it's not showing - any ideas why?

     

    Code below

     

    package atavism.agis.core;
    
    import java.io.Serializable;
    import java.util.HashMap;
    import java.util.LinkedList;
    import java.util.Map;
    
    import atavism.server.engine.BasicWorldNode;
    import atavism.server.engine.Engine;
    import atavism.server.engine.EnginePlugin;
    import atavism.server.engine.OID;
    import atavism.server.math.AOVector;
    import atavism.server.objects.ObjectTypes;
    import atavism.server.plugins.WorldManagerClient;
    import atavism.server.plugins.WorldManagerClient.ExtensionMessage;
    import atavism.server.plugins.WorldManagerClient.TargetedExtensionMessage;
    import atavism.server.util.*;
    import atavism.agis.objects.*;
    import atavism.agis.plugins.AgisInventoryClient;
    import atavism.agis.plugins.CombatPlugin;
    import atavism.agis.plugins.CraftingClient;
    import atavism.agis.plugins.VoxelClient;
    import atavism.agis.util.ExtendedCombatMessages;
    
    /**
    * An acquire hook for items that turn into an ability
    * when acquired.
    */
    public class ConsumeAbilityActivateHook implements ActivateHook {
       public ConsumeAbilityActivateHook() {
       	super();
       }
    
       public ConsumeAbilityActivateHook(int abilityID) {
       	super();
       	setAbilityID(abilityID);
       }
    
       public void setAbilityID(int abilityID) {
           if (abilityID == -1) {
               throw new RuntimeException("ConsumeAbilityActivateHook.setResource: bad resource");
           }
           this.abilityID = abilityID;
       }
       public int getAbilityID() {
       	return abilityID;
       }
       protected int abilityID;
    
       /**
        * Adds the item to the Building Resources map for the player and returns true telling the item to be
        * destroyed.
        */
       public boolean activate(OID activatorOid, AgisItem item, OID targetOid) {
           if (Log.loggingDebug)
               Log.debug("ConsumeAbilityActivateHook.activate: activator=" + activatorOid + " item=" + item + " ability=" + abilityID);
    
           // Only convert it if it is activated by a player
           if (WorldManagerClient.getObjectInfo(activatorOid).objType != ObjectTypes.player) {
           	return false;
           }
    
           // Add ability resource
           LinkedList abilities = (LinkedList)EnginePlugin.getObjectProperty(activatorOid, WorldManagerClient.NAMESPACE, "abilities");
           if (abilities == null) {
           	abilities = new LinkedList();
           } else if (abilities.contains("" + abilityID)) {
           	ExtendedCombatMessages.sendErrorMessage(activatorOid, "You already know that ability");
           	return false;
           }
           abilities.add("" + abilityID);
    	EnginePlugin.setObjectProperty(activatorOid, WorldManagerClient.NAMESPACE, "abilities", abilities);
           ExtendedCombatMessages.sendCombatText(activatorOid, "Learned new ability", 16);
           sendAbilities(activatorOid, abilities);
           //ExtendedCombatMessages.sendAnouncementMessage(activatorOid, "You have learned a new ability", "Skill");
           // Need to remove the item
           AgisInventoryClient.removeSpecificItem(activatorOid, item.getOid(), true, 1);
    
    
    
           return true;
       }
    
       /**
        * Sends down the map of Ability Resources the player has to the client. Static function so can be called from anywhere.
        * @param oid
        * @param resources
        */
    
       public static void sendAbilities(OID oid, LinkedList abilities) {
    	Map props = new HashMap();
           props.put("ext_msg_subtype", "abilities");
           int numResources = 0;
           for (String resourceID : abilities) {
           	Log.debug("RESOURCE: got currency to send: " + resourceID);
           	props.put("resource" + numResources + "ID", resourceID);
           	numResources++;
           }
    
    	props.put("numAbilities", numResources);
           TargetedExtensionMessage msg = new TargetedExtensionMessage(WorldManagerClient.MSG_TYPE_EXTENSION,
           		oid, oid, false, props);
        Engine.getAgent().sendBroadcast(msg);
        Log.debug("ABILITIES: sending down ability message to: " + oid + " with props: " + props);
    }
    
       public String toString() {
       	return "ConsumeAbilityActivateHook=" + abilityID;
       }
    
       private static final long serialVersionUID = 1L;
    }
    
    

  4. i want to post that this is how you stop the camera going underground

     

    the reason i necro this is because there is no searchable text to match the solution for this, just a picture which cannot be searched for :)

     

    so hopefully it will help others

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.