3 # script that creates an "assault circuit"
8 my @objectives = @ARGV;
13 Assault Circuit Board Creator
20 perl $0 breakables1[,buttons1] breakables2[,buttons2] breakables3[,buttons3] ... \\
24 ofs_z=1024 perl $0 1 1 3,2 1 > assault.map
29 my $bp = $ENV{brushprimit};
30 my @ofs = ($ENV{ofs_x} || 0, $ENV{ofs_y} || 0, $ENV{ofs_z} || 0);
32 my $BRUSHDEF_START = $bp ? "{\nbrushDef\n{" : "{";
33 my $BRUSHDEF_END = $bp ? "}\n}" : "}";
34 my $BRUSHDEF_PRE = $bp ? "( ( 0.03125 0 -0 ) ( -0 0.03125 0 ) ) " : "";
35 my $BRUSHDEF_POST = $bp ? " 0 0 0" : " 0 0 0 0.500000 0.500000 0 0 0";
37 sub BrushRectangle($@@)
39 my ($shader, $x0, $y0, $z0, $x1, $y1, $z1) = @_;
42 ( $x1 $y1 $z1 ) ( $x1 $y0 $z1 ) ( $x0 $y1 $z1 ) $BRUSHDEF_PRE$shader$BRUSHDEF_POST
43 ( $x1 $y1 $z1 ) ( $x0 $y1 $z1 ) ( $x1 $y1 $z0 ) $BRUSHDEF_PRE$shader$BRUSHDEF_POST
44 ( $x1 $y1 $z1 ) ( $x1 $y1 $z0 ) ( $x1 $y0 $z1 ) $BRUSHDEF_PRE$shader$BRUSHDEF_POST
45 ( $x0 $y0 $z0 ) ( $x1 $y0 $z0 ) ( $x0 $y1 $z0 ) $BRUSHDEF_PRE$shader$BRUSHDEF_POST
46 ( $x0 $y0 $z0 ) ( $x0 $y0 $z1 ) ( $x1 $y0 $z0 ) $BRUSHDEF_PRE$shader$BRUSHDEF_POST
47 ( $x0 $y0 $z0 ) ( $x0 $y1 $z0 ) ( $x0 $y0 $z1 ) $BRUSHDEF_PRE$shader$BRUSHDEF_POST
56 if(ref $h{model} eq 'ARRAY')
58 @brushes = @{$h{model}};
61 return join "", ("{\n", (map { qq{"$_" "$h{$_}"\n} } keys %h), @brushes, "}\n");
72 $dmg = (1 + int(10 / $cnt)) * 10;
74 if $dmg * ($cnt - 1) < 100;
77 $dmg = (1 + int(20 / $cnt)) * 5;
79 if $dmg * ($cnt - 1) < 100;
82 $dmg = (1 + int(50 / $cnt)) * 2;
84 if $dmg * ($cnt - 1) < 100;
87 $dmg = (1 + int(100 / $cnt));
89 if $dmg * ($cnt - 1) < 100;
92 return (100 / $cnt + 100 / ($cnt + 1)) / 2;
95 sub ObjectiveSpawns($@)
97 my ($target, $x, $y, $z) = @_;
106 my $yy = $y + ($_ - 3.5) * 64;
107 my $zz = $z - 8 - 32; # align feet to 64-grid
109 classname => "info_player_attacker",
111 origin => "$xx $yy $zz";
115 classname => "info_player_defender",
117 origin => "$xx $yy $zz";
123 my @assault_entities = ();
125 my $obj_prev = undef;
126 my $des_prev = undef;
128 my @prevorigin = @ofs;
130 for my $i(0..@objectives - 1)
134 $ofs[0] + ($i + 1) * 256,
139 my $count = $objectives[$i];
140 $count =~ /^(\d+)(?:,(\d+))?$/s
141 or die "Invalid count spec: must be number or number,number";
142 my $count_destroy = $1;
143 my $count_push = $2 || 0;
144 $count = $count_destroy + $count_push;
147 my $des = "obj$i\_destructible";
148 my $dec = "obj$i\_decrease";
152 push @assault_entities, Entity
153 classname => "target_assault_roundstart",
156 origin => "@prevorigin";
160 push @assault_entities, Entity
161 classname => "target_objective",
162 targetname => $obj_prev,
165 origin => "@prevorigin";
167 push @assault_entities, ObjectiveSpawns $obj_prev, @prevorigin;
169 push @assault_entities, Entity
170 classname => "func_assault_wall",
175 $origin[0] - 128 - 32,
178 $origin[0] - 128 + 32,
184 @prevorigin = @origin;
188 my $dmg = FindDamage($count);
190 push @assault_entities, Entity
191 classname => "target_objective_decrease",
199 for(1..$count_destroy)
201 push @assault_entities, Entity
202 classname => "func_assault_destructible",
206 mdl => "rocket_explode",
208 noise => "weapons/rocket_impact.wav",
229 push @assault_entities, Entity
230 classname => "func_button",
251 my $obj = "roundend";
254 $ofs[0] + (@objectives + 1) * 256,
259 push @assault_entities, Entity
260 classname => "target_objective",
261 targetname => $obj_prev,
263 origin => "@prevorigin";
265 push @assault_entities, ObjectiveSpawns $obj_prev, @prevorigin;
267 push @assault_entities, Entity
268 classname => "target_assault_roundend",
274 Entity(classname => "worldspawn"),