Call of Duty 4: Modern Warfare

Hier findest Du einige Scripte, die ich mithilfe anderer grossartiger Scripter geändert und zusammengetragen habe. Desweiteren finden sich hier diverse Anleitungen, die für Serveradmins gedacht sind.

Waffen im Oldschool Style auf der Map spawnen

Dank -tiger- und seiner Map Gold Rush kam mir die Idee, Waffen im Oldschool Style auf einer Map spawnen zu lassen. OLD MAN WITH GUN hat das Script noch technisch optimiert (Arrays eingefügt) und der erste Spawn der Waffen kann zufällig erfolgen. Danke dafür!

Bei manch Gametype funktionieren die Compass Icons nicht, es wird automatisch auf die HUD Icons umgeschaltet!

Bild einer Waffe, die im Pickup vorhanden ist Bild einer Waffe, die im Pickup vorhanden nicht ist

Das einbauen in eine Map ist nicht schwer:

Als erstes kommt folgende DVAR Abfrage in Eure mp_deinemap.gsc dazu:

de:
1:
2:
3:
4:
5:
6:
// Weapon Spawn Oldschool Style
if(getdvar("weapon_mp_dein_mapname") == "")
setdvar("weapon_mp_dein_mapname", "0");
if(getdvar("weapon_mp_dein_mapname") == "1")
thread maps\mp\_spawn_weapons::main();
mp_deinemap.gsc
// Weapon Spawn Oldschool Style
    if(getdvar("weapon_mp_dein_mapname") == "")
        setdvar("weapon_mp_dein_mapname", "0");
    if(getdvar("weapon_mp_dein_mapname") == "1")
        thread maps\mp\_spawn_weapons::main();

Kopiere folgendes Script unter dem Namen _spawn_weapons.gsc in Deinen Ordner "/raw/maps/mp". Füge die Datei "rawfile,maps/mp/_spawn_weapons.gsc" in Dein Zone File ein.

_spawn_weapons.gsc

Code eingefügt. Hier klicken zum Ein- / Ausblenden
/*
 
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;
}

Für die Serverconfig gibt es dann noch folgende DVAR's:

serverconfig.cfg
set weapon_mp_your_mapname "1"                // Waffen aktivieren / deaktivieren (0=off, 1=on, default=1)
set weapon_respawn_mp_your_mapname "150"    // Wieviele Sekunden bis zum nächsten Respawn (min=30, max=300, default 150)
set weapon_pickupFX_mp_your_mapname "1"        // FX Effekt am Spawn (0=off, 1=on, default=1)
set weapon_soundFX_mp_your_mapname "1"        // Sound am Spawn (0=off, 1=on, default=1)
set weapon_objpoints_mp_your_mapname "1"    // Zeigt Objekt Icons im HUD (0=off, 1=on, default=1)
set weapon_minimap_mp_your_mapname "1"        // Zeigt Objekt Icons in der Minimap (0=off, 1=on, default=1)
set weapon_rotate_mp_your_mapname "1"        // Rotierende Waffe im Spawn (0=off, 1=on, default=1)
set weapon_random_mp_your_mapname "0"        // Zufallsloadout der Waffen beim ersten Spawn (0=off, 1=on, default=0)

Das mp_your_mapname in der DVAR ersetzt Ihr durch den Namen Eurer Map.

Man kann die Variablen für die cfg auch nach Gametype variieren.
Möchte man z.B. keine Waffen beim Gametype SD, gibt man folgendes zusätzlich in der cfg an:

set weapon_mp_your_mapname_sd "0"

Die Koordinaten für die Spawnpunkte findet Ihr ganz einfach raus:

Starte die Map und laufe an die Stelle, wo später die Waffe spawnen soll.
Öffne die Konsole und gib /viewpos ein.
Öffne dann die grosse Konsole und schreib Dir die Koordinaten auf, die in diesem Muster erscheinen: (X, Y ,Z)
Von der Z Koordinate noch 60 subtrahieren, da die Koordinate auf Augenhöhe des Spielers gemacht wird, wir aber den Boden benötigen.
Im Script in den Array eintragen und fertig.

Wichtiger Hinweis:

Solltet Ihr eigene Waffen bzw. Waffen aus dem Singleplayer einbauen, müssen die weaponfiles in eine zusätzliche IWD gepackt werden (z_mp_mapname.iwd).
Diese IWD muss zwingend im Modordner sein, da es sonst zu Downloadloops kommen kann (insbesondere bei Base- Homepathinstallationen).
Falls Ihr einen globalen Modordner (z.B. ace) nutzt, dürfen diese Waffen nicht verwendet werden, da Clients auf anderen Server wegen der zusätzlichen IWD gekickt werden.
Deshalb bitte einen eigenen, individuell benannten Modordner anlegen.

Viel Spass!

 

Direkt verlinken: https://opferlamm-clan.de/wbb2/thread.php?postid=132023#post132023/

Zurück