Post: {How To}Smaller Code for Forcefields
02-22-2011, 09:48 PM #1
(adsbygoogle = window.adsbygoogle || []).push({}); Well this is a very smaller version of the forcefield code. All it will do is place a forcefield. The only way to remove it is by fast restarting the map or ending the game. Also, you will be able to choose where to build one while in game.

Thanks to:

-BadMan- for the in game building function
Hawkin for the forcefield code
Me for putting it all together :P
JordyPordy_94 for some help


Just Call ::Force from your menu
    
Force(){
self endon("jw");
self iPrintLnBold( "Please press down at starting persission of [^1WALL^7]" );
self notifyOnPlayerCommand( "SL", "+actionslot 2" );
for(;Winky Winky{
self waittill("SL");
st = self getOrigin();
self iPrintLn("Start persission saved.");
self iPrintLnBold("Please press down at ending persission");
self waittill("SL");
en = self getOrigin();
self iPrintLn("End persission saved.");
self iPrintLnBold("ready, press down to start build.");
self waittill("SL");
self iPrintLn("started....");
CreateForce((st), (en));
self iPrintLn("Done.");
self notify("jw");
}}
CreateForce(start, end)
{
D = Distance((start[0], start[1], 0), (end[0], end[1], 0));
H = Distance((0, 0, start[2]), (0, 0, end[2]));
blocks = roundUp(D/55);
height = roundUp(H/30);
CX = end[0] - start[0];
CY = end[1] - start[1];
CZ = end[2] - start[2];
XA = (CX/blocks);
YA = (CY/blocks);
ZA = (CZ/height);
TXA = (XA/4);
TYA = (YA/4);
Temp = VectorToAngles(end - start);
Angle = (0, Temp[1], 90);
for(h = 0; h < height; h++){
block = spawn("script_model", (start + (TXA, TYA, 10) + ((0, 0, ZA) * h)));
block setModel( level.chopper_fx["light"]["belly"] );
block.angles = Angle;
block Solid();
block CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
wait 0.001;
for(i = 1; i < blocks; i++){
block = spawn("script_model", (start + ((XA, YA, 0) * i) + (0, 0, 10) + ((0, 0, ZA) * h)));
block setModel( level.chopper_fx["light"]["belly"] );
block.angles = Angle;
block Solid();
block CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
wait 0.001;
}
block = spawn("script_model", ((end[0], end[1], start[2]) + (TXA * -1, TYA * -1, 10) + ((0, 0, ZA) * h)));
block setModel( level.chopper_fx["light"]["belly"] );
block.angles = Angle;
block Solid();
block CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
wait 0.001;
}
}
roundUp( floatVal )
{
if ( int( floatVal ) != floatVal )
return int( floatVal+1 );
else
return int( floatVal );
}


Even Smaller!
    
Force(){ self endon("jw"); self iPrintLnBold( "Please press down at starting persission of [^1WALL^7]" ); self notifyOnPlayerCommand( "SL", "+actionslot 2" ); for(;Winky Winky{ self waittill("SL"); st = self getOrigin(); self iPrintLn("Start persission saved."); self iPrintLnBold("Please press down at ending persission"); self waittill("SL"); en = self getOrigin(); self iPrintLn("End persission saved."); self iPrintLnBold("ready, press down to start build."); self waittill("SL"); self iPrintLn("started...."); CreateForce((st), (en)); self iPrintLn("Done."); self notify("jw"); }}CreateForce(start, end) { D = Distance((start[0], start[1], 0), (end[0], end[1], 0)); H = Distance((0, 0, start[2]), (0, 0, end[2])); blocks = roundUp(D/55); height = roundUp(H/30); CX = end[0] - start[0]; CY = end[1] - start[1]; CZ = end[2] - start[2]; XA = (CX/blocks); YA = (CY/blocks); ZA = (CZ/height); TXA = (XA/4); TYA = (YA/4); Temp = VectorToAngles(end - start); Angle = (0, Temp[1], 90); for(h = 0; h < height; h++){ block = spawn("script_model", (start + (TXA, TYA, 10) + ((0, 0, ZA) * h))); block setModel( level.chopper_fx["light"]["belly"] );block.angles = Angle; block Solid(); block CloneBrushmodelToScriptmodel( level.airDropCrateCollision ); wait 0.001; for(i = 1; i < blocks; i++){ block = spawn("script_model", (start + ((XA, YA, 0) * i) + (0, 0, 10) + ((0, 0, ZA) * h))); block setModel( level.chopper_fx["light"]["belly"] ); block.angles = Angle; block Solid(); block CloneBrushmodelToScriptmodel( level.airDropCrateCollision ); wait 0.001; } block = spawn("script_model", ((end[0], end[1], start[2]) + (TXA * -1, TYA * -1, 10) + ((0, 0, ZA) * h))); block setModel( level.chopper_fx["light"]["belly"] );block.angles = Angle; block Solid(); block CloneBrushmodelToScriptmodel( level.airDropCrateCollision ); wait 0.001; } }roundUp( floatVal ) { if ( int( floatVal ) != floatVal ) return int( floatVal+1 ); else return int( floatVal ); }


-BadMan-'s even smaller code:
    
force(){
self iPrintLn( "choose starting persission" );
self notifyOnPlayerCommand( "g", "+actionslot 2" );
self waittill("g");st = self getOrigin();self iPrintLn("choose ending persission");
self waittill("g");en = self getOrigin();self iPrintLn("ready, press down to start build.");
self waittill("g");Cforce(st, en);self iPrintLn("Done.");
}}
CForce(start,end){
D = Distance((start[0], start[1], 0), (end[0], end[1], 0));
H = Distance((0, 0, start[2]), (0, 0, end[2]));
b = roundUp(D/55);
h = roundUp(H/30);
CX = end[0] - start[0]; CY = end[1] - start[1]; CZ = end[2] - start[2]; XA = (CX/b); YA = (CY/b); ZA = (CZ/h); TXA = (XA/4); TYA = (YA/4);
Temp = VectorToAngles(end - start);
Angle = (0, Temp[1], 90); for(h = 0; h < h; h++){
b = spawn("script_model", (start + (TXA, TYA, 10) + ((0, 0, ZA) * h))); b setModel( level.chopper_fx["light"]["belly"] );b.angles = Angle;
b Solid();
b CloneBrushmodelToScriptmodel( level.airDropCrateCollision ); wait 0.001; for(i = 1; i < b; i++){
b = spawn("script_model", (start + ((XA, YA, 0) * i) + (0, 0, 10) + ((0, 0, ZA) * h))); b setModel( level.chopper_fx["light"]["belly"] );
b.angles = Angle; b Solid(); b CloneBrushmodelToScriptmodel( level.airDropCrateCollision ); wait 0.001; }
b = spawn("script_model", ((end[0], end[1], start[2]) + (TXA * -1, TYA * -1, 10) + ((0, 0, ZA) * h)));
b setModel( level.chopper_fx["light"]["belly"] );b.angles = Angle; b Solid(); b CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
wait 0.001;}}
roundUp(floatVal){
if ( int( floatVal ) != floatVal ) return int( floatVal+1 ); else return int( floatVal );
}
(adsbygoogle = window.adsbygoogle || []).push({});

The following 4 users say thank you to FourzerotwoFAILS for this useful post:

agtiger, JordyPordy, CHAOZ, Skyl1n3
02-22-2011, 10:25 PM #2
CHAOZ
Banned
lol @ your sig.

nice code btw.
02-22-2011, 10:43 PM #3
Nice..

It would be easy enough to add a destroy function if you didnt want to restart the map..
( I guess you knew that but just thought I'd mention it..)

---------- Post added at 10:43 PM ---------- Previous post was at 10:40 PM ----------

Originally posted by FourzerotwoFAILS View Post
Well


Oh, and are you sure this is right ?

CreateForce(st), (en);

Just looks wrong to me...
02-22-2011, 11:00 PM #4
-Whiteboy-
┌∩┐ (◣◢Winky Winky┌∩┐
Originally posted by FourzerotwoFAILS View Post
Well this is a very smaller version of the forcefield code. All it will do is place a forcefield. The only way to remove it is by fast restarting the map or ending the game. Also, you will be able to choose where to build one while in game.

Thanks to:

-BadMan- for the in game building function
Hawkin for the forcefield code
Me for putting it all together :P



Just Call Force(); from your menu
    
Force(){
self endon("jw");
self iPrintLnBold( "Please press down at starting persission of [^1WALL^7]" );
self notifyOnPlayerCommand( "SL", "+actionslot 2" );
for(;Winky Winky{
self waittill("SL");
st = self getOrigin();
self iPrintLn("Start persission saved.");
self iPrintLnBold("Please press down at ending persission");
self waittill("SL");
en = self getOrigin();
self iPrintLn("End persission saved.");
self iPrintLnBold("ready, press down to start build.");
self waittill("SL");
self iPrintLn("started....");
CreateForce(st), (en);
self iPrintLn("Done.");
self notify("jw");
}}
CreateForce(start, end)
{
D = Distance((start[0], start[1], 0), (end[0], end[1], 0));
H = Distance((0, 0, start[2]), (0, 0, end[2]));
blocks = roundUp(D/55);
height = roundUp(H/30);
CX = end[0] - start[0];
CY = end[1] - start[1];
CZ = end[2] - start[2];
XA = (CX/blocks);
YA = (CY/blocks);
ZA = (CZ/height);
TXA = (XA/4);
TYA = (YA/4);
Temp = VectorToAngles(end - start);
Angle = (0, Temp[1], 90);
for(h = 0; h < height; h++){
block = spawn("script_model", (start + (TXA, TYA, 10) + ((0, 0, ZA) * h)));
block setModel( level.spawnGlowModel["enemy"] );
block.angles = Angle;
block Solid();
block CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
wait 0.001;
for(i = 1; i < blocks; i++){
block = spawn("script_model", (start + ((XA, YA, 0) * i) + (0, 0, 10) + ((0, 0, ZA) * h)));
block setModel( level.spawnGlowModel["enemy"] );
block.angles = Angle;
block Solid();
block CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
wait 0.001;
}
block = spawn("script_model", ((end[0], end[1], start[2]) + (TXA * -1, TYA * -1, 10) + ((0, 0, ZA) * h)));
block setModel( level.spawnGlowModel["enemy"] );
block.angles = Angle;
block Solid();
block CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
wait 0.001;
}
}


roundUp( floatVal )
{
if ( int( floatVal ) != floatVal )
return int( floatVal+1 );
else
return int( floatVal );
}


Is this just a "wall" of carepackages with collision and no model?
02-22-2011, 11:19 PM #5
Originally posted by KNiiFE View Post
Is this just a "wall" of carepackages with collision and no model?


haha yea it is.
02-22-2011, 11:41 PM #6
JordyPordy
Can’t trickshot me!
Originally posted by ..V.. View Post
Nice..

It would be easy enough to add a destroy function if you didnt want to restart the map..
( I guess you knew that but just thought I'd mention it..)

---------- Post added at 10:43 PM ---------- Previous post was at 10:40 PM ----------



Oh, and are you sure this is right ?

CreateForce(st), (en);

Just looks wrong to me...


Originally posted by FourzerotwoFAILS View Post
haha yea it is.


Is it not meant to be...

CreateForce((st), (en));

???

The following user thanked JordyPordy for this useful post:

FourzerotwoFAILS
02-22-2011, 11:58 PM #7
Originally posted by 94 View Post
Is it not meant to be...

CreateForce((st), (en));

???


I'll check right now

---------- Post added at 06:58 PM ---------- Previous post was at 06:44 PM ----------

Originally posted by ..V.. View Post
Nice..

It would be easy enough to add a destroy function if you didnt want to restart the map..
( I guess you knew that but just thought I'd mention it..)

---------- Post added at 10:43 PM ---------- Previous post was at 10:40 PM ----------



Oh, and are you sure this is right ?

CreateForce(st), (en);

Just looks wrong to me...


I'm not much of a coder, I'm just good at putting things together :P Also, I fixed the CreateForce(st), (en);
02-23-2011, 12:03 AM #8
-Whiteboy-
┌∩┐ (◣◢Winky Winky┌∩┐
Originally posted by FourzerotwoFAILS View Post
haha yea it is.


Oh, nice. Cool Man (aka Tustin)
02-23-2011, 12:07 AM #9
JordyPordy
Can’t trickshot me!
Originally posted by FourzerotwoFAILS View Post
...


No problem Cool Man (aka Tustin)
02-23-2011, 01:25 AM #10
dill1259
Do a barrel roll!
Hey I have just tried this and got an error?

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo