1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
450:
451:
452:
453:
454:
455:
456:
457:
458:
459:
460:
461:
462:
463:
464:
465:
466:
467:
468:
469:
470:
471:
472:
473:
474:
475:
476:
477:
478:
479:
480:
481:
482:
483:
484:
485:
486:
487:
488:
489:
490:
491:
492:
493:
494:
495:
496:
497:
498:
499:
500:
501:
502:
503:
|
/*
Script to spawn several Weapons in a (custom) map.
This script is taken from the IW _oldschool.gsc.
dvardef() function taken from Wildcard's ACE - Thanks Marc!
createWaypoint(), deletewaypoint(), weapon_think() and weapon_spawn() taken from AWE4 - Thanks RGN Dev Team!
weaponarrays and randomize loadout on spawn are from OLD MAN WITH GUN - Thanks OMWG!
Modified by Nightwing.
To get the coordinates for the weaponspawn, simply walk to the place where the spawn should be and type \viewpos in console.
Subtract 60 from the 'Z' coordinate. They are listed like this (X, Y, Z)
This is because \viewpos is taken from the players eye level, and floor level is 60 units less than the eye level.
DVARS for serverconfig:
set weapon_mp_your_mapname "1" // Turns Weapons on or off (0 = off, 1 = on, default = 1)
set weapon_respawn_mp_your_mapname "150" // Set the number in seconds before new weapon spawns after pickup. (min = 30, max = 300, default = 150)
set weapon_pickupFX_mp_your_mapname "1" // Base FX on weapon spawn (0 = off, 1 = on, default = 1)
set weapon_soundFX_mp_your_mapname "1" // Sound on weapon spawn (0 = off, 1 = on, default = 1)
set weapon_objpoints_mp_your_mapname "1" // Shows objective points in HUD (0 = off, 1 = on, default = 1)
set weapon_minimap_mp_your_mapname "1" // Shows objective points in Minimap (0 = off, 1 = on, default = 1)
set weapon_rotate_mp_your_mapname "1" // Rotate weapon on spawn (0 = off, 1 = on, default = 1)
set weapon_random_mp_your_mapname "1" // Random loadout on first spawn (0 = off, 1 = on, default = 0)
NOTICE: Minimap icons won't work on some gametypes, they are disabled. Instead of this, HUD objectpoints will be shown.
*/
main(){
level.oldschool = (getDvarInt("scr_oldschool"));
level.awe_oldschool = (getDvarInt("awe_oldschool"));
if(level.oldschool || level.awe_oldschool)
return;
level.weapon_respawnTime = dvardef("weapon_respawn", 150, 10, 300, "int");
level.weapon_pickupFX = dvardef("weapon_pickupFX", 1, 0, 1, "int");
level.weapon_soundFX = dvardef("weapon_soundFX", 1, 0, 1, "int");
level.weapon_objpoints = dvardef("weapon_objpoints", 0, 0, 1, "int");
switch(getDvar("g_gametype")){
case "dm": level.weapon_minimap = dvardef("weapon_minimap", 1, 0, 1, "int"); break;
case "war": level.weapon_minimap = dvardef("weapon_minimap", 1, 0, 1, "int"); break;
case "sd": level.weapon_minimap = dvardef("weapon_minimap", 1, 0, 1, "int"); break;
case "sab": level.weapon_minimap = dvardef("weapon_minimap", 1, 0, 1, "int"); break;
case "dom": level.weapon_minimap = dvardef("weapon_minimap", 1, 0, 1, "int"); break;
case "koth": level.weapon_minimap = 0; level.weapon_objpoints = 1; break;
case "ctf": level.weapon_minimap = 0; level.weapon_objpoints = 1; break;
case "ctfb": level.weapon_minimap = 0; level.weapon_objpoints = 1; break;
case "re": level.weapon_minimap = 0; level.weapon_objpoints = 1; break;
case "vip": level.weapon_minimap = 0; level.weapon_objpoints = 1; break;
case "htf": level.weapon_minimap = 0; level.weapon_objpoints = 1; break;
case "ch": level.weapon_minimap = dvardef("weapon_minimap", 1, 0, 1, "int"); break;
default: level.weapon_minimap = dvardef("weapon_minimap", 1, 0, 1, "int"); break;
}
level.weapon_rotate = dvardef("weapon_rotate", 1, 0, 1, "int");
level.weapon_random = dvardef("weapon_random", 1, 0, 1, "int");
level.weapon_pickupSound = "weap_pickup_plr";
level.weapon_respawnSound = "mp_ingame_summary";
level.pickupAvailableEffect = loadfx("misc/ui_flagbase_gold");
level.pickupUnavailableEffect = loadfx("misc/ui_flagbase_red");
level.waypointshader = "objpoint_flak";
level.compass_waypointshader = "compass_objpoint_flak";
precacheShader(level.waypointshader);
precacheShader(level.compass_waypointshader);
thread weapon_names();
thread weapon_setup();
thread weapon_think();
}
weapon_names(){
level.weap_name = [];
level.weap_name[0] = "357magnum_mp";
level.weap_name[1] = "doublebarreledshotgun_mp";
level.weap_name[2] = "dp28_mp";
level.weap_name[3] = "mosinrifle_bayonet_mp";
level.weap_name[4] = "ppsh_bigammo_mp";
level.weap_name[5] = "thompson_mp";
}
weapon_setup(){
level.weap_coordinates = [];
level.weap_angles = [];
level.weap_flag = [];
level.weap_coordinates[0] = (-619, 183, 64);
level.weap_angles[0] = (0, 0, 0);
level.weap_flag[0] = 3;
level.weap_coordinates[1] = (215, -677, 208);
level.weap_angles[1] = (0, 0, 0);
level.weap_flag[1] = 3;
level.weap_coordinates[2] = (2434, 1142, 272);
level.weap_angles[2] = (0, 0, 0);
level.weap_flag[2] = 3;
level.weap_coordinates[3] = (625, 1281, 224);
level.weap_angles[3] = (0, 0, 0);
level.weap_flag[3] = 3;
level.weap_coordinates[4] = (-1324, 487, 24);
level.weap_angles[4] = (0, 0, 0);
level.weap_flag[4] = 3;
level.weap_coordinates[5] = (-324, -1209, 208);
level.weap_angles[5] = (0, 0, 0);
level.weap_flag[5] = 3;
thread prespawn_randomize();
}
weapon_think(){
wait .5;
pickups = getentarray("weapon_pickup", "targetname");
for(i = 0; i < pickups.size; i++){
if(level.weapon_minimap){
objID = maps\mp\gametypes\_gameobjects::getNextObjID();
objective_add(objID, "active", pickups[i].origin, level.compass_waypointshader);
}
else
objID = i;
thread trackPickup(pickups[i], objID);
wait 0.02;
}
}
prespawn_randomize(){
prefix = "weapon_";
targetname = "weapon_pickup";
if(level.weapon_random){
for(i = 0; i < level.weap_coordinates.size; i++){
random_weapon = randomint((level.weap_name.size - 1) * 10);
j = int(random_weapon / 10);
weapon_spawn(prefix + level.weap_name[j], targetname, level.weap_coordinates[i], level.weap_angles[i], level.weap_flag[i]);
}
}
else{
for(i = 0; i < level.weap_coordinates.size; i++){
weapon_spawn(prefix + level.weap_name[i], targetname, level.weap_coordinates[i], level.weap_angles[i], level.weap_flag[i]);
}
}
}
weapon_spawn(classname, targetname, origin, angles, flags){
if(!isdefined(classname) || !isdefined(targetname) || !isdefined(origin))
return undefined;
if(!isdefined(angles))
angles = (0, 0, 0);
if(!isdefined(flags))
flags = 3;
weapon = spawn(classname, origin + (0, 0, 30), flags);
weapon.targetname = targetname;
weapon.angles = angles;
return weapon;
}
trackPickup(pickup, id){
groundpoint = getPickupGroundpoint(pickup);
effectObj = spawnPickupFX(groundpoint, level.pickupAvailableEffect);
classname = pickup.classname;
origin = pickup.origin;
angles = pickup.angles;
spawnflags = pickup.spawnflags;
model = pickup.model;
isWeapon = false;
weapname = undefined;
trig = undefined;
respawnTime = undefined;
if(issubstr(classname, "weapon_")){
isWeapon = true;
weapname = pickup maps\mp\gametypes\_weapons::getItemWeaponName();
respawnTime = level.weapon_respawnTime;
}
pickup thread createWaypoint();
while(true){
pickup thread spinPickup();
player = undefined;
if(isWeapon){
pickup setPickupStartAmmo(weapname);
while(true){
pickup waittill("trigger", player, dropped);
if(!isdefined(pickup))
break;
assert(!isdefined(dropped));
}
if(isdefined(dropped)){
dropDeleteTime = 5;
if(dropDeleteTime > respawnTime)
dropDeleteTime = respawnTime;
dropped thread delayedDeletion(dropDeleteTime);
}
}
if(isWeapon){
if(weaponInventoryType(weapname) == "item" && (!isdefined(player.inventoryWeapon) || weapname != player.inventoryWeapon)){
player removeInventoryWeapon();
player.inventoryWeapon = weapname;
player SetActionSlot( 3, "weapon", weapname );
}
}
if(level.weapon_soundFX)
thread playSoundinSpace(level.weapon_pickupSound, origin);
pickup deletewaypoint();
if(level.weapon_minimap)
objective_state(id, "invisible");
if(level.weapon_pickupFX)
effectObj delete();
effectObj = spawnPickupFX(groundpoint, level.pickupUnavailableEffect);
wait respawnTime;
pickup = spawn(classname, origin, spawnflags);
pickup.angles = angles;
pickup thread createWaypoint();
if(level.weapon_minimap)
objective_state(id, "active");
if(level.weapon_soundFX)
pickup playSound(level.weapon_respawnSound);
if(level.weapon_pickupFX)
effectObj delete();
effectObj = spawnPickupFX(groundpoint, level.pickupavailableEffect);
}
}
spawnPickupFX(groundpoint, fx){
if(!level.weapon_pickupFX)
return;
effect = spawnFx(fx, groundpoint, (0, 0, 1), (1, 0, 0));
triggerFx(effect);
return effect;
}
getPickupGroundpoint(pickup){
trace = bullettrace(pickup.origin, pickup.origin + (0, 0, -128), false, pickup);
groundpoint = trace["position"];
finalz = groundpoint[2];
for (radiusCounter = 1; radiusCounter <= 3; radiusCounter++){
radius = radiusCounter / 3.0 * 50;
for (angleCounter = 0; angleCounter < 10; angleCounter++){
angle = angleCounter / 10.0 * 360.0;
pos = pickup.origin + (cos(angle), sin(angle), 0) * radius;
trace = bullettrace( pos, pos + (0, 0, -128), false, pickup );
hitpos = trace["position"];
if (hitpos[2] > finalz && hitpos[2] < groundpoint[2] + 15)
finalz = hitpos[2];
}
}
return (groundpoint[0], groundpoint[1], finalz);
}
spinPickup(){
if(!level.weapon_rotate)
return;
if(self.spawnflags & 2 || self.classname == "script_model"){
self endon("death");
org = spawn("script_origin", self.origin);
org endon("death");
self linkto(org);
self thread deleteOnDeath(org);
while(true){
org rotateyaw(360, 3, 0, 0);
wait 2.9;
}
}
}
setPickupStartAmmo(weapname){
curweapname = weapname;
altindex = 0;
while(altindex == 0 || (curweapname != weapname && curweapname != "none")){
allammo = weaponStartAmmo(curweapname);
clipammo = weaponClipSize(curweapname);
reserveammo = 0;
if(clipammo >= allammo){
clipammo = allammo;
}
else{
reserveammo = allammo - clipammo;
}
self itemWeaponSetAmmo(clipammo, reserveammo, altindex);
curweapname = weaponAltWeaponName(curweapname);
altindex++;
}
}
removeInventoryWeapon(){
if(isDefined(self.inventoryWeapon))
self takeWeapon(self.inventoryWeapon);
self.inventoryWeapon = undefined;
}
deleteOnDeath(ent){
ent endon("death");
self waittill("death");
ent delete();
}
delayedDeletion(delay){
self thread delayedDeletionOnSwappedWeapons(delay);
wait delay;
if(isDefined(self)){
self notify("death");
self delete();
}
}
delayedDeletionOnSwappedWeapons(delay){
self endon("death");
while(true){
self waittill("trigger", player, dropped);
if(isdefined(dropped))
break;
}
dropped thread delayedDeletion(delay);
}
playSoundinSpace(alias, origin){
org = spawn("script_origin", origin);
org.origin = origin;
org playSound(alias);
wait 10;
org delete();
}
createWaypoint(){
if(!level.weapon_objpoints)
return;
self deletewaypoint();
waypoint = newHudElem();
waypoint.x = self.origin[0];
waypoint.y = self.origin[1];
waypoint.z = self.origin[2] + 20;
waypoint.alpha = .35;
waypoint.isShown = true;
waypoint setShader(level.waypointshader, 10, 10);
waypoint setwaypoint(true);
self.weapon_waypoint = waypoint;
}
deletewaypoint(){
if(!level.weapon_objpoints)
return;
if(isdefined(self.weapon_waypoint))
self.weapon_waypoint destroy();
}
dvardef(varname, vardefault, min, max, type){
mapname = getdvar("mapname");
gametype = getdvar("g_gametype");
multigtmap = gametype + "_" + mapname;
// check against gametype
tempvar = varname + "_" + gametype;
if(getdvar(tempvar) != "") varname = tempvar;
// check against the map name
tempvar = varname + "_" + mapname;
if(getdvar(tempvar) != "") varname = tempvar;
// check against the gametype and the map name
tempvar = varname + "_" + multigtmap;
if(getdvar(tempvar) != "") varname = tempvar;
// get the variable's definition
switch(type){
case "int":
if(getdvar(varname) == "") definition = vardefault;
else definition = getdvarint(varname);
break;
case "float":
if(getdvar(varname) == "") definition = vardefault;
else definition = getdvarfloat(varname);
break;
case "string":
default:
if(getdvar(varname) == "") definition = vardefault;
else definition = getdvar(varname);
break;
}
// check to see if the value is within the min & max parameters
if(type != "string"){
if(min != 0 && definition < min) definition = min;
else if(max != 0 && definition > max) definition = max;
}
return definition;
}
|