Texedova 1 Posted November 29, 2013 Hello people, I made this simple zombie script but it seems that the zombie (blufor soilder) doesn't move at all. He slightly turns to face me, but that's all he does. Please help me as soon as possible. Thank you so much in advance. Code: #start ?(not alive _zomb): exit _zomb = _this select 0; if(_zomb distance player <25 and alive _zomb) then {_zomb domove getpos player;} else {}; goto "start" Share this post Link to post Share on other sites
wok 1 Posted November 29, 2013 Are you running this code in a .sqf or a .sqs file? Also always check your .rpt log file for errors, in Win 7 its in :/Users/youruser/AppData/Local/Arma 3/ Share this post Link to post Share on other sites
Texedova 1 Posted November 29, 2013 (edited) I am running a .sqs file. And also I am sorry, i'm not sure what to check for in the .rpt. to initialize the code i have the the following line in the init of a blufor soilder. [this] exec "zombie.sqs"; Edited November 29, 2013 by Texedova Share this post Link to post Share on other sites
iceman77 19 Posted November 30, 2013 (edited) [this] execVM "zombie.sqf"; _zomb = _this select 0; while {alive _zomb} do { if (_zomb distance player < 25 && {alive _zomb}) then { _zomb doMove getPosATL player; }; sleep 5; }; Edited November 30, 2013 by Iceman77 Share this post Link to post Share on other sites
Texedova 1 Posted November 30, 2013 [this] execVM "zombie.sqf"; _zomb = _this select 0; while {alive _zomb} do { if (_zomb distance player < 25 && {alive _zomb}) then { _zomb doMove getPosATL player; }; sleep 5; }; Thank you for replying, but how do i use [this] execVM "zombie.sqf"; in the init of a unit. It was giving an error saying "Type Script, Expected Nothing"? Share this post Link to post Share on other sites
iceman77 19 Posted November 30, 2013 yes sorry. Use: _nul = [this] execVM "zombie.sqf" Share this post Link to post Share on other sites
Texedova 1 Posted November 30, 2013 yes sorry. Use: _nul = [this] execVM "zombie.sqf" It's okay. But now i am getting preprocessor failed..............error 7. Share this post Link to post Share on other sites
iceman77 19 Posted November 30, 2013 sec , I'll go run a test and sort it out. Share this post Link to post Share on other sites
Texedova 1 Posted November 30, 2013 ok thank you so much Share this post Link to post Share on other sites
iceman77 19 Posted November 30, 2013 Okay, just tested with the following and it works fine: unit init line: (nato rifleman) _nul = [this] execVM "zombie.sqf"; zombie.sqf _zomb = _this select 0; while {alive _zomb} do { if (_zomb distance player < 25 && {alive _zomb}) then { _zomb doMove getPosATL player; }; sleep 5; }; Share this post Link to post Share on other sites
Texedova 1 Posted November 30, 2013 ok now it's working, thank you heaps. I would like the zombie to attack the player as well. If it put the following would it work? _zomb = _this select 0; while {alive _zomb} do { if (_zomb distance player < 25 && {alive _zomb}) then { _zomb doMove getPosATL player; }; sleep 5; if(_zomb distance player <2 && {alive _zomb}) then { zomb switchmove "AwopPercMstpSgthWnonDnon_End" player setDammage +0.2; }; }; Share this post Link to post Share on other sites
iceman77 19 Posted November 30, 2013 Looks like that would work. You've one small typo in the switchMove statement. It should be _zomb and not zomb. Aside from that, I'm not sure how it will work in conjunction with the animation, but the concept you have is good. It may even work great with the animation though. You can decrease the sleep too, to 1 second to have him constantly charge when you're in range. kind regards, iceman77 Share this post Link to post Share on other sites
Texedova 1 Posted November 30, 2013 Ok. Now i've got a simple attack working. I'm running the attack from another file called "Bite.sqf". It looks like _zomb = _this select 0; while {alive _zomb} do { if(_zomb distance player < 2 && {alive _zomb}) then { _zomb say "zombie_attack_2"; player setDammage +0.2; player say "ouch"; }; sleep 2; }; The problem is, the sound does play over and over if i'm within 2m of the zombie. But, my character only takes damage once. Even if i go out of range and come back in. Please help. Thank you in advance. Also, I'm really sorry to keep bothering you Iceman77. Share this post Link to post Share on other sites
mikie boy 18 Posted November 30, 2013 An old script - not tested of late - but it did work when i used it for suicide bombers - added your attack bit May help you along the way - new commands have appeared since this. lineIntersectsWith? ////////////////////// //Zombie basic // [FOCK] MIKIE J ////////////////////// //place this in the init of each zombie //zombie = [this] execVM "ZombieCtrl.sqf"; quitscript=0; zombiekilled = { if (!alive _this) exitWith {hint "Zombie killed";}; }; followdude = { _killer = _this select 0; _tokill = _this select 1; while {(position _tokill distance _killer > 10) and (quitscript == 0)} do { hintSilent "following"; _killer doMove (getPos _tokill); //modify the distance to make it easier or hard to run away if (position _tokill distance _killer > 100) exitWith {hint "quitting"; sleep 2; _killer doMove (getPos _killer); quitscript = 1;}; sleep 5; }; }; _zombie = _this select 0; _zombie addEventHandler["killed",{ (_this select 0) spawn zombiekilled;}]; //this runs whilst zombie is alive while {alive _zombie} do { _searchtarget = nearestObjects [_zombie,["CAManBase"],100]; { if (side _x == WEST && isPlayer _x) then { hint "targeted identified"; // use hints to find out where your scripts get to before breaking - this is just an example sleep 1; _kv = _zombie knowsAbout _x; //does the AI actually see the target if (_kv ==4) then //higer level = less likely to see { hint "targeted is gona die!"; _zombie doMove (getPos _x); _zombie setSpeedMode "LIMITED"; [_zombie, _x]call followdude; waitUntil {(position _x distance _zombie <= 10) or (quitscript == 1);}; if (quitscript == 0) then { _zombie setSpeedMode "FULL"; sleep 1; if(_zombie distance player < 2 && {alive _zombie}) then { _zombie say "zombie_attack_2"; _X setDammage +0.2; _x say "ouch"; }; } else { hint "aborting"; quitscript = 0; _x = nil; }; } else { hint "target not detected"; }; }; sleep 10; } forEach _searchtarget; }; Share this post Link to post Share on other sites
das attorney 858 Posted November 30, 2013 Try this: _zomb = _this select 0; while {alive _zomb} do { if(_zomb distance player < 2 && {alive _zomb}) then { _zomb say "zombie_attack_2"; _damage = damage player; player setDamage (_damage + 0.2); player say "ouch"; }; sleep 2; }; You could also check if the zombie is facing the right way with BIS_fnc_inAngleSector or similar. Share this post Link to post Share on other sites
jw custom 56 Posted November 30, 2013 Use global var(null) in global space not local var(_null) Share this post Link to post Share on other sites
Texedova 1 Posted November 30, 2013 (edited) Thank you Das Attorney. Mikie Boy appreciate your effort but i didn't really know the lines in the script so i couldn't customize it and i'd rather have my own scripts. Thank you though. Das Attorney, that worked perfectly thank you. Scripts are: Zombie.sqf _zomb = _this select 0; while {alive _zomb} do { if (_zomb distance player < 25 && {alive _zomb}) then { _zomb doMove getPosATL player; }; sleep 1; }; Bite.sqf _zomb = _this select 0; while {alive _zomb} do { if(_zomb distance player < 2 && {alive _zomb}) then { _zomb say "zombie_attack_2"; _zomb switchMove "AwopPercMstpSgthWnonDnon_End"; _damage = damage player; player setDamage (_damage + 0.2); player say "ouch"; }; sleep 2; }; Edited December 2, 2013 by Texedova Share this post Link to post Share on other sites
RudyPoo 10 Posted December 1, 2013 [/color]Sorry everyone but one more thing. I would like to spawn the units by a trigger, with code in the init of the unit. The unit would be a nato rifleman and the code to be in the init would be Init: removeAllItems this; removeAllWeapons this; _nul = [this] execVM "zombie.sqf"; _nul = [this] execVM "bite.sqf"; How exactly would i do this. And yes i do research and look this stuff up before i post this kind of stuff. I just didn't find what i need. Thank you so much in advance. I've been trying to figure this out too. Share this post Link to post Share on other sites
iceman77 19 Posted December 1, 2013 (edited) Use global var(null) in global space not local var(_null) Not trying to question your knowledge, I'm trying to learn as much as I can and any more tips would be appreciated. Anyhow, why can't the handle be a local variable if you don't need to access it? I always just seen the handle as a place holder of sorts (unless making a return), as it's required in the editor, is why I used _nul in example. Also, wouldn't using global variable null or nil as a handle conflict with something? For example nil would now be overidden and not work properly afterwords? Kind Regards, Iceman77 Edited December 1, 2013 by Iceman77 I assume it wouldn't effect null though as that's not even a command. Share this post Link to post Share on other sites