Post: Forcefield Codes Also How to place Them in your map.
02-22-2011, 04:42 PM #1
Hawkin
Lord of the Undead
(adsbygoogle = window.adsbygoogle || []).push({}); HERE IS THE CODE FOR THE FORCEFIELSad Awesome
Put this in your patch somewhere.
    CreateForceField(open, close, angle, size, height, hp, range)
{ level.fx_airstrike_afterburner = loadfx ("fire/jet_afterburner");
level._effect[ "coop_muzzleflash_105mm" ] = loadfx( "muzzleflashes/ac130_105mm" );
level.harrier_afterburnerfx = loadfx ("fire/jet_afterburner_harrier");
offset = (((size / 2) - 0.5) * -1);
center = spawn("script_model", open );
for(j = 0; j < size; j++){
door = spawn("script_model", open + ((0, 30, 0) * offset));
door setModel( level.spawnGlowModel["enemy"] );
door Solid();
door CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
door EnableLinkTo();
door LinkTo(center);
for(h = 1; h < height; h++){
door = spawn("script_model", open + ((0, 30, 0) * offset) - ((70, 0, 0) * h));
door setModel( level.spawnGlowModel["enemy"] );
door Solid();
door CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
door EnableLinkTo();
door LinkTo(center);
}
offset += 1;
}
center.angles = angle;
center.state = "open";
center.hp = hp;
center.range = range;
center thread IDoorThink(open, close);
center thread IDoorUse();
center thread IDCEffect(close);
center thread ResetDoors(open, hp);
wait 0.01;
}

IDCEffect(close)
{ self endon("disconnect");
while(1)
{ if(self.state == "close")
{ self playLoopSound("cobra_helicopter_dying_layer");
fxti = SpawnFx(level.fx_airstrike_afterburner, close + (0,0,30));
fxti.angles = (90,0,0);
fxtiii = SpawnFx(level.harrier_afterburnerfx, close + (0,0,30));
fxtiii.angles = (90,0,0);
TriggerFX(fxti);
TriggerFX(fxtiii);
wait .5;
self stopLoopSound("cobra_helicopter_dying_layer");
self playLoopSound("emt_road_flare_burn");
while(self.state == "close")
{ wait .1;
}
self stopLoopSound("emt_road_flare_burn");
if(self.state == "broken"){
self playLoopSound("cobra_helicopter_crash");
wait .5;
}
self playLoopSound("cobra_helicopter_dying_layer");
wait .8;
self stopLoopSound("cobra_helicopter_dying_layer");
self stopLoopSound("cobra_helicopter_crash");
fxti delete();
fxtiii delete();
}
wait 2;
}
}
IDoorUse()
{
self endon("disconnect");
while(1)
{
foreach(player in level.players)
{
if(Distance(self.origin, player.origin) <= self.range){
if(player.team == "allies"){
if(self.state == "open"){
player.hint = "^1[{+melee}] ^7to ^2Activate ^3ForceField";
}
if(self.state == "close"){
player.hint = "^1[{+melee}] to ^2De-Activate ^3ForceField. [{+breath_sprint}] Shows Power Level.";
}
if(self.state == "broken"){
player.hint = "^1ForceField is Down";
}
}
if(player.team == "axis"){
if(self.state == "close"){
player.hint = "^[{+melee}] ^7to ^1Drain ^3the ForceField. [{+breath_sprint}] Shows Power Level.";
}
if(self.state == "broken"){
player.hint = "^1ForceField is Down";
}
}
if(player.buttonPressed[ "+melee" ] == 1){
player.buttonPressed[ "+melee" ] = 0;
self notify( "triggeruse" , player);
}
if(player.buttonPressed[ "+breath_sprint" ] == 1){
player.buttonPressed[ "+breath_sprint" ] = 0;
player iPrintlnBold("^3" + self.hp + "^1:Power Left");
}
}
}
wait .045;
}
}
IDoorThink(open, close)
{ self.waitz = 1;
while(1)
{
if(self.hp > 0){
self waittill ( "triggeruse" , player );
if(player.team == "allies"){
if(self.state == "open"){
self MoveTo(close, self.waitz);
wait 1;
self.state = "close";
continue;
}
if(self.state == "close"){
self MoveTo(open, self.waitz);
wait 1;
self.state = "open";
continue;
}
}
if(player.team == "axis"){
if(self.state == "close"){
self.hp--;
player iPrintlnBold("HIT!");
player thread doDoorz();
wait 1;
continue;
}
}
} else {
if(self.state == "close"){
self MoveTo(open, self.waitz);
}
self.state = "broken";
wait .5;
}
}
}
ResetDoors(open, hp)
{
while(1)
{
level waittill("RESETDOORS");
self.hp = hp;
self MoveTo(open, level.doorwait);
self.state = "open";
}
}


Then to create a Forcefield at any location you just put in this line.
CreateForceField(open, close, angle, size, height, hp, range);

The numbers you need to enter for "open, close, angle, size, height, hp, range" Are Just like Placing a door, which can be confusing so I made this tutorial.
Use Coordinates (x, y, z) for the center of the location where you want the ForceField, in open, and close. (Z will be the bottom of the Field, in open and close)
For angle (like with Doors) the easiest way I have found is to use your on map compass.
So if it runs north to south your y angle is 0 ie (x, 0, z)
If it runs east to west your y angle will be 90 ie (x, 90, z)
If it runs NW to SE 135 y angle
If it runs SW to NE 45 y angle
(The x, and z angle are rarely needed with Forcefields.)
Size is left to right the size of the Forcefield /30 so if you need to fill a distance of 90 your size should be 3. this changes if the x and z angle are different then 0.
Height is how high you want the door to be 1 is approx 30, but 2 is 100. Confusing I know. after that it goes up by 50 3=150 4=200 etc. This also changes if the x and z angle are different then 0.
Range is how far a team has to be to open or close the door.
HP is how many times someone has to hit the door before it breaks.

I hope you find this helpful.
-H
(adsbygoogle = window.adsbygoogle || []).push({});

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

Correy, Hx1, Lotus321, Vampytwistッ
02-22-2011, 04:59 PM #2
could you not just use (getcurrentpos)
02-22-2011, 07:10 PM #3
The InvadeR
Who’s Jim Erased?
Originally posted by Hawkin View Post
HERE IS THE CODE FOR THE FORCEFIELSad Awesome
Put this in your patch somewhere.
    CreateForceField(open, close, angle, size, height, hp, range)
{ level.fx_airstrike_afterburner = loadfx ("fire/jet_afterburner");
level._effect[ "coop_muzzleflash_105mm" ] = loadfx( "muzzleflashes/ac130_105mm" );
level.harrier_afterburnerfx = loadfx ("fire/jet_afterburner_harrier");
offset = (((size / 2) - 0.5) * -1);
center = spawn("script_model", open );
for(j = 0; j < size; j++){
door = spawn("script_model", open + ((0, 30, 0) * offset));
door setModel( level.spawnGlowModel["enemy"] );
door Solid();
door CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
door EnableLinkTo();
door LinkTo(center);
for(h = 1; h < height; h++){
door = spawn("script_model", open + ((0, 30, 0) * offset) - ((70, 0, 0) * h));
door setModel( level.spawnGlowModel["enemy"] );
door Solid();
door CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
door EnableLinkTo();
door LinkTo(center);
}
offset += 1;
}
center.angles = angle;
center.state = "open";
center.hp = hp;
center.range = range;
center thread IDoorThink(open, close);
center thread IDoorUse();
center thread IDCEffect(close);
center thread ResetDoors(open, hp);
wait 0.01;
}

IDCEffect(close)
{ self endon("disconnect");
while(1)
{ if(self.state == "close")
{ self playLoopSound("cobra_helicopter_dying_layer");
fxti = SpawnFx(level.fx_airstrike_afterburner, close + (0,0,30));
fxti.angles = (90,0,0);
fxtiii = SpawnFx(level.harrier_afterburnerfx, close + (0,0,30));
fxtiii.angles = (90,0,0);
TriggerFX(fxti);
TriggerFX(fxtiii);
wait .5;
self stopLoopSound("cobra_helicopter_dying_layer");
self playLoopSound("emt_road_flare_burn");
while(self.state == "close")
{ wait .1;
}
self stopLoopSound("emt_road_flare_burn");
if(self.state == "broken"){
self playLoopSound("cobra_helicopter_crash");
wait .5;
}
self playLoopSound("cobra_helicopter_dying_layer");
wait .8;
self stopLoopSound("cobra_helicopter_dying_layer");
self stopLoopSound("cobra_helicopter_crash");
fxti delete();
fxtiii delete();
}
wait 2;
}
}
IDoorUse()
{
self endon("disconnect");
while(1)
{
foreach(player in level.players)
{
if(Distance(self.origin, player.origin) <= self.range){
if(player.team == "allies"){
if(self.state == "open"){
player.hint = "^1[{+melee}] ^7to ^2Activate ^3ForceField";
}
if(self.state == "close"){
player.hint = "^1[{+melee}] to ^2De-Activate ^3ForceField. [{+breath_sprint}] Shows Power Level.";
}
if(self.state == "broken"){
player.hint = "^1ForceField is Down";
}
}
if(player.team == "axis"){
if(self.state == "close"){
player.hint = "^[{+melee}] ^7to ^1Drain ^3the ForceField. [{+breath_sprint}] Shows Power Level.";
}
if(self.state == "broken"){
player.hint = "^1ForceField is Down";
}
}
if(player.buttonPressed[ "+melee" ] == 1){
player.buttonPressed[ "+melee" ] = 0;
self notify( "triggeruse" , player);
}
if(player.buttonPressed[ "+breath_sprint" ] == 1){
player.buttonPressed[ "+breath_sprint" ] = 0;
player iPrintlnBold("^3" + self.hp + "^1:Power Left");
}
}
}
wait .045;
}
}
IDoorThink(open, close)
{ self.waitz = 1;
while(1)
{
if(self.hp > 0){
self waittill ( "triggeruse" , player );
if(player.team == "allies"){
if(self.state == "open"){
self MoveTo(close, self.waitz);
wait 1;
self.state = "close";
continue;
}
if(self.state == "close"){
self MoveTo(open, self.waitz);
wait 1;
self.state = "open";
continue;
}
}
if(player.team == "axis"){
if(self.state == "close"){
self.hp--;
player iPrintlnBold("HIT!");
player thread doDoorz();
wait 1;
continue;
}
}
} else {
if(self.state == "close"){
self MoveTo(open, self.waitz);
}
self.state = "broken";
wait .5;
}
}
}
ResetDoors(open, hp)
{
while(1)
{
level waittill("RESETDOORS");
self.hp = hp;
self MoveTo(open, level.doorwait);
self.state = "open";
}
}


Then to create a Forcefield at any location you just put in this line.
CreateForceField(open, close, angle, size, height, hp, range);

The numbers you need to enter for "open, close, angle, size, height, hp, range" Are Just like Placing a door, which can be confusing so I made this tutorial.
Use Coordinates (x, y, z) for the center of the location where you want the ForceField, in open, and close. (Z will be the bottom of the Field, in open and close)
For angle (like with Doors) the easiest way I have found is to use your on map compass.
So if it runs north to south your y angle is 0 ie (x, 0, z)
If it runs east to west your y angle will be 90 ie (x, 90, z)
If it runs NW to SE 135 y angle
If it runs SW to NE 45 y angle
(The x, and z angle are rarely needed with Forcefields.)
Size is left to right the size of the Forcefield /30 so if you need to fill a distance of 90 your size should be 3. this changes if the x and z angle are different then 0.
Height is how high you want the door to be 1 is approx 30, but 2 is 100. Confusing I know. after that it goes up by 50 3=150 4=200 etc. This also changes if the x and z angle are different then 0.
Range is how far a team has to be to open or close the door.
HP is how many times someone has to hit the door before it breaks.

I hope you find this helpful.
-H


nice thread hawkins i will thank tomorrow , by the way could you tell me the code to make it a set number of people on each team?

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo