SC CODE: // Copyright 2024. Civilware. All rights reserved.
// TELA Decentralized Web Document (TELA-DOC-1)
Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "data2.js")
31 STORE("descrHdr", "Data file 2")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "data2.js")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "19a010d170b00f894460f61a87814d7d6592f126af0668812414ec5e4773ec03")
37 STORE("fileCheckS", "10fe2583a0b185516d3028a79916b1a2bd352eaa3f96badbabd01a14a4f77a78")
100 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("docVersion", "1.0.0")
60 STORE("hash", HEX(TXID()))
70 STORE("likes", 0)
80 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
/*function createVehicle(e="tank",r=!1){const t=cloneVehicleBlueprint();if(t.transform.parent=t,t.turret.transform.parent=t.turret,t.barrel.transform.parent=t.barrel,"tank"===e?t.profile=VehicleTypes.tank:"car"===e?t.profile=VehicleTypes.car:"drift"===e&&(t.profile=VehicleTypes.drift),t.width=t.profile.width,t.length=t.profile.length,t.height=t.profile.height,t.halfHeight=t.profile.halfHeight,t.wheelBase=t.profile.wheelBase,t.lift=t.profile.lift,t.turretOffsetY=t.profile.turretOffsetY,t.collider=t.profile.collider,t.skipShading=!0,"drift"!==e){const e=createTankHullMesh(t.width,t.height,t.length,r);t.mesh=new Mesh(gl,e.vertices,e.normals,e.colors)}else{const e=createTankHullMesh(t.width,t.height,t.length,r);for(let r=0;r<e.uvs.length;r++)e.uvs[r]=-1;const a=.75,s=0,n=1,o=.25;e.uvs[0]=a,e.uvs[1]=s,e.uvs[2]=n,e.uvs[3]=s,e.uvs[4]=n,e.uvs[5]=o,e.uvs[6]=a,e.uvs[7]=s,e.uvs[8]=n,e.uvs[9]=o,e.uvs[10]=a,e.uvs[11]=o,t.mesh=new Mesh(gl,e.vertices,e.normals,e.colors,e.uvs),t.mesh.material.texture=windshield}const a=createCylinderMesh(.5,.8,16);t.turret.mesh=new Mesh(gl,a.vertices,a.normals,a.colors);const s=createCylinderMesh(.12,3,16,!0);t.barrel.mesh=new Mesh(gl,s.vertices,s.normals,s.colors);const n=createCylinderMesh(.5,2,16,!1,.5,.5,.5),o=new Mesh(gl,n.vertices,n.normals,n.colors),h=new SceneObject(o);if(h.transform.y=t.halfHeight+t.turretOffsetY-.1,h.transform.sx=.6,h.transform.sy=.8,h.transform.sz=.6,t.children.push(h),"tank"===e)t.profile=VehicleTypes.tank,addTreadSegment(t,createTreadMesh(.3,.1,2.25),"left","top",1.1,.41,0,0,0,0),addTreadSegment(t,createTreadMesh(.3,.1,.66),"left","front",1.1,-.25,2.25,-Math.PI/2,0,0),addTreadSegment(t,createTreadMesh(.3,.1,2.25),"left","bottom",1.1,-.91,0,Math.PI,0,0),addTreadSegment(t,createTreadMesh(.3,.1,.66),"left","back",1.1,-.25,-2.25,Math.PI/2,0,0),addTreadSegment(t,createTreadMesh(.3,.1,2.25),"right","top",-1.1,.41,0,0,0,0),addTreadSegment(t,createTreadMesh(.3,.1,.66),"right","front",-1.1,-.25,2.25,-Math.PI/2,0,0),addTreadSegment(t,createTreadMesh(.3,.1,2.25),"right","bottom",-1.1,-.91,0,Math.PI,0,0),addTreadSegment(t,createTreadMesh(.3,.1,.66),"right","back",-1.1,-.25,-2.25,Math.PI/2,0,0);else if("car"===e){t.profile=VehicleTypes.car;const e=createCylinderMesh(.5,2,16,!1,.1,.1,.1),r=new Mesh(gl,e.vertices,e.normals,e.colors),a=[[-1.2,-.7,1.2],[1.2,-.7,1.2],[-1.2,-.7,-1.2],[1.2,-.7,-1.2]];for(const[e,s,n]of a){const a=createWheel(1,.5,r);a.transform.x=e,a.transform.y=s,a.transform.z=n,a.isWheel=!0,a.skipShading=!0,t.children.push(a)}}else if("drift"===e){t.profile=VehicleTypes.drift;const e=createCylinderMesh(.5,2,16,!1,.1,.1,.1),r=new Mesh(gl,e.vertices,e.normals,e.colors),a=[[-1.1,-1.2,1.3],[1.1,-1.2,1.3]];for(const[e,s,n]of a){const a=createWheel(.85,.4,r);a.transform.x=e,a.transform.y=s,a.transform.z=n,a.isWheel=!0,a.skipShading=!0,t.children.push(a)}addTreadSegment(t,createTreadMesh(.2,.1,1.2),"left","top",1.1,-.65,-.95,0,0,0),addTreadSegment(t,createTreadMesh(.2,.1,.45),"left","front",1.1,-1.1,.22,-Math.PI/2,0,0),addTreadSegment(t,createTreadMesh(.2,.1,1.2),"left","bottom",1.1,-1.55,-.95,Math.PI,0,0),addTreadSegment(t,createTreadMesh(.2,.1,.45),"left","back",1.1,-1.1,-2.15,Math.PI/2,0,0),addTreadSegment(t,createTreadMesh(.2,.1,1.2),"right","top",-1.1,-.65,-.95,0,0,0),addTreadSegment(t,createTreadMesh(.2,.1,.45),"right","front",-1.1,-1.1,.22,-Math.PI/2,0,0),addTreadSegment(t,createTreadMesh(.2,.1,1.2),"right","bottom",-1.1,-1.55,-.95,Math.PI,0,0),addTreadSegment(t,createTreadMesh(.2,.1,.45),"right","back",-1.1,-1.1,-2.15,Math.PI/2,0,0)}return t}function respawnPlayer(e=0,r=0,t=0){game.player=createVehicle("tank"),game.player.owner="player",game.player.topSpeed=15,game.player.primaryFireCooldown=0,game.player.secondaryFireCooldown=0,game.player.mineCooldown=0,game.player.primaryFireRate=.5,game.player.secondaryFireRate=.05,game.player.mineFireRate=1,game.player.x=e,game.player.yaw=t,game.player.z=r,game.player.radius=4.565,scene.push(game.player),scene.push(game.player.turret),scene.push(game.player.barrel)}function spawnEnemy(e="chaser",r=0,t=0,a=100){const s=createVehicle(enemyTypes[e].model,!0);s.owner="enemy",s.type=e,s.topSpeed=enemyTypes[e].speed,s.health=enemyTypes[e].hp,s.maxHealth=enemyTypes[e].hp,s.primaryFireCooldown=0,s.secondaryFireCooldown=0,s.primaryFireRate=enemyTypes[e].primaryFireRate,s.secondaryFireRate=enemyTypes[e].secondaryFireRate,s.mass=enemyTypes[e].weight,s.tempGoal=null,s.lastX=s.x,s.lastZ=s.z,s.stuckTimer=0,s.activated=!1;const n=r+Math.random()*a,o=t+Math.random()*a,h=hmap.sample(n,o);s.x=n,s.y=h,s.z=o,s.radius=Math.sqrt(enemyTypes[e].length*enemyTypes[e].length+enemyTypes[e].width*enemyTypes[e].width),game.enemies.push(s),scene.push(s),scene.push(s.turret),scene.push(s.barrel)}const enemyTypes={tank:{speed:9,hp:60,primaryFireRate:.5,secondaryFireRate:.05,weight:4,model:"tank"},chaser:{speed:12,hp:30,primaryFireRate:1,secondaryFireRate:.05,weight:1,model:"car"},strafer:{speed:10,hp:50,primaryFireRate:1.2,secondaryFireRate:.05,weight:3,model:"drift"}};function createBase(e,r,t,a,s){const n=[];for(const o of s){const s=createBox(r+o.x,t+o.y,a+o.z,o.hw,o.hh,o.hd,o.mesh,o.rotateY);s.baseId=e,s.skipShading=!0,n.push(s)}return{id:e,x:r,y:t,z:a,hp:100,boxes:n,state:"alive"}}function createBaseBox(e,r,t,a,s,n,o,h,i){const l=createBox(r,t,a,s,n,o,h,i);return l.baseId=e,l}function spawnExplosion(e,r,t){let a=e.transform.x,s=e.transform.y,n=e.transform.z;for(const o of worldObjects){if(!o.destructible&&!o.baseId)continue;if(o==e)continue;if(void 0===o.transform.x||void 0===o.transform.y||void 0===o.transform.z)continue;const h=o.transform.x-a,i=o.transform.y-s,l=o.transform.z-n,d=Math.sqrt(h*h+i*i+l*l);if(d<r){const e=t*(1-d/r);if("barrel"===o.type&&(o.hp-=e,o.hp<=0&&destroyBarrel(o)),"mine"===o.type&&(o.hp-=e,o.hp<=0&&destroyMine(o)),o.baseId){const r=game.bases[o.baseId];r.hp-=e,r.hp<=0&&destroyBase(r)}}}const o=[...game.enemies,game.player];for(const e of o){const o=e.x-a,h=e.y-s,i=e.z-n,l=Math.sqrt(o*o+h*h+i*i);if(l<r){const a=t*(1-l/r);e.health-=a,e.health<=0&&killTank(e)}}}function spawnBarrel(e,r,t){const a=createCylinderMesh(1.5,4,16,!1,.5,.2,.1,!0),s=new Mesh(gl,a.vertices,a.normals,a.colors);let n=createCylinder(e,r,t,1.5,4,s);return n.type="barrel",n.destructible=!0,n.hp=40,n.maxHp=40,n.skipShading=!0,n}function cloneVehicleBlueprint(){return{x:0,y:0,z:0,yaw:0,pitch:0,roll:0,forward:[0,0,1],right:[1,0,0],width:2.2,length:4,height:1.8,halfHeight:.9,wheelBase:2.2,lift:.3,mass:4,vy:0,grounded:!0,speed:0,turnSpeed:0,steerAngle:0,lateralVel:0,forwardVel:0,slipAngle:0,groundY:0,groundNormal:[0,1,0],collider:{halfWidth:1.1,halfLength:2,halfHeight:.9},obb:{},health:100,maxHealth:100,mesh:null,color:null,modelMatrix:null,transform:{parent:null,getMatrix(){return this.parent.modelMatrix}},profile:null,treadOffset:0,leftOffset:0,rightOffset:0,leftTreads:[],rightTreads:[],turretOffsetY:-.2,turret:{yaw:0,pitch:0,mesh:null,modelMatrix:null,transform:{parent:null,getMatrix(){return this.parent.modelMatrix}}},barrel:{mesh:null,modelMatrix:null,transform:{parent:null,getMatrix(){return this.parent.modelMatrix}}},children:[]}}const VehicleTypes={tank:{steeringModel:"tank",accelRate:.05,brakeRate:.1,friction:.01,turnAccel:.002,turnFriction:.05,maxTurnSpeed:.03,topSpeed:20,width:2.2,length:4,height:1.8,halfHeight:.9,wheelBase:2.2,lift:.3,turretOffsetY:-.2,collider:{halfWidth:1.1,halfLength:2,halfHeight:.9}},car:{steeringModel:"car",accelRate:.06,brakeRate:.15,friction:.02,steerSpeed:.04,maxSteerAngle:.5,topSpeed:18,width:1.8,length:3,height:1.6,halfHeight:.9,wheelBase:1.8,lift:.35,turretOffsetY:-.2,collider:{halfWidth:.9,halfLength:1.5,halfHeight:.8}},drift:{steeringModel:"drift",accelRate:.05,brakeRate:.1,friction:.003,steerSpeed:.06,maxSteerAngle:.6,topSpeed:15,width:2,length:4,height:2.8,halfHeight:1.4,wheelBase:2,lift:.35,turretOffsetY:-.45,collider:{halfWidth:1,halfLength:2,halfHeight:1.4}}};function updateTankSteering(e,t,r){const a=e.profile,l=.02*(e.speed/e.topSpeed);if("enemy"===a.owner||Math.abs(input.analogTurn)<.2)e.turnSpeed+=t*a.turnAccel;else{const t=(a.maxTurnSpeed+l)*input.analogTurn;e.turnSpeed+=.15*(t-e.turnSpeed)}0===input.turn&&(e.turnSpeed*=1-a.turnFriction),e.turnSpeed=Math.max(-a.maxTurnSpeed-l,Math.min(e.turnSpeed,a.maxTurnSpeed+l)),e.yaw+=e.turnSpeed}function updateCarSteering(e,t,r){const a=e.profile;e.steerAngle+=t*a.steerSpeed,e.steerAngle=Math.max(-a.maxSteerAngle,Math.min(e.steerAngle,a.maxSteerAngle)),0===t&&(e.steerAngle*=.85);const l=a.wheelbase||2.5,n=e.speed/l*Math.tan(e.steerAngle);e.yaw+=n*r,e.forward[0]=-Math.sin(e.yaw),e.forward[2]=Math.cos(e.yaw)}function updateDriftSteering(e,t,r){const a=e.profile;e.steerAngle+=t*a.steerSpeed,e.steerAngle=Math.max(-a.maxSteerAngle,Math.min(e.steerAngle,a.maxSteerAngle)),0===t&&(e.steerAngle*=.9),e.forwardVel=e.speed,e.lateralVel*=.95,e.lateralVel+=e.steerAngle*e.forwardVel*.02,e.slipAngle=Math.atan2(e.lateralVel,Math.abs(e.forwardVel)+1e-4);const l=a.wheelbase||2.5,n=e.forwardVel/l*Math.tan(e.steerAngle-e.slipAngle);e.yaw+=n*r,e.forward[0]=-Math.sin(e.yaw),e.forward[2]=Math.cos(e.yaw)}function updateMovement(e,t,r,a){const l=e.profile;t&&(e.speed<0?e.speed+=l.brakeRate:e.speed+=l.accelRate),r&&(e.speed>0?e.speed-=l.brakeRate:e.speed-=l.accelRate),e.speed>0&&(e.speed-=l.friction),e.speed<0&&(e.speed+=l.friction),e.speed=Math.max(-l.topSpeed,Math.min(e.speed,e.topSpeed));let n=e.forward[0]*e.speed*a,s=e.forward[2]*e.speed*a;e.groundY=hmap.sample(e.x+n,e.z+s);let i=e.groundY-e.y;if(e.speed<1)return e.x+=n,e.y+=i,void(e.z+=s);let o=n,f=i,h=s,d=Math.sqrt(o*o+f*f+h*h),p=Math.abs(e.speed*a)/d;o*=p,f*=p,h*=p,e.x+=o,e.y+=f,e.z+=h}function updateVehicle(e){const t=Math.sin(e.yaw),r=Math.cos(e.yaw),a=[-t,0,r],l=[r,0,t];e.forward=a;const n=.5*e.width,s=.5*e.length,i=e.x+a[0]*s+l[0]*n,o=e.z+a[2]*s+l[2]*n,f=e.x+a[0]*s-l[0]*n,h=e.z+a[2]*s-l[2]*n,d=e.x-a[0]*s+l[0]*n,p=e.z-a[2]*s+l[2]*n,u=e.x-a[0]*s-l[0]*n,c=e.z-a[2]*s-l[2]*n,g=hmap.sample(i,o),m=hmap.sample(f,h),M=hmap.sample(d,p),w=hmap.sample(u,c),x=.5*(g+m-(M+w)),y=.5*(m+w-(g+M)),S=.25*(g+m+M+w);e.groundY=S,e.pitch=Math.atan2(x,s),e.roll=Math.atan2(y,n);const A=rotationZ(e.roll),O=rotationX(e.pitch),T=rotationY(e.yaw),b=e.groundY+e.halfHeight+e.lift,z=multiply(multiply(T,A),O);if(e.modelMatrix=multiply(translate(e.x,b,e.z),z),e.speed-=.002*x,e.speed+=.001*-x,e.turret){const t=0,r=e.halfHeight+e.turretOffsetY,a=0,l=(e.turret.transform,rotationX(e.pitch)),n=rotationZ(e.roll),s=rotationY(e.yaw),i=multiply(multiply(s,n),l),o=rotationY(e.turret.yaw),f=multiply(i,o),h=translate(t,r,a);e.turret.modelMatrix=multiply(multiply(translate(e.x,b,e.z),f),h);const d=rotationX(0),p=rotationX(e.turret.pitch),u=translate(0,0,.8);e.barrel.modelMatrix=multiply(multiply(multiply(e.turret.modelMatrix,d),p),u)}if("car"===e.profile.steeringModel||"drift"===e.profile.steeringModel){let t=1;for(const r of e.children)r.isWheel&&(r.transform.rz+=.01*e.speed,t++<=2&&(r.transform.ry=e.steerAngle+.5*Math.PI))}if("tank"===e.profile.steeringModel||"drift"===e.profile.steeringModel){e.leftOffset+=.003*e.speed,e.rightOffset+=.003*e.speed,e.leftOffset+=.2*e.turnSpeed,e.rightOffset-=.2*e.turnSpeed;for(const t of e.leftTreads)t.treadOffset=e.leftOffset;for(const t of e.rightTreads)t.treadOffset=e.rightOffset;e.leftOffset=e.leftOffset%1e3,e.rightOffset=e.rightOffset%1e3}}function createWheel(e,t,r){const a=new SceneObject(r);return a.transform.rx=.5*-Math.PI,a.transform.ry=.5*Math.PI,a.transform.sx=e,a.transform.sy=t,a.transform.sz=e,a}function createTreadMesh(e,t,r){return{vertices:new Float32Array([-e,0,r,e,0,r,-e,0,-r,e,0,-r]),normals:new Float32Array([0,1,0,0,1,0,0,1,0,0,1,0]),colors:new Float32Array([.2,.2,.2,.2,.2,.2,.2,.2,.2,.2,.2,.2]),uvs:new Float32Array([0,0,1,0,0,1,1,1])}}function addTreadSegment(e,t,r,a,l,n,s,i,o,f){const h=new SceneObject(new Mesh(gl,t.vertices,t.normals,t.colors,t.uvs,gl.TRIANGLE_STRIP));h.transform.x=l,h.transform.y=n,h.transform.z=s,h.transform.rx=i,h.transform.ry=o,h.transform.rz=f,h.isTread=!0,"front"!==a&&"back"!==a||(h.isShortTread=!0),h.treadOffset=0,e.children.push(h),"left"===r?e.leftTreads.push(h):e.rightTreads.push(h)}function updateProjectileMovement(e,r){return e.x+=e.dx*e.speed*r,e.y+=e.dy*e.speed*r,e.z+=e.dz*e.speed*r,e.mesh.transform.x=e.x,e.mesh.transform.y=e.y,e.mesh.transform.z=e.z,e.distanceTraveled+=e.speed*r,!(e.distanceTraveled>e.maxRange)||(e.alive=!1,!1)}function updateProjectiles(e){for(let r=projectiles.length-1;r>=0;r--){const t=projectiles[r];let n=!1;if(updateProjectileMovement(t,e)||(n=!0),n||checkProjectileCollision(t),n||!t.alive){const e=scene.indexOf(t.mesh);-1!==e&&scene.splice(e,1),projectiles.splice(r,1)}}}function shootMachineGun(e){if(!e.transform.getMatrix())return;const r=e.transform.getMatrix(),t=r[12],n=r[13],a=r[14],s={x:t,y:n,z:a,dx:r[8],dy:r[9],dz:r[10],speed:100,radius:.15,length:1,alive:!0,mesh:null,damage:1,type:"mg",owner:e.owner,maxRange:800,distanceTraveled:0},o=createCylinderMesh(s.radius,s.length,12,!1,1,.8,.3),l=new Mesh(gl,o.vertices,o.normals,o.colors),i=createCylinder(t,n,a,s.radius,s.length,l),d=-Math.atan2(s.dx,s.dz),c=Math.atan2(s.dy,Math.sqrt(s.dx*s.dx+s.dz*s.dz)),h=Math.PI/2;i.transform.rx=h+c,i.transform.ry=d,i.transform.rz=0,s.mesh=i,scene.push(i),projectiles.push(s),sfxMachineGun(e)}function shootTurret(e){if(!e.barrel.transform.getMatrix())return;const r=e.barrel.transform.getMatrix(),t=r[8],n=r[9],a=r[10],s=r[12]+.4*t,o=r[13]+.4*n,l=r[14]+.4*a,i={x:s,y:o,z:l,dx:t,dy:n,dz:a,speed:100,radius:.3,length:1.5,alive:!0,mesh:null,damage:15,type:"turret",owner:e.owner,maxRange:1e3,distanceTraveled:0},d=createCylinderMesh(i.radius,i.length,12),c=new Mesh(gl,d.vertices,d.normals,d.colors),h=createCylinder(s,o,l,i.radius,i.length,c),m=-Math.atan2(t,a),p=Math.atan2(n,Math.sqrt(t*t+a*a)),f=Math.PI/2;h.transform.rx=f+p,h.transform.ry=m,h.transform.rz=0,i.mesh=h,scene.push(h),projectiles.push(i),sfxCannon(e)}function dropMine(e){const r=e.forward,n=e.x+-2.8*r[0],a=e.z+-2.8*r[2],s=hmap.sample(n,a),o=hmap.normal(n,a),l=-Math.atan2(o[2],o[1]),i=(Math.atan2(o[0],o[1]),createCylinderMesh(.55,.4,12,!1,.4,.4,.4)),d=new Mesh(gl,i.vertices,i.normals,i.colors),c=createCylinder(n,s,a,.55,.4,d);c.transform.rx=l,c.transform.ry=0,c.owner=e.owner,c.alive=!0,c.damage=25,c.type="mine",c.destructible=!0,c.hp=10,c.maxHp=10,c.deployed=t;const h=createCylinderMesh(.1,.5,8,!1,.7,.1,.1),m=new Mesh(gl,h.vertices,h.normals,h.colors),p=new SceneObject(m);p.transform.x=0,p.transform.y=0,p.transform.z=0,c.children.push(p),updateObjectOBB(c),scene.push(c),worldObjects.push(c),sfxMine()}function explode(e){e.alive=!1}*/ |
| SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'// Copyright 2024. Civilware. All rights reserved.
// TELA Decentralized Web Document (TELA-DOC-1)
Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "data2.js")
31 STORE("descrHdr", "Data file 2")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "data2.js")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "19a010d170b00f894460f61a87814d7d6592f126af0668812414ec5e4773ec03")
37 STORE("fileCheckS", "10fe2583a0b185516d3028a79916b1a2bd352eaa3f96badbabd01a14a4f77a78")
100 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("docVersion", "1.0.0")
60 STORE("hash", HEX(TXID()))
70 STORE("likes", 0)
80 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
/*function createVehicle(e="tank",r=!1){const t=cloneVehicleBlueprint();if(t.transform.parent=t,t.turret.transform.parent=t.turret,t.barrel.transform.parent=t.barrel,"tank"===e?t.profile=VehicleTypes.tank:"car"===e?t.profile=VehicleTypes.car:"drift"===e&&(t.profile=VehicleTypes.drift),t.width=t.profile.width,t.length=t.profile.length,t.height=t.profile.height,t.halfHeight=t.profile.halfHeight,t.wheelBase=t.profile.wheelBase,t.lift=t.profile.lift,t.turretOffsetY=t.profile.turretOffsetY,t.collider=t.profile.collider,t.skipShading=!0,"drift"!==e){const e=createTankHullMesh(t.width,t.height,t.length,r);t.mesh=new Mesh(gl,e.vertices,e.normals,e.colors)}else{const e=createTankHullMesh(t.width,t.height,t.length,r);for(let r=0;r<e.uvs.length;r++)e.uvs[r]=-1;const a=.75,s=0,n=1,o=.25;e.uvs[0]=a,e.uvs[1]=s,e.uvs[2]=n,e.uvs[3]=s,e.uvs[4]=n,e.uvs[5]=o,e.uvs[6]=a,e.uvs[7]=s,e.uvs[8]=n,e.uvs[9]=o,e.uvs[10]=a,e.uvs[11]=o,t.mesh=new Mesh(gl,e.vertices,e.normals,e.colors,e.uvs),t.mesh.material.texture=windshield}const a=createCylinderMesh(.5,.8,16);t.turret.mesh=new Mesh(gl,a.vertices,a.normals,a.colors);const s=createCylinderMesh(.12,3,16,!0);t.barrel.mesh=new Mesh(gl,s.vertices,s.normals,s.colors);const n=createCylinderMesh(.5,2,16,!1,.5,.5,.5),o=new Mesh(gl,n.vertices,n.normals,n.colors),h=new SceneObject(o);if(h.transform.y=t.halfHeight+t.turretOffsetY-.1,h.transform.sx=.6,h.transform.sy=.8,h.transform.sz=.6,t.children.push(h),"tank"===e)t.profile=VehicleTypes.tank,addTreadSegment(t,createTreadMesh(.3,.1,2.25),"left","top",1.1,.41,0,0,0,0),addTreadSegment(t,createTreadMesh(.3,.1,.66),"left","front",1.1,-.25,2.25,-Math.PI/2,0,0),addTreadSegment(t,createTreadMesh(.3,.1,2.25),"left","bottom",1.1,-.91,0,Math.PI,0,0),addTreadSegment(t,createTreadMesh(.3,.1,.66),"left","back",1.1,-.25,-2.25,Math.PI/2,0,0),addTreadSegment(t,createTreadMesh(.3,.1,2.25),"right","top",-1.1,.41,0,0,0,0),addTreadSegment(t,createTreadMesh(.3,.1,.66),"right","front",-1.1,-.25,2.25,-Math.PI/2,0,0),addTreadSegment(t,createTreadMesh(.3,.1,2.25),"right","bottom",-1.1,-.91,0,Math.PI,0,0),addTreadSegment(t,createTreadMesh(.3,.1,.66),"right","back",-1.1,-.25,-2.25,Math.PI/2,0,0);else if("car"===e){t.profile=VehicleTypes.car;const e=createCylinderMesh(.5,2,16,!1,.1,.1,.1),r=new Mesh(gl,e.vertices,e.normals,e.colors),a=[[-1.2,-.7,1.2],[1.2,-.7,1.2],[-1.2,-.7,-1.2],[1.2,-.7,-1.2]];for(const[e,s,n]of a){const a=createWheel(1,.5,r);a.transform.x=e,a.transform.y=s,a.transform.z=n,a.isWheel=!0,a.skipShading=!0,t.children.push(a)}}else if("drift"===e){t.profile=VehicleTypes.drift;const e=createCylinderMesh(.5,2,16,!1,.1,.1,.1),r=new Mesh(gl,e.vertices,e.normals,e.colors),a=[[-1.1,-1.2,1.3],[1.1,-1.2,1.3]];for(const[e,s,n]of a){const a=createWheel(.85,.4,r);a.transform.x=e,a.transform.y=s,a.transform.z=n,a.isWheel=!0,a.skipShading=!0,t.children.push(a)}addTreadSegment(t,createTreadMesh(.2,.1,1.2),"left","top",1.1,-.65,-.95,0,0,0),addTreadSegment(t,createTreadMesh(.2,.1,.45),"left","front",1.1,-1.1,.22,-Math.PI/2,0,0),addTreadSegment(t,createTreadMesh(.2,.1,1.2),"left","bottom",1.1,-1.55,-.95,Math.PI,0,0),addTreadSegment(t,createTreadMesh(.2,.1,.45),"left","back",1.1,-1.1,-2.15,Math.PI/2,0,0),addTreadSegment(t,createTreadMesh(.2,.1,1.2),"right","top",-1.1,-.65,-.95,0,0,0),addTreadSegment(t,createTreadMesh(.2,.1,.45),"right","front",-1.1,-1.1,.22,-Math.PI/2,0,0),addTreadSegment(t,createTreadMesh(.2,.1,1.2),"right","bottom",-1.1,-1.55,-.95,Math.PI,0,0),addTreadSegment(t,createTreadMesh(.2,.1,.45),"right","back",-1.1,-1.1,-2.15,Math.PI/2,0,0)}return t}function respawnPlayer(e=0,r=0,t=0){game.player=createVehicle("tank"),game.player.owner="player",game.player.topSpeed=15,game.player.primaryFireCooldown=0,game.player.secondaryFireCooldown=0,game.player.mineCooldown=0,game.player.primaryFireRate=.5,game.player.secondaryFireRate=.05,game.player.mineFireRate=1,game.player.x=e,game.player.yaw=t,game.player.z=r,game.player.radius=4.565,scene.push(game.player),scene.push(game.player.turret),scene.push(game.player.barrel)}function spawnEnemy(e="chaser",r=0,t=0,a=100){const s=createVehicle(enemyTypes[e].model,!0);s.owner="enemy",s.type=e,s.topSpeed=enemyTypes[e].speed,s.health=enemyTypes[e].hp,s.maxHealth=enemyTypes[e].hp,s.primaryFireCooldown=0,s.secondaryFireCooldown=0,s.primaryFireRate=enemyTypes[e].primaryFireRate,s.secondaryFireRate=enemyTypes[e].secondaryFireRate,s.mass=enemyTypes[e].weight,s.tempGoal=null,s.lastX=s.x,s.lastZ=s.z,s.stuckTimer=0,s.activated=!1;const n=r+Math.random()*a,o=t+Math.random()*a,h=hmap.sample(n,o);s.x=n,s.y=h,s.z=o,s.radius=Math.sqrt(enemyTypes[e].length*enemyTypes[e].length+enemyTypes[e].width*enemyTypes[e].width),game.enemies.push(s),scene.push(s),scene.push(s.turret),scene.push(s.barrel)}const enemyTypes={tank:{speed:9,hp:60,primaryFireRate:.5,secondaryFireRate:.05,weight:4,model:"tank"},chaser:{speed:12,hp:30,primaryFireRate:1,secondaryFireRate:.05,weight:1,model:"car"},strafer:{speed:10,hp:50,primaryFireRate:1.2,secondaryFireRate:.05,weight:3,model:"drift"}};function createBase(e,r,t,a,s){const n=[];for(const o of s){const s=createBox(r+o.x,t+o.y,a+o.z,o.hw,o.hh,o.hd,o.mesh,o.rotateY);s.baseId=e,s.skipShading=!0,n.push(s)}return{id:e,x:r,y:t,z:a,hp:100,boxes:n,state:"alive"}}function createBaseBox(e,r,t,a,s,n,o,h,i){const l=createBox(r,t,a,s,n,o,h,i);return l.baseId=e,l}function spawnExplosion(e,r,t){let a=e.transform.x,s=e.transform.y,n=e.transform.z;for(const o of worldObjects){if(!o.destructible&&!o.baseId)continue;if(o==e)continue;if(void 0===o.transform.x||void 0===o.transform.y||void 0===o.transform.z)continue;const h=o.transform.x-a,i=o.transform.y-s,l=o.transform.z-n,d=Math.sqrt(h*h+i*i+l*l);if(d<r){const e=t*(1-d/r);if("barrel"===o.type&&(o.hp-=e,o.hp<=0&&destroyBarrel(o)),"mine"===o.type&&(o.hp-=e,o.hp<=0&&destroyMine(o)),o.baseId){const r=game.bases[o.baseId];r.hp-=e,r.hp<=0&&destroyBase(r)}}}const o=[...game.enemies,game.player];for(const e of o){const o=e.x-a,h=e.y-s,i=e.z-n,l=Math.sqrt(o*o+h*h+i*i);if(l<r){const a=t*(1-l/r);e.health-=a,e.health<=0&&killTank(e)}}}function spawnBarrel(e,r,t){const a=createCylinderMesh(1.5,4,16,!1,.5,.2,.1,!0),s=new Mesh(gl,a.vertices,a.normals,a.colors);let n=createCylinder(e,r,t,1.5,4,s);return n.type="barrel",n.destructible=!0,n.hp=40,n.maxHp=40,n.skipShading=!0,n}function cloneVehicleBlueprint(){return{x:0,y:0,z:0,yaw:0,pitch:0,roll:0,forward:[0,0,1],right:[1,0,0],width:2.2,length:4,height:1.8,halfHeight:.9,wheelBase:2.2,lift:.3,mass:4,vy:0,grounded:!0,speed:0,turnSpeed:0,steerAngle:0,lateralVel:0,forwardVel:0,slipAngle:0,groundY:0,groundNormal:[0,1,0],collider:{halfWidth:1.1,halfLength:2,halfHeight:.9},obb:{},health:100,maxHealth:100,mesh:null,color:null,modelMatrix:null,transform:{parent:null,getMatrix(){return this.parent.modelMatrix}},profile:null,treadOffset:0,leftOffset:0,rightOffset:0,leftTreads:[],rightTreads:[],turretOffsetY:-.2,turret:{yaw:0,pitch:0,mesh:null,modelMatrix:null,transform:{parent:null,getMatrix(){return this.parent.modelMatrix}}},barrel:{mesh:null,modelMatrix:null,transform:{parent:null,getMatrix(){return this.parent.modelMatrix}}},children:[]}}const VehicleTypes={tank:{steeringModel:"tank",accelRate:.05,brakeRate:.1,friction:.01,turnAccel:.002,turnFriction:.05,maxTurnSpeed:.03,topSpeed:20,width:2.2,length:4,height:1.8,halfHeight:.9,wheelBase:2.2,lift:.3,turretOffsetY:-.2,collider:{halfWidth:1.1,halfLength:2,halfHeight:.9}},car:{steeringModel:"car",accelRate:.06,brakeRate:.15,friction:.02,steerSpeed:.04,maxSteerAngle:.5,topSpeed:18,width:1.8,length:3,height:1.6,halfHeight:.9,wheelBase:1.8,lift:.35,turretOffsetY:-.2,collider:{halfWidth:.9,halfLength:1.5,halfHeight:.8}},drift:{steeringModel:"drift",accelRate:.05,brakeRate:.1,friction:.003,steerSpeed:.06,maxSteerAngle:.6,topSpeed:15,width:2,length:4,height:2.8,halfHeight:1.4,wheelBase:2,lift:.35,turretOffsetY:-.45,collider:{halfWidth:1,halfLength:2,halfHeight:1.4}}};function updateTankSteering(e,t,r){const a=e.profile,l=.02*(e.speed/e.topSpeed);if("enemy"===a.owner||Math.abs(input.analogTurn)<.2)e.turnSpeed+=t*a.turnAccel;else{const t=(a.maxTurnSpeed+l)*input.analogTurn;e.turnSpeed+=.15*(t-e.turnSpeed)}0===input.turn&&(e.turnSpeed*=1-a.turnFriction),e.turnSpeed=Math.max(-a.maxTurnSpeed-l,Math.min(e.turnSpeed,a.maxTurnSpeed+l)),e.yaw+=e.turnSpeed}function updateCarSteering(e,t,r){const a=e.profile;e.steerAngle+=t*a.steerSpeed,e.steerAngle=Math.max(-a.maxSteerAngle,Math.min(e.steerAngle,a.maxSteerAngle)),0===t&&(e.steerAngle*=.85);const l=a.wheelbase||2.5,n=e.speed/l*Math.tan(e.steerAngle);e.yaw+=n*r,e.forward[0]=-Math.sin(e.yaw),e.forward[2]=Math.cos(e.yaw)}function updateDriftSteering(e,t,r){const a=e.profile;e.steerAngle+=t*a.steerSpeed,e.steerAngle=Math.max(-a.maxSteerAngle,Math.min(e.steerAngle,a.maxSteerAngle)),0===t&&(e.steerAngle*=.9),e.forwardVel=e.speed,e.lateralVel*=.95,e.lateralVel+=e.steerAngle*e.forwardVel*.02,e.slipAngle=Math.atan2(e.lateralVel,Math.abs(e.forwardVel)+1e-4);const l=a.wheelbase||2.5,n=e.forwardVel/l*Math.tan(e.steerAngle-e.slipAngle);e.yaw+=n*r,e.forward[0]=-Math.sin(e.yaw),e.forward[2]=Math.cos(e.yaw)}function updateMovement(e,t,r,a){const l=e.profile;t&&(e.speed<0?e.speed+=l.brakeRate:e.speed+=l.accelRate),r&&(e.speed>0?e.speed-=l.brakeRate:e.speed-=l.accelRate),e.speed>0&&(e.speed-=l.friction),e.speed<0&&(e.speed+=l.friction),e.speed=Math.max(-l.topSpeed,Math.min(e.speed,e.topSpeed));let n=e.forward[0]*e.speed*a,s=e.forward[2]*e.speed*a;e.groundY=hmap.sample(e.x+n,e.z+s);let i=e.groundY-e.y;if(e.speed<1)return e.x+=n,e.y+=i,void(e.z+=s);let o=n,f=i,h=s,d=Math.sqrt(o*o+f*f+h*h),p=Math.abs(e.speed*a)/d;o*=p,f*=p,h*=p,e.x+=o,e.y+=f,e.z+=h}function updateVehicle(e){const t=Math.sin(e.yaw),r=Math.cos(e.yaw),a=[-t,0,r],l=[r,0,t];e.forward=a;const n=.5*e.width,s=.5*e.length,i=e.x+a[0]*s+l[0]*n,o=e.z+a[2]*s+l[2]*n,f=e.x+a[0]*s-l[0]*n,h=e.z+a[2]*s-l[2]*n,d=e.x-a[0]*s+l[0]*n,p=e.z-a[2]*s+l[2]*n,u=e.x-a[0]*s-l[0]*n,c=e.z-a[2]*s-l[2]*n,g=hmap.sample(i,o),m=hmap.sample(f,h),M=hmap.sample(d,p),w=hmap.sample(u,c),x=.5*(g+m-(M+w)),y=.5*(m+w-(g+M)),S=.25*(g+m+M+w);e.groundY=S,e.pitch=Math.atan2(x,s),e.roll=Math.atan2(y,n);const A=rotationZ(e.roll),O=rotationX(e.pitch),T=rotationY(e.yaw),b=e.groundY+e.halfHeight+e.lift,z=multiply(multiply(T,A),O);if(e.modelMatrix=multiply(translate(e.x,b,e.z),z),e.speed-=.002*x,e.speed+=.001*-x,e.turret){const t=0,r=e.halfHeight+e.turretOffsetY,a=0,l=(e.turret.transform,rotationX(e.pitch)),n=rotationZ(e.roll),s=rotationY(e.yaw),i=multiply(multiply(s,n),l),o=rotationY(e.turret.yaw),f=multiply(i,o),h=translate(t,r,a);e.turret.modelMatrix=multiply(multiply(translate(e.x,b,e.z),f),h);const d=rotationX(0),p=rotationX(e.turret.pitch),u=translate(0,0,.8);e.barrel.modelMatrix=multiply(multiply(multiply(e.turret.modelMatrix,d),p),u)}if("car"===e.profile.steeringModel||"drift"===e.profile.steeringModel){let t=1;for(const r of e.children)r.isWheel&&(r.transform.rz+=.01*e.speed,t++<=2&&(r.transform.ry=e.steerAngle+.5*Math.PI))}if("tank"===e.profile.steeringModel||"drift"===e.profile.steeringModel){e.leftOffset+=.003*e.speed,e.rightOffset+=.003*e.speed,e.leftOffset+=.2*e.turnSpeed,e.rightOffset-=.2*e.turnSpeed;for(const t of e.leftTreads)t.treadOffset=e.leftOffset;for(const t of e.rightTreads)t.treadOffset=e.rightOffset;e.leftOffset=e.leftOffset%1e3,e.rightOffset=e.rightOffset%1e3}}function createWheel(e,t,r){const a=new SceneObject(r);return a.transform.rx=.5*-Math.PI,a.transform.ry=.5*Math.PI,a.transform.sx=e,a.transform.sy=t,a.transform.sz=e,a}function createTreadMesh(e,t,r){return{vertices:new Float32Array([-e,0,r,e,0,r,-e,0,-r,e,0,-r]),normals:new Float32Array([0,1,0,0,1,0,0,1,0,0,1,0]),colors:new Float32Array([.2,.2,.2,.2,.2,.2,.2,.2,.2,.2,.2,.2]),uvs:new Float32Array([0,0,1,0,0,1,1,1])}}function addTreadSegment(e,t,r,a,l,n,s,i,o,f){const h=new SceneObject(new Mesh(gl,t.vertices,t.normals,t.colors,t.uvs,gl.TRIANGLE_STRIP));h.transform.x=l,h.transform.y=n,h.transform.z=s,h.transform.rx=i,h.transform.ry=o,h.transform.rz=f,h.isTread=!0,"front"!==a&&"back"!==a||(h.isShortTread=!0),h.treadOffset=0,e.children.push(h),"left"===r?e.leftTreads.push(h):e.rightTreads.push(h)}function updateProjectileMovement(e,r){return e.x+=e.dx*e.speed*r,e.y+=e.dy*e.speed*r,e.z+=e.dz*e.speed*r,e.mesh.transform.x=e.x,e.mesh.transform.y=e.y,e.mesh.transform.z=e.z,e.distanceTraveled+=e.speed*r,!(e.distanceTraveled>e.maxRange)||(e.alive=!1,!1)}function updateProjectiles(e){for(let r=projectiles.length-1;r>=0;r--){const t=projectiles[r];let n=!1;if(updateProjectileMovement(t,e)||(n=!0),n||checkProjectileCollision(t),n||!t.alive){const e=scene.indexOf(t.mesh);-1!==e&&scene.splice(e,1),projectiles.splice(r,1)}}}function shootMachineGun(e){if(!e.transform.getMatrix())return;const r=e.transform.getMatrix(),t=r[12],n=r[13],a=r[14],s={x:t,y:n,z:a,dx:r[8],dy:r[9],dz:r[10],speed:100,radius:.15,length:1,alive:!0,mesh:null,damage:1,type:"mg",owner:e.owner,maxRange:800,distanceTraveled:0},o=createCylinderMesh(s.radius,s.length,12,!1,1,.8,.3),l=new Mesh(gl,o.vertices,o.normals,o.colors),i=createCylinder(t,n,a,s.radius,s.length,l),d=-Math.atan2(s.dx,s.dz),c=Math.atan2(s.dy,Math.sqrt(s.dx*s.dx+s.dz*s.dz)),h=Math.PI/2;i.transform.rx=h+c,i.transform.ry=d,i.transform.rz=0,s.mesh=i,scene.push(i),projectiles.push(s),sfxMachineGun(e)}function shootTurret(e){if(!e.barrel.transform.getMatrix())return;const r=e.barrel.transform.getMatrix(),t=r[8],n=r[9],a=r[10],s=r[12]+.4*t,o=r[13]+.4*n,l=r[14]+.4*a,i={x:s,y:o,z:l,dx:t,dy:n,dz:a,speed:100,radius:.3,length:1.5,alive:!0,mesh:null,damage:15,type:"turret",owner:e.owner,maxRange:1e3,distanceTraveled:0},d=createCylinderMesh(i.radius,i.length,12),c=new Mesh(gl,d.vertices,d.normals,d.colors),h=createCylinder(s,o,l,i.radius,i.length,c),m=-Math.atan2(t,a),p=Math.atan2(n,Math.sqrt(t*t+a*a)),f=Math.PI/2;h.transform.rx=f+p,h.transform.ry=m,h.transform.rz=0,i.mesh=h,scene.push(h),projectiles.push(i),sfxCannon(e)}function dropMine(e){const r=e.forward,n=e.x+-2.8*r[0],a=e.z+-2.8*r[2],s=hmap.sample(n,a),o=hmap.normal(n,a),l=-Math.atan2(o[2],o[1]),i=(Math.atan2(o[0],o[1]),createCylinderMesh(.55,.4,12,!1,.4,.4,.4)),d=new Mesh(gl,i.vertices,i.normals,i.colors),c=createCylinder(n,s,a,.55,.4,d);c.transform.rx=l,c.transform.ry=0,c.owner=e.owner,c.alive=!0,c.damage=25,c.type="mine",c.destructible=!0,c.hp=10,c.maxHp=10,c.deployed=t;const h=createCylinderMesh(.1,.5,8,!1,.7,.1,.1),m=new Mesh(gl,h.vertices,h.normals,h.colors),p=new SceneObject(m);p.transform.x=0,p.transform.y=0,p.transform.z=0,c.children.push(p),updateObjectOBB(c),scene.push(c),worldObjects.push(c),sfxMine()}function explode(e){e.alive=!1}*/'] |