Call of Duty: Modern Warfare 2 (2009)

Call of Duty: Modern Warfare 2 (2009)

檢視統計資料:
Soap 2020 年 6 月 17 日 下午 9:26
Spawning friendly AI in Singleplayer (finally found it)
I found a mod, actually a npc spawner script for MW2. I installed the mod and result was what i had in my mind as a dream, i was able to spawn friendy npcs in story missions.

Mod page for NPC Spawner; https://cabconmodding.com/threads/mw2-singleplayer-spec-ops-modloader.2481/
Bot Spawner Script(Old); https://cabconmodding.com/attachments/bot_spawning_test_script-rar.3802/
Bot Spawner Script (Updated); see post comments below for this

How the NPC spawner works in the game? (Old Script)
-When you press X, spawner gives you a random ai/npc from current mission, NPCs are spawning randomly, there is no spawn order or spawn select. To spawn friendly ai/npcs, there should be friendly npc in the mission you are playing. Example; you can spawn General Shepherd in first mission and have him fighting on your side, becuse he appears in the mission normally, but you can't spawn Ghost because he never appears in first mission.

Important Update: There is an updated AI Spawner script and now it spawns only friendlies(Rangers/Task Force etc.) and friendly AI will follow you and take cover. Go to this post's comments below, I explained how to install the updated script. You can still find the old AI Spawner script at cabconmodding website from the link above if you scroll down the page.

Installation Guide:

1. Download d3d9.dll from modloader page above. Copy it to your main game folder.

2. Download iw4sp.exe from modloader page and change it with your current one in main game folder.

3. In main game folder launch the game from iw4sp.exe you downloaded, start a mission and play until game autosaves and exit the game. In your main game folder, there should be a new folder named "ccm_data".

4. Download bot spawner script from link above, open it and copy "maps" file, go into "ccm_data" and paste it there. It should look like this;

ccm_data/maps/_load.gsc
ccm_data/maps/test_script.gsc

5. You are ready to go, always launch the game from iw4sp.exe in your main game folder. After launching the game, open any mission, there should be a text on screen "press X to spawn bots on crosshair"

6. (Optional) You can make the text disappear that says "press x to spawn bots". Go to ccm_data/maps/test_script.gsc Make backup first and open it with notepad. Remove every line starting with "self.info_text" then save and exit. Text on screen should be gone in the game.

7. (Optional) If you want AI to stop following you and fight on their own, go to ccm_data/maps/test_script gsc. Open it with notepad and delete all instances of playerseek and
setgoalentity( level.player ).

8. (Turn Enemies to Friendly NPCs/Optional/Works with Old Spawner) Thanks to @Pol You can now make all spawning NPCs friendly, enemies and even enemy dogs can fight for you . . . Spawns are still random, you can't choose to spawn Task Force or Rangers. Spawner will give you enemy models too, but they will not attack you, they will be friendly and will fight for you. You can skip this step, if you skip, Spawner will give you spawns randomly, you will get enemy and friendlies but mostly enemy. Here is what you should do for friendly NPC from @Pol's own words;

Go to MW2\ccm_data\maps\test_script.gsc and open it with notepad
- Look for "bot = spawners[number] stalingradspawn();" without the quotes of course.
- Add the following text below it: bot.team = "allies";
- Make sure it looks like this: https://i.gyazo.com/4badcacbf943c19d788eafd1e171c570.png

If you have trouble launching the game after copying mod files, download iw4sp.exe from modloader page and change it with your current one in main game folder.
I am using steam version and i had an error after copying mod files, couldn't launch the game, but after i downloaded iw4sp.exe and copied it to my main game folder, it was fixed for me, remember to always launch the game from this iw4sp.exe in your main folder.
最後修改者:Soap; 2023 年 12 月 18 日 上午 12:34
< >
目前顯示第 1-12 則留言,共 12
vlad[54rus] 2020 年 6 月 17 日 下午 11:19 
Nice work
Soap 2020 年 6 月 17 日 下午 11:20 
引用自 vlad54rus
Nice work
Thanks man, if you like npc spawning stuff consider subscribing to my channel, my videos are all about npc battles and having fun with watching them.
最後修改者:Soap; 2020 年 6 月 17 日 下午 11:32
Soap 2020 年 7 月 7 日 上午 12:34 
Anyone tried this on MW3? It should be working on both games, haven't tested MW3 personally.
最後修改者:Soap; 2020 年 7 月 7 日 上午 12:34
Moolissa 2020 年 7 月 26 日 下午 9:47 
Thats cool i guess it would make the game easier right? lol
Soap 2020 年 7 月 28 日 上午 4:48 
引用自 Dancing Kappa
Thats cool i guess it would make the game easier right? lol
Not necessarily. You can spawn enemy AI too! :WTL_Cat_Happy:
storm/eagle 2021 年 9 月 11 日 上午 9:17 
Dude do you mind to tell me how..it said the link has been removed.. i really want to make npc battle on mw3
Soap 2021 年 9 月 11 日 上午 11:15 
引用自 storm/eagle
Dude do you mind to tell me how..it said the link has been removed.. i really want to make npc battle on mw3
This is not for MW3, for MW2 go to the tutorial link in the description. All links in the tutorial video works.
Heavani 2023 年 12 月 17 日 下午 10:31 
The file for edited one got deleted
Soap 2023 年 12 月 18 日 上午 12:13 
引用自 Heavani
The file for edited one got deleted

So to get the updated AI Spawner with friendly NPCs that can follow you and take cover, first complete all the steps above in the guide. Then go to ccm_data/maps/test_script.gsc, open the test_script.gsc and delete everything inside and paste everything below inside that file:


#include common_scripts\utility;
#include maps\_utility;
#include maps\_debug;
#include maps\_vehicle;
#include maps\_hud_util;

init()
{
player1 = level.players[0];
player1 thread spawnBotBind();
player1 thread spawnBotBind2();
}

spawnBotBind()
{
for(;;)
{
if(self ButtonPressed("v"))
{
self doBotSpawn();
iprintln("^1FRIENDLY BOT SPAWNED");
wait .4;
}
wait 0.05;
}
}

spawnBotBind2()
{
for(;;)
{
if(self ButtonPressed("<"))
{
self doBotSpawn2();
iprintln("^1ENEMY BOT SPAWNED");
wait .4;
}
wait 0.05;
}
}

doBotSpawn()
{
//Get Spawners
spawners = GetSpawnerTeamArray( "allies" );

wait .2;

//Get Random Spawner Number
number = randomInt(spawners.size);

//Save Original pos for Current Spawner
pos_original = spawners[number].origin;

//Change Current Spawner pos to crosshair pos
spawners[number].origin = self getCursorPos();

//Spawn Bot
spawners[number].script_forcespawn = true;//force spawner to stalingradspawn ai
spawners[number].fixednode = false;
spawners[number].script_forcegoal = true;
spawners[number].script_playerseek = undefined;
spawners[number].script_pacifist = undefined;//ai only attacks after you hurt it
spawners[number].script_ignoreme = true;//ai ignores player
spawners[number].script_moveoverride = false;
spawners[number].script_patroller = false;
spawners[number].script_stealth = true;
spawners[number].script_startrunning = undefined;
spawners[number].count = 9999;
spawners[number] magic_bullet_shield();
spawners[number] setthreatbiasgroup( "allies" );
bot = spawners[number] stalingradspawn();
bot.team = "allies";
bot.script_forcegoal = true;
bot.script_playerseek = undefined;//ai runs to player
bot.goalradius = 500;
bot setgoalentity ( level.player );

wait .2;

//Change Current Spawner pos back to original
spawners[number].origin = pos_original;
}

doBotSpawn2()
{
//Get Spawners
spawners = GetSpawnerArray();

wait .2;

//Get Random Spawner Number
number = randomInt(spawners.size);

//Save Original pos for Current Spawner
pos_original = spawners[number].origin;

//Change Current Spawner pos to crosshair pos
spawners[number].origin = self getCursorPos();

//Spawn Bot
spawners[number].script_forcespawn = true;//force spawner to stalingradspawn ai
spawners[number].fixednode = false;
bot = spawners[number] spawn_ai();
spawners[number].fixednode = false;
spawners[number].script_forcegoal = true;
spawners[number].script_playerseek = false;
spawners[number].goalradius = 500;
spawners[number].script_pacifist = false;//ai only attacks after you hurt it
spawners[number].script_moveoverride = false;
spawners[number].count = 9999;
spawners[number] magic_bullet_shield();
spawners[number] setthreatbiasgroup( "allies" );
bot.script_forcegoal = true;
bot.script_playerseek = false;//ai runs to player
bot.goalradius = 500;

wait .2;

//Change Current Spawner pos back to original
spawners[number].origin = pos_original;
}



getCursorPos(multiplier)
{
if(!isDefined(multiplier))
{
multiplier = 1000000;
}
angle_forward = AnglesToForward(self getPlayerAngles());
multiplied_vector3 = angle_forward * multiplier;
return BulletTrace(self getEye(),self getEye()+multiplied_vector3,false,self)["position"];
}
最後修改者:Soap; 2023 年 12 月 18 日 上午 12:24
Soap 2023 年 12 月 18 日 上午 12:35 
So to get the updated AI Spawner with friendly NPCs that can follow you and take cover, first complete all the steps above in the guide. Then go to ccm_data/maps/test_script.gsc, open the test_script.gsc and delete everything inside and paste everything below inside that file:


#include common_scripts\utility;
#include maps\_utility;
#include maps\_debug;
#include maps\_vehicle;
#include maps\_hud_util;

init()
{
player1 = level.players[0];
player1 thread spawnBotBind();
player1 thread spawnBotBind2();
}

spawnBotBind()
{
for(;;)
{
if(self ButtonPressed("v"))
{
self doBotSpawn();
iprintln("^1FRIENDLY BOT SPAWNED");
wait .4;
}
wait 0.05;
}
}

spawnBotBind2()
{
for(;;)
{
if(self ButtonPressed("<"))
{
self doBotSpawn2();
iprintln("^1ENEMY BOT SPAWNED");
wait .4;
}
wait 0.05;
}
}

doBotSpawn()
{
//Get Spawners
spawners = GetSpawnerTeamArray( "allies" );

wait .2;

//Get Random Spawner Number
number = randomInt(spawners.size);

//Save Original pos for Current Spawner
pos_original = spawners[number].origin;

//Change Current Spawner pos to crosshair pos
spawners[number].origin = self getCursorPos();

//Spawn Bot
spawners[number].script_forcespawn = true;//force spawner to stalingradspawn ai
spawners[number].fixednode = false;
spawners[number].script_forcegoal = true;
spawners[number].script_playerseek = undefined;
spawners[number].script_pacifist = undefined;//ai only attacks after you hurt it
spawners[number].script_ignoreme = true;//ai ignores player
spawners[number].script_moveoverride = false;
spawners[number].script_patroller = false;
spawners[number].script_stealth = true;
spawners[number].script_startrunning = undefined;
spawners[number].count = 9999;
spawners[number] magic_bullet_shield();
spawners[number] setthreatbiasgroup( "allies" );
bot = spawners[number] stalingradspawn();
bot.team = "allies";
bot.script_forcegoal = true;
bot.script_playerseek = undefined;//ai runs to player
bot.goalradius = 500;
bot setgoalentity ( level.player );

wait .2;

//Change Current Spawner pos back to original
spawners[number].origin = pos_original;
}

doBotSpawn2()
{
//Get Spawners
spawners = GetSpawnerArray();

wait .2;

//Get Random Spawner Number
number = randomInt(spawners.size);

//Save Original pos for Current Spawner
pos_original = spawners[number].origin;

//Change Current Spawner pos to crosshair pos
spawners[number].origin = self getCursorPos();

//Spawn Bot
spawners[number].script_forcespawn = true;//force spawner to stalingradspawn ai
spawners[number].fixednode = false;
bot = spawners[number] spawn_ai();
spawners[number].fixednode = false;
spawners[number].script_forcegoal = true;
spawners[number].script_playerseek = false;
spawners[number].goalradius = 500;
spawners[number].script_pacifist = false;//ai only attacks after you hurt it
spawners[number].script_moveoverride = false;
spawners[number].count = 9999;
spawners[number] magic_bullet_shield();
spawners[number] setthreatbiasgroup( "allies" );
bot.script_forcegoal = true;
bot.script_playerseek = false;//ai runs to player
bot.goalradius = 500;

wait .2;

//Change Current Spawner pos back to original
spawners[number].origin = pos_original;
}



getCursorPos(multiplier)
{
if(!isDefined(multiplier))
{
multiplier = 1000000;
}
angle_forward = AnglesToForward(self getPlayerAngles());
multiplied_vector3 = angle_forward * multiplier;
return BulletTrace(self getEye(),self getEye()+multiplied_vector3,false,self)["position"];
}
zachksmith 2024 年 7 月 13 日 下午 2:37 
can i make the friendlies invincible? ik this is old but if you respond would be much appreciated
does it work for Call of Duty World at War, just asking.
< >
目前顯示第 1-12 則留言,共 12
每頁顯示: 1530 50