Icons mehrerer Objekte (variable Anzahl) in Minimap anzeigen

Nightwing
Ich hab letztens mal das _spawn_weapons Script hier vorgestellt.
Man hat damit die Möglichkeit, mehrere Waffen im Oldschool Style auf einer Map zu spawnen.
Dank dem Wissen von OMWG kann man im Script mehr Waffen als Pickups (und umgedreht) angeben, es funktioniert trotzdem.
Die HUD Icons für die Pickups funktionieren auch wunderbar, jedoch tu ich mir mit den Icons in der Minimap schwer:

Ich bekomme nur ein Icon hin, das sich den zuerst spawnenden Pickup aussucht.
Verwendete Funktion: objective_add(1, "active", origin, level.compass_waypointshader);
Nach Durchlauf des Scripts und respawn einer Waffe wechselt das Icon zum letzt gespawnten Pickup.

Meine Frage wäre:

Wie kann ich am besten die Vars objnum und origin in einen Array packen, damit dynamisch die Icons angezeigt werden, je nach gewählter Anzahl der Pickups?
Beziehungsweise: Was muss ich ändern, um die Vars zu vervielfältigen?

Hier mal mein Fortschritt (In der Funktion trackPickup(pickup, id)):

Code einblendenCode angehängt. Klicke hier zum Ein-/Ausblenden

code:
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:
/*

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 "0"		// Random loadout on first spawn (0=off, 1=on, default=0)

*/	

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", 15, 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", 1, 0, 1, "int");
	level.weapon_minimap 			= dvardef("weapon_minimap", 1, 0, 1, "int");
	level.weapon_rotate 			= dvardef("weapon_rotate", 1, 0, 1, "int");
	level.weapon_random 			= dvardef("weapon_random", 1, 0, 1, "int");
	
	level.weapon_pickupSound 		= "oldschool_pickup";
	level.weapon_respawnSound 		= "oldschool_return";
	
	level.pickupAvailableEffect 	= loadfx("misc/ui_pickup_available");
	level.pickupUnavailableEffect 	= loadfx("misc/ui_pickup_unavailable");
	
	level.waypointshader 			= "objpoint_ammo";
	level.compass_waypointshader 	= "compass_objpoint_ammo";
	
	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]  = "ak47_mp";
	level.weap_name[1]  = "ak74u_mp";
	level.weap_name[2]  = "beretta_mp";
	level.weap_name[3]  = "colt45_mp";
	level.weap_name[4]  = "concussion_grenade_mp";
	level.weap_name[5]  = "frag_grenade_mp";
	level.weap_name[7]  = "m16_mp";
	level.weap_name[8]  = "m40a3_mp";
	level.weap_name[9]	= "mp5_mp";
	level.weap_name[10]	= "remington700_mp";
	level.weap_name[11]	= "rpd_mp";
	level.weap_name[12]	= "saw_mp";
}

weapon_setup(){

	level.weap_coordinates		= [];
	level.weap_angles			= [];
	level.weap_flag				= [];
	
	level.weap_coordinates[0]	= (1069, 2738, 4);
	level.weap_angles[0] 		= (0, 0, 0);
	level.weap_flag[0]	 		= 3;
	
	level.weap_coordinates[1] 	= (1772, 1247, 0);
	level.weap_angles[1] 		= (0, 0, 0);
	level.weap_flag[1] 			= 3;
	
	level.weap_coordinates[2] 	= (3692, 199, 6);
	level.weap_angles[2] 		= (0, 0, 0);
	level.weap_flag[2] 			= 3;
	
	level.weap_coordinates[3] 	= (-40, -2892, -144);
	level.weap_angles[3] 		= (0, 0, 0);
	level.weap_flag[3] 			= 3;
	
	level.weap_coordinates[4]	= (-2684, -875, 58);
	level.weap_angles[4] 		= (0, 0, 0);
	level.weap_flag[4] 			= 3;
	
	level.weap_coordinates[5] 	= (-2897, 511, 8);
	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++){
	
		thread trackPickup(pickups[i], i);
		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();
	
	if(level.weapon_minimap)
		objective_add(1, "active", origin, level.compass_waypointshader);
	
	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_delete(1);
		
		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_add(1, "active", origin, level.compass_waypointshader);
		
		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;
}


ToM
OLD MAN WITH GUN
Hab wenig Zeit und habs nur mal überflogen (und weiß auch nicht, ob das jetzt das ist, was du suchst, oder dir irgendwie weiterhilft).

Du benutzt ja die funktion
Objective_Add( <objective_number>, <state>, <text>, <position>, <iconshader> )

1. <objective_number> The number of the objective to add
2. <state> A string value representing the state of the objective. Valid states are "empty", "active", "invisible", "done", "current" and "failed"
3. <text> The text to use for the objective. This should be a valid localized text reference
4. <position> The position of the objective
5. <iconshader> The objective icon to embed

Du benutzt bei objective_number fest eine 1 (also immer das 1. Objective).
Warum nutzt du nicht die Nummer des Spawnpoints für objective_number?
Du übergibst sie ja sogar schon im Funktionsaufruf.
trackPickup(pickup, id)


Versuch es also doch mal mit (z.B. Zeile 194)
objective_add(id, "active", origin, level.compass_waypointshader);

Edit:
Oder noch anders, erstelle die Objectives gleich mit den Spawns und anstatt sie dauernd zu definieren und zu löschen, ändere doch einfach deren Status
Objective_State( <objective_number>, <state> )
1. <objective_number> The number of the objective to alter
2.<state> A string value representing the state of the objective. Valid states are "empty", "active", "invisible", "done", "current" and "failed"
Nightwing
Perfekt, das war genau das, was gefehlt hat!

Ich habe beim Spawn, auch in der Funkion trackPickup(pickup, id) zuerst das objective mit objective_add zugewiesen.
Von da an verstecke ich es / mache ich es sichtbar mit objective_state(id, "active"); bzw. objective_state(id, "invisible");
Funktioniert bestens!

Code einblendenCode angehängt. Klicke hier zum Ein-/Ausblenden

code:
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:
/*

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 "0"		// Random loadout on first spawn (0=off, 1=on, default=0)

*/	

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", 1, 0, 1, "int");
	level.weapon_minimap 			= dvardef("weapon_minimap", 1, 0, 1, "int");
	level.weapon_rotate 			= dvardef("weapon_rotate", 1, 0, 1, "int");
	level.weapon_random 			= dvardef("weapon_random", 1, 0, 1, "int");
	
	level.weapon_pickupSound 		= "oldschool_pickup";
	level.weapon_respawnSound 		= "oldschool_return";
	
	level.pickupAvailableEffect 	= loadfx("misc/ui_pickup_available");
	level.pickupUnavailableEffect 	= loadfx("misc/ui_pickup_unavailable");
	
	level.waypointshader 			= "objpoint_ammo";
	level.compass_waypointshader 	= "compass_objpoint_ammo";
	
	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]   		= "uzi_silencer_mp";
	level.weap_name[1]   		= "deserteaglegold_mp";
	level.weap_name[2]   		= "m1014_grip_mp";
	level.weap_name[3]  		= "ak47_mp";
	level.weap_name[4]   		= "g36c_reflex_mp";
	level.weap_name[5]   		= "mp5_mp";
}

weapon_setup(){

	level.weap_coordinates		= [];
	level.weap_angles			= [];
	level.weap_flag				= [];
	
	level.weap_coordinates[0]	= (333, -1561, 1500);
	level.weap_angles[0] 		= (0, 0, 0);
	level.weap_flag[0]	 		= 3;
	
	level.weap_coordinates[1] 	= (-983, -975, 1528);
	level.weap_angles[1] 		= (0, 0, 0);
	level.weap_flag[1] 			= 3;
	
	level.weap_coordinates[2] 	= (-909, -4, 1768);
	level.weap_angles[2] 		= (0, 0, 0);
	level.weap_flag[2] 			= 3;
	
	level.weap_coordinates[3] 	= (315, 1017, 1405);
	level.weap_angles[3] 		= (0, 0, 0);
	level.weap_flag[3] 			= 3;
	
	level.weap_coordinates[4]	= (1602, -159, 1533);
	level.weap_angles[4] 		= (0, 0, 0);
	level.weap_flag[4] 			= 3;
	
	level.weap_coordinates[5] 	= (850, 1936, 1520);
	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)
			objective_add(i, "active", pickups[i].origin, level.compass_waypointshader);
			
		thread trackPickup(pickups[i], i);
		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;
	
	weapon thread createwaypoint();

	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;
}


Vielen Dank, OMWG!

ToM
Nightwing
Vorgestern Abend fiel mir zufällig ein Bug auf: Bei Gametypes mit Minimapicons waren die Icons falsch zu sehen.
Ich hab nun die Funktion weapon_think() überarbeitet, sodass sich der pickup eine freie Objektnummer holt:

Code einblendenCode angehängt. Klicke hier zum Ein-/Ausblenden

code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
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;
	}
}


Mein einzigstes Problem ist nun der Modus HQ, da ändert sich nichts am Problem, nur das es jetzt noch schöne Logmessages gibt:

Code einblendenCode angehängt. Klicke hier zum Ein-/Ausblenden

code:
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:
******* script runtime error *******
index 16 is an illegal objective index. Valid indexes are 0 to 15
: (file 'maps/mp/_spawn_weapons.gsc', line 117)
   objective_add(objID, "active", pickups[i].origin, level.compass_waypointshader);
                 *
Error: started from:
(file 'maps/mp/_spawn_weapons.gsc', line 124)
  wait 0.02;
  *
Error: ************************************

******* script runtime error *******
index 17 is an illegal objective index. Valid indexes are 0 to 15
: (file 'maps/mp/_spawn_weapons.gsc', line 117)
   objective_add(objID, "active", pickups[i].origin, level.compass_waypointshader);
                 *
Error: started from:
(file 'maps/mp/_spawn_weapons.gsc', line 124)
  wait 0.02;
  *
Error: ************************************
PunkBuster Server: Game Version [CoD4 MP 1.7 build 568 nightly Wed Jun 18 2008 04:48:38PM win-x86]

******* script runtime error *******
index 18 is an illegal objective index. Valid indexes are 0 to 15
: (file 'maps/mp/gametypes/koth.gsc', line 241)
 objective_add( locationObjID, "invisible", (0,0,0) );
                *
Error: started from:
(file 'maps/mp/gametypes/koth.gsc', line 219)
 wait 5;
 *
Error: ************************************


Ich weiss, das nur 16 Objekte in der Minimap angezeigt werden können (ID 0 - 15) bzw. mehr ID's zu Fehler führen.
Wenn ich mich noch richtig entsinne, kann man in einer Map maximal 7 HQ's setzen.
Ich hab mir mal einen Print mit der Var level.numGametypeReservedObjectives gesetzt, wenn ich eine Waffe aufhebe. Ergebnis: 19
Jetzt die Frage: Woher kommen die 19 ID's, wenn 7 HQ's + 6 Weapons zusammen 13 ID's sind verwirrt
Minimapicons hab ich vorübergehend mal deaktiviert, aber ich fürchte, das ich die bei HQ nicht nutzen kann. Teufel

ToM

EDIT: Problem gelöst:

Ich hab das Script dahingehend geändert, das bei den entsprechenden Gametypes die Compassicons automatisch deaktiviert werden, stattdessen werden die HUD Icons eingeblendet:

Code einblendenCode angehängt. Klicke hier zum Ein-/Ausblenden

code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
	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;
	}