Script Questions

I'm stuck again..
Can you help me figure out how to package up a couple variables into a string I suppose, so I can use that to write to the database?

Here's what I got...

_WildDogsDir = (getDir _WildDogs); //returns: 76.8654
_WildDogsPos = (getPos _WildDogs); //returns: [11476.6,7674.13,0]
_WildDogsWorldSpace =

I want to get _WildDogsWorldSpace to look like: [76.8654,[11476.6,7674.13,0.001]]
so I can write _WildDogsWorldSpace to a "worldspace" field in the database.

I've tried like:
_WildDogsWorldSpace = ("[" + (_WildDogsDir) + "," + (_WildDogsPos) + "]");
or
_WildDogsWorldSpace = ['"[",'_WildDogsDir',",",'_WildDogsPos',"]"'];

but obviously I don't know what I'm doing and those don't work.
My eyes are fried from searching code examples and I need a little push..
 
I think I got it!
_WildDogsWorldSpace = format ["[%1,%2]",_WildDogsDir, _WildDogsPos];

results in...
"WildDogs: Test of _WildDogsWordSpace [138.184,[11485.9,7671.49,0]]"

and cleaned up a bit with..
_WildDogsWorldSpace = format ["[%1,%2]",round(_WildDogsDir), _WildDogsPos];

results in...
"WildDogs: Test of _WildDogsWordSpace [50,[11487.3,7673.55,0]]"
 
Last edited:
looks guud .... but ... but ...
where is rabbit attachto wilddog?

and I just had an idea. EDIT: after 20 minutes I couldnt get it to work .. but I will and you WILL BE AMAZED!

But until then, this will have to do.
 
Last edited:
What do you guys think would be a good way get these WildDogs to roam from town to town, maybe like AI waypoint logic?
I thought there were someones tamed dogs?

Get a list of 4 nearest towns/locations. Randomly set next waypoint to one of those. Repeat. This way they will travel from place to place in an orderly but random fashion
 
something maybe like this... get array of all cities within 1500m. Select one at random, add waypoint.

_nearby = nearestLocations [position wilddog, ["NameCity"], 1500];
_next = _nearby select (random (count _nearby) -1);
(group wilddog) addWaypoint [position _next, 300];
 
looks guud .... but ... but ...
where is rabbit attachto wilddog?

and I just had an idea. EDIT: after 20 minutes I couldnt get it to work .. but I will and you WILL BE AMAZED!

But until then, this will have to do.

the stuff you come up is great!! KEEP DOING IT!!!
We want to be AMAZED!!!! LOL
 
I need to figure out how to tie in the WildDog attack to the damage handler or whatever... right now you don't see you blood level drop during an attack.. hmm
 
in the fn_damagehandeler file ... therenis a part thst says "if ammo == zombie " ... copy that for the dog classname.... i would guess
 
Ok! Here's another WildDogs logic portion I'm trying to figure out, though not a quickly as you guys can...
I want to figure out how I can incorporate a player going PRONE or "Playing Dead" during a WildDogs encounter causing the WildDogs to think your dead and move on to other prey. Cool, right?

Here some of my logic process, but I can't figure out the scripting portion yet...if ever...but I'm searching..

//CHECK FOR PRONE PLAYER/PREY

// IF PLAYER or _TargetPrey is PRONE which equals "PlayDead"
// then PLAYER or _TargetPrey would be considered !Alive until they are not PRONE and considered Alive again
// WildDogs would look and growl at PRONE player and then leave and begin search for new prey

// _PlayDead = "amovppnemstpsraswrfldnon" //PRONE
// _PreyAnimationState = (animationState _TargetPrey)
// If _PreyAnimationState <> _PlayDead then _TargetPrey = !Alive

This is where they determine what/who to attack right now...
Code:
_Prey = nearestObjects [_WildDogs, ["Man"],1000];
_alivePrey = [];
{if (alive _x) then {_alivePrey set [(count _alivePrey),_x];};} forEach _Prey;
if (count _alivePrey != 0) then
{
 //CHASE PREY
 
Something like this maybe?
Not sure if the: then {alive = false}} forEach _Prey;
part is gonna work properly or not...

Thoughts?

Code:
_alivePrey = [];
_Prey = nearestObjects [_WildDogs,["Man"], 1000];
{if (animationState _x == "amovppnemstpsraswrfldnon") then {alive = false}} forEach _Prey;  //CHECK FOR PLAYDEAD
{if (alive _x) then {_alivePrey set [(count _alivePrey),_x];};} forEach _Prey;
if (count _alivePrey != 0) then
{
    //CHASE PREY
 
Looks good ... almost.
// "AmovPpneMstpSrasWrflDnon" - Prone with Rifle
// "AmovPpneMstpSrasWpstDnon" - Prone with Pistol

I think the "alive" logic is a bit twisted.
You are checking the animationstate to see if they are prone (with rifle, have to use other animation also to check for pistol, not sure about unarmed).
You set a "alive = false" if prone. Right idea but that will probably produce an error because alive is a keyword, you can't use keywords as variables.
then in the next line you use the keyword alive to check if any of the _prey objects are playing dead. But instead this will always return true because alive returns whether an object is alive or dead.

So, I would use both animation states in your one if statement. And where you use then {alive = false} change that to a local variable _playingdead = true . Another thought about that line. You are using foreach _prey. I am not sure of the flow but I think it will loop through all objects and each time change _playingdead variable ... get what I mean? There is only one variable to check for multiple player objects. So we either need to combine the if loops .. or combine the if loops.

After all my babbling, ... I think this will work. One last thing to keep track of is the locality of each object and where you are running the code. Are the dogs spawning on the server? and this code running on the server? ... getting a headache just thinking about locality ....

Code:
_alivePrey = [];
_Prey = nearestObjects [_WildDogs,["Man"], 1000];
//check if player is NOT playing dead ..
{if ((animationState _x != "amovppnemstpsraswrfldnon") || (animationState _x != "AmovPpneMstpSrasWpstDnon")) then {
         // add players who are NOT playing dead to the array to be chased.
          _alivePrey set [(count _alivePrey),_x];
          }
} forEach _Prey;  //CHECK FOR PLAYDEAD

if (count _alivePrey != 0) then
{
    //CHASE PREY
 
I'm so glad your not on vacation! lol I appreciate all this...truly!

So my WildDogs script starts with: If (isServer) Then
and the Dogs are spawned in within the same script you are helping me with the logic code for.
The flow goes like this: SPAWN - SEARCH - CHASE - ATTACK - BACK TO SEARCH so to speak...

Problem:
So your logic to code looks great and generates no errors..though the dogs tried to kill me.. yah yah laugh it up, bub..
They tore the jeans up on my Hero skin, but I was able to get away by jumping fences..just like when I was young..
They didn't care if I was playing dead, they wanted me dead... the animation state being checked matched the state in the database. It's like it didn't even check..
I'll pop a diag_log in to see what it reports my animationState as...
UPDATE: and it says..
"WildDogs: TargetPrey AnimationState is: amovppnemstpsraswrfldnon"

Maybe I need to check for animateState and then set some kinda "setCaptive" thing, seems like I read enemies don't attack Captives.. thinkin thinkin....

Code:
//LOCATE PREY
diag_log format ["WildDogs: WildDogs Are Locating Prey!"];
_alivePrey = [];
_Prey = nearestObjects [_WildDogs,["CAManBase"], 1000];
//check if player is NOT playing dead ..
{if ((animationState _x != "amovppnemstpsraswrfldnon") || (animationState _x != "amovppnemstpsraswpstdnon")) then {_alivePrey set [(count _alivePrey),_x];};} forEach _Prey;
if (count _alivePrey != 0) then
{
//CHASE PREY
 
Last edited:
yeah, setcaptive would work.
animation states are difficult. like,my video with the hooker on my crotch. i was trying to make the hooker ai sit like on a chair and then was going to attach her to my shoulders. then if we could set hookers to attack other hookers with their hands (like the zombies do) we could have 'chicken fights'.
but couldnt get animation to work on her.
and if your script,is,running on the server, the player objects is client side ... maybe server doesnt know the state?

what you want to do is set an eventhandler for animchanged and have that setvariable "playdead" on the unit. then check for that variable in your server code.
 
yeah, setcaptive would work.
animation states are difficult. like,my video with the hooker on my crotch. i was trying to make the hooker ai sit like on a chair and then was going to attach her to my shoulders. then if we could set hookers to attack other hookers with their hands (like the zombies do) we could have 'chicken fights'.
but couldnt get animation to work on her.
and if your script,is,running on the server, the player objects is client side ... maybe server doesnt know the state?

what you want to do is set an eventhandler for animchanged and have that setvariable "playdead" on the unit. then check for that variable in your server code.

ROTFLMAO!!!!
 
I haven't implemented any setCaptive stuff yet as I'm still bugged about the PRONE check not working..but I whipped up this code section to try the PRONE check again. I'm not home to test it yet.

I'm trying to filter down to a viable targetPrey by checking for PRONE and if so, they are PlayingDead
then omitting any PlayingDead players from the targetsQuery array and then filtering again to make sure the dogs don't stand by deadbodies after they kill them and start the search again. If I said all that right.... : )

What do you think? : )

Code:
//LOCATE PREY
   
diag_log format ["WildDogs: WildDogs Are Locating Prey!"];
_alivePrey = [];
_PlayingDead = [];
//CHECK FOR PRONE PLAYERS AND ADD TO _PLAYINGDEAD ARRAY
{if ((animationState _x = "amovppnemstpsraswrfldnon") || (animationState _x = "amovppnemstpsraswpstdnon")) then {_PlayingDead set [(count _PlayingDead),_x];};} forEach _x;
_Prey = _WildDogs targetsQuery [_PlayingDead, sideUnknown ,"CAManBase", [], 0];  // OMIT PLAYERS THAT ARE PLAYINGDEAD DURING SEARCH FOR NEW PREY
{if (alive _Prey) then {_alivePrey set [(count _alivePrey),_Prey];};} forEach _Prey;  //  MAKES DOGS LEAVE DEADBODIES AFTER KILLING THEM AND SEARCH FOR NEW PREY

//CHASE PREY
 
Back
Top