Best way to make "animations"

Discussion in 'Plugin Development' started by Webbeh, Oct 28, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Webbeh

    Hi.

    For my siege plugin, I "need" some way to animate certain mechanisms on my map. For example, a battering ram that would move forwards, then backwards.

    I'm now using CraftBook areas to do this, but the more frames, the more complicated it gets, so I was wondering if there was any better solution to do this.

    Any help would be appreciated.
     
  2. Offline

    FerusGrim

    I'm not sure that you're in the correct forum section.

    This is plugin development. No one here, though, is going to code you a plugin that handles what you're asking for. Or any other plugin, for that matter. That's what the Plugin Request section is for.

    Now, if you're asking for help to develop a CraftBook alternative... well, you're going to need to provide some of your own code first, in which case we may attempt to fill in some gaps for you.

    No one here is going to spoon feed you a solution, though.
     
  3. Offline

    Webbeh

    Sorry for not being specific enough :

    Yes, I am in the right section. I'm not asking anyone to code a plugin for me at all, just to help me figure out which way is the best to code the feature I want.

    The only thing I said was that I wanted to get rid of craftbook's areas, not that I want anyone of you to do that for me.
     
  4. Offline

    FerusGrim

    The best way to code the feature you want is by using Java. :p

    Do you have any work done that I can look at and tell you if you're going in the right direction?
     
  5. Offline

    Webbeh

    I'm not disclosing any of my code to the public at the moment, even if it's to help me. That's why I ask for POINTERS to do it. I was willing to use block changes, but defining them wouldn't be as modular as I want it to be (need to hardcode every position, ...). The best way I found now, sadly, is to use areas, and I want to get rid of it, to simplify my code.
     
  6. Offline

    FerusGrim

    I assure you that no one here is going to steal snippets of your code. :)

    But, I respect your decision. I can't provide very specific pointers without knowing your code (not to mention that seeing your own code helps reaffirm in my mind what you really want to do), but I'll try to give you some pseudo-code.

    Assuming a battering ram is placed on a command such as, /ram:
    Command is issued -> check if sender is instanceof Player. If not, disregard command.
    -> Get player location, then select relative location to player. Make sure relative location is clear of blocks. If not, get new relative location.
    -> Save a 'core' block from this location into a list (or Hashmap, if you need to save it to a player), so that you can get relative blocks from it later. Make this consistent.
    -> Do a for-loop through this list/map, get the blocks involved, and then do the animation.

    The above will solve the problem of you having to manually code in locations of the blocks. :)
     
  7. Offline

    Webbeh

    Well, let's try to be more specific :

    For a "siege"-like plugin, I am doing gate bashing, flag capturing and all kind of stuff. The plugin works really well for now, and I want to add some fancy things in it.

    The ram part

    There are gates on my maps, and some of them would be rammable. For the time being, I'm using worldguard regions with a specific name to define if you can "build" a ram at said location. You build it by interacting with the ground whilst standing in said area. The ram is then "displayed" by using a Craftbook Area (so the ram is pre-built and the area is simply toggled on/off to display the ram).

    If the ram is built, players around it can "use" the ram by interacting with it (more or less). I created a ram tick scheduler that fires "<gate>.damageGate" every 4-5 seconds, according to the amount of players, and to the "bash damage" each and every player normally has when he selects a class (you know, trolls are heavy and deal more than simple peasants).

    What I would like to do is "move" the blocks composing the ram forwards when the scheduler fires the "damageGate" method, to make it look like it's working.

    All the rest is more or less done, your snippet doesn't help since it's just doing the things I already do in another way. The "hardcode" problem is there because I can't, now, know exactly which blocks to move and which to not move.

    Also I want all the rams to be looking different, that's why using Areas was the best way to go, or so I thought.


    If there is no better way, I'll keep using it and optimizing my code the best I can but... yeah well I hope there's another way.
     
  8. Offline

    FerusGrim


    If you've already done everything that I explained above, this should already be solved for you, considering that my explanation was really nothing more than how to save the blocks, and then move them around.


     
  9. Offline

    Webbeh

    Won't work because
     
Thread Status:
Not open for further replies.

Share This Page