I actually managed to make the portal gun, but it is a script file, and so cannot be posted here.
it has problems with any z rotation not 0 or 180, although all that means is is faces sideways, unless both the x and y sizes are the same, no x or y rotation allowed, but it can infinite loop just fine .
heres some of the code, you will need to place the player collision part and supply a weapon for the code.
the player collision hook in:
code:
if(%col.gunportal)gunportal(%col,%obj);
the script for the portalgun
code:
function portalgunProjectile: :onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
if(!%col.portalguntarget && !$pref::server: :portalanywhere)return;
%rot=%col.eulerrot;
if(getword(%rot,0)!=0)return;
if(getword(%rot,1)!=0)return;
if(!(getword(%rot,2)==0||getword(%rot,2)==90||getword(%rot,2)==180||getword(%rot,2)==270))return;
%rotz=getword(%rot,2);
%colpos=%col.getposition();
if(getword(%pos,1)<getword(%colpos,1)+0.1&&%rotz<180)
{
echo("-y hit");
%p=newportal();
%p.portaldir="-y";
%p.settransform(vectoradd(%pos,"-1 0 -1.5") SPC eulerToQuat("90 0 0"));
%p.offset="1 0 1.5";
}
else if(getword(%pos,1)>getword(%colpos,1)+getword(%col.getscale(),1)*%col.getdatablock().y/2-0.1&&%rotz<180)
{
echo("y hit");
%p=newportal();
%p.portaldir="y";
%p.settransform(vectoradd(%pos,"1 0 -1.5") SPC eulerToQuat("90 0 180"));
%p.offset="-1 0 1.5";
}
else if(getword(%pos,1)>getword(%colpos,1)-0.1&&%rotz>90)
{
echo("y hit");
%p=newportal();
%p.portaldir="y";
%p.settransform(vectoradd(%pos,"1 0 -1.5") SPC eulerToQuat("90 0 180"));
%p.offset="-1 0 1.5";
}
else if(getword(%pos,1)<getword>90)
{
echo("-y hit");
%p=newportal();
%p.portaldir="-y";
%p.settransform(vectoradd(%pos,"-1 0 -1.5") SPC eulerToQuat("90 0 0"));
%p.offset="1 0 1.5";
}
else if(getword(%pos,0)<getword(%colpos,0)+0.1&&(%rotz==0||%rotz==270))
{
echo("-x hit");
%p=newportal();
%p.portaldir="-x";
%p.settransform(vectoradd(%pos,"0 1 -1.5") SPC eulerToQuat("90 0 270"));
%p.offset="0 -1 1.5";
}
else if(getword(%pos,0)>getword(%colpos,0)+getword(%col.getscale(),0)*%col.getdatablock().x/2-0.1&&(%rotz==0||%rotz==270))
{
echo("x hit");
%p=newportal();
%p.portaldir="x";
%p.settransform(vectoradd(%pos,"0 -1 -1.5") SPC eulerToQuat("90 0 90"));
%p.offset="0 1 1.5";
}
else if(getword(%pos,0)>getword(%colpos,0)-0.1&&(%rotz==90||%rotz==180))
{
echo("x hit");
%p=newportal();
%p.portaldir="x";
%p.settransform(vectoradd(%pos,"0 -1 -1.5") SPC eulerToQuat("90 0 90"));
%p.offset="0 1 1.5";
}
else if(getword(%pos,0)<getword(%colpos,0)-getword(%col.getscale(),0)*%col.getdatablock().x/2+0.1&&(%rotz==90||%rotz==180))
{
echo("-x hit");
%p=newportal();
%p.portaldir="-x";
%p.settransform(vectoradd(%pos,"0 1 -1.5") SPC eulerToQuat("90 0 270"));
%p.offset="0 -1 1.5";
}
else if(getword(%pos,2)<getword(%colpos,2)+0.1)
{
echo("-z hit");
%p=newportal();
%p.portaldir="-z";
%p.settransform(vectoradd(%pos,"-1 1.5 0") SPC eulerToQuat("180 0 0"));
%p.offset="1 -1.5 0";
}
else if(getword(%pos,2)>getword(%colpos,2)+getword(%col.getscale(),2)*%col.getdatablock().z/5-0.1)
{
echo("z hit");
%p=newportal();
%p.portaldir="z";
%p.settransform(vectoradd(%pos,"-1 -1.5 0") SPC eulerToQuat("0 0 0"));
%p.offset="1 1.5 0";
}
else return;
if(%obj.client.placeredportal)
{
%obj.client.placeredportal=0;
if(isobject(%obj.client.redportal))%obj.client.redportal.delete();
%obj.client.redportal=%p;
%p.setskinname("redhairline");
}
else
{
%obj.client.placeredportal=1;
if(isobject(%obj.client.blueportal))%obj.client.blueportal.delete();
%obj.client.blueportal=%p;
%p.setskinname("bluehairline");
}
%p.gunportal=1;
%p.owner=%obj.client;
}function gunportal(%col,%player)
{
if(!isobject(%col.owner.redportal)||!isobject(%col.owner.blueportal))return;
if(%col.owner.redportal==%col)%end=%col.owner.blueportal;else %end=%col.owner.redportal;
if(%end.portaldir$="x")%dir="1 0 0";
else if(%end.portaldir$="-x")%dir="-1 0 0";
else if(%end.portaldir$="y")%dir="0 1 0";
else if(%end.portaldir$="-y")%dir="0 -1 0";
else if(%end.portaldir$="z")%dir="0 0 1";
else if(%end.portaldir$="-z")%dir="0 0 -1";
%vel=vectorscale(%dir,vectorlen(%player.portalvelocity));
%player.setvelocity(%vel);
%player.settransform(vectoradd(vectoradd(%end.gettransform(),%end.offset),vectorscale(%dir,3)));
}
function newportal()
{
%p=new StaticShape()
{
position = "0 0 0";
rotation = "0 0 0";
datablock = statictile2x2round;
scale = "2 3 0.1";
};
//missioncleanup.add(%p);
return %p;
}
edit: and while I'm at it, the mining part...
code:
$nodfbrick=1;
if($curdfbrick$="")$curdfbrick=0;
function dfpickaxeProjectile: :onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
if(%obj.client.digdelay)return;
if(!%obj.client.issuperadmin && ($nomining || %obj.client.nomining))return;
if($nodfbrick&&%col.getClassName() $= "staticshape"){$curdfbrick+=2;$dfbrick[0,0,0]=$curdfbrick;%col.dfx=0;%col.dfy=0;%col.dfz=0;%col.dfbrick=1;}
if(%col.dfbrick)
{$nodfbrick=0;
//messageall("","hit!");
%x=%col.dfx;
%y=%col.dfy;
%z=%col.dfz;
if(%x$="")%x=0;
if(%y$="")%y=0;
if(%z$="")%z=0;
%p=%col.gettransform();
%d=%col.getdatablock();
//$dfbrick[%x,%y,%x]=2;
for(%x2=-1;%x2<2;%x2++)
{
for(%y2=-1;%y2<2;%y2++)
{
for(%z2=-1;%z2<2;%z2++)
{
if($dfbrick[%x+%x2,%y+%y2,%z+%z2]<$curdfbrick)
{
$dfbrick[%x+%x2,%y+%y2,%z+%z2]=$curdfbrick;
%newBrick = new StaticShape(){datablock = %d;};
MissionCleanup.add(%newBrick);
%newbrick.setscale(%col.getscale());
%newbrick.settransform(getword(%p,0)+%x2*(getword(%col.getscale(),0)/2*%col.getdatablock().x) SPC getword(%p,1)+%y2*(getword(%col.getscale(),1)/2*%col.getdatablock().y) SPC getword(%p,2)+%z2*(getword(%col.getscale(),2)/5*%col.getdatablock().z));
%newBrick.dfbrick=1;
%newbrick.setskinname(%col.getskinname());
%newBrick.dfx=%x+%x2;%newBrick.dfy=%y+%y2;%newBrick.dfz=%z+%z2;
}
}
}
}
%col.delete();
%obj.client.digdelay=1;
schedule(4000,0,"cleardigdelay",%obj.client);
}
}
function cleardigdelay(%c){%c.digdelay=0;}
[ December 07, 2007: Message edited by: qwertyuiopas ]
edit again: to click the "disable smileys" box...
[ December 07, 2007: Message edited by: qwertyuiopas ]