some tinkering of my own

overdhose

Active Member
Contributor
Design
World
GUI
this is not related to any issue, but might be nice to let people interact a little bit with minions...

BEHOLD! the magnificent mionionbar.... I created a vertical toolbar at the right of the screen, pressing X switches active toolbars. The toolbar is empty by default, right click on a selected block somewhere (make it a top block) and a cube will spawn. right click again and it will despawn, left click a block and it will stop following you and move to the targeted block, you can repeat that process...

if you think it's fun I can add some gimmicks, to me it was mostly a fun exercise and a way to get acustomed to the code.

can be found on my fork if you want to play around, based on a recent fork from Immortius.

some details : I created a new toolbar, some minion components, a new AI, an icon for the minions and altered mouse and keyboard behaviour for localplayer (same color for all though)
 

overdhose

Active Member
Contributor
Design
World
GUI
I was trying to code one last thing, instead of having a cube just move to a location, I wanted to let it gather the clicked block. It seemed easy, I copied the attack function of the player, and added it to my minion component. then I would let the cube attack that location yntill the blcok was gathered. I know I might be jumping the gun here it just seemed fun to try.

My first attempt at this the minion would hit things faster then a machine gun, as it would loop through it's updates and attack every time. On top of that it attacked anything I would point at, making me a walking brick breaking god. I realized mt errors looking at the calculating of the block intersection code, based on the player cam, and obviously added a timer mechanic to slow down the attack rate.

However, while I did manage to simulate the cube actually attacking a block like an npc, I never got to solve that block calculating issue, even if I did replace the cam by a fixed point. If anyone has a pointer as to where I should start looking (maybe in the location component?) to solve this issue? I will have another go at it, after I manage to solve my github woes that made me lose part of that code.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Neat! Got it to work out of your develop, the minionTinker didn't work. Spiffy to be able to pop up a few gelcubes and play fetch with them :D

No real clue how to make a viewpoint like that work/change for a non-player tho

Edit: I tried to merge your branch to Integrate (experimental branch) so it could be built and advertised but hit mass conflicts. It looks like you've been merging in changes from elsewhere in a way Git can't recognize as previous commits. Then trying to merge in the same commits normally gets the two sets of changes in a slapfight :)

You might want to branch something clean off MovingBlocks or Immortius and then manually copy over just the changes you made. http://wiki.movingblocks.net/Main/Fancy ... Management may help
 

overdhose

Active Member
Contributor
Design
World
GUI
will do...

yeah me and Git, we got in a bit of a quarrel, Git won apparently.

I'll refork the base, create a branch and add my changes. Hopefully Git will get my drift this time around...
 

overdhose

Active Member
Contributor
Design
World
GUI
I uch also wanted to see if i could give my cubes a name... I would like to show their name above them on screen, anyone have an idea / reference how to go about this? something that might actually be usefull later?

I found this :
Code:
public get2DFrom3D(float x, float y, float z)
{
    /*
    FloatBuffer screen_coords = GLAllocation.createDirectFloatBuffer(4);
    IntBuffer viewport = GLAllocation.createDirectIntBuffer(16);
    FloatBuffer modelview = GLAllocation.createDirectFloatBuffer(16);
    FloatBuffer projection = GLAllocation.createDirectFloatBuffer(16);
    */

    double[] screen_coords = new double[4];
    int[] viewport = new int[4];
    double[] modelview = new double[16];
    double[] projection = new double[16];


    GL11.glGetFloat(2982 /*GL_MODELVIEW_MATRIX*/, modelview);
    GL11.glGetFloat(2983 /*GL_PROJECTION_MATRIX*/, projection);
    GL11.glGetInteger(2978 /*GL_VIEWPORT*/, viewport);

    boolean result = GLU.gluProject(x, y, z, modelview, projection, viewport, screen_coords);
    if (result)
    {
        //System.out.printf("Convert [ %6.2f %6.2f %6.2f ] -> Screen [ %4d %4d ]\n", x, y, z, (int)screen_coords[0], (int)(screen_coords[3] - screen_coords[1]));
        System.out.printf("Convert [ %6.2f %6.2f %6.2f ] -> Screen [ %4d %4d ]\n", x, y, z, (int)screen_coords.get(0), (int)(screen_coords.get(3) - screen_coords.get(1)));
        return new Vector2(screen_coords[0], screen_coords[3] - screen_coords[1]);
    }
    else
    {
        System.out.printf("Failed to convert 3D coords to 2D screen coords");
        return null;
    }
}
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
overdhose said:
However, while I did manage to simulate the cube actually attacking a block like an npc, I never got to solve that block calculating issue, even if I did replace the cam by a fixed point. If anyone has a pointer as to where I should start looking (maybe in the location component?) to solve this issue? I will have another go at it, after I manage to solve my github woes that made me lose part of that code.
Well, there's a couple of ways to do it. Probably easiest is when the player orders a minion, record the block the player is looking at on the minion in some way (in one of its components), so when it arrives it knows which block to harvest explicitly. You can also use the minion's location component to determine where it is and where it is looking at, but that may not be quite what you want.

On the name above minion - typically you'ld have some method that can convert a world location to a screen location, and then have the GUI place the text a bit above that. Can also calculate the distance away the minion is from the camera and use that as a factor for scaling or coloring the text.
 

overdhose

Active Member
Contributor
Design
World
GUI
allright, new miniions branch is available now, the way it's intended to (I hope)
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Closed https://github.com/MovingBlocks/Terasology/issues/243 as complete! Go check it out in develop. Can be a little tricky getting used to the minion bar (toggle back and forward with 'x' use mouse scroll to remind yourself which is active). Don't hold a bulky object while you try to work the new bar, as it'll get covered up :)

Next up gray goo world as the AI and multi-block digging turns the world into a giant meal...
 

overdhose

Active Member
Contributor
Design
World
GUI
another gimmicky thing, selecting a minion lights it up, so you can easily determine which gel cube you have selected. My original idea was to use it as a walking torch (une baladeuse as the french call it :p)

I wonder now how hard it would be to actually have it emit light when its selected *whistles* :twisted:

it looks out of place now in the dark, being visible but not emitting light...
 
Top