ItsMods

Full Version: MoveTo thingy :(
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I want the block to fall down if it doesnt have any health left.. its not moving after its death Sad but it does get destroyed after 5 sec Sad

Code:
CreateGrids(corner1, corner2, angle)
{
    W = Distance((corner1[0], 0, 0), (corner2[0], 0, 0));
    L = Distance((0, corner1[1], 0), (0, corner2[1], 0));
    H = Distance((0, 0, corner1[2]), (0, 0, corner2[2]));
    CX = corner2[0] - corner1[0];
    CY = corner2[1] - corner1[1];
    CZ = corner2[2] - corner1[2];
    ROWS = roundUp(W/35);
    COLUMNS = roundUp(L/70);
    HEIGHT = roundUp(H/35);
    XA = CX/ROWS;
    YA = CY/COLUMNS;
    ZA = CZ/HEIGHT;
    b = 0;
    center = spawn("script_model", corner1, 0);
    for(r = 0; r <= ROWS; r++)
    {
        for(c = 0; c <= COLUMNS; c++)
        {
            for(h = 0; h <= HEIGHT; h++)
            {
                if(!isDefined(level.blocks))
                {
                    level.blocks = [];
                }
                level.blocks[b] = spawn("script_model", (corner1 + (XA * r, YA * c, ZA * h)), 1);
                level.blocks[b] setModel(level.crateModelFriendly);
                level.blocks[b].angles = (0, 0, 0);
                level.blocks[b] SetOwner( level );
                level.blocks[b] LinkTo(center);
                level.blocks[b].health = 100;
                level.blocks[b] SetCanDamage(true);
                level.blocks[b] thread destroyBlock( b );
                b++;
                wait 0.01;
            }
        }
    }
    center.angles = angle;
}

destroyBlock( b )
{
    for(;;)
    {
        block = level.blocks[b];
        block waittill("death");
        block moveTo((block.origin[0], block.origin[1], block.origin[2]-600), 4);
        wait 5;
        block delete();
    }
}

Big Grin
Quote:destroyBlock( b )
{
for(;Wink
{
block = level.blocks[b];
block waittill("death");
if( (self.block.health <= 0)
{
block moveTo((block.origin[0], block.origin[1], block.origin[2]-600), 4);
}
wait 5;
block delete();
}
}
(03-26-2011, 20:45)Romuald27 Wrote: [ -> ]
Quote:destroyBlock( b )
{
for(;Wink
{
block = level.blocks[b];
block waittill("death");
if( (self.block.health <= 0)
{
block moveTo((block.origin[0], block.origin[1], block.origin[2]-600), 4);
}
wait 5;
block delete();
}
}

Code:
block waittill("death");
is the same as
Code:
if(block.health <= 0)

just some advise to you, self is (in most cases) an entity, block is the entity so you have to replace self with block Wink