RudyPoo 10 Posted December 2, 2013 (edited) I'm trying to have this create 10 soldiers but it's only creating one and then stopping. It does perform the execvm on that's init, and he will chase me when he sees me but it will only spawn that 1. SHK_pos\shk_pos_init.sqf refers to this script http://forums.bistudio.com/showthread.php?162695 init.sqf call compile preprocessfile "SHK_pos\shk_pos_init.sqf"; pmoney = 0; alive_zombies = 0; zcount = 0; centerRes = createCenter resistance; centerLogic = createCenter sideLogic; ZSpawnGRP = createGroup resistance; //spawned units required a group to join on creation null = [] execVM "zombiespawn.sqf"; zombiespawn.sqf sleep 1; while {alive player} do { //runs while the player is alive if (alive_zombies < 10) then { //if amount of alive zombies is less than this number it spawns another pos = [player,25,random 360,0,[0],50] call SHK_pos; sleep 1; null = "I_soldier_F" createUnit [pos,ZSpawnGRP,format ["_zombie%1 = this; [_zombie%2] execVM 'zombies.sqf';",zcount,zcount],1,"PRIVATE"]; alive_zombies = alive_zombies + 1; //tells the variable another zombie was created zcount = zcount + 1; sleep 0.1; }; sleep 1; }; zombies.sqf (Thanks to [FOCK] MIKIE J for the majority of zombie.sqf) quitscript=0; _zombie = _this select 0; sleep 1; removeAllWeapons _zombie; _zombie addEventHandler["killed",{pmoney = pmoney + 25; hint format ["Zombie Killed! (+$25) - Total: $%1",pmoney];}]; _zombie allowFleeing 0; //prevents them from running away _zombie addRating -10000; //makes sure everyone wants to kill them _zombie setBehaviour "CARELESS"; //zombies they do what they want [_zombie] joinSilent grpNull; //removes the zombie from the spawn group followdude = { _killer = _this select 0; _tokill = _this select 1; while {position _tokill distance _killer > 150 && alive _zombie} do { _killer doMove (getPos _tokill); _zombie setSpeedMode "LIMITED"; sleep 1; }; }; sleep 0.2; //this runs whilst zombie is alive while {alive _zombie} do { _searchtarget = _zombie nearEntities 350; sleep 1; {if (isPlayer _x) then { _kv = _zombie knowsAbout _x; //does the AI actually see the target sleep 1; if (_kv >= 1) then { _zombie doMove (getPos _x); sleep 1; [_zombie, _x]call followdude; waitUntil {position _x distance _zombie <= 150}; if (quitscript == 0) then { _zombie setSpeedMode "FULL"; sleep 1; if (_zombie distance player < 2) then { _X setDamage +0.25; }; }; }; }; } forEach _searchtarget; sleep 1; }; Edited December 2, 2013 by RudyPoo Share this post Link to post Share on other sites
iceman77 18 Posted December 2, 2013 (edited) After tinkering, this is what I came up with. Initially showed only how to create units properly, then it snowballed into a sort of mini project lol. Hope it helps. init.sqf: pMoney = 0; call compile PreProcessFile "functions.sqf"; [] spawn TAG_FNC_Zombie; functions.sqf: TAG_fnc_playerMoney = { pMoney = pMoney + 25; hint format ["Zombie Killed! (+$25) - Total: $%1",pMoney]; }; TAG_FNC_Zombie = { _grp = createGroup resistance; for "_i" from 0 to 10 - 1 do { _spawnPos = [player, 10 + (random 15), random 360] call BIS_fnc_relPos; _unit = _grp createUnit ["I_soldier_F", _spawnPos, [], 0, "FORM"]; }; { _x addEventHandler["killed",{call TAG_fnc_playerMoney}]; _x allowFleeing 0; _x addRating -10000; _x setBehaviour "CARELESS"; _x setSpeedMode "FULL"; removeAllWeapons _x; [_x] joinSilent grpNull; } forEach units _grp; while {{alive _x && typeOf _x == "I_soldier_F"} count allUnits > 0} do { { if (typeOf _x == "I_soldier_F" && {_x distance player < 125}) then { _x doMove getPosATL player; if (_x distance player < 2) then { player setDamage damage player + (0.25); }; }; } forEach allUnits; sleep 3; }; }; Edited December 2, 2013 by Iceman77 Using createUnit instead of createVehicle might help LOL Share this post Link to post Share on other sites
iceman77 18 Posted December 2, 2013 Updated it a bit. If it's not useful in it's entirety, you can at least see how I spawned the units. Cheers. Share this post Link to post Share on other sites
mikie boy 18 Posted December 2, 2013 Glad u made use of the follow script :) Share this post Link to post Share on other sites
iceman77 18 Posted December 2, 2013 (edited) Hey Mikie. I hadn't realized you wrote the guy's follow script. Probably better than the one I presented in any case lol. Was bored and decided to write one of my own. Well it started out as just showing how to properly create the units.. then kind of snowballed from there, into a mini project haha. Probably not worth a shit though, I've not put to much testing into it. Edited December 2, 2013 by Iceman77 Share this post Link to post Share on other sites
mikie boy 18 Posted December 2, 2013 Lol, I was just talking about the follow player bit. Taken from that suicide bomber one I made in A2. It needs line intersect command of similar to work better. Share this post Link to post Share on other sites
RudyPoo 10 Posted December 3, 2013 Here is where I'm at so far with the script/mission. Right now it's just showing a concept for it. You're a lone soldier with only a pistol. Zombies will always gravitate towards your position. They don't ever stop coming. You receive $25 dollars for each zombie killed. You can spend this money at the store (a big box next to a decommissioned truck). Pistol Mags $5, Rifle Mags $30, Rifle $500. I'm going to add in a lot more items to the store, as well as the ability to upgrade your home base so it's safer for you. You'll be able to find vehicles and survivors out in the wild. The survivors will join your group and fight with you once you find them. Then after all that's done I'd like to add another survival group as "bad guys" who you'll have to keep an eye out for when venturing out of your base. I uploaded both the sqf files and the pbo if you want to check it out: http://dropcanvas.com/rek8i init.sqf //Big thanks to Mikie boy and Iceman77 for their help! pMoney = 0; call compile PreProcessFile "functions.sqf"; [] spawn TAG_FNC_Zombie; removeallweapons player; player addmagazine "16Rnd_9x21_Mag"; player addmagazine "16Rnd_9x21_Mag"; player addmagazine "16Rnd_9x21_Mag"; player addweapon "hgun_P07_F"; functions.sqf TAG_fnc_playerMoney = { pMoney = pMoney + 25; hint format ["Zombie Killed! (+$25) - Total: $%1",pMoney]; }; Tag_fnc_Store_PistolAmmo = { player addItemToUniform "16Rnd_9x21_Mag"; pmoney = pmoney - 5; hint format ["Pistol Ammo (-$5) - Total: $%1",pMoney]; }; Tag_fnc_Store_RifleAmmo = { player addItemToUniform "30Rnd_65x39_caseless_mag"; pmoney = pmoney - 30; hint format ["Rifle Ammo (-$30) - Total: $%1",pMoney]; }; Tag_fnc_Store_Rifle = { player addWeapon "arifle_MX_ACO_pointer_F"; pmoney = pmoney - 500; purchase_rifle = 1; hint format ["Rifle (-$500) - Total: $%1",pMoney]; }; Tag_fnc_OpenUpShop = { if (pmoney >= 5) then {0 = player addAction ["Buy 1 Pistol Magazine $5", {call TAG_fnc_Store_PistolAmmo}]}; if (pmoney >= 30 && purchase_rifle == 1) then {1 = player addAction ["Buy 1 Rifle Magazine $30", {call TAG_fnc_Store_RifleAmmo}]}; if (pmoney >= 500 && purchase_rifle == 0) then {2 = player addAction ["Upgrade to Rifle $500", {call TAG_fnc_Store_Rifle}]}; }; TAG_FNC_Zombie_ReSpawn = { sleep 5; _grp = createGroup resistance; for "_i" from 0 to 0 do { _spawnPos = [player, 100 + (random 150), random 360] call BIS_fnc_relPos; _unit = _grp createUnit ["I_soldier_F", _spawnPos, [], 0, "FORM"]; }; { _x addEventHandler["killed",{call TAG_fnc_playerMoney; call TAG_FNC_Zombie_ReSpawn;}]; _x allowFleeing 0; _x addRating -10000; _x setBehaviour "CARELESS"; _x setSpeedMode "FULL"; removeAllWeapons _x; [_x] joinSilent grpNull; } forEach units _grp; }; TAG_FNC_Zombie = { _grp = createGroup resistance; for "_i" from 0 to 10 - 1 do { _spawnPos = [player, 100 + (random 150), random 360] call BIS_fnc_relPos; _unit = _grp createUnit ["I_soldier_F", _spawnPos, [], 0, "FORM"]; }; { _x addEventHandler["killed",{call TAG_fnc_playerMoney; call TAG_FNC_Zombie_ReSpawn;}]; _x allowFleeing 0; _x addRating -10000; _x setBehaviour "CARELESS"; _x setSpeedMode "FULL"; removeAllWeapons _x; [_x] joinSilent grpNull; } forEach units _grp; while {{alive _x && typeOf _x == "I_soldier_F"} count allUnits > 0} do { { if (typeOf _x == "I_soldier_F") then { _x doMove getPosATL player; _x forceSpeed 1.12; _kv0 = _x knowsAbout player; if (_x distance player < 60 && _kv0 >= 1) then { _x doMove getPosATL player; _x forceSpeed -1; _x setSpeedMode "LIMITED"; _kv1 = _x knowsAbout player; if (_x distance player < 25 && _kv1 >= 1) then { _x doMove getPosATL player; _x setSpeedMode "FULL"; if (_x distance player < 2) then { player setDamage damage player + (0.25); }; }; }; }; } forEach allUnits; sleep 3; }; }; mission.sqm version=12; class Mission { addOns[]= { "A3_Characters_F_BLUFOR", "a3_map_stratis", "A3_Structures_F_Mil_Fortification", "A3_Structures_F_EPA_Mil_Scrapyard", "A3_Signs_F" }; addOnsAuto[]= { "A3_Characters_F_BLUFOR", "A3_Structures_F_Mil_Fortification", "A3_Structures_F_EPA_Mil_Scrapyard", "A3_Signs_F", "a3_map_stratis" }; randomSeed=830043; class Intel { briefingName="DevZombies"; overviewText="Rudy Poo's Zombies! Development Version"; resistanceWest=0; startWeather=0.29999998; startWind=0.099999994; startWaves=0.099999994; forecastWeather=0.29999998; forecastWind=0.099999994; forecastWaves=0.099999994; forecastLightnings=0.099999994; year=2035; month=7; day=6; hour=12; minute=0; startFogDecay=0.013; forecastFogDecay=0.013; }; class Groups { items=1; class Item0 { side="WEST"; class Vehicles { items=1; class Item0 { position[]={2445.0547,73.760933,5675.9341}; azimut=-200.40601; id=0; side="WEST"; vehicle="B_soldier_M_F"; player="PLAYER COMMANDER"; leader=1; rank="SERGEANT"; skill=1; }; }; }; }; class Vehicles { items=10; class Item0 { position[]={2425.5227,73.108841,5683.7471}; azimut=-90; special="NONE"; id=1; side="EMPTY"; vehicle="Land_HBarrier_3_F"; leader=1; skill=1; }; class Item1 { position[]={2425.5227,73.203308,5681.8921}; azimut=-90; special="NONE"; id=2; side="EMPTY"; vehicle="Land_HBarrier_1_F"; leader=1; skill=1; }; class Item2 { position[]={2425.5354,73.169189,5682.6304}; azimut=-90; special="NONE"; id=3; side="EMPTY"; vehicle="Land_HBarrier_1_F"; leader=1; skill=1; }; class Item3 { position[]={2471.4634,73.749237,5687.1104}; azimut=-56.116432; special="NONE"; id=4; side="EMPTY"; vehicle="Land_HBarrier_1_F"; leader=1; skill=1; }; class Item4 { position[]={2447.0701,73.08699,5666.3301}; azimut=114.128; special="NONE"; id=5; side="EMPTY"; vehicle="Land_Scrap_MRAP_01_F"; skill=1; }; class Item5 { position[]={2464.9666,73.971039,5651.7964}; azimut=179.95645; special="NONE"; id=6; side="EMPTY"; vehicle="Land_Sign_WarningMilitaryArea_F"; skill=1; }; class Item6 { position[]={2489.9822,73.519051,5685.4302}; azimut=83.436203; special="NONE"; id=7; side="EMPTY"; vehicle="Land_Sign_WarningMilitaryArea_F"; skill=1; }; class Item7 { position[]={2467.0703,73.790695,5669.6743}; azimut=203.49081; special="NONE"; id=8; side="EMPTY"; vehicle="Land_Razorwire_F"; skill=1; }; class Item8 { position[]={2472.7629,73.752029,5679.606}; azimut=216.36122; special="NONE"; id=9; side="EMPTY"; vehicle="Land_Razorwire_F"; skill=1; }; class Item9 { position[]={2448.2312,73.392677,5668.394}; azimut=114.128; special="NONE"; id=10; side="EMPTY"; vehicle="Land_PaperBox_open_full_F"; skill=1; }; }; class Markers { items=2; class Item0 { position[]={2473.0752,73.785309,5672.8022}; name="gate1"; type="Empty"; angle=124.14693; }; class Item1 { position[]={2448.073,73.364197,5668.1338}; name="Store"; text="Purchase Upgrades/Weapons"; markerType="ELLIPSE"; type="Empty"; colorName="ColorOrange"; fillName="FDiagonal"; a=3; b=3; }; }; class Sensors { items=1; class Item0 { position[]={2448.0957,73.36396,5668.1152}; a=3; b=3; activationBy="VEHICLE"; repeating=1; interruptable=1; age="UNKNOWN"; idVehicle=0; expActiv="call Tag_fnc_OpenUpShop;"; expDesactiv="removeAllActions player;"; class Effects { }; }; }; }; class Intro { addOns[]= { "a3_map_stratis" }; addOnsAuto[]= { "a3_map_stratis" }; randomSeed=12716975; class Intel { timeOfChanges=1800.0002; startWeather=0.30000001; startWind=0.1; startWaves=0.1; forecastWeather=0.30000001; forecastWind=0.1; forecastWaves=0.1; forecastLightnings=0.1; year=2035; month=7; day=6; hour=12; minute=0; startFogDecay=0.013; forecastFogDecay=0.013; }; }; class OutroWin { addOns[]= { "a3_map_stratis" }; addOnsAuto[]= { "a3_map_stratis" }; randomSeed=14227633; class Intel { timeOfChanges=1800.0002; startWeather=0.30000001; startWind=0.1; startWaves=0.1; forecastWeather=0.30000001; forecastWind=0.1; forecastWaves=0.1; forecastLightnings=0.1; year=2035; month=7; day=6; hour=12; minute=0; startFogDecay=0.013; forecastFogDecay=0.013; }; }; class OutroLoose { addOns[]= { "a3_map_stratis" }; addOnsAuto[]= { "a3_map_stratis" }; randomSeed=9630303; class Intel { timeOfChanges=1800.0002; startWeather=0.30000001; startWind=0.1; startWaves=0.1; forecastWeather=0.30000001; forecastWind=0.1; forecastWaves=0.1; forecastLightnings=0.1; year=2035; month=7; day=6; hour=12; minute=0; startFogDecay=0.013; forecastFogDecay=0.013; }; }; Share this post Link to post Share on other sites