Thread: [PI] summoning [need help]

Results 1 to 5 of 5
  1. #1 [PI] summoning [need help] 



    Join Date
    Dec 2010
    Posts
    833
    Thanks given
    261
    Thanks received
    121
    Rep Power
    204
    Hey, I have added (didn't write it by myself lol) full summoning in my opinion. But I have problem, I can't make summoning npcs to spawn when I click on pouch.

    Any solutions or tips?

    Thanks in advance.
    Reply With Quote  
     

  2. #2  
    Registered Member

    Join Date
    Sep 2008
    Posts
    4,833
    Thanks given
    894
    Thanks received
    1,439
    Rep Power
    2924
    What base are you using? And When you say click, you mean right click and press "summon" right?
    Reply With Quote  
     

  3. #3  
    Registered Member Da D4v1nci C0de's Avatar
    Join Date
    Jul 2010
    Posts
    422
    Thanks given
    128
    Thanks received
    30
    Rep Power
    56
    Code:
    case ####:
    		
    server.ItemHandler.createGroundItem(c, server.npcHandler.npcs[c.summoningnpcid].absX, server.npcHandler.npcs[c.summoningnpcid].absY, 1, c.playerId);
    Very rouch code, lol. Something like that, but you should really use this as an idea, and not paste this into your code.

    Quote Originally Posted by atsiv3 View Post
    When I see your name login to my server, I will ban you.
    Reply With Quote  
     

  4. #4  
    Registered Member

    Join Date
    Sep 2008
    Posts
    4,833
    Thanks given
    894
    Thanks received
    1,439
    Rep Power
    2924
    So lazy so im just giving you my summoning.java its got a few minor upgrades, like Deletes pouches after you summon them, and summons correct NPCS ect,
    Code:
    package server.model.players.skills;
    
    import server.model.players.*;
    import server.Config;
    import server.Server;
    import server.util.Misc;
    
    /**
    * @Author Sanity
    */
    
    public class Summoning {
    	
    	Client c;
    	
    
    	public Summoning(Client c) {
    		this.c = c;
    		}
    public int shards = 18016;
    public int charm = 1;
    public int item = 1;
    public int amountofshard = 1;
    public int gold = 12158;
    public int green = 12159;
    public int crim = 12160;
    public int blue = 12163;
    public int pouchreq;
    public boolean hasitem()
    {
    if(c.getItems().playerHasItem(charm, 1) && c.getItems().playerHasItem(item, 1) && c.getItems().playerHasItem(18016, amountofshard) && c.getItems().playerHasItem(12155, 1) && c.playerLevel[22] >= req) {
    c.getItems().deleteItem(charm, 1);
    c.getItems().deleteItem(item, 1);
    c.getItems().deleteItem(shards, amountofshard);
    c.getItems().deleteItem(12155, 1);
    return true;
    } else {
    c.sendMessage("You need the following items: 1x "+c.getItems().getItemName(charm)+" ");
    c.sendMessage("1x "+c.getItems().getItemName(item)+" ");
    c.sendMessage(""+amountofshard+"x "+c.getItems().getItemName(shards)+" ");
    c.sendMessage("You also need a summoning Level of "+req+" to make this pouch ");
    return false;
    }
    
    
    }
    
    
    public void store()
    {
    
    c.getPA().sendFrame126("Summoning BoB", 7421);
    				for (int k = 0; k < 29; k++)
    {
    if(c.storeditems[k] > 0)
    {
    					c.getPA().Frame34(7423, c.storeditems[k], k, 1);
    }
    
    
    if(c.storeditems[k] <= 0)
    {
    					c.getPA().Frame34(7423, -1, k, 1);
    }
    
    }
    			
    
    				c.isBanking = true;
    				c.storing = true;
    				c.getItems().resetItems(5064);
    	
    				c.getItems().rearrangeBank();
    				c.getItems().resetBank();
    				c.getItems().resetTempItems();
    				c.getOutStream().createFrame(248);
    
    				c.getOutStream().writeWordA(4465);
    				c.getOutStream().writeWord(5063);
    //c.getOutStream().writeWord(10600);
    c.getPA().sendFrame87(286, 0);
    
    				c.flushOutStream();
    
    
    
    
    				
    				//c.ResetKeepItems();
    				//c.getPA().showInterface(17100);
    }
    public void SummonNewNPC(int npcID) {
    int maxhit = 0;
    int attack = 0;
    int defence = 0;
    switch(npcID)
    {
    case 6830:
    maxhit = 4;
    attack = 10;
    defence = 80;
    
    break;
    
    case 6826:
    maxhit = 6;
    attack = 10;
    defence = 80;
    break;
    
    case 6842:
    maxhit = 6;
    attack = 10;
    defence = 80;
    break;
    
    case 6807:
    maxhit = 5;
    attack = 20;
    defence = 80;
    c.maxstore = 3;
    break;
    
    case 6797:
    maxhit = 8;
    attack = 20;
    defence = 80;
    break;
    
    
    case 7332:
    maxhit = 8;
    attack = 20;
    defence = 80;
    break;
    
    case 6832:
    maxhit = 8;
    attack = 20;
    defence = 80;
    break;
    
    
    case 6838:
    maxhit = 8;
    attack = 20;
    defence = 80;
    break;
    
    case 7362:
    maxhit = 8;
    attack = 20;
    defence = 80;
    break;
    
    
    case 6848:
    maxhit = 8;
    attack = 20;
    defence = 80;
    break;
    
    case 6995:
    maxhit = 10;
    attack = 20;
    defence = 80;
    break;
    
    case 6872:
    maxhit = 10;
    attack = 20;
    defence = 80;
    break;
    
    case 7354:
    maxhit = 11;
    attack = 20;
    defence = 80;
    break;
    
    case 6836:
    maxhit = 12;
    attack = 20;
    defence = 80;
    break;
    
    case 6846:
    maxhit = 14;
    attack = 40;
    defence = 80;
    break;
    
    case 6808:
    maxhit = 12;
    attack = 40;
    defence = 80;;
    break;
    
    case 7371:
    case 7369:
    case 7368:
    case 7370:
    case 7352:
    maxhit = 11;
    attack = 40;
    defence = 80;
    break;
    
    case 6854:
    case 68:
    maxhit = 12;
    attack = 40;
    defence = 80;
    break;
    
    case 6868:
    maxhit = 12;
    attack = 40;
    defence = 80;
    c.maxstore = 6;
    break;
    
    case 6852:
    maxhit = 8;
    attack = 40;
    defence = 80;
    break;
    case 6834:
    maxhit = 14;
    attack = 40;
    defence = 80;
    break;
    
    case 6856:
    maxhit = 15;
    attack = 40;
    defence = 80;
    break;
    
    case 7378:
    maxhit = 14;
    attack = 40;
    defence = 80;
    break;
    
    case 6824:
    maxhit = 13;
    attack = 40;
    defence = 80;
    break;
    
    case 6844:
    maxhit = 12;
    attack = 40;
    defence = 80;
    break;
    
    case 6795:
    c.maxstore = 12;
    maxhit = 11;
    attack = 60;
    defence = 80;
    break;
    
    case 6819:
    maxhit = 13;
    attack = 60;
    defence = 80;
    break;
    case 6993:
    maxhit = 15;
    attack = 60;
    defence = 80;
    break;
    
    case 6858:
    maxhit = 11;
    attack = 60;
    defence = 80;
    break;
    
    case 6991:
    maxhit = 11;
    attack = 60;
    defence = 80;
    break;
    
    
    case 7364:
    case 7366:
    case 7338:
    maxhit = 20;
    attack = 60;
    defence = 80;
    break;
    
    case 6810:
    maxhit = 11;
    attack = 60;
    defence = 80;
    break;
    
    
    case 6821:
    maxhit = 11;
    attack = 60;
    defence = 80;
    break;
    
    
    case 6803:
    maxhit = 14;
    attack = 60;
    defence = 80;
    break;
    
    case 6828:
    maxhit = 18;
    attack = 60;
    defence = 80;
    break;
    
    case 6860:
    maxhit = 20;
    attack = 60;
    defence = 80;
    break;
    
    
    case 6890:
    maxhit = 20;
    attack = 60;
    defence = 80;
    break;
    
    case 6816:
    c.maxstore = 18;
    maxhit = 21;
    attack = 60;
    defence = 80;
    break;
    
    case 6814:
    maxhit = 17;
    attack = 60;
    defence = 80;
    break;
    
    
    case 7372:
    case 7373:
    case 7374:
    maxhit = 11;
    attack = 60;
    defence = 80;
    break;
    
    case 6840:
    pouchreq = 71;
    break;
    
    case 6817:
    maxhit = 11;
    attack = 60;
    defence = 80;
    break;
    case 8576:
    pouchreq = 999;
    break;
    
    case 7346:
    maxhit = 25;
    attack = 80;
    defence = 80;
    break;
    
    case 6799:
    maxhit = 11;
    attack = 60;
    defence = 80;
    break;
    
    case 6850:
    maxhit = 11;
    attack = 60;
    defence = 80;
    break;
    
    case 6862:
    maxhit = 22;
    attack = 60;
    defence = 80;
    break;
    
    case 7336:
    maxhit = 24;
    attack = 60;
    defence = 80;
    break;
    
    case 6801:
    maxhit = 11;
    attack = 60;
    defence = 80;
    break;
    
    case 7356:
    case 7358:
    case 7360:
    maxhit = 26;
    attack = 60;
    defence = 80;
    break;
    
    case 6812:
    maxhit = 28;
    attack = 60;
    defence = 80;
    break;
    
    
    case 6805:
    case 7342:
    maxhit = 30;
    attack = 60;
    defence = 80;
    break;
    
    case 7330:
    maxhit = 31;
    attack = 60;
    defence = 80;
    break;
    case 6864:
    maxhit = 32;
    attack = 60;
    defence = 80;
    break;
    case 6823:
    maxhit = 33;
    attack = 60;
    defence = 80;
    break;
    case 7340:
    maxhit = 34;
    attack = 60;
    defence = 80;
    break;
    
    case 6870:
    maxhit = 35;
    attack = 60;
    defence = 80;
    break;
    
    
    case 7350:
    maxhit = 36;
    attack = 60;
    defence = 80;
    break;
    
    case 7376:
    maxhit = 37;
    attack = 60;
    defence = 80;
    break;
    case 6874:
    c.maxstore = 30;
    maxhit = 38;
    attack = 60;
    defence = 80;
    break;
    case 7344:
    maxhit = 39;
    attack = 90;
    defence = 80;
    break;
    }
    switch(npcID)
    {
    case 6830:
    pouchreq = 0;
    break;
    
    case 6826:
    pouchreq = 4;
    break;
    
    case 6842:
    pouchreq = 10;
    break;
    
    case 6807:
    pouchreq = 13;
    break;
    
    case 6797:
    pouchreq = 16;
    break;
    
    
    case 7332:
    pouchreq = 17;
    break;
    
    case 6832:
    pouchreq = 18;
    break;
    
    
    case 6838:
    pouchreq = 19;
    break;
    
    case 7362:
    pouchreq = 22;
    break;
    
    
    case 6848:
    pouchreq = 23;
    break;
    
    case 6995:
    pouchreq = 25;
    break;
    
    case 6872:
    pouchreq = 28;
    break;
    
    case 7354:
    pouchreq = 29;
    break;
    
    case 6836:
    pouchreq = 31;
    break;
    
    case 6846:
    pouchreq = 32;
    break;
    
    case 6808:
    pouchreq = 33;
    break;
    
    case 7371:
    case 7369:
    case 7368:
    case 7370:
    case 7352:
    pouchreq = 34;
    break;
    
    case 6854:
    case 68:
    pouchreq = 36;
    break;
    
    case 6868:
    pouchreq = 40;
    break;
    
    case 6852:
    pouchreq = 41;
    break;
    case 6834:
    pouchreq = 42;
    break;
    
    case 6856:
    pouchreq = 46;
    break;
    
    case 7378:
    pouchreq = 46;
    break;
    
    case 6824:
    pouchreq = 47;
    break;
    
    case 6844:
    pouchreq = 49;
    break;
    
    case 6795:
    pouchreq = 52;
    break;
    
    case 6819:
    pouchreq = 54;
    break;
    case 6993:
    pouchreq = 55;
    break;
    
    case 6858:
    pouchreq = 56;
    break;
    
    case 6991:
    pouchreq = 56;
    break;
    
    
    case 7364:
    case 7366:
    case 7338:
    pouchreq = 57;
    break;
    
    case 6810:
    pouchreq = 58;
    break;
    
    case 6866:
    pouchreq = 999;
    break;
    
    case 6821:
    pouchreq = 62;
    break;
    
    
    case 6803:
    pouchreq = 63;
    break;
    
    case 6828:
    pouchreq = 64;
    break;
    
    case 6860:
    pouchreq = 66;
    break;
    
    
    case 6890:
    pouchreq = 66;
    break;
    
    case 6816:
    pouchreq = 67;
    break;
    
    case 6814:
    pouchreq = 68;
    break;
    
    
    case 7372:
    case 7373:
    case 7374:
    pouchreq = 70;
    break;
    
    case 6840:
    pouchreq = 71;
    break;
    
    case 6817:
    pouchreq = 69;
    break;
    case 8576:
    pouchreq = 999;
    break;
    
    case 7346:
    pouchreq = 73;
    break;
    
    case 6799:
    pouchreq = 75;
    break;
    
    case 6850:
    pouchreq = 74;
    break;
    
    case 6862:
    pouchreq = 76;
    break;
    
    case 7336:
    pouchreq = 76;
    break;
    
    case 6801:
    pouchreq = 78;
    break;
    
    case 7356:
    case 7358:
    case 7360:
    pouchreq = 79;
    break;
    
    case 6812:
    pouchreq = 80;
    break;
    
    
    case 6805:
    case 7342:
    pouchreq = 83;
    break;
    
    case 7330:
    pouchreq = 85;
    break;
    case 6864:
    pouchreq = 86;
    break;
    case 6823:
    pouchreq = 88;
    break;
    case 7340:
    pouchreq = 89;
    break;
    
    case 6870:
    pouchreq = 92;
    break;
    
    
    case 7350:
    pouchreq = 93;
    break;
    
    case 7376:
    pouchreq = 95;
    break;
    case 6874:
    pouchreq = 96;
    break;
    case 7344:
    pouchreq = 99;
    break;
    }
    
    if(c.playerLevel[22] >= pouchreq)
    {
    Server.npcHandler.Summon(c, npcID, c.absX, c.absY-1, c.heightLevel, 0, 100, maxhit, false, attack, defence);
    c.getItems().deleteItem(c.s, 1);
    for (int i = 0; i < Server.npcHandler.maxNPCs; i++) {
    		if (Server.npcHandler.npcs[i] != null) {
    c.npcslot = Server.npcHandler.npcs[i].npcId;
    }
    }
    } else {
    
    c.sendMessage("You need "+pouchreq+" Summoning to summon this monster");
    }
    
    }
    //c.gfx0(1315);
    
    //    c.summonedNPCS++;
       // c.sendMessage("You Summon a "+name);
     
    
    public int pouch = 12155;
    public int req;
    public void ItemonItem(int itemUsed, int useWith)
    {
    
    
    //variables
    //charm = charm id, item = itemmatirial, amountofshard = shard amount
    switch(itemUsed)
    {
    case 2138:
    useWith = pouch;
    charm = gold;
    req = 1;
    item = 2138;
    amountofshard = 8;
    if(hasitem())
    {
    c.getItems().addItem(12043, 1);
    c.getPA().addSkillXP(300, 22); //AmtExp is different so its defined in the method
    }
    
    break;
    
    
    case 2859:
    req = 1;
    useWith = pouch;
    charm = gold;
    item = 2859;
    amountofshard = 7;
    if(hasitem())
    {
    c.getItems().addItem(12047, 1);
    c.getPA().addSkillXP(500, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 6291:
    useWith = pouch;
    charm = gold;
    item = 6291;
    amountofshard = 8;
    req = 10;
    if(hasitem())
    {
    c.getItems().addItem(12059, 1);
    c.getPA().addSkillXP(800, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 3369:
    req = 13;
    useWith = pouch;
    charm = gold;
    item = 3369;
    amountofshard = 9;
    if(hasitem())
    {
    c.getItems().addItem(12019, 1);
    c.getPA().addSkillXP(1000, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 440:
    req = 16;
    useWith = pouch;
    charm = gold;
    item = 440;
    amountofshard = 7;
    if(hasitem())
    {
    c.getItems().addItem(12009, 1);
    c.getPA().addSkillXP(1500, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 6319:
    req = 17;
    useWith = pouch;
    charm = gold;
    item = 6319;
    amountofshard = 1;
    if(hasitem())
    {
    c.getItems().addItem(12778, 1);
    c.getPA().addSkillXP(1600, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 1783:
    req = 18;
    useWith = pouch;
    charm = green;
    item = 1783;
    amountofshard = 45;
    if(hasitem())
    {
    c.getItems().addItem(12049, 1);
    c.getPA().addSkillXP(2000, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 3095:
    req = 19;
    useWith = pouch;
    charm = green;
    item = 3095;
    amountofshard = 57;
    if(hasitem())
    {
    c.getItems().addItem(12055, 1);
    c.getPA().addSkillXP(2100, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 12168:
    req = 22;
    useWith = pouch;
    charm = crim;
    item = 3095;
    amountofshard = 64;
    if(hasitem())
    {
    c.getItems().addItem(12808, 1);
    c.getPA().addSkillXP(2400, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 2134:
    req = 23;
    useWith = pouch;
    charm = blue;
    item = 2134;
    amountofshard = 75;
    if(hasitem())
    {
    c.getItems().addItem(12067, 1);
    c.getPA().addSkillXP(2800, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 3138:
    req = 25;
    useWith = pouch;
    charm = blue;
    item = 3138;
    amountofshard = 51;
    if(hasitem())
    {
    c.getItems().addItem(12063, 1);
    c.getPA().addSkillXP(3000, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 6032:
    req = 28;
    useWith = pouch;
    charm = green;
    item = 6032;
    amountofshard = 47;
    if(hasitem())
    {
    c.getItems().addItem(12091, 1);
    c.getPA().addSkillXP(4000, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 9976:
    req = 29;
    useWith = pouch;
    charm = green;
    item = 9976;
    amountofshard = 84;
    if(hasitem())
    {
    c.getItems().addItem(12800, 1);
    c.getPA().addSkillXP(4500, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 3325:
    req = 31;
    useWith = pouch;
    charm = crim;
    item = 3325;
    amountofshard = 81;
    if(hasitem())
    {
    c.getItems().addItem(12053, 1);
    c.getPA().addSkillXP(5000, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 12156:
    req = 32;
    useWith = pouch;
    charm = crim;
    item = itemUsed;
    amountofshard = 84;
    if(hasitem())
    {
    c.getItems().addItem(12065, 1);
    c.getPA().addSkillXP(5400, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 1519:
    req = 33;
    useWith = pouch;
    charm = green;
    item = itemUsed;
    amountofshard = 72;
    if(hasitem())
    {
    c.getItems().addItem(12021, 1);
    c.getPA().addSkillXP(5300, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 12164:
    req = 34;
    useWith = pouch;
    charm = green;
    item = itemUsed;
    amountofshard = 74;
    if(hasitem())
    {
    c.getItems().addItem(12818, 1);
    c.getPA().addSkillXP(5200, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 12165:
    req = 34;
    useWith = pouch;
    charm = blue;
    item = itemUsed;
    amountofshard = 74;
    if(hasitem())
    {
    c.getItems().addItem(12814, 1);
    c.getPA().addSkillXP(5800, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 12167:
    req = 34;
    useWith = pouch;
    charm = blue;
    item = itemUsed;
    amountofshard = 74;
    if(hasitem())
    {
    c.getItems().addItem(12798, 1);
    c.getPA().addSkillXP(6000, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 2349:
    req = 36;
    useWith = pouch;
    charm = blue;
    item = itemUsed;
    amountofshard = 102;
    if(hasitem())
    {
    c.getItems().addItem(12073, 1);
    c.getPA().addSkillXP(6100, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 6010:
    req = 40;
    useWith = pouch;
    charm = gold;
    item = itemUsed;
    amountofshard = 11;
    if(hasitem())
    {
    c.getItems().addItem(12087, 1);
    c.getPA().addSkillXP(6200, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 249:
    req = 41;
    useWith = pouch;
    charm = green;
    item = itemUsed;
    amountofshard = 78;
    if(hasitem())
    {
    c.getItems().addItem(12071, 1);
    c.getPA().addSkillXP(6300, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 12153:
    req = 42;
    useWith = pouch;
    charm = crim;
    item = itemUsed;
    amountofshard = 104;
    if(hasitem())
    {
    c.getItems().addItem(12051, 1);
    c.getPA().addSkillXP(6400, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    
    case 2351:
    req = 46;
    useWith = pouch;
    charm = blue;
    item = itemUsed;
    amountofshard = 125;
    if(hasitem())
    {
    c.getItems().addItem(12075, 1);
    c.getPA().addSkillXP(6500, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 13403:
    req = 46;
    useWith = pouch;
    charm = crim;
    item = itemUsed;
    amountofshard = 111;
    if(hasitem())
    {
    c.getItems().addItem(12816, 1);
    c.getPA().addSkillXP(6600, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 1635:
    req = 47;
    useWith = pouch;
    charm = green;
    item = itemUsed;
    amountofshard = 88;
    if(hasitem())
    {
    c.getItems().addItem(12041, 1);
    c.getPA().addSkillXP(6700, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 2132:
    req = 49;
    useWith = pouch;
    charm = crim;
    item = itemUsed;
    amountofshard = 117;
    if(hasitem())
    {
    c.getItems().addItem(12061, 1);
    c.getPA().addSkillXP(6800, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 9978:
    req = 52;
    useWith = pouch;
    charm = gold;
    item = itemUsed;
    amountofshard = 12;
    if(hasitem())
    {
    c.getItems().addItem(12007, 1);
    c.getPA().addSkillXP(6900, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 12161:
    req = 54;
    useWith = pouch;
    charm = green;
    item = itemUsed;
    amountofshard = 106;
    if(hasitem())
    {
    c.getItems().addItem(12036, 1);
    c.getPA().addSkillXP(7000, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 1937:
    req = 55;
    useWith = pouch;
    charm = blue;
    item = itemUsed;
    amountofshard = 151;
    if(hasitem())
    {
    c.getItems().addItem(12027, 1);
    c.getPA().addSkillXP(7100, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 2353:
    req = 56;
    useWith = pouch;
    charm = blue;
    item = itemUsed;
    amountofshard = 141;
    if(hasitem())
    {
    c.getItems().addItem(12077, 1);
    c.getPA().addSkillXP(7200, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 311:
    req = 56;
    useWith = pouch;
    charm = green;
    item = itemUsed;
    amountofshard = 109;
    if(hasitem())
    {
    c.getItems().addItem(12531, 1);
    c.getPA().addSkillXP(7300, 22); //AmtExp is different so its defined in the method
    }
    
    break;
    
    
    case 10099:
    req = 57;
    useWith = pouch;
    charm = blue;
    item = itemUsed;
    amountofshard = 154;
    if(hasitem())
    {
    c.getItems().addItem(12810, 1);
    c.getPA().addSkillXP(7400, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 10103:
    req = 57;
    useWith = pouch;
    charm = blue;
    item = itemUsed;
    amountofshard = 153;
    if(hasitem())
    {
    c.getItems().addItem(12812, 1);
    c.getPA().addSkillXP(7500, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 10095:
    req = 57;
    useWith = pouch;
    charm = blue;
    item = itemUsed;
    amountofshard = 155;
    if(hasitem())
    {
    c.getItems().addItem(12784, 1);
    c.getPA().addSkillXP(7600, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 9736:
    req = 58;
    useWith = pouch;
    charm = crim;
    item = itemUsed;
    amountofshard = 141;
    if(hasitem())
    {
    c.getItems().addItem(12805, 1);
    c.getPA().addSkillXP(7700, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    //case 12161:
    //useWith = pouch;
    //charm = green;
    //item = itemUsed;
    //amountofshard = 141;
    //if(hasitem())
    //{
    //c.getItems().addItem(12037, 1);
    
    //}
    //break;
    
    case 7801:
    req = 63;
    useWith = pouch;
    charm = green;
    item = itemUsed;
    amountofshard = 116;
    if(hasitem())
    {
    c.getItems().addItem(12015, 1);
    c.getPA().addSkillXP(7800, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 8431://stranger plant
    req = 64;
    useWith = pouch;
    charm = crim;
    item = itemUsed;
    amountofshard = 128;
    if(hasitem())
    {
    c.getItems().addItem(12045, 1);
    c.getPA().addSkillXP(7900, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 2359://stranger plant
    req = 66;
    useWith = pouch;
    charm = blue;
    item = itemUsed;
    amountofshard = 152;
    if(hasitem())
    {
    c.getItems().addItem(12079, 1);
    c.getPA().addSkillXP(8000, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 2150://stranger plant
    req = 66;
    useWith = pouch;
    charm = gold;
    item = itemUsed;
    amountofshard = 11;
    if(hasitem())
    {
    c.getItems().addItem(12123, 1);
    c.getPA().addSkillXP(8100, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 7939://stranger plant
    req = 67;
    useWith = pouch;
    charm = gold;
    item = itemUsed;
    amountofshard = 1;
    if(hasitem())
    {
    c.getItems().addItem(12031, 1);
    c.getPA().addSkillXP(8200, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 383://stranger plant
    req = 68;
    useWith = pouch;
    charm = green;
    item = itemUsed;
    amountofshard = 110;
    if(hasitem())
    {
    c.getItems().addItem(12029, 1);
    c.getPA().addSkillXP(8300, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 1963://stranger plant
    req = 69;
    useWith = pouch;
    charm = green;
    item = itemUsed;
    amountofshard = 130;
    if(hasitem())
    {
    c.getItems().addItem(12033, 1);
    c.getPA().addSkillXP(8400, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 1933://stranger plant
    req = 70;
    useWith = pouch;
    charm = crim;
    item = itemUsed;
    amountofshard = 79;
    if(hasitem())
    {
    c.getItems().addItem(12820, 1);
    c.getPA().addSkillXP(8500, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 10117://stranger plant
    req = 71;
    useWith = pouch;
    charm = gold;
    item = itemUsed;
    amountofshard = 14;
    if(hasitem())
    {
    c.getItems().addItem(12057, 1);
    c.getPA().addSkillXP(8600, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 14616://stranger plant
    req = 72;
    useWith = pouch;
    charm = crim;
    item = itemUsed;
    amountofshard = 165;
    if(hasitem())
    {
    c.getItems().addItem(14623, 1);
    c.getPA().addSkillXP(8700, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 4188://changed
    req = 73;
    useWith = pouch;
    charm = blue;
    item = itemUsed;
    amountofshard = 195; 
    if(hasitem())
    {
    c.getItems().addItem(12792, 1);
    c.getPA().addSkillXP(8800, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    
    case 6979://changed
    req = 74;
    useWith = pouch;
    charm = crim;
    item = itemUsed;
    amountofshard = 166; 
    if(hasitem())
    {
    c.getItems().addItem(12069, 1);
    c.getPA().addSkillXP(8900, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 2460://changed
    req = 75;
    useWith = pouch;
    charm = crim;
    item = itemUsed;
    amountofshard = 168; 
    if(hasitem())
    {
    c.getItems().addItem(12011, 1);
    c.getPA().addSkillXP(9000, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 2361://changed
    req = 75;
    useWith = pouch;
    charm = blue;
    item = itemUsed;
    amountofshard = 144; 
    if(hasitem())
    {
    c.getItems().addItem(12081, 1);
    c.getPA().addSkillXP(9100, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 10020://changed
    req = 76;
    useWith = pouch;
    charm = green;
    item = itemUsed;
    amountofshard = 141; 
    if(hasitem())
    {
    c.getItems().addItem(12782, 1);
    c.getPA().addSkillXP(9200, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 12162: //changed
    req = 77;
    useWith = pouch;
    charm = crim;
    item = itemUsed;
    amountofshard = 174; 
    if(hasitem())
    {
    c.getItems().addItem(12794, 1);
    c.getPA().addSkillXP(9300, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    
    case 5933: //changed
    req = 78;
    useWith = pouch;
    charm = green;
    item = itemUsed;
    amountofshard = 124; 
    if(hasitem())
    {
    c.getItems().addItem(12013, 1);
    c.getPA().addSkillXP(9400, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 1442: //changed
    req = 79;
    useWith = pouch;
    charm = blue;
    item = itemUsed;
    amountofshard = 198; 
    if(hasitem())
    {
    c.getItems().addItem(12802, 1);
    c.getPA().addSkillXP(9500, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 1438: //changed
    req = 79;
    useWith = pouch;
    charm = blue;
    item = itemUsed;
    amountofshard = 198; 
    if(hasitem())
    {
    c.getItems().addItem(12806, 1);
    c.getPA().addSkillXP(9600, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 1440: //changed
    req = 79;
    useWith = pouch;
    charm = blue;
    item = itemUsed;
    amountofshard = 202; 
    if(hasitem())
    {
    c.getItems().addItem(12804, 1);
    c.getPA().addSkillXP(9700, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 571: //changed
    req = 80;
    useWith = pouch;
    charm = green;
    item = itemUsed;
    amountofshard = 128;
    if(hasitem())
    {
    c.getItems().addItem(12025, 1);
    c.getPA().addSkillXP(9900, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 6155: //changed
    req = 83;
    useWith = pouch;
    charm = crim;
    item = itemUsed;
    amountofshard = 1;
    if(hasitem())
    {
    c.getItems().addItem(12017, 1);
    c.getPA().addSkillXP(10000, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 4699: //changed lava rune
    req = 85;
    useWith = pouch;
    charm = blue;
    item = itemUsed;
    amountofshard = 219;
    if(hasitem())
    {
    c.getItems().addItem(12788, 1);
    c.getPA().addSkillXP(11000, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 10149: //changed
    req = 86;
    useWith = pouch;
    charm = crim;
    item = itemUsed;
    amountofshard = 150;
    if(hasitem())
    {
    c.getItems().addItem(12776, 1);
    c.getPA().addSkillXP(12000, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 2363: //changed
    req = 88;
    useWith = pouch;
    charm = blue;
    item = itemUsed;
    amountofshard = 1;
    if(hasitem())
    {
    c.getItems().addItem(12083, 1);
    c.getPA().addSkillXP(13800, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    
    case 1486: //changed
    req = 89;
    useWith = pouch;
    charm = green;
    item = itemUsed;
    amountofshard = 140;
    if(hasitem())
    {
    c.getItems().addItem(12039, 1);
    c.getPA().addSkillXP(5800, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 1444: //changed
    req = 92;
    useWith = pouch;
    charm = blue;
    item = itemUsed;
    amountofshard = 222;
    if(hasitem())
    {
    c.getItems().addItem(12786, 1);
    c.getPA().addSkillXP(5800, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 3228: //changed
    req = 93;
    useWith = pouch;
    charm = crim;
    item = itemUsed;
    amountofshard = 203;
    if(hasitem())
    {
    c.getItems().addItem(12089, 1);
    c.getPA().addSkillXP(5800, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 7979: //changed abyss head
    req = 93;
    useWith = pouch;
    charm = green;
    item = itemUsed;
    amountofshard = 113;
    if(hasitem())
    {
    c.getItems().addItem(12796, 1);
    c.getPA().addSkillXP(5800, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 1115: //changed
    req = 95;
    useWith = pouch;
    charm = crim;
    item = itemUsed;
    amountofshard = 198;
    if(hasitem())
    {
    c.getItems().addItem(12822, 1);
    c.getPA().addSkillXP(5800, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    case 10818: //changed
    req = 96;
    useWith = pouch;
    charm = crim;
    item = itemUsed;
    amountofshard = 211;
    if(hasitem())
    {
    c.getItems().addItem(12093, 1);
    c.getPA().addSkillXP(5800, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    case 1119: //changed
    req = 99;
    useWith = pouch;
    charm = crim;
    item = itemUsed;
    amountofshard = 178;
    if(hasitem())
    {
    c.getItems().addItem(12790, 1);
    c.getPA().addSkillXP(5800, 22); //AmtExp is different so its defined in the method
    }
    break;
    
    
    }
    }
    
    }
    Reply With Quote  
     

  5. #5  



    Join Date
    Dec 2010
    Posts
    833
    Thanks given
    261
    Thanks received
    121
    Rep Power
    204
    Quote Originally Posted by Faris View Post
    What base are you using? And When you say click, you mean right click and press "summon" right?
    Enigma's summoning base And yes I mean right click.

    My ItemClick3.java:

    Code:
    package server.model.players.packets;
    
    import server.model.players.Client;
    import server.model.players.PacketType;
    import server.util.Misc;
    
    /**
     * Item Click 3 Or Alternative Item Option 1
     * 
     * @author Ryan / Lmctruck30
     * 
     * Proper Streams
     */
    
    public class ItemClick3 implements PacketType {
    	public void processPacket(Client c, int packetType, int packetSize) {
    		int itemId11 = c.getInStream().readSignedWordBigEndianA();
    		int itemId1 = c.getInStream().readUnsignedWordA();
    		int itemId = c.getInStream().readSignedWordA();
    		switch (itemId) {
    		case 1712:
    			c.getPA().handleGlory(itemId);
    		break;
    		default:
    			c.getSummoning().summonFamiliar(itemId, true);
    			if (c.playerRights == 3)
    				Misc.println(c.playerName+ " - Item3rdOption: "+itemId+" : "+itemId11+" : "+itemId1);
    			break;
    		}
    
    	}
    
    }
    summoning.java:

    Code:
    package server.model.players;
    
    import java.util.HashMap;
    
    import server.Server;
    import server.Config;
    
    /**
     * The Summoning Handler class.
     * @Author: Mr-Nick
     */
    public class Summoning {
    
    	/**
    	 * Owner of the summoning instance.
    	 */
    	public final Client c;
    
    	/**
    	 * The owner's summoned familiar.
    	 */
    	public Familiar summonedFamiliar = null;
    	
    	/**
    	 * Instances the summoning class.
    	 */
    	public Summoning(Player p) {
    		this.c = (Client) p;
    	}
    
    	/**
    	 * Represents different FamiliarType's.
    	 * @Author: Mr Nick
    	 */
    	public static enum FamiliarType {
    		NORMAL,
    		COMBAT,
    		BOB;
    	}
    
    	/**
    	 * Familiar special interface.
    	 */
    	public static interface FamiliarSpecial {
    		public abstract void execute(Object... arguements);
    	}
    	
    	/**
    	 * Represents different Familiar's.
    	 * @Author: Mr-Nick
    	 */
    	public static enum Familiar {
    		SPIRIT_TERRORBIRD(6794, 12007, 12437, 15, FamiliarType.BOB, 12, 0, false, "Take BoB", "", new FamiliarSpecial() {
    				@Override
    				public void execute(Object... arguments) {
    				}}), 
    		WOLPERTINGER(6869, 12089, 12437, 15, FamiliarType.NORMAL, 0, 40, false, "Cast @gre@Magic Focus", "Mew!", new FamiliarSpecial() {
    				@Override
    				public void execute(Object... arguments) {
    					((Client) arguments[0]).startAnimation(7660);
    					((Client) arguments[0]).gfx(1313, 0);
    					((Client) arguments[0]).getPotions().doWolperSpecial(6, false);
    					((Client) arguments[0]).sendMessage("Your magic is boosted!");
    				}}), 
    		UNICORN(6822, 12039, 12434, 15, FamiliarType.NORMAL, 0, 40, false, "Cast @gre@Healing Aura", "", new FamiliarSpecial() {
    				@Override
    				public void execute(Object... arguments) {
    					((Client) arguments[0]).addHp(80);
    					if (((Client) arguments[0]).maxhp == 0) {					
    					((Client) arguments[0]).startAnimation(7660);
    					((Client) arguments[0]).gfx(1313, 0);
    					//if (c.constitution >= c.maxConstitution) {
    					//((Client) arguments[0]).constitution += 100;
    					((Client) arguments[0]).sendMessage("You restored 80 Hp!");
    					} else if (((Client) arguments[0]).maxhp == 1) {
    					((Client) arguments[0]).sendMessage("You allready full hp!");	
    					((Client) arguments[0]).maxhp = 0;
    					}
    				}}), 
    		WAR_TORTOISE(6815, 12031, 12435, 30, FamiliarType.BOB, 18, 0, true, "Take BoB", "", new FamiliarSpecial() {
    				@Override
    				public void execute(Object... arguments) {
    				}}),
    		SteelTitan(7343, 12790, 12825, 30, FamiliarType.COMBAT, 18, 0, false, "Cast @gre@Steel of Legends", "", new FamiliarSpecial() {
    				@Override
    				public void execute(Object... arguments) {
    				}}),
    		GeyserTitan(7339, 12786, 12825, 30, FamiliarType.COMBAT, 18, 0, false, "Cast @gre@Boil", "", new FamiliarSpecial() {
    				@Override
    				public void execute(Object... arguments) {
    				}}),
    		IceTitan(7359, 12806, 12825, 30, FamiliarType.COMBAT, 18, 0, false, "Cast @gre@Titan's Constitution", "I'm melting!", new FamiliarSpecial() {
    				@Override
    				public void execute(Object... arguments) {
    					((Client) arguments[0]).addHp(250);
    					if (((Client) arguments[0]).maxhp == 0) {					
    					((Client) arguments[0]).startAnimation(7660);
    					((Client) arguments[0]).gfx(1313, 0);
    					//if (c.constitution >= c.maxConstitution) {
    					//((Client) arguments[0]).constitution += 100;
    					((Client) arguments[0]).sendMessage("You restored 250 Hp!");
    					} else if (((Client) arguments[0]).maxhp == 1) {
    					((Client) arguments[0]).sendMessage("You allready full hp!");	
    					((Client) arguments[0]).maxhp = 0;
    					}
    				}}),
    		PACK_YAK(6873, 12093, 12435, 30, FamiliarType.BOB, 30, 10, true, "Take BoB;Cast @gre@Winter Storage", "Baroo baroo!", new FamiliarSpecial() {
    				@Override
    				public void execute(Object... arguments) {
    					((Client) arguments[0]).sendMessage(":moi: 24000");
    				}});
    			
    		private Familiar(int npcId, int pouchId, int scrollId, int timeLimit, FamiliarType familiarType, int storeCapacity, int specialEnergyConsumption, boolean large, String clientTooltip, String textChat, FamiliarSpecial familiarSpecial) {
    			this.npcId = npcId;
    			this.pouchId = pouchId;
    			this.scrollId = scrollId;
    			this.timeLimit = timeLimit;
    			this.familiarType = familiarType;
    			this.storeCapacity = storeCapacity;
    			this.specialEnergyConsumption = specialEnergyConsumption;
    			this.large = large;
    			this.clientTooltip = "Dismiss Familiar;Renew Familiar;Call Familiar;" + clientTooltip;
    			this.speakText = textChat;
    			this.familiarSpecial = familiarSpecial;
    		}
    			
    		public int npcId;
    		public int pouchId;
    		public int scrollId;
    		public int timeLimit;
    		public FamiliarType familiarType;
    		public int storeCapacity;
    		public int specialEnergyConsumption;
    		public boolean large;
    		public String clientTooltip;
    		public String speakText;
    		public FamiliarSpecial familiarSpecial;
    		
    		public static HashMap <Integer, Familiar> familiars = new HashMap<Integer, Familiar>();
    		
    		public static Familiar forPouchId(int id) {
    			return familiars.get(id);
    		}
    		
    		static {
    			for (Familiar f : Familiar.values())
    				familiars.put(f.pouchId, f);
    		}
    	}
    	
    	/**
    	 * Summons a familiar based on pouch id
    	 * @param itemId - Pouch Id from ActionButton packet.
    	 */
    	public void summonFamiliar(int itemId, boolean login) {
    		if(c.playerRights >= 0)  {
    			Familiar summonedFamiliar = Familiar.forPouchId(itemId);
    			if(summonedFamiliar != null && this.summonedFamiliar == null) {
    				this.summonedFamiliar = summonedFamiliar;
    				c.sendMessage(":summonactive:");
    				c.sendMessage(":sumoptions:" + summonedFamiliar.clientTooltip);
    				burdenedItems = new int[summonedFamiliar.storeCapacity];
    				for(int i = 0; i < burdenedItems.length; i++)
    					burdenedItems[i] = 0;
    				if(!login) {
    					c.specRestoreTimer = (((summonedFamiliar.timeLimit * 60) * 1000) / 600); 
    					c.summoned = Server.npcHandler.summonNPC(c, summonedFamiliar.npcId, c.getX(), c.getY() + (summonedFamiliar.large ? 2 : 1), c.heightLevel, 0, 100, 1, 1, 1);
    					callFamiliar();
    					c.sendMessage("You summon a " + summonedFamiliar.toString() + ".");
    					c.getItems().deleteItem(itemId, 1);
    				} else {
    					loginCycle = 4;
    				}
    			} else if(this.summonedFamiliar != null && c.summoned != null) {
    				c.sendMessage("You already have a familiar!");
    			}
    		}
    	}
    	
    	/**
    	 * Renews a familiar before death.
    	 */
    	public void renewFamiliar() {
    		if(summonedFamiliar != null && this.summonedFamiliar != null) {
    			if(c.specRestoreTimer < 300) {
    				if(c.getItems().playerHasItem(summonedFamiliar.pouchId, 1)) {
    					c.specRestoreTimer = (((summonedFamiliar.timeLimit * 60) * 1000) / 600); 
    					c.sendMessage("You sacrifice a pouch to renew your familiar's strength.");
    					c.getItems().deleteItem(summonedFamiliar.pouchId, 1);
    				} else {
    					c.sendMessage("You need a pouch to sacrifice!");
    				}
    			} else {
    				c.sendMessage("You still have excess time left on your current familiar!");
    			}
    		}
    	}
    	
    	/**
    	 * Dismisses/Destroy's the familiar.
    	 */
    	public void dismissFamiliar(boolean logout) {
    		if(summonedFamiliar != null && c.summoned != null) {
    			c.summoned.isDead = true;
    			c.summoned.applyDead = true;
    			c.summoned.actionTimer = 0;
    			c.summoned.npcType = -1;
    			c.summoned.updateRequired = true;
    			c.sendMessage(":summoninactive:");
    			if(!logout) {
    				for(int i = 0; i < burdenedItems.length; i++) {
    					Server.itemHandler.createGroundItem(c, burdenedItems[i] - 1, c.summoned.absX, c.summoned.absY, 1, c.summoned.summonedFor);
    				}
    				burdenedItems = null;
    				summonedFamiliar = null;
    			}
    			c.summoned = null;
    		} else {
    			c.sendMessage(":summoninactive:");
    		}
    		
    	}
    	
    	/**
    	 * If player dies, the summoning will dismiss
    	 */
    	public void dismissOnDeath() {
    		if(summonedFamiliar != null && c.summoned != null) {
    			c.summoned.npcType = -1;
    		}
    	}
    	
    	
    
    	/**
    	 * If player gets offscreen (most likely teleports), familiar will come to them
    	 */
    	public void callOnTeleport() {
    		if(summonedFamiliar != null && c.summoned != null) {
    			c.summoned.npcTeleport(c.absX, c.absY + (summonedFamiliar.large ? 2 : 1), c.heightLevel);
    			c.summoned.updateRequired = true;
    		} else {
    			c.sendMessage(":summoninactive:");
    		}
    	}
    	
    	/**
    	 * Calls the familiar to the owner.
    	 */
    	public void callFamiliar() {
    		if(summonedFamiliar != null && c.summoned != null) {
    			c.summoned.npcTeleport(c.absX, c.absY + (summonedFamiliar.large ? 2 : 1), c.heightLevel);
    			c.summoned.updateRequired = true;
    		} else {
    			c.sendMessage(":summoninactive:");
    		}
    	}
    	
    	/**
    	 * Array of the burdened items.
    	 */
    	public int[] burdenedItems;
    	
    	/**
    	 * Gets the next slot for the specified itemId.
    	 * @param itemId - The specified item id.
    	 */
    	public int getSlotForId(int itemId) {
    		if(summonedFamiliar.familiarType == FamiliarType.BOB) {
    			for(int i = 0; i < burdenedItems.length; i++) {
    				if((burdenedItems[i] + 1) == itemId)
    					return i;
    			}
    		}
    		return -1;
    	}
    	
    	/**
    	 * Gets the count of the specified item.
    	 * @return the amount of contained items.
    	 */
    	public int getItemCount(int itemId) {
    		int count = 0;
    		if(summonedFamiliar.familiarType == FamiliarType.BOB) {
    			for(int i = 0; i < burdenedItems.length; i++) {
    				if((burdenedItems[i] - 1) == itemId) {
    					count++;
    				}
    			}
    		}
    		return count;
    	}
    	
    	/**
    	 * Shifts and re-arranges the familiar's inventory.
    	 */
    	public void shift() {
    		int totalItems = 0;
    		int highestSlot = 0;
    		for (int i = 0; i < summonedFamiliar.storeCapacity; i++) {
    			if (burdenedItems[i] != 0) {
    				totalItems++;
    				if (highestSlot <= i) {	
    					highestSlot = i;
    				}
    			}  
    		}
    		for (int i = 0; i <= highestSlot; i++) {
    			if (burdenedItems[i] == 0) {
    				boolean stop = false;
    				for (int k = i; k <= highestSlot; k++) {
    					if (burdenedItems[k] != 0 && !stop) {
    						int spots = k - i;
    						for (int j = k; j <= highestSlot; j++) {
    							burdenedItems[j - spots] = burdenedItems[j];
    							stop = true;
    							burdenedItems[j] = 0;
    						}
    					}
    				}					
    			}
    		}
    	}
    	
    	/**
    	 * Withdraws an item from the familiar's inventory, to the owner's inventory.
    	 * @param id - Item id
    	 * @param slot - Item slot
    	 * @param amount - Item amount
    	 */
    	public void withdrawItem(int id, int amount) {
    	  if (c.inWild() && c.wildLevel <= 30) {
    		c.sendMessage("You can't use This option if your below 30 wilderness.");//this sends a message for each item need to fix
    		return;
    	}
    		if(summonedFamiliar != null && c.summoned != null) {
    			if(summonedFamiliar.familiarType == FamiliarType.BOB) {
    				if(amount > 0 && id > 0) {
    					int slot = getSlotForId(id + 2);
    					while(amount > 0 && slot != -1) {
    						if(c.getItems().addItem(burdenedItems[slot] - 1, 1)) {
    							burdenedItems[slot] = 0;
    							slot = getSlotForId(id + 2);
    							amount--;
    						} else {
    							break;
    						}
    					}
    				}
    				c.getItems().resetItems(24006);
    				c.getItems().resetItems(24002, burdenedItems);
    				c.startAnimation(827);//does the animation everytime  even if the npc doesn't have items in it
    		}
    	}
    }
    	
    	/**
    	 * Deposits an item from the owner's inventory, to the familiar's inventory.
    	 * @param id - Item id
    	 * @param slot - Item slot
    	 * @param amount - Item amount
    	 */
    	public void depositItem(int id, int slot, int amount) {
    		if(summonedFamiliar != null && c.summoned != null) {
    			if(summonedFamiliar.familiarType == FamiliarType.BOB) {
    				if(amount > 0 && c.playerItems[slot] > 0 && slot >= 0 && slot < 28) {
    					if(!c.getItems().isStackable(c.playerItems[slot] - 1)) {
    						if(itemIsAllowed(c.playerItems[slot] - 1)) {
    							while(amount > 0 && slot != -1) {
    								if(addItem(c.playerItems[slot])) {
    									int tempVar = c.playerItems[slot] - 1;
    									c.getItems().deleteItem(c.playerItems[slot] - 1, slot, 1);
    									slot = c.getItems().getItemSlot(tempVar);
    									amount--;
    									c.startAnimation(827);
    								} else {
    									break;
    								}
    							}
    						} else {
    							c.sendMessage("You cannot deposit this item!");
    						}
    					}
    				}
    				c.getItems().resetItems(24006);
    				c.getItems().resetItems(24002, burdenedItems);
    			}
    		}
    	}
    	
    	/**
    	 * Checks if the specific item is allowed to be deposited.
    	 * @return returns if the item is allowed.
    	 */
    	public boolean itemIsAllowed(int itemId) {
    		switch(itemId) {
    			case 15272: // Rocktail
    			case 7060: // Tuna potato
    			case 6685: case 6687: case 6689: case 6691: //Saradomin brew
    			case 3024: case 3026: case 3028: case 3030: //Super restore
    			case 391: // Manta Ray
    			case 385: // Shark
    			case 229: // Vial
    				return true;
    		}
    		return false;
    	}
    	
    	/**
    	 * Returns true if the item was added to the container successfully.
    	 */
    	public boolean addItem(int itemId) {
    		int nextFreeSlot = getSlotForId(1);
    		if(itemId <= 0)
    			return false;
    		if(nextFreeSlot != -1 && burdenedItems[nextFreeSlot] == 0) {
    			burdenedItems[nextFreeSlot] = itemId;
    			return true;
    		} else {
    			return false;
    		}
    	}
    
    	/**
    	 * Opens the beast of burden.
    	 */
    	public void openBoB() {
    		if(summonedFamiliar != null && c.summoned != null) {
    			if(summonedFamiliar.familiarType == FamiliarType.BOB) {
    				shift();
    				if(c.getOutStream() != null && c != null) {
    					c.getItems().resetItems(24002, burdenedItems);
    					c.flushOutStream();
    				}
    				c.getItems().resetItems(24006);
    				c.getOutStream().createFrame(248);
    				c.getOutStream().writeWordA(24000);
    				c.getOutStream().writeWord(24005);
    				c.flushOutStream();
    			}
    		}
    	}
    	
    	/**
    	 * Handles the left click option.
    	 */
    	public void handleLeftClick() {
    		if(summonedFamiliar != null && c.summoned != null) {
    			if(summonedFamiliar.familiarType == FamiliarType.BOB) {
    				for(int i = 0; i < burdenedItems.length; i++) {
    					if(c.getItems().freeSlots() > 0)
    						withdrawItem(burdenedItems[i] - 1, 1);
    				}
    			} else {
    				useSpecial(c);
    			}
    		} else {
    			c.sendMessage(":summoninactive:");
    		}
    	}
    	
    	/**
    	 * Executes the familiar's special using the specified arguments (for compatibility)
    	 * @param arguements - The correct arguments.
    	 */
    	public void useSpecial(Object... arguments) {
    		if(summonedFamiliar != null && c.summoned != null) {
    			if(summonedFamiliar.familiarSpecial != null && specialTimer < 1) {
    				if(familiarSpecialEnergy >= summonedFamiliar.specialEnergyConsumption) {
    					if(c.getItems().playerHasItem(summonedFamiliar.scrollId)) {
    						c.getItems().deleteItem2(summonedFamiliar.scrollId, 1);
    						familiarSpecialEnergy -= summonedFamiliar.specialEnergyConsumption;
    						summonedFamiliar.familiarSpecial.execute(arguments);
    						specialTimer = 12;
    					}
    				} else {
    					c.sendMessage("Your familiar doesn't have the special energy required...");
    				}
    			}
    		}
    	}
    	
    	
    	
    	
    	//has timer but glitched so just process with the 1 above..
    	
    		/**
    	 * Executes the familiar's special using the specified arguments (for compatibility)
    	 * @param arguements - The correct arguments.
    	 */
    /*	public void useSpecial(Object... arguments) {
    		if(summonedFamiliar != null && c.summoned != null) {
    			if(summonedFamiliar.familiarSpecial != null && specialTimer < 1) {
    				if(familiarSpecialEnergy >= summonedFamiliar.specialEnergyConsumption) {
    					if(c.getItems().playerHasItem(summonedFamiliar.scrollId)) {
    						c.getItems().deleteItem2(summonedFamiliar.scrollId, 1);
    						familiarSpecialEnergy -= summonedFamiliar.specialEnergyConsumption;
    						summonedFamiliar.familiarSpecial.execute(arguments);
    						specialTimer = 12;
    					}
    				} else {
    					c.sendMessage("Your familiar doesn't have the special energy required...");
    				}
    			} else {
    				c.sendMessage("You must wait before casting this again.");
    			}
    		}
    	}*/
    	
    	private boolean bobWithSpec(int npcType) {
    		switch (npcType) {
    			case 6873:
    				return true;
    		}
    		return false;
    	}
    	
    	public void handleButtonClick(int buttonId) {
    		if (!bobWithSpec(summonedFamiliar.npcId)) {
    			switch (buttonId) {
    				case 58155:
    				case 58156:
    					handleLeftClick();
    					break;
    				case 58157:
    					callFamiliar();
    					break;
    				case 58158:
    					renewFamiliar();
    					break;
    				case 58159:
    					dismissFamiliar(false);
    					break;
    				default:
    					return;
    			}
    		} else {
    			switch (buttonId) {
    				case 58156:
    					useSpecial(c);
    					break;
    				case 58157:
    					handleLeftClick();
    					break;
    				case 58158:
    					callFamiliar();
    					break;
    				case 58159:
    					renewFamiliar();
    					break;
    				case 58160:
    					dismissFamiliar(false);
    					break;
    				default:
    					return;
    			}
    		}
    	}
    	
    	private int specialRestoreCycle = 0;
    	private int speakTimer = 70;
    	public int familiarSpecialEnergy = 100;
    	private int loginCycle = -1;
    	public int specialTimer = 5;
    	public int renewTimer = -1;
    	
    	/**
    	 * The "process" for familiars.
    	 */
    	public void familiarTick() {
    		if(summonedFamiliar != null && c.summoned != null && loginCycle == 0) {
    			if(!c.goodDistance(c.getX(), c.getY(), c.summoned.getX(), c.summoned.getY(), 8)) {
    				callFamiliar();
    			}
    			speakTimer++;
    			if(speakTimer == 100) {
    				c.summoned.forceChat(summonedFamiliar.speakText);
    				speakTimer = 0;
    			}
    			c.specRestoreTimer--;
    			if(c.specRestoreTimer == 100) {
    				c.sendMessage("@red@Your familiar will run out in approximately 1 minute.");
    				c.sendMessage("@red@Warning! Item's stored in familiar will be dropped upon death!");
    			} else if(c.specRestoreTimer == 50) {
    				c.sendMessage("@red@Your familiar will run out in approximately 30 seconds.");
    				c.sendMessage("@red@Warning! Item's stored in familiar will be dropped upon death!");
    			} else if(c.specRestoreTimer == 25) {
    				c.sendMessage("@red@Your familiar will run out in approximately 15 seconds.");
    				c.sendMessage("@blu@ You can renew your familiar with a new pouch by clicking @red@ Renew pouch");
    				c.sendMessage("@red@Warning! Item's stored in familiar will be dropped upon death!");
    			} else if(c.specRestoreTimer == 0) {
    				dismissFamiliar(false);
    			}
    			specialRestoreCycle++;
    			if(specialRestoreCycle == 30) {
    				if(familiarSpecialEnergy != 100) {
    					familiarSpecialEnergy += 10;
    				}
    				specialRestoreCycle = 0;
    			}
    			specialTimer--;
    		}
    		if(renewTimer > 0) {
    			renewTimer--;
    			if(renewTimer == 0 && c.summoned == null && summonedFamiliar != null) {
    				c.summoned = Server.npcHandler.summonNPC(c, summonedFamiliar.npcId, c.getX(), c.getY() + (summonedFamiliar.large ? 2 : 1), c.heightLevel, 0, 100, 1, 1, 1);
    				callFamiliar();
    			}
    		}
    		if(loginCycle > 0) {
    			loginCycle--;
    			if(loginCycle == 0 && c.summoned == null && summonedFamiliar != null) {
    				c.summoned = Server.npcHandler.summonNPC(c, summonedFamiliar.npcId, c.getX(), c.getY() + (summonedFamiliar.large ? 2 : 1), c.heightLevel, 0, 100, 1, 1, 1);
    				callFamiliar();
    			}
    		}
    	}
    }
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 14
    Last Post: 01-20-2012, 01:24 AM
  2. Replies: 1
    Last Post: 01-03-2012, 10:48 PM
  3. Replies: 20
    Last Post: 09-15-2011, 05:31 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •