needed this ty mate
rep+
|
|
This is from my Paragon winterlove server WAY WAY BACK MANY CENTURIES AGO. This is before I figured out object animations so this rotates the cannon around completely.. A video of this:
Good luckCode:public class Cannon { public int getNPC() { for (int i = 0; i < server.npcHandler.maxNPCs; i++) { NPC npc = server.npcHandler.npcs[i]; if (npc != null && !npc.isDieing) { int directionFacingF = directionFacing+1; if (directionFacingF == 4) { directionFacingF = 0; } if (directionFacingF == 0) { //West if ((npc.absY == (y+1) || npc.absY == (y-1) || npc.absY == y) && npc.absX < x && c.GoodDistance(x, y, npc.absX, npc.absY, 8)) { return i; } } if (directionFacingF == 2) { //East if ((npc.absY == (y+1) || npc.absY == (y-1) || npc.absY == y) && npc.absX > x && c.GoodDistance(x, y, npc.absX, npc.absY, 8)) { return i; } } if (directionFacingF == 1) { //North if ((npc.absX == (x+1) || npc.absX == (x-1) || npc.absX == x) && npc.absY > y && c.GoodDistance(x, y, npc.absX, npc.absY, 8)) { return i; } } if (directionFacingF == 3) { //South if ((npc.absX == (x+1) || npc.absX == (x-1) || npc.absX == x) && npc.absY < y && c.GoodDistance(x, y, npc.absX, npc.absY, 8)) { return i; } } } } return -1; } public long spinDelay = -1; public void fireCannon(int x, int y) { if (server.cannonX[c.playerId] != x || server.cannonY[c.playerId] != y) { c.sendMessage("That is not your cannon!"); return; } else if (spinDelay != -1) { c.sendMessage("Your cannon is already firing!"); return; } else if (cannonBalls == 0) { c.sendMessage("Your cannon has no cannonballs in it!"); return; } else { spinDelay = System.currentTimeMillis()+1*1250; } } public void pickupCannon(int x, int y) { if (server.cannonX[c.playerId] != x || server.cannonY[c.playerId] != y) { c.sendMessage("That is not your cannon!"); return; } else if ((c.freeSlots() == 4 && cannonBalls != 0 && !c.playerHasItemAmount(2, 1)) || (c.freeSlots() < 4)) { c.sendMessage("You don't have enough room to pickup your cannon!"); return; } else { c.addItem(2, cannonBalls); c.addItem(6, 1); c.addItem(8, 1); c.addItem(10, 1); c.addItem(12, 1); c.deleteGlobalObject(x, y); c.sendMessage("You pickup your cannon!"); resetValues(); } } public void resetValues() { server.cannonX[c.playerId] = 0; server.cannonY[c.playerId] = 0; x = 0; y = 0; spinDelay = -1; cannonBalls = 0; } public boolean cannonNear() { for (int i = 0; i < server.playerHandler.maxPlayers; i++) { if (c.GoodDistance(c.absX, c.absY, server.cannonX[i], server.cannonY[i], 3)) { return true; } } return false; } public void createCannon() { if (server.cannonX[c.playerId] != 0 && server.cannonX[c.playerId] != -1) { c.sendMessage("You already have a cannon out!"); return; } else if (cannonNear()) { c.sendMessage("You cannot put your cannon here!"); return; } else { x = c.absX; y = c.absY; c.addGlobalObject(6, x, y, 0); server.cannonX[c.playerId] = x; server.cannonY[c.playerId] = y; } } public int x = -1; public int y = -1; public int directionFacing = 0; public void spinCannon() { if (directionFacing+1 == 4) { directionFacing = 0; } else { directionFacing += 1; } c.addGlobalObject(6, x, y, directionFacing); spinDelay = System.currentTimeMillis()+1*1250; } public void fire() { if (cannonBalls == 0) { c.sendMessage("Your cannon has run out of ammo!"); spinDelay = -1; return; } if (getNPC() == -1) { return; } NPC npc = server.npcHandler.npcs[getNPC()]; if (npc == null) { return; } if (npc.NPCCombat.isDieing) { return; } int offsetX = (server.cannonX[c.playerId] - npc.absX) * -1; int offsetY = (server.cannonY[c.playerId] - npc.absY) * -1; c.createProjectile(server.cannonY[c.playerId], server.cannonX[c.playerId], offsetX, offsetY, 50, 80, 194, 40, 31, npc.npcId+1); attackOnPast = npc; cannonBalls--; hitDelay = System.currentTimeMillis()+1*1000; if (cannonBalls == 0) { c.sendMessage("Your cannon has run out of ammo!"); spinDelay = -1; return; } } public NPC attackOnPast = null; public long hitDelay = -1; public void process() { if (hitDelay != -1 && hitDelay <= System.currentTimeMillis()) { if (attackOnPast != null && !attackOnPast.isDieing) { int hit = misc.random(30); attackOnPast.hit(hit); c.addSkillXP(25*hit, 4); } attackOnPast = null; hitDelay = -1; } if (spinDelay != -1) { if (spinDelay <= System.currentTimeMillis()) { spinCannon(); fire(); } } } public void addBalls(int x, int y, int useID) { if (useID != 2) { return; } else if (server.cannonX[c.playerId] != x || server.cannonY[c.playerId] != y) { c.sendMessage("This isn't your cannon!"); return; } else if (cannonBalls == 30) { c.sendMessage("Your cannon is full!"); return; } else { int ballsNeeded = 30-cannonBalls; int ballsHave = c.GetXItemsInBag(2); if (ballsHave >= ballsNeeded) { c.deleteItem(2, c.GetItemSlot(2), ballsNeeded); cannonBalls += ballsNeeded; c.sendMessage("You add "+ballsNeeded+" cannonballs to your cannon"); return; } if (ballsHave < ballsNeeded) { c.deleteItem(2, c.GetItemSlot(2), ballsHave); cannonBalls += ballsHave; c.sendMessage("You add "+ballsHave+" cannonballs to your cannon"); return; } } } public int cannonBalls = 0; public Cannon(client c) { this.c = c; } private client c; }![]()
needed this ty mate
rep+
omgssBoomer for president!
butt... i got these err0rz.
Code:Cannon.java:5: cannot find symbol symbol : variable isDieing location: class NPC if (npc != null && !npc.isDieing) { ^ Cannon.java:36: array required, but int found if (server.cannonX[c.playerId] != x || server.cannonY[c.playerId ] != y) { ^ Cannon.java:36: array required, but int found if (server.cannonX[c.playerId] != x || server.cannonY[c.playerId ] != y) { ^ Cannon.java:53: array required, but int found if (server.cannonX[c.playerId] != x || server.cannonY[c.playerId ] != y) { ^ Cannon.java:53: array required, but int found if (server.cannonX[c.playerId] != x || server.cannonY[c.playerId ] != y) { ^ Cannon.java:67: cannot find symbol symbol : method deleteGlobalObject(int,int) location: class client c.deleteGlobalObject(x, y); ^ Cannon.java:73: array required, but int found server.cannonX[c.playerId] = 0; ^ Cannon.java:74: array required, but int found server.cannonY[c.playerId] = 0; ^ Cannon.java:83: array required, but int found if (c.GoodDistance(c.absX, c.absY, server.cannonX[i], se rver.cannonY[i], 3)) { ^ Cannon.java:83: array required, but int found if (c.GoodDistance(c.absX, c.absY, server.cannonX[i], se rver.cannonY[i], 3)) { ^ Cannon.java:90: array required, but int found if (server.cannonX[c.playerId] != 0 && server.cannonX[c.playerId ] != -1) { ^ Cannon.java:90: array required, but int found if (server.cannonX[c.playerId] != 0 && server.cannonX[c.playerId ] != -1) { ^ Cannon.java:101: cannot find symbol symbol : method addGlobalObject(int,int,int,int) location: class client c.addGlobalObject(6, x, y, 0); ^ Cannon.java:102: array required, but int found server.cannonX[c.playerId] = x; ^ Cannon.java:103: array required, but int found server.cannonY[c.playerId] = y; ^ Cannon.java:116: cannot find symbol symbol : method addGlobalObject(int,int,int,int) location: class client c.addGlobalObject(6, x, y, directionFacing); ^ Cannon.java:132: cannot find symbol symbol : variable NPCCombat location: class NPC if (npc.NPCCombat.isDieing) { ^ Cannon.java:135: array required, but int found int offsetX = (server.cannonX[c.playerId] - npc.absX) * -1; ^ Cannon.java:136: array required, but int found int offsetY = (server.cannonY[c.playerId] - npc.absY) * -1; ^ Cannon.java:137: array required, but int found c.createProjectile(server.cannonY[c.playerId], server.cannonX[c. playerId], offsetX, offsetY, 50, 80, 194, 40, 31, npc.npcId+1); ^ Cannon.java:137: array required, but int found c.createProjectile(server.cannonY[c.playerId], server.cannonX[c. playerId], offsetX, offsetY, 50, 80, 194, 40, 31, npc.npcId+1); ^ Cannon.java:152: cannot find symbol symbol : variable isDieing location: class NPC if (attackOnPast != null && !attackOnPast.isDieing) { ^ Cannon.java:154: cannot find symbol symbol : method hit(int) location: class NPC attackOnPast.hit(hit); ^ Cannon.java:173: array required, but int found else if (server.cannonX[c.playerId] != x || server.cannonY[c.pla yerId] != y) { ^ Cannon.java:173: array required, but int found else if (server.cannonX[c.playerId] != x || server.cannonY[c.pla yerId] != y) { ^ Note: EconomyReset.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. 25 errors Finished! Press any key to continue . . .
Jesus! pretty sweet dude, i will try make the cannon rotate better.


Good job Boomer.
EDIT: @ The OP can delete the topic.



| « fixing the offset bug for ground Items in rs2dbase 2.2 | Good for I/O base? » |
| Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |