Jump to content
Sign in to follow this  
eegore

createunit Sheep/Cows with names

Recommended Posts

From what I can tell the only way to have a sheep or cow that follows commands is to create it.

Is there a way to create 5 or 6 cows that will respond to a distance trigger?

player distance cow1 < 3

Cow1 domove getposATL barn

Can this be done? I cant figure it out.

Share this post


Link to post
Share on other sites
This thread may be of some help:

Making Sheep Sprint

I read through that one but most of it doesn't make sense to me.

I will retry moveto commands and see if I can get them to go.

Share this post


Link to post
Share on other sites

I use this command to spawn animals, maybe help u.

- create a marker on map, "name it: marker_1"

_spawnPos = getMarkerPos "marker_1";
_group = createGroup West;
Goat1= _group createUnit ["Goat", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"];

Goat1 is ur animal name.

player distance Goat1 < 3

Goat1 domove getposATL barn

Edited by Persian MO

Share this post


Link to post
Share on other sites

This is exactly what I was asking for, just spawning an animal.

I assume I just place 6 separate markers and hope the player doesn't look on the map to know exactly where each animal is.

Unfortunately I don't know where the code goes. I tried in a trigger but it says variable in global space and nothing happens if its in a script.

Share this post


Link to post
Share on other sites

Have you tried using createAgent for animals, rather than createUnit?

Share this post


Link to post
Share on other sites

I will have to look up createAgent and see how to use it.

The pain is that it takes weeks to learn and trouble-shoot all these commands just for a mission where a player walks up to a cow.

Thanks for the help.

Share this post


Link to post
Share on other sites

I have created some sheeps, the only problem is that they are like a BLUFOR group and if you shoot them, they will tell you to cease fire etc lol.

Also, I don't know why, but if you touch them you get hurt, anyway when I'll be on pc I'll post it.

Inviato dal mio GT-I9300 utilizzando Tapatalk

Share this post


Link to post
Share on other sites

Here it is, place down a Marker where you want them to spawn and call it "sheepspawn", and another marker where you want them to move called "sheepmove", then make a script that will create the sheep and make them move:

grp = createGroup west;  
sheep2 = grp createUnit ["Sheep_random_F", getMarkerPos "sheepspawn", [], 0, "FORM"];
sheep3 = grp createUnit ["Sheep_random_F", getMarkerPos "sheepspawn", [], 0, "FORM"];
sleep 1;
sheep2 doMove (getMarkerPos "sheepmove");
sheep3 doMove (getMarkerPos "sheepmove");

There is probably a better way, and even a way to make this script with less lines, but I tried without luck.

Anyway as I said before, they will say "Cease Fire" over chat if you shoot them and they will say "2 Taking command" etc, because they are a BLUFOR group, maybe if you create them as civilians they will not talk.

Sorry for my poor english, hope this help you out.

EDIT: I thought that was in the Arma 3 section, sorry, it will probably work anyway but you will have to change the sheep class name.

Share this post


Link to post
Share on other sites
This is exactly what I was asking for, just spawning an animal.

I assume I just place 6 separate markers and hope the player doesn't look on the map to know exactly where each animal is.

Unfortunately I don't know where the code goes. I tried in a trigger but it says variable in global space and nothing happens if its in a script.

yes,its script.

easy way to use it:

// spawnpos is my marker
_spawnPos = getMarkerPos "marker_1";
// the animal belong to which side ""WEST", "EAST", "GUER", "CIV""
_group = createGroup West;
// spawn the animal at my pos
Goat1= _group createUnit ["Goat", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"];
// hide the created marker "u can use this line in ur init.sqf too
"marker_1" setMarkerAlpha 0;

Save it as myanimal.sqf and move it to ur mission folder

create a trigger, any condition u like,

in ON ACT: _nul = [] execVM "myanimal.sqf";

to move them somewhere, i think is better if use waypoint: http://community.bistudio.com/wiki/addWaypoint

Other links: hide markers - http://community.bistudio.com/wiki/setMarkerAlpha

sides: - http://community.bistudio.com/wiki/side

Share this post


Link to post
Share on other sites
Another option. Check out this mission:

Old MacDonald's Farm Adventure by Rough Knight

There are several scripts used in the mission to move animals around, etc

Funny you bring that up.

This is what I originally tried to do but the scripts have various on-screen indicators etc. that I do not understand. I tried getting them to work for about 3 weeks and I have now learned what 7 various errors mean after researching them but have yet to actually spawn a single cow that will move using a script from that mission.

The thing I liked best was that the animals act normal instead of just standing rigid like spawned cows.

There is a Hoz follow script in there I have been trying to figure out how to implement as well.

---------- Post added at 12:49 AM ---------- Previous post was at 12:32 AM ----------

I finally got somewhere. I know this code creates side West but they just wont spawn unless I have a BLUFOR unit somewhere on the map already.

// spawnpos is my marker
_spawnPos = getMarkerPos "marker_1";
// the animal belong to which side ""WEST", "EAST", "GUER", "CIV""
_group = createGroup West;
// spawn the animal at my pos
Goat1= _group createUnit ["Goat", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"];
// hide the created marker "u can use this line in ur init.sqf too
"marker_1" setMarkerAlpha 0;

_spawnPos = getMarkerPos "marker_2";
_group = createGroup West;
Goat1= _group createUnit ["Goat", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"];
"marker_2" setMarkerAlpha 0;

This will spawn two goats at two markers but this trigger, set to "repeatedly" will only move one goat (the second one spawned):

Con: player distance Goat1 < 3

Activ: Goat1 domove detposATL barn

Is there a way to get every goat to move only when I am near the specific goat? I though naming them would work and making a trigger for each name etc. but there isn't a way to name them in this script.

Edited by eegore

Share this post


Link to post
Share on other sites

_spawnPos = getMarkerPos "marker_2";

_group = createGroup West;

Goat1= _group createUnit :"marked red" is ur goat name, u can't have same name for 2 objects/units, should change to goat2.

The thing I liked best was that the animals act normal instead of just standing rigid like spawned cows.

search ups.sqf script in forum.

- create a marker Solid, example 50 X 50 cover the area you want goat walking.name it: marker_1

_spawnPos = getMarkerPos "marker_1";
_group = createGroup West;
"Goat" createUnit [(_spawnPos), _group, "",0.1,"PRIVATE"];
"Goat" createUnit [(_spawnPos), _group, "",0.1,"PRIVATE"];
"Goat" createUnit [(_spawnPos), _group, "nul = [this, 'marker_1','nofollow'] execVM 'ups.sqf'",0.2,"SERGEANT"];

This will spawn two goats at two markers but this trigger, set to "repeatedly" will only move one goat (the second one spawned):

Con: player distance Goat1 < 3

Activ: Goat1 domove detposATL barn

Is there a way to get every goat to move only when I am near the specific goat?

im not sure what is ur mean "my weak english".maybe this help u:

Con:

player distance Goat1 < 3

Activ:

Goat1 domove detposATL barn; Goat2 domove detposATL barn; Goat3 domove detposATL barn

Share this post


Link to post
Share on other sites

Why not use civilian side instead of west, for the group? You guys gonna get gunned down for friendly fire on sheep LOL.

Share this post


Link to post
Share on other sites

// spawnpos is my marker
_spawnPos = getMarkerPos "marker_1";
// the animal belong to which side ""WEST", "EAST", "GUER", "CIV""
_group = createGroup West;
// spawn the animal at my pos
[color="#FF0000"]Goat1[/color]= _group createUnit ["Goat", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"];
// hide the created marker "u can use this line in ur init.sqf too
"marker_1" setMarkerAlpha 0;

_spawnPos = getMarkerPos "marker_2";
_group = createGroup West;
[color="#FF0000"]Goat1[/color]= _group createUnit ["Goat", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"];
"marker_2" setMarkerAlpha 0;

This will spawn two goats at two markers but this trigger, set to "repeatedly" will only move one goat (the second one spawned):

Con: player distance Goat1 < 3

Activ: Goat1 domove detposATL barn

You are overwriting the reference(name) of the first goat created with the same reference(name) for the second goat...Goat1

Share this post


Link to post
Share on other sites

Ok its coming together, thanks everyone for the help here. It looks like I thought goat1 was the class name and not "goat" in quotation.

I thought about using UPS.sqf since I am familiar with it but the directions state to place the activation of it into the Init: of each unit (or leader) and since the goats are spawned I have no way of placing it into their Init: line.

This is handy as spawning a separate animal group (I changed them to chickens):

_spawnPos = getMarkerPos "marker_1";
_group = createGroup West;
"Goat" createUnit [(_spawnPos), _group, "",0.1,"PRIVATE"];
"Goat" createUnit [(_spawnPos), _group, "",0.1,"PRIVATE"];
"Goat" createUnit [(_spawnPos), _group, "nul = [this, 'marker_1','nofollow'] execVM 'ups.sqf'",0.2,"SERGEANT"];

However the goats being sent back to the barn (Goat1, Goat2 etc.) are not effected by this. Is there a way to implement the UPS.sqf script after Goat1 has been spawned? This would be handy for any spawned unit.

This doesn't work:

[goat1] = [this, 'marker_1','nofollow'] execVM 'ups.sqf'",0.2,"SERGEANT"];

All the goats are spread out, they are not in a group.

The last thing I would look for is a way to randomly place a marker within a radius, like when we place units in the editor there is a placement radius. That way the goat isn't in the exact same spot every time. Of course if UPS is running they will move about, but random placement will help with future missions

Edited by eegore

Share this post


Link to post
Share on other sites

im not sure, maybe this work for spawn just a goat with name.

_spawnPos = getMarkerPos "marker_1";
goat1 = createGroup West;
"Goat" createUnit [(_spawnPos), goat1, "nul = [this, 'marker_1','nofollow'] execVM 'ups.sqf'",0.2,"SERGEANT"];

[goat1] = [this, 'marker_1','nofollow'] execVM 'ups.sqf'",0.2,"SERGEANT"];

Don't use this [ ] for naming.

The last thing I would look for is a way to randomly place a marker within a radius, like when we place units in the editor there is a placement radius. That way the goat isn't in the exact same spot every time. Of course if UPS is running they will move about, but random placement will help with future missions

If using UPS.sqf : add this parameter, "random" ,

//last line code change to
"Goat" createUnit [(_spawnPos), goat1, "nul = [this, 'marker_1','random','nofollow'] execVM 'ups.sqf'",0.2,"SERGEANT"];

Find random location in map:

there is some ways to do this.

1- find location with buildings classname "also good way to put something inside buildings

- Put a location GameLogic in the center of map and name it: centertown

// my game logic
_gamelogic = centertown;
// "Land_Barn_Metal" is building classname,collect all buildings in radios 25000 meter from game logic
_objects = nearestObjects [_gamelogic, ["Land_Barn_Metal"], 25000];
// select random a building 
_RandomTownPosition = position (_objects select (floor (random (count _objects)))); 

Now _RandomTownPosition is position and i use it in my script :

// my game logic
_gamelogic = centertown;

// "Land_Barn_Metal" is building classname,collect all buildings in radios 25000 meter from game logic
_objects = nearestObjects [_gamelogic, ["Land_Barn_Metal"], 25000];

// select random a building 
_RandomTownPosition = position (_objects select (floor (random (count _objects)))); 

// CREATE UPS MARKER
_ups_areamarker = createMarker ["marker_1",_RandomTownPosition];
_ups_areamarker setMarkerShape "RECTANGLE";
_ups_areamarker setmarkercolor "Colorred";
_ups_areamarker setMarkerSize [200, 200];
_ups_areamarker setMarkerBrush "SOLID";
_ups_areamarker setMarkerDir 0;

// SPAWN GOAT AT MARKER
_spawnPos = getMarkerPos "marker_1";
_group = createGroup West;
"Goat" createUnit [(_spawnPos), _group, "nul = [this, 'marker_1','random','nofollow'] execVM 'ups.sqf'",0.2,"SERGEANT"];

I think now u know how it work, find random location, create a marker at selected location and spawn object/unit at the marker, so other ways to find random location in map:

2- find location around towns ...

//my game logic in center map
_gamelogic = centertown;

//find positions//5000 M is radios from center to search
_towns = nearestLocations [getPosATL _gamelogic, [
"NameVillage","NameCity","NameCityCapital"], 5000];

//select random a position
_RandomTownPosition = position (_towns select (floor (random (count _towns))));

Note: now u have to add this code to the script first lines:

// Server only
if (!isServer) exitWith {}; 
//waiting for done FUNCTION MODULE
waituntil {!isnil "bis_fnc_init"};

Note: put a FUNCTION MODULE to ur map.

...Still there is some other ways to find random location, u can search for it in forum.

easy way to get classnames: http://forums.bistudio.com/showthread.php?171208-Need-Help-Finding-This-Class-Name-Urgent

Edited by Persian MO

Share this post


Link to post
Share on other sites

Alright I am almost done. All of this information has been helpful.

The only problem I have now is that any goat that uses UPS ignores the trigger telling it to go to the "barn" Game Logic.

In this script Goat0 uses UPS, all others are stationary.

//spawn a goat that uses UPS
_spawnPos = getMarkerPos "goatpatrol";
goat0 = createGroup Civilian;
"Goat" createUnit [(_spawnPos), goat0, "nul = [this, 'goatpatrol','nofollow'] execVM 'ups.sqf'",0.2,"SERGEANT"];
// NOTE: Learn how to hide "goatpatrol" marker

// spawnpos is my marker
_spawnPos = getMarkerPos "goat1";
// the animal belong to which side ""WEST", "EAST", "GUER", "CIV""
_group = createGroup Civilian;
// spawn the animal at my pos
Goat1= _group createUnit ["Goat01_EP1", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"];
// hide the created marker "u can use this line in ur init.sqf too
"goat1" setMarkerAlpha 0;

//Repeat of commands without notation
_spawnPos = getMarkerPos "goat2";
_group = createGroup Civilian;
Goat2= _group createUnit ["Goat", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"];
"goat2" setMarkerAlpha 0;

_spawnPos = getMarkerPos "goat3";
_group = createGroup Civilian;
Goat3= _group createUnit ["Goat", [_spawnPos select 0,_spawnPos select 1,1], [], 1, "FORM"];
"goat3" setMarkerAlpha 0;

He ignores this trigger:

player distance Goat0 < 3

Goat0 domove getposATL barn

All other goats haul ass to the barn. Any ideas on how to get this deviant jerk-goat to get back to the barn where he belongs?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×