Forum Jump :

Author Message


Posts: 10
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2015-06-05 09:00        
     
I have recently taken up editing in Arma2 as a way to pass time and teach myself a little about the problems of mission/game design. I am using the approach of learning to do simple tasks and solve problems as I go (getting characters to start in aircraft, getting a bus to "pick up" passengers, using way points and triggers to accomplish complex tasks or move the story along). and then proceeding to ever more complex tasks as I go. I will often build a simple test mission to solve the problem, before using it in the story driven mission I am building for friends. For now I am working with Arma 2, because that is what I have and people have been working with it longer. If I am happy with my results I may port it over to Arma 3 and post it publicly.

So far I have been able to solve most problems by experimentation and consulting resources here including forums, FAQs and Guides which I have found very helpful. Unfortunately, I have run into a proble that I cannot seem to work out, nor find anything that helps (perhaps I am searching wrong.

I am trying to get an AI controlled character (we will call him "Bob") to walk casually to a designated position inside a building (in this case an apartment in Chernarsus) using the established building positions (building position 4), wait for small period, and then proceed to another position (pos 7) inside the same building. Ultimately, I would like the AI to lead the player through the interior of the building pausing in different rooms where he would deliver some dialogue (perhaps with some animation) in each room, like giving a tour... But for now I just want to make him movee from room to room in a controlled manner.

My first attempts involved using the "doMove" command inside the "On Activation" box of a way point: Example: "Bob doMove ((position this nearestObject 31598) buildingPos 4)" If I do not place the way point on the building, nothing happens. If I attach the way point to the building he will proceed to position 1 (irrespective of selected position in the available drop down menu)where he will pause briefly before proceeding to the point designated by the "doMove" command. So it appears that the command in the Activation Box overrides anything selected in the drop down menu. Further if I use a series of "doMove" commands (spaced with sleep commands) I get the exact same result! Bob enters the building goes to way point one, pauses and goes directly to the LAST point in the series...

For my second attempt, having learned that the "sleep" command only works from an external script and hypothesizing that commands placed in an "Activation" box may run simultaneously (resulting in only the last command being acknowledged) I tried calling an external script. For this I wrote the following simple script:

"Hint "Moving to position one";
Bob doMove ((position this nearestObject 31598) buildingPos 4);
sleep 40;
Hint "Moving to position 2";
Bob doMove ((position this nearestObject 31598) buildingPos 7);
sleep 40;
Hint "Moving to final position";
Bob doMove ((position this nearestObject 31598) buildingPos 14);
Hint "Movements complete";
exit;"

I have tried using both way points and radio activated triggers. Regardless I get the same result; The script is successfully called and DOES run as the hints appear on screen after the appropriate delays, however the character FAILS to move at all, simply standing in place. Nothing I do, including using other movement commands changes this...

I have tried to "reverse engineer" several house patrol scripts I have found. However most house patrol scripts use a random system (I want to direct specifically where the character moves) and with the one non random script that I have found I am unable to identify the operative command ("move", "doMove", "setpos") that would cause the character to move from one position to the next. I can't make heads or tails of them (even with embedded explanations)! Maybe there is another command, or I have my syntax wrong...

I am stumped! Any help in this matter is greatly appreciated, I would really like to move forward with this but cannot without solving this problem unless I am willing to abandon or completely rework key scenes in the final project. Help!

This post was edited by Foxhound (2015-06-05 09:58, 868 days ago)


Author Message


Posts: 1473
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#2 Posted at 2015-06-05 16:05        
     
I think your main problem is that Position this does not exist outside the init box of an object.
In a trigger it does not know what this is.

You could name an object/gamelogic eg myobject and then refer to that object instead of this.

Also If you placed the following in a trigger or waypoint it should work, you still need the game logic named myobject over the building.
By spawning the code it allows you to use sleeps without having to call an external script, it also passes the myobject variable to the code _this points to that variable

null=myobject spawn { 
Hint "Moving to position one";
Bob doMove ((position _this nearestObject 31598) buildingPos 4);
sleep 40;
Hint "Moving to position 2";
Bob doMove ((position _this nearestObject 31598) buildingPos 7);
sleep 40;
Hint "Moving to final position";
Bob doMove ((position _this nearestObject 31598) buildingPos 14);
Hint "Movements complete";
};

Another way would be to just use a series of waypoints.

Place the first WP directly on the building and set the #postion 4 and timers.

Now place a second waypoint close to it, you won't have the position option so you need to code it.
In the on act put
Bob doMove ((waypointPosition [group bob, currentWaypoint (group bob)] nearestObject 31598) buildingPos 7);

the repeat for the third waypoint
Bob doMove ((waypointPosition [group bob, currentWaypoint (group bob)] nearestObject 31598) buildingPos 14);

Set the timers for each waypoint by adjusting the three boxes 5,5,5 = 5 second delay.

This post was edited by F2kSel (2015-06-06 13:55, 867 days ago)


Advertisement


Author Message


Posts: 10
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2015-06-06 02:59        
     
I tried the "multiple way point" approach, and had the same result as just using the single WP (e.g. Bob goes to last position only). However your scripting is different than mine, so I will try again. I am new to this, so excuse me for asking the question, what does adding "[group bob, currentWaypoint (group bob)]" actually do for me as apposed to "position this"? My understanding is that "this" is referring to Bob, or am I misunderstanding and "this" is refering to the way point? I am a bit fuzzy here.

Interesting about using a gamelogic to define the building for the script (that is what I am trying to do here?) Seems redundant. But what does the "Null=myobject" do? If I were to venture a guess what happens here is that when Bob hits the way point, the way point wither calls or spawns a script (depending on how I set it up) and that the "Null=myobject" essentially "points" the script to the building on which the object is placed. Though that does give rise to the question of isn't what the building's reference number is for?

Thank you for the help (I'll see if it works tonight or tomorrow and let you know how it panned out). Please excuse me for all the questions. As I said I am new to this, but I am trying to actually learn something about how it all works as apposed to just "cutting and pasting" my way through it.


Author Message


Posts: 1473
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#4 Posted at 2015-06-06 15:07        
     
The fist code will only work if the delays are large enough as your stopping the script not the unit so if it doesn't get to the position before the timer expires it won't stop.

You are correct about this being bob in a waypoint but it won't be true in a trigger.

Null=myobject passes the variable to the code, you could use the name directly but later if you want to copy it to other units you have to change every reference to that name but if you it correctly you only need to do it once.

The real reason I use a game logic is to save time later on.
You are correct about the ID number and BIS don't recommend using it as they can change when patches are release so the whole script can fail.

The following code will work from a waypoint or trigger it could be used for other units by just changing the AI's name or change the building by just moving the logic to a new location

null=[myobject,bob] spawn {  _lg =_this select 0;
  _man =_this select 1;
  _man doMove (nearestObject [getpos _lg,"house"] buildingPos 4);
     waitUntil {!alive _man or moveToCompleted _man};
       sleep 5;
  _man doMove (nearestObject [getpos _lg,"house"] buildingPos 7);
     waitUntil {!alive _man or moveToCompleted _man};
       sleep 10;  
  _man doMove (nearestObject [getpos _lg,"house"] buildingPos 14);
     waitUntil {!alive _man or moveToCompleted _man};
  
  If (alive _man) then  {hint "Search Complete"} else {hint "Search Failed" };
  };
I'm a little rusty these days so I'm probably more fuzzy than you are.
waitUntil {!alive _man or moveToCompleted _man}; this waits until the unit is either dead or has reached the position before starting the delay timer.

This post was edited by F2kSel (2015-06-06 15:37, 867 days ago)


Author Message


Posts: 10
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#5 Posted at 2015-06-06 23:02        
     
Nice! Thanks for the explanation. I got it to work (though I had to play around with it too get a persistent response)! Yay!
Unfortunately, I discovered I am only halfway fixed. This works perfectly for what I have in mind for the apartment. Sadly, it appears it won't work for the other planned "safehouse" (located in the rooms above one of the coffee shops) because there are no building positions corresponding to locations on the second floor! Arrrghhh. I mean really! Why would one take the time to create an environment (rooms in a building) and then provide no way to reference them in the blasted editor?!? It's like designing and building a car and forgetting to include the drive shaft (or wheels)!Sigh...

I hope it is not to much to ask, but is it possible to drive an AI unit up the stairs placing an object (perhaps a piece of furniture like a chair) and referencing his moments based on it. E.g. send Bob to a position based a chair located in one of the upstairs rooms (that has no building pos)? Is there any other way to move AIs through buildings without using the building positions? I would really like to use the upstairs of the coffee shop as it has excellent sight lines to something the characters/player need to witness later in the game... I hate the idea of having to abandon it...

Edit: I wonder if this is why the zombies in the Arma2DayZ rarely attacked inside buildings?

This post was edited by KurojI (2015-06-06 23:08, 867 days ago)


Author Message


Posts: 1473
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#6 Posted at 2015-06-07 02:19        
     
I don't think it's possible, you can place an object in the building but AI won't climb ladders or stairs if there is no building pos.


Author Message


Posts: 10
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#7 Posted at 2015-06-07 08:31        
     
That's disappointing. I guess I will have to digest what I have for the moment (I still have to figure out how to add dialogue and animations...). I also need to look up how to fade the screen and pass time (called from way point or trigger) and how to get idle animations to stop on cue (or delete units). The scene has the characters inside the safe house with the coffee shop full of patrons (civilians doing various idles), fades to black, sets clock to the following morning at which point the patrons should be gone... Any suggestions or links to specific topics greatly appreciated.

Oh just had a thought. what if I "beam" (e.g.) place the character in the upstairs room after the fade. So characters are down stairs in the coffee shop have their last conversation (in which the player is told that the safehouse is upstairs and to get some rest)...screen fades to black...and when the fade ends it is morning and both characters are now upstairs ready for the next part of the mission. In other words, can I drop/spawn the character at a way point whose height is preset (much like an initial placement) but mid way through the mission?

Also, how do I kill the "move 50 paces north" "move to that house" every time I have the characters move to the next waypoint? I found out how to kill the radio, but I haven't found out how to stop him from saying it "locally". For that matter can I hide the waqypoint indicator, I just want the player to follow the AI character directly without the extra "voice commands" or onscreen markers...I know it can be done I just haven't come up with the "correct" search terms to lead me to an answer...

I really appreciate the help. If I get this thing to anywhere halfway passable, I will be sure to flip you a copy and see what you think!


Author Message


Posts: 1473
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#8 Posted at 2015-06-07 13:07        
     
I found animations to be a bit tricky, some will insist on playing to the end no matter what you do.
You can try unitname switchMove ""; to stop animations.
Also you can't run an animation from the init line of a unit.
You will find it easier making a proper script for animations rather than trying to do loads of them through triggers/waypoints.
Will this be MP, as that may be an issue as some commands will need to be broadcast across the network, I can't help with that.

There are a few ways you can set the height of an object
myman setpos (myman modelToWorld [0,0,5];// just adjust the XYX

myman  setpos [(getpos myman select 0),(getpos myman select 1),5];// increase height from current position
myman  setpos [(getpos myman select 0),(getpos myman select 1)+100,(getpos myman select 2)+5];// move object 100 and increase current height 5

myman  setpos getpos anotherobject;// will move myman to another location
myman  setpos [(getpos anotherobject select 0),(getpos anotherobject select 1),5];// move to another object and set height
Ect.

You can make a little utility for finding positions, when you exit the script the current x,y,z are copied to clipboard and can be pasted directly into code
Place a trigger set to repeating
cond
Round (Time %1) == 1
On Act
hint str (getpos player);copyToClipboard str (getpos player)

example
player setpos [3575.97,3645.58,0.00143814]

For the voice/text try enableSentences false;
Wypoint marker, I think you can only do it by increasing difficulty

This post was edited by F2kSel (2015-06-07 13:22, 866 days ago)


Author Message


Posts: 10
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#9 Posted at 2015-06-07 13:52        
     
Wasn't expecting to hear from you so quickly, but I actually managed to figure out how to "beam/teleport" them for myself. Surprisingly easy for once. I do intend to do all animations for main chars through scripts. For the coffee patrons I was thinking using a way point to get them started with idles, and then make them eventually piss off (actually my little beam them trick might work just as well e.g when I teleport characters upstairs I simply delete the patrons in the same script that covers teleport). I only have one more problem to work out before I can begin to pull this togeter...once I have teleported my chars upstairs (via waypoint) how do I keep them from moving to the next waypoint until I am ready for them to do so(e.g. necessary dialogue spoken/scripts run)?

Big picture. Characters go to coffee shop, player is told that the safe house is upstairs (supplies etc), and to get some rest. Then either the AI walks out of view and is teleported up stairs to be joined by player at players convenience (which initiates the fade to black and moves clock forward 10 hrs) OR the screen fades to black and time is advanced, while player and AI are teleported to upstairs together where player is then told to grab some gear before heading out...Either way I need to hold the AI in place for a moment but he won't be sitting on a waypoint...so...

Hopefully I am making sense.

For the record, this is intended to be a single player story driven campaign for some friends of mine. I really really enjoyed "For the Life of a Friend" (if you haven't played it I believe it is here on the Armaholic sight), and I wanted to try my own hand at something similar.

PS. does enableSentences false prevent me from having the character give scripted directions of my own? For example: instead of saying "move 1234 meters north" I could have him say "turn left up here" or "keep heading up the road"?

This post was edited by KurojI (2015-06-07 14:04, 866 days ago)


Author Message


Posts: 1473
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#10 Posted at 2015-06-07 21:47        
     
I don't think enableSentences false will prevent scripted Text messages or user made sounds.

To stop them moving unitname disableAI "move";
and unitname enableAI "move"; to get them moving again


Author Message


Posts: 10
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#11 Posted at 2015-06-08 00:19        
     
Thanks. I think I might have away to pull of what I intend. I will basically have the last way point before chars go up stairs call a script that transports the AI upstairs, waits until the player joins him (by setting it up so that it checks the players "altitude" e.g. and range I think I can make it so the player has to be upstairs and next to the AI) at which point the script will execute the required dialogues and animations before the fade to black. Once the script ends the AI will be free to move to his next waypoint with a "join me downstairs after you get your gear" hint... Hopefully I can get it to work. (I still have to learn the syntax to check players position, wish me luck!). It will take me a bit of time to do this I think...

Really, thank you for your help on this. I have learned quite a bit so far, and I would not have without you taking the time out to help.


Author Message


Posts: 1473
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#12 Posted at 2015-06-08 01:31        
     
Yea a distance and height check would work.

condition
(player distance myunit < 3 and (getposatl player select 2) > xx)
xx would be the height


Are you using an editor there are several around, you can get on screen error reports by enabling showscripterrors
Showscripterrors

I hope you can make it do what you want but be warned it can become addictive.
It does take a while to get into the syntax especially the local/global stuff.

Cya Sel.


Author Message


Posts: 10
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#13 Posted at 2015-06-09 14:25        
     
Just when I think I have a handle on it! I can now get Bob to go into a building and using a group of way points I can roughly move him around inside the building where I want. Though I have not been able to get a script to work based on any example above. I can also convincingly get him upstairs (by simply having him walk into another room and "warp" before the player gets there). What I can't get him to do is STAY PUT!!!! Time delays in the waypoints have completely unpredictable results and if he stops at all it will be completely random location (after he takes a random detour outside as often as not)! Wait commands do not work. Triggers do not work (if he stops it will be a random location NOT associated with the waypoints or building positions...)! Conditions (like player presence) do not work! DisableAI "move" does not work! Spawning the script does not work. NOTHING FRAKING WORKS! If I use a warp (to target) or doMove to position Bob, he will not stay put, but insists on proceeding to his next external waypoint! All I want to do is:

1. Have Bob wait inside the coffee shop for the player,and when the player arrives; inform him that the safehouse is upstairs and that he should get some rest.

2. when the player arrives upstairs, a script launches that fades the screen to black, advances the clock 10 hours (to morning), places (warps) the player to a position laying down on a sleeping mat (already created) before fading back in

AND

3. have Bob wait in place (upstairs) until the player has grabbed his gear before heading down stairs/leaving the building (e.g. proceeding to waypoint -a car parked out front).

But nothing seems to stop him! I don't know what I am doing wrong, and it is making me crazy...


Author Message


Posts: 1473
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#14 Posted at 2015-06-09 16:01        
     
If your not using any addons you could zip it up and I could take a look.
Strip out all the clutter and just leave the basic problem.

What your trying to do doesn't sound too difficult.


Author Message


Posts: 10
Rank:


Level: Member

Country: au
Location:
Occupation:
Age:
In-game name:

 
#15 Posted at 2015-06-09 22:34        
     
Appreciated, I am running it as a separate test problem (while developing the mission in a separate file. There is one other thing I want to try before throwing hands up in disgust. It is a bit unorthodox as the issues seem to revolve around running anything (like scripts) from Bob himself.

It looks like has to do with the fact that the AI is trying to move to the physical waypoint before being "interrupted" with the doMove or setPosition commands. So effectively the waypoint and move order conflict! The the first waypoint attached to the building or object gets him in the door, but then sends him to to the assigned building position before he actually "reaches" it preventing him from executing a script or waiting where you want him before he attempts to move to the next waypoint. The subsequent waypionts work in a similar manner, Bob moving toward next waypoint then "diverting" to the move order. Consequently the subsequent waypoints (with move orders to interior positions) must be close to the center of the building where they have a chance to interrupt his movement, or Bob will wander outside where he can't find his way back in to the building and "hangs". It is his inability to find his way in (without the first WP attached to the building itself) that I believe is what is preventing him from running or spawning scripts that "drive" him inside. They run, but the AI can't "generate" a path that takes him to the interior... So we are stuck with multiple "interrupted" WP. However I have had small (but unpredictable) results with a radio activated trigger, which give me an idea...

So I am thinking that the main issue is predictability of results (in timing scripts/movements/actions) so what if I assign those actions and scripts to waypoints that belong to a unrelated AI. E.g. I place a civilian (call him the "Gardner") near by. Bobs arrival is synchronized to the Gardener's first WP... the Gardner moves to his subsequent way points which are synchronized to Bobs, however all scripts and actions are called from the Gardener's more predictable (WP only/external) movement. The player just sees another "random extra" much like the coffee shop patrons or cars driving by never realizing that the Gardener only exists to drive and regulate Bob's movements/dialogue/etc...

As I said unorthodox, but may give me the control I need....

Give me a day or two to experiment, if it doesn't get results, I will "clean up" the problem (I have several experimental moves set up in parallel in the same file) and add "hints" to stand in for effects that I am trying to work out before I flip it to you. But who knows? I might get lucky!


Kind Regards
K