Author Topic: Spawned blocks not colliding?  (Read 1349 times)

If there's any part of your code where a loop of any sort calls brickGen_makeRow or any kind of function that calls createDungeonBrick, post it.

Any function that calls createDungeonBrick, post it.

Any function that calls a function that calls createDungeonBrick, post it.

Or just post the whole add-on

Or just post the whole add-on
Clearly he's afraid of giving out too much of the code.

Basically, post any part of the code having to do with this.

Code: [Select]
function createDungeonBrick(%id,%db,%pos,%col,%fx) {
   %pos = getWords(%pos,0,2) SPC getWord(%pos,2) - (-50*%id);
   if($DG::isBrick[%pos])
      return -1;
   if(strLen(%fx) < 1)
      %fx = 0;
   %brick = new fxDTSBrick() {
      position = %pos;
      datablock = %db;
      isPlanted = true;
      colorId = %col;
      colorFxId = %fx;
   };
   %err = %brick.plant();
   MissionCleanup.add(%brick);
   if(!isObject(BrickGroup_88)) {
      new SimGroup(BrickGroup_88) {
         name = "Dungeon Generator";
         bl_id = 88;
      };
      MainBrickGroup.add(BrickGroup_88);
   }
   BrickGroup_88.add(%brick);
   $DG::isBrick[%pos] = true;
   return %brick;
}

you need a client for the brick to work right.
Also make sure the 'Z' position of your brick is above ground (greater than 0).

Lastly -- plant a regular brick, use /getid to get the obj id for it.  do a dump() in console and look to see what the properties are for the brick.  Then make sure your code uses those values.

v21 changed the rules when creating bricks from script, so a lot of the old ways wont work.

v21 changed the rules when creating bricks from script, so a lot of the old ways wont work.
I'm reasonably sure that the only big thing changed was that you now need a client for a brick.

If there's any part of your code where a loop of any sort calls brickGen_makeRow or any kind of function that calls createDungeonBrick, post it.

Any function that calls createDungeonBrick, post it.

Any function that calls a function that calls createDungeonBrick, post it.
...
alot of the code calls that...


Here is some, i took out some parts that were un important..
function Player::generateDungeon(%this) {
   cancel(%this.generateDungeon);
   if(!$DG::Enabled)
      return;
   %grid = 4 / 2;
   %x = %grid * mFloatLength(getWord(%this.getPosition(),0) / %grid,0);
   %y = %grid * mFloatLength(getWord(%this.getPosition(),1) / %grid,0);
   %z = %grid * mFloatLength(getWord(%this.getPosition(),2) / %grid,0);
   if(!$DG::Generated[%x,%y]) {
      for(%offset_x=-10;%offset_x<11;%offset_x+=2) {
         for(%offset_y=-10;%offset_y<11;%offset_y+=2) {
            brickGen_makeRow(%x+%offset_x SPC %y+%offset_y,%noPillar,%this.dungeonID);
         }
      }
      $DG::Generated[%x,%y] = true;
   }
}

First, try making the bricks have a client. I don't know if an AIConnection would work for that or not.
Then, try using schedules to build the bricks. There are a few ways to do this, you can have a function that recurses with schedules, in this case, the easiest may be to create schedules all at once with an increasing time on them, however the former is much better to do if you can do it.

Here is the working PlaceBrick function from my mining server:
Code: [Select]
function PlaceBrick(%pos, %health, %color, %colorFx, %shapeFX, %type)
   {
    %client = $Dig_host;
    %brick = new fxDTSBrick()
      {
       client = %client;
       datablock = "brick4xCubeData";
       position = %pos;
       rotation = "0 0 0 0";
       colorID = %color;
       scale = "1 1 1";
       angleID = "0";
       colorfxID = %colorfx;
       shapefxID = %shapeFx;
       isPlanted = 1;
       stackBL_ID = $Dig_Host.bl_id;
       type = %type;
       health = %health;
       isMineable = 1;
      };
    %r = %brick.plant();
    %brick.setTrusted(1);

    $Dig_host.brickgroup.add(%brick);
    $Dig_placedDirt[%pos] = %brick;
    return %brick;
   }

the %health and %type are specific to my mining mod -- you can ignore those.  See if this gives you any more clues (unless you have fixed it already).

psst

Badspot broke floating brick collision, Port told me about it

psst

Badspot broke floating brick collision, Port told me about it
Red_guys unlimited mining still works

So nope

Red_guys unlimited mining still works

So nope
Hmmm, I wonder how Red_Guy bypassed the check

Hmmm, I wonder how Red_Guy bypassed the check
Here is the working PlaceBrick function:
Code: [Select]
function PlaceBrick(%client, %datablock, %pos, %health, %color, %colorFx, %shapeFX, %type)
   {
    %brick = new fxDTSBrick()
      {
       client = %client;
       datablock = %datablock;
       position = %pos;
       rotation = "0 0 0 0";
       colorID = %color;
       scale = "1 1 1";
       angleID = "0";
       colorfxID = %colorfx;
       shapefxID = %shapeFx;
       isPlanted = 1;
       stackBL_ID = %client.bl_id;
      };
    %r = %brick.plant();
    %brick.setTrusted(1);

    return %brick;
   }

Hmmm, I wonder how Red_Guy bypassed the check

Seems like you need an object inherited from NetConnection as a client now.

I found creating a "fake client" works.  I had this same code before v21 and it still works:

Code: [Select]
function Dig_CheckHost()
  {
   if (!isObject($Dig_Host))
     {
      %bl_id = GetNumKeyID();
      $Dig_Host = new ScriptObject() {
         isAdmin=1;
         brickgroup=0;
         bl_id=%bl_id;
      };
     }

    if ( !isObject($Dig_Host.brickgroup) )
      {
       %bl_id = GetNumKeyID();
       %brickgroup= new SimGroup("BrickGroup_" @ %bl_id) {
         client =0;
         bl_id=%bl_id;
         name="\cBL_ID: " @ %bl_id @ "\c1\c0";
         };
       $Dig_Host.brickgroup = %brickgroup;
       if (isObject(MainBrickGroup) )
         {
          MainBrickGroup.add($Dig_Host.brickgroup);
         }
      }
  }

I just use the $Dig_Host global as the argument when %client is needed somewhere.