ArrowTurrets does what the name says. It creates arrow "turrets". You simply aim at any block (can be far away) with an arrow in your hand(configurable) and write /addt and it will add a turret to that location and choose you as an owner. The "turret" will be shooting at anyone who isn't you. To remove a "turret" simply write /delt while aiming at it with an arrow in your hand. I might update with more functions if people like the plugin. When bukkit has support for onRightClick and onClick, i will make the plugin add and remove turrets by simple left/right-clicking them. Be sure that the block you are choosing has a good line of sight or it will be hitting other blocks. The turret remains even when you have removed the block so you can create invisible "turrets" . Please give me suggestions of other names of this plugin! Commands: Code: /addt - adds a turret /delt - deletes a turret (Does not work in 1.2.0) /addto [name] - adds an owner to a turret /delto [name] - deletes an owner of a turret /addta [name] - adds an "accessor" to a turret /delta [name] - deletes an "accessor" of a turret /settn [turretname] - Names the turret you are aiming at /addts [turretname] - Set the turrets seat where you are aiming /delts [turretname] - Deletes a turrets seat (May not work in 1.2.0) To do all these commands you need to be aiming at a block. Install Download the plugin here Put it in the plugins folder in your server folder Run the server once (You may stop here if you want) Shut down the server See ArrowTurrets.properties file inside the ArrowTurrets folder in your server folder for settings See ArrowTurrets.perms file inside the ArrowTurrets folder in your server folder for permissions Changelog v1.2.0(Krathlak) - 2011-01-16 Updated for new CraftBukkit version. Added turret seats Added permissions Added settings You can currently not remove turrets without manually doing so by stopping the server and modifying the ArrowTurrets\ArrowTurrets.txt file v1.1 (Kleynach) - 2011-01-10 Updated for new CraftBukkit version. Thanks sk89q for fixing arrow spawning bug! v1.0 (Ethros) - 2011-01-07 Turrets can now have multiple owners Added commands for adding and deleting owners of turrets Turrets can have "accessors". Accessors can't modify the turret but the turret won't shoot them. Added commands to add and delete accessors Fixed bug where config wasn't loaded v0.1 (Fyarl) - 2011-01-07 Initial convertion from my hmod plugin Hardcore forker: feverdream
This is for CraftBukkit Which is a SMP Server Wrapper and this is a plugin for it. Thus meaning its for SMP not SP. 100% Multiplayer
Any chance I can get this setup so it will not attack admins, or a full group of people? And does it ever run out of arrows?
@feverdream: It never runs out of arrows, might just add that tho. Maybe it should cost x arrows to make a turret and then you can fill up it's "quiver" with more arrows. If you for example would fill it up with 10 arrows i could make it get 10 * x arrows where x is a configurable multiplier in the config. This would also let anyone create a turret without being able to get unlimited kills with it. Might add this in next release. Will need to be able to take items from the player though. Ohh and yeah i updated it with new stuff EDIT: Just noticed that it seems like i can't edit the title of the topic, would a good Samaritan please change it to just ArrowTurrets?
Is source available? EDIT: Just looked in the jar, found what may be it. It looks like adding multiple owners would not be hard.
If you look at the first post again you can see that i already added multiple owners But the source is avaliable at https://github.com/toimelin/ArrowTurrets and if you make the code better please submit (Or whatever you do to suggest a change) it to github My coding is real bad i know xD
Have anyone actually got this to work? I just remembered i ran another version of Craftbukkit that possibly had a spawn arrow fix EDIT: Posted redmine bug report about the spawnArrow bug
Plugin works perfectly, I switched my server over to bukkit last night and played on it all night - its now 8am - and really enjoyed this mod, people scoffed at my "no trespassing, trespassers will be shot, survivors will be shot again" double signs.. then i left and they all tried to swarm my stash, got shot, and died wondering "wtf?". I loved it! The only thing I can think of after using thsi mod extensively to protect a castle is the cpu lag generated with foreach loop search for the player; It would be MUCH better if on adding a turret, it scanned the possible blocks around it and added these blocks to a in memory lookup cache that was then checked on playerMove directly (base the cache around a hashtable for locations for lookup speed, you should not care if adding can be slow or not as its a 1 time operation each turret so not an issue) instead of trying to brute force the lock every time. You could easily reference count locations in x/y/z to be sure that areas covered by more than 1 turret are handled correctly when one is removed. This would dramatically enhance lock and fire speed, while removing cpu lag from its search functions, and in general speed up the server when this mod is used. If you have any more questions about the correct caching mechanism to use, just ask.
@feverdream i will attempt to do this but i have never done it before. Would it be best to have a hastable for each turret or have all turrets in a hastable?
https://github.com/toimelin/ArrowTurrets my attempt to use hashtables, it seems like the server runs out of memory really fast. Just tried the old version and it seems alot more stable. Would appreciate if someone could comment on this and what i am doing wrong.
On a embeded device with a small screen so sorry about the crappy psudocode. I will check this later tonight again. The idea is to use a single hashtable for everything was not what I had intended; Perhaps I was unclear? If so, my apologizes. Instead, Use multiple collections and reference them as keys within each other. 1. A collection of turrets is a sington object. 2. Scan/Lock data would be a collection populated and used based on the location of the turrets in the first collection since it is derived in memory based on the configured range and location of the turrets themselves. This would give you map to give you the lists of turrets in range for a given x/y/z location. For any given x/y/z you get returned a list of turret id's corresponding to the id's used in the first collection of turrets. Not the turret objects themselves. Then when a person moves (psudocode): Code: If( turret_scan_collection.contains(player.getLoc().getX(),player.getLoc().getY()player.getLoc().getZ()) == true){ List<turret_id> tsc = turret_scan_collection.get( player.getLoc().getX(),player.getLoc().getY()player.getLoc().getZ() // for each possible turret to shoot in that location check access and if they should shoot , make them. for(turret_id t_id : tsc) { Turret turret = turret_data_collection.getById(t_id); if (turret.canShoot()) { this.shoot(player, speed, spread, playerHead.toLocation(player.getWorld()), turret.getLoc().toVector()); turret.setCanShoot(false); } } } From looking at the code you are adding the same single item turret data list multiple times, effectivly adding the same turrent data for the entire range of the turret, and doing so only if it does not exist already.. problem with this is that you are taking up more memory than you should, as well as not taking into consideration that multiple turrets may be within range of a single point. You should be: (Again, psudocode) Code: // Add the turret to the turet collection, use the index as its turret id. List<Turret> turret_data_collection = List<Turret>(); private Hashtable<Vector, ArrayList<Turret>> hashturrets = new Hashtable<Vector, ArrayList<Turret>>(); private void addTurret(Location loc, ArrayList<String> owners, ArrayList<String> accessors) { turret_data_collection.add(new Turret(owners, accessors, loc)); int turret_id = turret_data_collection.size() - 1; // Index in list. // Add the current turret id to our collection ArrayList<int> turret_current_id_list = new ArrayList<int>(); turret_current_id_list.Add(turret_id); int cx = loc.getBlockX() - this.xDis; int cy = loc.getBlockY() - this.yDis; int cz = loc.getBlockZ() - this.zDis; for (int x = 0; x < (this.xDis * 2) + 1; x++) { for (int y = 0; y < (this.yDis * 2) + 1; y++) { for (int z = 0; z < (this.zDis * 2) + 1; z++) { Vector cBlock = new Vector(cx + x, cy + y, cz + z); ArrayList<int> turrets_covering_location = new ArrayList<int>(); // get scan data from scan data collection. turrets_covering_location = turret_scan_collection.get(cBlock); if(turrets_covering_location == null){ // No other turrets cover this location. Add the list as-is // the only the current turret turret_scan_collection.put(cBlock, turret_current_id_list); }else{ // Other turrets are in range.. add the current turret to it. turrets_covering_location.add(turrent_id); turret_scan_collection.removeByKey(cBlock); turret_scan_collection.put(cBlock, turrets_covering_location); } cBlock = null; } } } this.saveTurrets(); } Sorry about the crappy response I'm on a embeded device with a small screen, I will check this later when I can.
uploaded a new version containing these changes. Commented out some old parts(remove) to get it to compile. Looks like it is working better. Will try more later today though (00:25 here). Thanks so much for the help!
I cant work on this tonight as I need to get some actual work done while working late in the office tonight - no doubt payback for my full night of minecraft with this mod, but it was worth it! - but expect actual patch sets from me in the near future, as clearly now that I can look at this in a browser my post included some errors in my attempt to communicate. On memory usage: Yes, this way with the default of range of 5, 125 items are added to the cach when you add a turret. But locking a person is also 125+ times faster. Its a trade off, you can either do this fast with memory usage up a bit, or slow with memory usage down. It all depends on what part of the server - CPU or RAM - you want to use the most of. Glad to know I was helpful, either way.
What do you think about letting the player choose what method to use? I can image some small servers might work better with the old method of detection. I would appreciate any help on how to remove the turrets in a good way as well and process the hashtable in a good way. At the moment it stores the index of the turret but when removing a turret that index will change and therefore make the hashtable call the wrong turret(s).
I envision you needing to seperate out each type to seperate classes - MoreCPU and MoreRAM versions, using a common parent interface. Its possible, That would however require more work and a clear architecture. Removing turrets would be as simple as iterating through the entire cache and removing scan data that contains the turret in question. Or, you could just delete all scan-data and re-initialize that cache without that removed turret for a faster and easier operation. I'm without a server to test on atm.. but after work I will look into this more.
It's definitely different than your plugin. You could certainly use the block type for display purposes, at least; that's the main reason I posted about it, figuring it might have something useful for your plugin. Actually though, I like the new built-in one because it actually uses up ammunition which needs to be replenished, and because it needs to be powered. That's good for a player-run defense system since it's not overpowered. You could hook up a bank of them to a switch to fire all at once as rapidly as possible, or better yet set up Indiana Jones style traps where stepping on a pressure plate triggers a hail of arrows flying from the walls.
It doesn't target people, it has a limited supply, and it has to be activated via redstone (or right clicking it I think). So I think its safe to say this plugin improves on that- although it would be cool if the plug-in modified dispensers instead of just making a weird invisible block lol. EDIT: Ack, I pretty much said what you said... I didn't hit refresh X_X
I just did some testing with the new beta and yes I agree, this plugin is still very much needed. Looking forward to the next dev-release of bukkit so I can start giving you patches..
I would like to see this added to the new despencer and use the ammo slots and such. --- merged: Jan 14, 2011 9:55 AM --- Maybe also add pve/pvp and maybe access lists and the works.. haha
When there is a working onEntityMove event i will make turrets setting whether to shoot at players/mobs or not. Hopefully Bukkit comes with some class for the dispenser so i could actually use the dispencer inventory to turn in stuff to the turret. I might do so it takes 1 arrow from the dispencer inventory each 10 shots it shoots so it doesn't run out fast, this would of course be configurable.
Nice video preview. However remember that you can't rightclick to create a turret in the current release. Might just add it next release though, but it could take a while since i am optimizing the plugin and adding some functions
Thanks. I could do another one when it gets updated. Feel free to use it in the topic as a tutorial if you wish.
Yeah i will if you make a new one when this is updated. Now i got a question do you people want be to upload a new "working" release of this? The release can however not remove turrets yet.