Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ffc script WeaponShooter{
- void run(){
- while(true){
- eweapon e = CreateEWeaponAt(EW_SCRIPT10, this->X, this->Y);
- e->UseSprite(13);
- e->Step = 25;
- e->Angular = true;
- e->Angle = DegtoRad(Angle(this->X, this->Y, Link->X, Link->Y));
- e->DrawYOffset = -1000;
- e->Script = 1;
- e->CollDetection = false;
- Waitframes(120);
- }
- }
- }
- int VectorX3D(int distance, int yaw, int pitch){
- return distance*Sin(pitch)*Cos(yaw);
- }
- int VectorY3D(int distance, int yaw, int pitch){
- return distance*Sin(pitch)*Sin(yaw);
- }
- int VectorZ3D(int distance, int yaw, int pitch){
- return distance*Cos(pitch);
- }
- void RotateX3D(int angle, int cx, int cy, int cz){
- for(int i=0; i<SizeOfArray(cx); i++){
- int y = cy[i];
- int z = cz[i];
- cy[i] = y * Cos(angle) - z * Sin(angle);
- cz[i] = z * Cos(angle) + y * Sin(angle);
- }
- }
- void RotateY3D(int angle, int cx, int cy, int cz){
- for(int i=0; i<SizeOfArray(cx); i++){
- int x = cx[i];
- int z = cz[i];
- cx[i] = x * Cos(angle) - z * Sin(angle);
- cz[i] = z * Cos(angle) + x * Sin(angle);
- }
- }
- void RotateZ3D(int angle, int cx, int cy, int cz){
- for(int i=0; i<SizeOfArray(cx); i++){
- int x = cx[i];
- int y = cy[i];
- cx[i] = x * Cos(angle) - y * Sin(angle);
- cy[i] = y * Cos(angle) + x * Sin(angle);
- }
- }
- float LargeDistance3D(int x1, int y1, int z1, int x2, int y2, int z2){
- int c1x = (x1+x2)/2;
- int c1y = (y1+y2)/2;
- int c2x = (x1+c1x)/2;
- int c2y = (y1+c1y)/2;
- int c3x = (x1+c2x)/2;
- int c3y = (y1+c2y)/2;
- int c1z = (z1+z2)/2;
- int c2z = (z1+c1z)/2;
- int c3z = (z1+c2z)/2;
- int dX = x1-c3x;
- int dY = y1-c3y;
- int dZ = z1-c3z;
- return Sqrt(dX*dX+dY*dY+dZ*dZ)*8;
- }
- float AngleYaw(int X1, int Y1, int Z1, int X2, int Y2, int Z2){
- int dX = X1-X2;
- int dY = Y1-Y2;
- int dZ = Z1-Z2;
- int yaw = RadtoDeg(ArcTan(dX, dZ));
- return yaw;
- }
- float AnglePitch(int X1, int Y1, int Z1, int X2, int Y2, int Z2){
- int dX = X1-X2;
- int dY = Y1-Y2;
- int dZ = Z1-Z2;
- float padj = Sqrt(dX*dX + dZ*dZ);
- int pitch = RadtoDeg(ArcTan(padj, dY));
- return pitch;
- }
- eweapon script TrickyTriangles{
- void run(){
- int a1;
- int a2;
- int a3;
- int r1 = Choose(-1, 1);
- int r2 = Choose(-1, 1);
- int r3 = Choose(-1, 1);
- int scale = 32;
- Trace(this->OriginalTile);
- while(true){
- a1 = WrapDegrees(a1+r1);
- a2 = WrapDegrees(a2+r2);
- a3 = WrapDegrees(a3+r3);
- // a1 = -135;
- // a2 = -60;
- //scale += 0.1;
- DrawTriforce(this->X+8, this->Y+8, scale, a1, a2, a3);
- if(this->X<-64||this->X>240+64||this->Y<-64||this->Y>160+64){
- this->DeadState = 0;
- Quit();
- }
- Waitframe();
- }
- }
- void DrawTriforce(int x, int y, int scale, int r1, int r2, int r3){
- int i; int j; int k;
- int triX[6];
- int triY[6];
- int triZ[6];
- int triC[6];
- for(i=0; i<3; i++){
- triX[i] = VectorX(scale, i*120-90);
- triY[i] = VectorY(scale, i*120-90);
- triZ[i] = -scale*0.25;
- triX[i+3] = VectorX(scale, i*120-90);
- triY[i+3] = VectorY(scale, i*120-90);
- triZ[i+3] = scale*0.25;
- }
- RotateX3D(r1, triX, triY, triZ);
- RotateY3D(r2, triX, triY, triZ);
- RotateZ3D(r3, triX, triY, triZ);
- // for(i=0; i<6; i++){
- // triX[i] += x;
- // triY[i] += y;
- //}
- // for(i=0; i<6; i++){
- // Screen->DrawInteger(6, 0, i*8, FONT_Z1, 0x01, 0x0F, -1, -1, triX[i], 0, 128);
- // Screen->DrawInteger(6, 64, i*8, FONT_Z1, 0x01, 0x0F, -1, -1, triY[i], 0, 128);
- // Screen->DrawInteger(6, 128, i*8, FONT_Z1, 0x01, 0x0F, -1, -1, triZ[i], 0, 128);
- // }
- // for(i=0; i<6; i++){
- // triC[i] = GetTriforceVertexColor(triX[i], triY[i], triZ[i], scale);
- // }
- DrawTriFace(x, y, triX, triY, triZ, triC, 0, 1, 2);
- DrawTriFace(x, y, triX, triY, triZ, triC, 3, 4, 5);
- DrawQuadFace(x, y, triX, triY, triZ, triC, 0, 1, 4, 3);
- DrawQuadFace(x, y, triX, triY, triZ, triC, 1, 2, 5, 4);
- DrawQuadFace(x, y, triX, triY, triZ, triC, 2, 0, 3, 5);
- //Screen->Circle(6, x, y, 4, 0x01, 1, 0, 0, 0, true, 128);
- }
- void DrawTriFace(int x, int y, int xA, int yA, int zA, int cA, int p1, int p2, int p3){
- int cZ = (zA[p1]+zA[p2]+zA[p3])/3;
- if(cZ>0){
- int cent[3];
- cent[0] = (xA[p1]+xA[p2]+xA[p3])/4;
- cent[1] = (yA[p1]+yA[p2]+yA[p3])/4;
- cent[1] = (zA[p1]+zA[p2]+zA[p3])/4;
- int c = 0x87;
- //int pos[9] = {xA[p1],yA[p1],0, xA[p2],yA[p2],0, xA[p3],yA[p3],0};
- int pos[9] = {x+xA[p1],y+yA[p1],zA[p1], x+xA[p2],y+yA[p2],zA[p2], x+xA[p3],y+yA[p3],zA[p3]};
- int uv[6] = {0,15, 15,15, 0,7};
- int csets[3] = {c,c,c};
- //int csets[3] = {cA[p1], cA[p2], cA[p3]};
- int size[2] = {1, 1};
- Screen->Triangle3D(2, pos, uv, csets, size, 0, 0, PT_FLATSHADED);
- }
- }
- void DrawQuadFace(int x, int y, int xA, int yA, int zA, int cA, int p1, int p2, int p3, int p4){
- int cZ = (zA[p1]+zA[p2]+zA[p3]+zA[p4])/4;
- if(cZ>0){
- int cent[3];
- cent[0] = (xA[p1]+xA[p2]+xA[p3]+xA[p4])/4;
- cent[1] = (yA[p1]+yA[p2]+yA[p3]+yA[p4])/4;
- cent[1] = (zA[p1]+zA[p2]+zA[p3]+zA[p4])/4;
- int c = GetTriforceVertexColor(cent[0], cent[1], cent[2]);
- int pos[12] = {x+xA[p1],y+yA[p1],zA[p1], x+xA[p2],y+yA[p2],zA[p2], x+xA[p3],y+yA[p3],zA[p3], x+xA[p4],y+yA[p4],zA[p4]};
- int uv[8] = {0,0, 15,0, 15,15, 0,15};
- int csets[4] = {c,c,c,c};
- //int csets[4] = {cA[p1], cA[p2], cA[p3], cA[p4]};
- int size[2] = {1, 1};
- Screen->Quad3D(2, pos, uv, csets, size, 0, 0, PT_FLATSHADED);
- }
- }
- int GetTriforceVertexColor(int x, int y, int z){
- int tX = -512;
- int tY = -512;
- int tZ = 512;
- int tAng1 = AngleYaw(0, 0, 0, tX, tY, tZ);
- int tAng2 = AnglePitch(0, 0, 0, tX, tY, tZ);
- int ang1 = AngleYaw(0, 0, 0, x, y, z);
- int ang2 = AnglePitch(0, 0, 0, x, y, z);
- int diff1 = Abs(TriforceAngleDiff(ang1, tAng1))/(90/7);
- int diff2 = Abs(TriforceAngleDiff(ang2, tAng2))/(90/7);
- int light = Clamp(Round(Sqrt(diff1*diff1 + diff2*diff2)), 0, 13);
- int c = 0x8E - light;
- return c;
- }
- int TriforceAngleDiff(int a1, int a2){
- // Get the difference between the two angles
- float dif = WrapDegrees(a2) - WrapDegrees(a1);
- // Compensate for the difference being outside of normal bounds
- if(dif >= 180)
- dif -= 360;
- else if(dif <= -180)
- dif += 360;
- return dif;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement