[HELP]add some script to NPC WorldBlesser to restore player HP & MP ?

Results 1 to 6 of 6
  1. #1
    Apprentice gangsterxx is offline
    MemberRank
    Jul 2013 Join Date
    10Posts

    [HELP]add some script to NPC WorldBlesser to restore player HP & MP ?

    Hi .
    Who can help me to add some script to WorldBlesser Npc to restore player HP and MP .

    I found the Npc Script at AL-game\gameserver\data\scripts\system\handlers\ai\worlds\WorldBlesserAI2.java

    This is the original script, start on line 59 .

    PHP Code:
    if (dialogId == 10000)  {int chance Rnd.get(12);
                
    //951: Blessing of Health I, 955: Blessing of Rock I, 954: Blessing of Health IV
                
    SkillEngine.getInstance().getSkill(getOwner(), (chance == 954 955) , 1player).useWithoutPropSkill();
            }
            else if (
    dialogId == 26 && questId != 0) {
                
    PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), dialogIdquestId));
            }
            return 
    true


  2. #2
    Enthusiast cookiehoar is offline
    MemberRank
    Jul 2013 Join Date
    32Posts

    Re: [HELP]add some script to NPC WorldBlesser to restore player HP & MP ?

    Quote Originally Posted by gangsterxx View Post
    Hi .
    Who can help me to add some script to WorldBlesser Npc to restore player HP and MP .

    I found the Npc Script at AL-game\gameserver\data\scripts\system\handlers\ai\worlds\WorldBlesserAI2.java

    This is the original script, start on line 59 .

    PHP Code:
    if (dialogId == 10000)  {int chance Rnd.get(12);
                
    //951: Blessing of Health I, 955: Blessing of Rock I, 954: Blessing of Health IV
                
    SkillEngine.getInstance().getSkill(getOwner(), (chance == 954 955) , 1player).useWithoutPropSkill();
            }
            else if (
    dialogId == 26 && questId != 0) {
                
    PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(getObjectId(), dialogIdquestId));
            }
            return 
    true
    What you can do is change the skill IDs from 954 : 955 to the skill ID for flash of recovery and splendor of recovery that will be 2155 and 2562, this gives a chance for player to get healed and it doesn't immediately heal up. Doubt there's any MP healing skills which can be taught to the NPC since MP skills come only after 4.0 patch for song weaver. The player would have to do this multiple times to get to full HP. However you might get bugs because of skill CD and what not. However if you want to change the NPC to heal full HP and MP of player then you will have to write a custom method to get HP & get MP of player and then heal it by full. You gotta know Java for that. I could do that for you, but I will need to test it first and I'm not at home right now so can't test. But you get the basic concept.

  3. #3
    Apprentice gangsterxx is offline
    MemberRank
    Jul 2013 Join Date
    10Posts

    Re: [HELP]add some script to NPC WorldBlesser to restore player HP & MP ?

    Thank you cookiehoar .
    I believe you can make a custom method to get HP & MP of player .
    maybe This screenshot can help you to make it .


    I get this screenshot from other Private server .

    Sorry for my bad english .

  4. #4
    Apprentice gangsterxx is offline
    MemberRank
    Jul 2013 Join Date
    10Posts

    Re: [HELP]add some script to NPC WorldBlesser to restore player HP & MP ?

    Quote Originally Posted by cookiehoar View Post
    Sorry mate, not at home but look, here's what you could do, if you don't wanna use a pre-made skill. You know the "//heal" admin command? Go to gameserver\data\scripts\system\handlers\admincommands there you should find heal.java and you'll see commands required there for targetting HP / Etc. Or what you could do is in the method you mentioned above with the Skill IDs, you could create an object for the heal class and try implementing "//heal" as a function that's useable by your NPC. :D
    I ever try this method, but often fail when I start server .
    I will try again with this method, maybe I can make it work .

  5. #5
    Enthusiast cookiehoar is offline
    MemberRank
    Jul 2013 Join Date
    32Posts

    Re: [HELP]add some script to NPC WorldBlesser to restore player HP & MP ?

    Sorry mate, not at home but look, here's what you could do, if you don't wanna use a pre-made skill. You know the "//heal" admin command? Go to gameserver\data\scripts\system\handlers\admincommands there you should find heal.java and you'll see commands required there for targetting HP / Etc. Or what you could do is in the method you mentioned above with the Skill IDs, you could create an object for the heal class and try implementing "//heal" as a function that's useable by your NPC. :D

    Code:
    public Heal() {	  super("heal");
       }
    
    
       @Override
       public void execute(Player player, String... params) {
    	  VisibleObject target = player.getTarget();
    	  if (target == null) {
    		 PacketSendUtility.sendMessage(player, "No target selected");
    		 return;
    	  }
    	  if (!(target instanceof Creature)) {
    		 PacketSendUtility.sendMessage(player, "Target has to be Creature!");
    		 return;
    	  }
    
    
    	  Creature creature = (Creature) target;
    
    
    	  if (params == null || params.length < 1) {
    		 creature.getLifeStats().increaseHp(TYPE.HP, creature.getLifeStats().getMaxHp() + 1);
    		 creature.getLifeStats().increaseMp(TYPE.MP, creature.getLifeStats().getMaxMp() + 1);
    		 creature.getEffectController().removeAbnormalEffectsByTargetSlot(SkillTargetSlot.SPEC2);
    		 PacketSendUtility.sendMessage(player, creature.getName() + " has been refreshed !");
    	  }
    	  else if (params[0].equals("dp") && creature instanceof Player) {
    		 Player targetPlayer = (Player) creature;
    		 targetPlayer.getCommonData().setDp(targetPlayer.getGameStats().getMaxDp().getCurrent());
    		 PacketSendUtility.sendMessage(player, targetPlayer.getName() + " is now full of DP !");
    	  }
    	  else if (params[0].equals("fp") && creature instanceof Player) {
    		 Player targetPlayer = (Player) creature;
    		 targetPlayer.getLifeStats().setCurrentFp(targetPlayer.getLifeStats().getMaxFp());
    		 PacketSendUtility.sendMessage(player, targetPlayer.getName() + " FP has been fully refreshed !");
    	  }
    	  else if (params[0].equals("repose") && creature instanceof Player) {
    		 Player targetPlayer = (Player) creature;
    		 PlayerCommonData pcd = targetPlayer.getCommonData();
    		 pcd.setCurrentReposteEnergy(pcd.getMaxReposteEnergy());
    		 PacketSendUtility.sendMessage(player, targetPlayer.getName() + " Reposte Energy has been fully refreshed !");
    		 PacketSendUtility.sendPacket(targetPlayer,
    				 new SM_STATUPDATE_EXP(pcd.getExpShown(), pcd.getExpRecoverable(), pcd.getExpNeed(), pcd
    				 .getCurrentReposteEnergy(), pcd.getMaxReposteEnergy()));
    	  }
    	  else {
    		 int hp;
    		 try {
    			String percent = params[0];
    			CreatureLifeStats cls = creature.getLifeStats();
    			Pattern heal = Pattern.compile("([^%]+)%");
    			Matcher result = heal.matcher(percent);
    			int value;
    
    
    			if (result.find()) {
    			   hp = Integer.parseInt(result.group(1));
    
    
    			   if (hp < 100)
    				  value = (int) (hp / 100f * cls.getMaxHp());
    			   else
    				  value = cls.getMaxHp();
    			}
    			else
    			   value = Integer.parseInt(params[0]);
    			cls.increaseHp(TYPE.HP, value);
    			PacketSendUtility.sendMessage(player, creature.getName() + " has been healed for " + value +" health points!");
    		 }
    		 catch (Exception ex) {
    			onFail(player, null);
    		 }
    	  }
       }
    
    
       @Override
       public void onFail(Player player, String message) {
    	  String syntax = "//heal : Full HP and MP\n"
    			  + "//heal dp : Full DP, must be used on a player !\n"
    			  + "//heal fp : Full FP, must be used on a player\n"
    			  + "//heal repose : Full repose energy, must be used on a player\n"
    			  + "//heal <hp | hp%> : Heal given amount/percentage of HP";
    	  PacketSendUtility.sendMessage(player, syntax);
       }

  6. #6
    Apprentice gangsterxx is offline
    MemberRank
    Jul 2013 Join Date
    10Posts

    Re: [HELP]add some script to NPC WorldBlesser to restore player HP & MP ?

    hy .
    I try you method but always fail .
    please Help me cookiehoar . .



Advertisement