Author Topic: Blueprint Mod?  (Read 16044 times)

oh boy
speak up boy dont be so secretive tell me what you mean by "oh boy"

Code: [Select]
//exec("config/5/blueprint/server.cs");bluePrint_clear();serverDirectSaveFileLoad("saves/houseTmp.bls",3,"",0,1);

datablock StaticShapeData(swol_borderShape)
{
shapeFile = "./border5.dts";
};
function rgbGradient(%step, %c1, %c2)
{
%r1 = getWord(%c1, 0);
%g1 = getWord(%c1, 1);
%b1 = getWord(%c1, 2);

%r2 = getWord(%c2, 0);
%g2 = getWord(%c2, 1);
%b2 = getWord(%c2, 2);

%r3 = %r1 + %step * (%r2 - %r1);
%g3 = %g1 + %step * (%g2 - %g1);
%b3 = %b1 + %step * (%b2 - %b1);

return %r3 SPC %g3 SPC %b3;
}
function eulerToAxis(%euler)
{
%euler = VectorScale(%euler,$pi / 180);
%matrix = MatrixCreateFromEuler(%euler);
return getWords(%matrix,3,6);
}
package swol_bluePrint
{
function fxDtsBrick::onPlant(%br)
{
bluePrint_addBrickStruct(%br);
bluePrint_formMesh(%br.struct);

%set = $Swol_BluePrintSet.bricks;
%line = %set.line[%set.pos-1];
%i = %line.getCount();
while(%i-->=0)
{
%struct = %line.getObject(%i);
%pos = getWords(%struct.tr,0,2);
if(%pos $= %br.getPosition() && %struct.db.getId() == %br.getDatablock().getId())
{
bluePrint_remBrickMesh(%struct);
%br.setColor(%struct.col);
%br.bluePrint_struct = %struct;
%line.cnt--;
break;
}
}
if(%line.cnt <= 0)
bluePrint_step();
return parent::onPlant(%br);
}
function fxDtsBrick::onLoadPlant(%br)
{
bluePrint_addBrickStruct(%br);
return parent::onLoadPlant(%br);
}
function fxDtsBrick::onRemove(%br)
{
return parent::onRemove(%br);
if(%br.bluePrint_struct_remove)
{
bluePrint_remBrickMesh(%br.struct);
}
if(isObject(%br.bluePrint_struct))
{
%set = $Swol_BluePrintSet.bricks;
%line = %set.line[%set.pos-1];
%struct = %br.bluePrint_struct;
bluePrint_formMesh(%struct);
%line.add(%struct);
%line.cnt++;
}
return parent::onRemove(%br);
}
};
activatePackage(swol_bluePrint);

function bluePrint_step()
{
%set = $Swol_BluePrintSet.bricks;
%line = %set.line[%set.pos];
if(%line $= "")
return;
%line.cnt = %line.getCount();
//if(isObject(%set.prev))
//{
// %i = %set.prev.getCount();
// while(%i-->=0)
// {
// %struct = %set.prev.getObject(%i);
// bluePrint_remBrickMesh(%struct);
// }
//}
//%cnt = %line.getCount();
bluePrint_stepTick(%line,0);
//for(%i=0;%i<%cnt;%i++)
//{
// %struct = %line.getObject(%i);
// bluePrint_formMesh(%struct);
// bluePrint_meshHighlightAnim(%struct);
//}
//%set.prev = %line;
%set.pos++;
}
function bluePrint_stepTick(%set,%i)
{
%struct = %set.getObject(%i);
bluePrint_formMesh(%struct);

if(%i+1 >= %set.getCount())
return;

%set.buildSched = schedule(30,0,bluePrint_stepTick,%set,%i++);
}
function bluePrint_buildList()
{
%set = $Swol_BluePrintSet.bricks;
%mCnt = %set.getCount();
%set.cnt = 0;
%set.pos = 0;
%safety = 0;
while(%mCnt > 0 && %safety < 99)
{
%low = bluePrint_findLowestGroup();
%mCnt -= %low.getCount();

%set.line[%set.cnt] = %low;
%set.cnt++;
echo(%low.getCount());
%safety++;
}
%i = %set.getCount();
while(%i-->=0)
%set.getObject(%i).br.delete();

bluePrint_step();
}
function bluePrint_findLowestGroup()
{
%set = $Swol_BluePrintSet.bricks;
%i = %set.getCount();
%tmp = new simSet();
%tmp.z = 99999;
%lowest = %tmp;
while(%i-->=0)
{
%struct = %set.getObject(%i);
if(%struct.accounted)
continue;
if(!isObject(%struct.br.getDownBrick(0)) && %struct.br.getDistanceFromGround() != 0)
continue;
if(%struct.z < %lowest.z)
{
%lowest = %struct;
}
}
%tmp.delete();
%low = new simSet();
%i = %set.getCount();
while(%i-->=0)
{
%struct = %set.getObject(%i);
if(%struct.z == %lowest.z)
{
%low.add(%struct);
%struct.accounted = 1;
}
}
return %low;
}
function bluePrint_addBrickStruct(%br)
{
%set = $Swol_BluePrintSet.bricks;
%struct = new simSet();
%struct.tr = %br.getTransform();
%struct.z = getWord(%struct.tr,2);
%struct.angId = %br.getAngleId();
%struct.db = %br.getDatablock();
%struct.col = %br.getColorId();
%struct.br = %br;
%set.add(%struct);

%br.struct = %struct;
}
function bluePrint_remBrickMesh(%br)
{
for(%i=0;%i<%br.bluePrint_meshCnt;%i++)
{
if(isObject(%br.bluePrint_mesh[%i]))
%br.bluePrint_mesh[%i].delete();
}
}
function bluePrint_buildFaceTable(%db)
{
%f = new FileObject();
%f.openForRead(%db.brickFile);

%f.readLine();

if(%f.readLine() $= "BRICK")
{
%db.bluePrint_faceTable = "simple";
%f.close();
%f.delete();
return;
}
%db.bluePrint_faceTable = "complex";
%db.bluePrint_faceCnt = 0;
while(!%f.isEOF())
{
%line = %f.readLine();
if(getSubStr(%line,0,4) $= "TEX:")
{
%tex = trim(getSubStr(%line,4,strLen(%line)));
if(%tex $= "TOP" || %tex $= "BOTTOMLOOP" || %tex $= "BOTTOMEDGE")
continue;
while(trim(%f.readLine()) !$= "POSITION:") {}
for(%i=0;%i<4;%i++)
{
%line = %f.readLine();

while(!strLen(%line))
%line = %f.readLine();

%pos = vectorAdd(%line, "0 0 0");

%pos = mFloatLength(getWord(%pos,0),3)
  SPC mFloatLength(getWord(%pos,1),3)
  SPC mFloatLength(getWord(%pos,2),3);
%db.bluePrint_face[%db.bluePrint_faceCnt,%i] = %pos;
}
%db.bluePrint_faceCnt++;
}
}
}
function bluePrint_formMesh(%br)
{
%br.bluePrint_meshCnt = 0;
%db = %br.db;
%sizex = %db.brickSizeX/4;
%sizey = %db.brickSizeY/4;
%sizez = %db.brickSizeZ/10;
%tr = %br.tr;
%ang = %br.angId;
%pos = posFromTransform(%tr);


%rotx = "0 1 0 1.57079";
%roty = "1 0 0 1.57079";
%rotz = "0 0 1 0";
%x = getWord(%pos,0);
%y = getWord(%pos,1);
%z = getWord(%pos,2);


if(%db.bluePrint_faceTable $= "")
bluePrint_buildFaceTable(%db);

if(%db.bluePrint_faceTable $= "simple")
{
if(%ang == 1 || %ang == 3)
{
%tmp = %sizeX;
%sizeX = %sizeY;
%sizeY = %tmp;
}
%scale = 1 SPC 1 SPC (%sizeY*2)+0.04;
bluePrint_meshAdd(%br,%x+%sizeX SPC %y SPC %z+%sizeZ,%rotY,%scale);
bluePrint_meshAdd(%br,%x-%sizeX SPC %y SPC %z+%sizeZ,%rotY,%scale);
bluePrint_meshAdd(%br,%x+%sizeX SPC %y SPC %z-%sizeZ,%rotY,%scale);
bluePrint_meshAdd(%br,%x-%sizeX SPC %y SPC %z-%sizeZ,%rotY,%scale);

%scale = 1 SPC 1 SPC (%sizeX*2)+0.04;
bluePrint_meshAdd(%br,%x SPC %y+%sizeY SPC %z+%sizeZ,%rotX,%scale);
bluePrint_meshAdd(%br,%x SPC %y-%sizeY SPC %z+%sizeZ,%rotX,%scale);
bluePrint_meshAdd(%br,%x SPC %y+%sizeY SPC %z-%sizeZ,%rotX,%scale);
bluePrint_meshAdd(%br,%x SPC %y-%sizeY SPC %z-%sizeZ,%rotX,%scale);

%scale = 1 SPC 1 SPC (%sizeZ*2);
bluePrint_meshAdd(%br,%x+%sizeX SPC %y+%sizeY SPC %z,%rotZ,%scale);
bluePrint_meshAdd(%br,%x+%sizeX SPC %y-%sizeY SPC %z,%rotZ,%scale);
bluePrint_meshAdd(%br,%x-%sizeX SPC %y+%sizeY SPC %z,%rotZ,%scale);
bluePrint_meshAdd(%br,%x-%sizeX SPC %y-%sizeY SPC %z,%rotZ,%scale);
}
else if(%db.bluePrint_faceTable $= "complex")
{
%q = 0.05;
%bitCnt = 0;
for(%i=0;%i<%db.bluePrint_faceCnt;%i++)
{
for(%a=0;%a<4;%a++)
{
%t = %db.bluePrint_face[%i,%a];
%px[%a] = getWord(%t,0)/2;
%py[%a] = getWord(%t,1)/2;
%pz[%a] = getWord(%t,2)/5;
if(%ang == 2)
{
%py[%a] *= -1;
%px[%a] *= -1;
}
else if(%ang == 3)
{
%py[%a] *= -1;

%tmp = %px[%a];
%px[%a] = %py[%a];
%py[%a] = %tmp;
}
else if(%ang == 1)
{
%px[%a] *= -1;

%tmp = %px[%a];
%px[%a] = %py[%a];
%py[%a] = %tmp;
}
%p[%a] = %px[%a] SPC %py[%a] SPC %pz[%a];
}

%k[0] = 0 SPC 1;
%k[1] = 1 SPC 2;
%k[2] = 2 SPC 3;
%k[3] = 3 SPC 0;

for(%j=0;%j<4;%j++)
{
%a = getWord(%k[%j],0);
%b = getWord(%k[%j],1);

%avx = (%px[%a]+%px[%b])/2;
%avy = (%py[%a]+%py[%b])/2;
%avz = (%pz[%a]+%pz[%b])/2;

%mPos = %x+%avx SPC %y+%avy SPC %z+%avz;
%doBreak = false;
for(%k=0;%k<%bitCnt;%k++)
{
if(vectorDist(%mPos,%bit[%k]) < %q)
{
%doBreak = true;
break;
}
}
if(%doBreak)
continue;

%dist = vectorDist(%p[%a],%p[%b]);

%v = vectorNormalize(vectorSub(%p[%b],%p[%a]));
%u = getWord(%v,0);
%w = getWord(%v,1);
%yaw = mATan(%u,%w)-($PI/2);
%pitch = 0 - mATan(getWord(%v,2),mSqrt(%u * %u + %w * %w));
%rot_xy = -90-%pitch*180/$PI;
%rot_z = -90-%yaw*180/$pi;
%rot = eulerToAxis(%rot_xy SPC 0 SPC %rot_z);

%s = bluePrint_meshAdd(%br,%mPos,%rot,1 SPC 1 SPC %dist,"1 0 0 1");
%s.roExt = %rot_xy SPC %rot_z;
%bit[%bitCnt] = %mPos;
%bitStore[%bitCnt] = %s;
%bitCnt++;
}
}
for(%i=0;%i<%bitCnt;%i++)
{
%ix = getWord(%bit[%i],0);
%iy = getWord(%bit[%i],1);
%iz = getWord(%bit[%i],2);
%ir = %bitStore[%i].roExt;

%above = %below = false;
for(%a=0;%a<%bitCnt;%a++)
{
if(%a == %i)
continue;
if(!%bit[%a])
continue;
%ax = getWord(%bit[%a],0);
%ay = getWord(%bit[%a],1);
%az = getWord(%bit[%a],2);
%ar = %bitStore[%a].roExt;
if(((%ax-%q < %ix && %ax+%q > %ix) || (%ay-%q < %iy && %ay+%q > %iy)) && %ar $= %ir)
{
if(%az > %iz)
%above = true;
if(%az < %iz)
%below = true;
}
}
if((%above+%below) == 2)
{
%bitStore[%i].delete();
%bit[%i] = "";
}
}
}
}
function bluePrint_meshAdd(%br,%pos,%rot,%scale,%col)
{
%set = $Swol_BluePrintSet.meshes;
%s = new StaticShape(){datablock = swol_borderShape;};
%s.setTransform(%pos SPC %rot);
%s.setScale(%scale);
if(%col $= "")
{
%col = getWords(getColorIdTable(%br.col),0,2);
%col = rgbGradient(0.3,%col,"1 1 1");
%s.setNodeColor("ALL",%col SPC 1);
}
else
{
%s.setNodeColor("ALL",%col);
}
%set.add(%s);
%br.bluePrint_mesh[%br.bluePrint_meshCnt] = %s;
%br.bluePrint_meshCnt++;
return %s;
}
function bluePrint_clear()
{
%set = $Swol_BluePrintSet.meshes;
%i = %set.getCount();
while(%i-->=0)
%set.getObject(%i).delete();
%set = $Swol_BluePrintSet.bricks;
%i = %set.getCount();
while(%i-->=0)
%set.getObject(%i).delete();
}
if(!isObject($Swol_BluePrintSet))
{
$Swol_BluePrintSet = new simSet();
$Swol_BluePrintSet.bricks = new simSet();
$Swol_BluePrintSet.meshes = new simSet();
}

code sucks and is not predictable


-snip-

hey make it not so messy mumbo jumbo when ya can mayb in free time

hey make it not so messy mumbo jumbo when ya can mayb in free time
shes not gonna work on the code ever again lol its been a full year and a half since she wrote it

yay

hey make it not so messy mumbo jumbo when ya can mayb in free time
that's asking for a bit much

whats the contents of config/5/blueprint/server.cs

whats the contents of config/5/blueprint/server.cs
that is config/5/blueprint/server.cs


bump
nvm saw that swollow posted code