Jump to content
The Dark Mod Forums

who stepped into my trigger? (scripting question)


Jasp

Recommended Posts

Hi,

 

what I want: On the way to the last path_corner of a path-chain the AI moves through a trigger which leads into a script. This script should check some variables and give the AI a new target. It has to work for every AI which passes this way.

But how do I get the name of the triggering AI into my script?

$guard.moveToPosition($player1.getOrigin());

Link to comment
Share on other sites

You can do this either by using a trigger_touch which checks for every entity entering its bounds and sort out the ai that way or use a script object on the ai which checks whether the ai is in the designated area.

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

What I wanna do is a waiting queue for a map with kind of open-world-feel. My first goal: Send each incoming AI to another path_corner.

 

I tried it this way.

AI walks to path_corner and while on the way it walks over a trigger on the way. This trigger changes the target of the path_corner.

But it doesn't change the route of the AI.

Then I placed a trigger_wait (wait 0) between them and changed its target, because I thought maybe the AI already 'knows' the target of the next node. But it doesn't change anything.

Is the whole path fix when the map is loaded?

 

EDIT: HEY! When I can't change the target of an AI - I fear I can forget my idea... (AI go to work, after some time have a break, go back to work, talk to someone... all controlled via script)

Edited by Jasp

$guard.moveToPosition($player1.getOrigin());

Link to comment
Share on other sites

Well, you could have a path_waitfortrigger.

Each AI have their pre-destined patrol route, but they stop and queue on a path_waitfortrigger. Then when the AI are standing and waiting, you just trigger the AI (The AI! NOT the path_waitfortrigger!) and off they go.

Clipper

-The mapper's best friend.

Link to comment
Share on other sites

Could you also use ai.goToPosition? Can't test it till after work but I think patrolling ai just stand idle after you interrupt their patrol with a go to, after which they can be restarted with another scriptevent, resetPatrol or restartPatrol I think it is.

Link to comment
Share on other sites

I made a small test. A AI walking around with path_corners and 1 path_wait.

When I trigger the script, the moveToPosition-waypoint is added before the next path_corner: AI is on way from A -> B. When script is triggered AI first moves to the script-waypoint and then immediately to B. When the script is triggered while path_wait is active the AI moves in the direction of the script-waypoint but when the path_wait ends it forgets the script-waypoint and continues the path.

void geh()
{
$frau.moveToPosition($player1.getOrigin());
}

Edited by Jasp

$guard.moveToPosition($player1.getOrigin());

Link to comment
Share on other sites

Ack, sorry, you're right. I remember Sotha had a similar problem a few pages back in the newbie questions thread: scripted instructions or animations don't suspend the AI's 'normal' behaviour and get interrupted by the AI's next move. [@Sotha: I can confirm the problem with kneel_down still happens when you use PlayAnimationOnce from a scriptobject, by the way].

 

Conversations get around it -- they suspend the AI's activity. And a conversation can hand control to a script. I have a similar general problem of wanting AI to do their stuff except for certain scripted events... If I find an easily portable/cloneable solution, I'll share it.

Link to comment
Share on other sites

It was fun getting this working (see attached test map), although I didn't manage to make a cloneable/prefab-able solution for controlling AIs like this. It seems you can't stop AIs doing their stuff except by using a conversation, and that you have to create one of those in the editor for each AI, and you need at least one script function for each ai with their name hard-coded. I did try lots of workarounds like creating new conversations at runtime in the script, but it seems conversations get compiled at map start.

 

But it's not a problem for one-off usage in maps. The attached one works, and the AI don't get borked. It starts with the four male AI circling the room on patrol. Each time you frob the left lever, one of them will go stand in front of the noblewoman at the lectern. If you frob it quickly several times, they'll all home in and form a more or less orderly queue. When you frob the right lever, the chap at the front resumes his patrol while the others move forward.

 

I used the conversation entity itself to mark where the head of the queue should be in the map. Other positions are calculated from its origin. Also to keep track of which AI can queue. It has all the participating AI as targets.

 

I don't have the right privs to uploads files other than images, so I'll have to paste them as text.

 

slq.map:

 

Version 2
// entity 0
{
"classname" "worldspawn"
"editor_drLastCameraPos" "176.882 300.271 86.0296"
"editor_drLastCameraAngle" "-31.5 84.3 0"
// primitive 0
{
brushDef3
{
( 0 0 1 -272 ) ( ( 0.0078125 0 0 ) ( 0 0.0078125 254.5 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 1 0 -640 ) ( ( 0.0078125 0 2.25 ) ( 0 0.0078125 1.125 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 1 0 0 -640 ) ( ( 0.0078125 0 0.125 ) ( 0 0.0078125 1.125 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 -1 0 0 ) ( ( 0.0078125 0 254.5 ) ( 0 0.0078125 1.125 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( -1 0 0 0 ) ( ( 0.0078125 0 1 ) ( 0 0.0078125 1.125 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 0 -1 256 ) ( ( 0.0078125 0 0 ) ( 0 0.0078125 3 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
}
}
// primitive 1
{
brushDef3
{
( 0 0 1 -256 ) ( ( 0.0078125 0 255.875 ) ( 0 0.0078125 254.5 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 1 0 -656 ) ( ( 0.0078125 0 2.25 ) ( 0 0.0078125 1 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 1 0 0 -640 ) ( ( 0.0078125 0 0 ) ( 0 0.0078125 1 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 0 -1 0 ) ( ( 0.0078125 0 255.875 ) ( 0 0.0078125 2.5 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( -1 0 0 0 ) ( ( 0.0078125 0 1.125 ) ( 0 0.0078125 1 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 -1 0 640 ) ( ( 0.0078125 0 5 ) ( 0 0.0078125 1 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
}
}
// primitive 2
{
brushDef3
{
( 0 0 1 -256 ) ( ( 0.0078125 0 0 ) ( 0 0.0078125 254.375 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 1 0 -640 ) ( ( 0.0078125 0 2.375 ) ( 0 0.0078125 1 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 1 0 0 -656 ) ( ( 0.0078125 0 0.125 ) ( 0 0.0078125 1 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 0 -1 0 ) ( ( 0.0078125 0 0 ) ( 0 0.0078125 2.625 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 -1 0 0 ) ( ( 0.0078125 0 254.375 ) ( 0 0.0078125 1 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( -1 0 0 640 ) ( ( 0.0078125 0 0 ) ( 0 0.0078125 1 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
}
}
// primitive 3
{
brushDef3
{
( 0 1 0 -640 ) ( ( 0.0078125 0 2.25 ) ( 0 0.0078125 0.875 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 1 0 0 -640 ) ( ( 0.0078125 0 0.125 ) ( 0 0.0078125 0.875 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 0 -1 -16 ) ( ( 0.0078125 0 0 ) ( 0 0.0078125 2.5 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 -1 0 0 ) ( ( 0.0078125 0 254.5 ) ( 0 0.0078125 0.875 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( -1 0 0 0 ) ( ( 0.0078125 0 1 ) ( 0 0.0078125 0.875 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 0 1 0 ) ( ( 0.0078125 0 0 ) ( 0 0.0078125 1 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
}
}
// primitive 4
{
brushDef3
{
( 0 0 1 -256 ) ( ( 0.0078125 0 0.125 ) ( 0 0.0078125 254.5 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 1 0 0 -640 ) ( ( 0.0078125 0 0.25 ) ( 0 0.0078125 1 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 0 -1 0 ) ( ( 0.0078125 0 0.125 ) ( 0 0.0078125 2.5 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 -1 0 -16 ) ( ( 0.0078125 0 254.5 ) ( 0 0.0078125 1 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( -1 0 0 0 ) ( ( 0.0078125 0 0.875 ) ( 0 0.0078125 1 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 1 0 0 ) ( ( 0.0078125 0 0 ) ( 0 0.0078125 1 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
}
}
// primitive 5
{
brushDef3
{
( 0 0 1 -256 ) ( ( 0.0078125 0 0 ) ( 0 0.0078125 254.625 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 1 0 -640 ) ( ( 0.0078125 0 2.125 ) ( 0 0.0078125 1 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 0 -1 0 ) ( ( 0.0078125 0 0 ) ( 0 0.0078125 2.375 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 -1 0 0 ) ( ( 0.0078125 0 254.625 ) ( 0 0.0078125 1 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( -1 0 0 -16 ) ( ( 0.0078125 0 1 ) ( 0 0.0078125 1 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 1 0 0 0 ) ( ( 0.0078125 0 0 ) ( 0 0.0078125 1 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
}
}
// primitive 6
{
brushDef3
{
( 0 0 1 -48 ) ( ( 0.01302083302289248 0 0.2083333283662796 ) ( 0 0.01302083302289248 0 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 1 0 -208 ) ( ( 0.01302083302289248 0 0 ) ( 0 0.01302083302289248 255.5833282470703 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 1 0 0 -272 ) ( ( 0.01302083302289248 0 0.2083333283662796 ) ( 0 0.01302083302289248 255.5833282470703 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 0 -1 0 ) ( ( 0.01302083302289248 0 0.2083333283662796 ) ( 0 0.01302083302289248 0 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 -1 0 192 ) ( ( 0.01302083302289248 0 0 ) ( 0 0.01302083302289248 255.5833282470703 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( -1 0 0 256 ) ( ( 0.01302083302289248 0 0 ) ( 0 0.01302083302289248 255.5833282470703 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
}
}
// primitive 7
{
brushDef3
{
( 0 0 1 -48 ) ( ( 0.01302083302289248 0 0.2083333283662796 ) ( 0 0.01302083302289248 254.5416717529297 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 1 0 -208 ) ( ( 0.01302083302289248 0 1.458333253860474 ) ( 0 0.01302083302289248 255.5833282470703 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 1 0 0 -384 ) ( ( 0.01302083302289248 0 0.2083333283662796 ) ( 0 0.01302083302289248 255.5833282470703 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 0 -1 0 ) ( ( 0.01302083302289248 0 0.2083333283662796 ) ( 0 0.01302083302289248 1.458333253860474 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( 0 -1 0 192 ) ( ( 0.01302083302289248 0 254.5416717529297 ) ( 0 0.01302083302289248 255.5833282470703 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
( -1 0 0 368 ) ( ( 0.01302083302289248 0 0 ) ( 0 0.01302083302289248 255.5833282470703 ) ) "textures/darkmod/stone/flat/smooth/ceramic_tile_tan03" 0 0 0
}
}
}
// entity 1
{
"classname" "light"
"name" "ambient_world"
"_color" "0.32 0.32 0.32"
"light_center" "0 0 0"
"light_radius" "640 640 288"
"nodiffuse" "0"
"noshadows" "1"
"nospecular" "0"
"origin" "320 320 128"
"parallel" "0"
}
// entity 2
{
"classname" "info_player_start"
"name" "info_player_start_1"
"angle" "90"
"origin" "320 96 0"
}
// entity 3
{
"classname" "path_corner"
"name" "path_corner_1"
"angle" "-166.08653259277344"
"origin" "320 608 0"
"target" "path_corner_2"
}
// entity 4
{
"classname" "path_corner"
"name" "path_corner_2"
"angle" "-115.43681335449219"
"origin" "96 544 0"
"target" "path_corner_3"
}
// entity 5
{
"classname" "path_corner"
"name" "path_corner_3"
"angle" "-91.45147705078125"
"origin" "32 320 0"
"target" "path_corner_4"
}
// entity 6
{
"classname" "path_corner"
"name" "path_corner_4"
"angle" "-35.68157958984375"
"origin" "96 96 0"
"target" "path_corner_5"
}
// entity 7
{
"classname" "path_corner"
"name" "path_corner_5"
"angle" "-0.390655517578125"
"origin" "320 32 0"
"target" "path_corner_6"
}
// entity 8
{
"classname" "path_corner"
"name" "path_corner_6"
"angle" "53.463642120361328"
"origin" "544 96 0"
"target" "path_corner_7"
}
// entity 9
{
"classname" "path_corner"
"name" "path_corner_7"
"angle" "94.415420532226563"
"origin" "608 320 0"
"target" "path_corner_8"
}
// entity 10
{
"classname" "path_corner"
"name" "path_corner_8"
"angle" "151.08128356933594"
"origin" "544 544 0"
"target" "path_corner_1"
}
// entity 11
{
"classname" "atdm:ai_townsfolk_beggar"
"name" "ai1"
"origin" "143.524 559.953 6.39771e-008"
"rotation" "-0.905522 -0.424299 2.61807e-007 0.424299 -0.905522 -9.96794e-009 2.41302e-007 1.02059e-007 1"
"target" "path_corner_2"
"team" "0"
}
// entity 12
{
"classname" "atdm:ai_townsfolk_commoner"
"name" "ai2"
"origin" "568.965 495.802 0"
"rotation" "-0.366392 0.930461 0 -0.930461 -0.366392 0 0 0 1"
"target" "path_corner_8"
"team" "0"
}
// entity 13
{
"classname" "atdm:ai_townsfolk_commoner_02"
"name" "ai3"
"origin" "480.077 79.7836 0"
"rotation" "0.852545 0.522654 0 -0.522654 0.852545 0 0 0 1"
"target" "path_corner_6"
"team" "0"
}
// entity 14
{
"classname" "atdm:ai_merchant01"
"name" "ai4"
"origin" "80.0527 144.558 0"
"rotation" "0.557391 -0.830251 0 0.830251 0.557391 0 0 0 1"
"target" "path_corner_4"
"team" "0"
}
// entity 15
{
"classname" "atdm:conversation_info"
"name" "qconv"
"conv_1_actor_1" "ai1"
"conv_1_actors_always_face_each_other_while_talking" "0"
"conv_1_actors_must_be_within_talkdistance" "0"
"conv_1_cmd_1_actor" "1"
"conv_1_cmd_1_arg_1" "sendAI1toQueue"
"conv_1_cmd_1_type" "RunScript"
"conv_1_cmd_1_wait_until_finished" "1"
"conv_1_max_play_count" "-1"
"conv_1_name" "queue_ai1"
"conv_1_talk_distance" "60"
"conv_2_actor_1" "ai2"
"conv_2_actors_always_face_each_other_while_talking" "0"
"conv_2_actors_must_be_within_talkdistance" "0"
"conv_2_cmd_1_actor" "1"
"conv_2_cmd_1_arg_1" "sendAI2toQueue"
"conv_2_cmd_1_type" "RunScript"
"conv_2_cmd_1_wait_until_finished" "1"
"conv_2_max_play_count" "-1"
"conv_2_name" "queue_ai2"
"conv_2_talk_distance" "60"
"conv_3_actor_1" "ai3"
"conv_3_actors_always_face_each_other_while_talking" "0"
"conv_3_actors_must_be_within_talkdistance" "0"
"conv_3_cmd_1_actor" "1"
"conv_3_cmd_1_arg_1" "sendAI3toQueue"
"conv_3_cmd_1_type" "RunScript"
"conv_3_cmd_1_wait_until_finished" "1"
"conv_3_max_play_count" "-1"
"conv_3_name" "queue_ai3"
"conv_3_talk_distance" "60"
"conv_4_actor_1" "ai4"
"conv_4_actors_always_face_each_other_while_talking" "0"
"conv_4_actors_must_be_within_talkdistance" "0"
"conv_4_cmd_1_actor" "1"
"conv_4_cmd_1_arg_1" "sendAI4toQueue"
"conv_4_cmd_1_type" "RunScript"
"conv_4_cmd_1_wait_until_finished" "1"
"conv_4_max_play_count" "-1"
"conv_4_name" "queue_ai4"
"conv_4_talk_distance" "60"
"origin" "224 320 32"
"target1" "ai1"
"target2" "ai2"
"target3" "ai3"
"target4" "ai4"
}
// entity 16
{
"classname" "atdm:switch_rotate_lever"
"name" "atdm_switch_rotate_lever_1"
"origin" "264 192 48"
"rotate" "0 0 45"
"target" "queuestarter"
}
// entity 17
{
"classname" "atdm:switch_rotate_lever"
"name" "atdm_switch_rotate_lever_2"
"origin" "376 192 48"
"rotate" "0 0 45"
"target" "waitstopper"
}
// entity 18
{
"classname" "atdm:target_startconversation"
"name" "start_ai1_qconv"
"angle" "-167.95429992675781"
"conversation" "queue_ai1"
"origin" "136 600 16"
}
// entity 19
{
"classname" "atdm:target_callscriptfunction"
"name" "waitstopper"
"call" "unwait"
"foreach" "0"
"origin" "376 200 51"
}
// entity 20
{
"classname" "atdm:target_callscriptfunction"
"name" "queuestarter"
"call" "enqueueSomeone"
"foreach" "0"
"origin" "264 200 51"
}
// entity 21
{
"classname" "atdm:target_startconversation"
"name" "start_ai2_qconv"
"angle" "-167.95429992675781"
"conversation" "queue_ai2"
"origin" "592 536 16"
}
// entity 22
{
"classname" "atdm:target_startconversation"
"name" "start_ai3_qconv"
"angle" "-167.95429992675781"
"conversation" "queue_ai3"
"origin" "504 40 16"
}
// entity 23
{
"classname" "atdm:target_startconversation"
"name" "start_ai4_qconv"
"angle" "-167.95429992675781"
"conversation" "queue_ai4"
"origin" "48 112 16"
}
// entity 24
{
"classname" "func_static"
"name" "func_static_1"
"origin" "206.952 321.052 0"
"model" "models/darkmod/furniture/lectern.lwo"
"rotation" "-0.00356278 -0.999994 0 0.999994 -0.00356278 0 0 0 1"
}
// entity 25
{
"classname" "atdm:ai_noblewoman01"
"name" "atdm_ai_noblewoman01_1"
"origin" "179.997 319.873 0"
"rotation" "0.998971 -0.0453609 0 0.0453609 0.998971 0 0 0 1"
"team" "0"
}
// entity 26
{
"classname" "func_static"
"name" "func_static_2"
"origin" "207.176 321.95 52.279"
"model" "models/darkmod/readables/book_open1.lwo"
"rotation" "0 -1 0 0.913829 0 0.406098 -0.406098 0 0.913829"
}
// entity 27
{
"classname" "light"
"name" "light_1"
"origin" "208 320 128"
"light_center" "-16 0 0"
"light_radius" "208 320 160"
}

 

 

 

slq.darkradiant:

 

DarkRadiant Map Information File Version 2
{
Layers
{
 Layer 0 { Default }
 Layer 1 { voidseal }
}
NodeToLayerMapping
{
 Node { 0 } // entity (world)
 Node { 0 1 } // primitive (Brush)
 Node { 0 1 } // primitive (Brush)
 Node { 0 1 } // primitive (Brush)
 Node { 0 1 } // primitive (Brush)
 Node { 0 1 } // primitive (Brush)
 Node { 0 1 } // primitive (Brush)
 Node { 0 } // primitive (Brush)
 Node { 0 } // primitive (Brush)
 Node { 0 } // entity (ambient_world)
 Node { 0 } // entity (info_player_start_1)
 Node { 0 } // entity (path_corner_1)
 Node { 0 } // entity (path_corner_2)
 Node { 0 } // entity (path_corner_3)
 Node { 0 } // entity (path_corner_4)
 Node { 0 } // entity (path_corner_5)
 Node { 0 } // entity (path_corner_6)
 Node { 0 } // entity (path_corner_7)
 Node { 0 } // entity (path_corner_8)
 Node { 0 } // entity (ai1)
 Node { 0 } // entity (ai2)
 Node { 0 } // entity (ai3)
 Node { 0 } // entity (ai4)
 Node { 0 } // entity (qconv)
 Node { 0 } // entity (atdm_switch_rotate_lever_1)
 Node { 0 } // entity (atdm_switch_rotate_lever_2)
 Node { 0 } // entity (start_ai1_qconv)
 Node { 0 } // entity (waitstopper)
 Node { 0 } // entity (queuestarter)
 Node { 0 } // entity (start_ai2_qconv)
 Node { 0 } // entity (start_ai3_qconv)
 Node { 0 } // entity (start_ai4_qconv)
 Node { 0 } // entity (func_static_1)
 Node { 0 } // entity (atdm_ai_noblewoman01_1)
 Node { 0 } // entity (func_static_2)
 Node { 0 } // entity (light_1)
}
}

 

 

 

slq.script:

 

 

// global variables / constants
vector QUEUE_SPACING = '32 0 0';

// initialisation
void main()
{
// add a few properties to our ai to keep track of them
$ai1.setKey("queuePosition", "0");
$ai2.setKey("queuePosition", "0");
$ai3.setKey("queuePosition", "0");
$ai4.setKey("queuePosition", "0");
$qconv.setKey("AIsInQueue", "0");
}

// called by the lever that starts someone queueing
void enqueueSomeone()
{
// choose an available ai and start their queue conversation
entity chosenAI;
string targetKey = "";
while (targetKey = $qconv.getNextKey("target", targetKey))
{
	entity nextAI = sys.getEntity($qconv.getKey(targetKey));
	if (nextAI.getKey("queuePosition") == "0")
	{
		chosenAI = nextAI;
		break;
	}
}
sys.println("chosen AI :" + chosenAI.getName());

if	  (chosenAI == $ai1) { $start_ai1_qconv.activate($player1); }
else if (chosenAI == $ai2) { $start_ai2_qconv.activate($player1); }
else if (chosenAI == $ai3) { $start_ai3_qconv.activate($player1); }
else if (chosenAI == $ai4) { $start_ai4_qconv.activate($player1); }
}

// work out coords where an ai should stand in line
vector queueCoords(float nthInLine)
{
vector v;
vector o = $qconv.getOrigin();
v_x = o_x + (QUEUE_SPACING_x * nthInLine);
v_y = o_y + (QUEUE_SPACING_y * nthInLine);
v_z = o_z + (QUEUE_SPACING_z * nthInLine);
return v;
}

// called by the Conversations via the sendAIxToQueue functions below
void addAIToQueue(entity ai_)
{
float queueingAIs = $qconv.getFloatKey("AIsInQueue");
queueingAIs++;
$qconv.setKey("AIsInQueue", queueingAIs);
ai_.setKey("queuePosition", queueingAIs);
vector destination = queueCoords(queueingAIs);
ai_.moveToPosition(destination);
ai_.waitMove();
ai_.faceEntity($qconv);
// main update loop
// keep the "conversation" running until AI is removed from queue
while (ai_.getFloatKey("queuePosition") > 0)
{
	sys.wait(1);	// less wasteful then waitFrame()?
	ai_.moveToPosition(queueCoords(ai_.getFloatKey("queuePosition")));
}
}

// functions called by the Conversations
void sendAI1toQueue() { addAIToQueue($ai1); }
void sendAI2toQueue() { addAIToQueue($ai2); }
void sendAI3toQueue() { addAIToQueue($ai3); }
void sendAI4toQueue() { addAIToQueue($ai4); }

// called by the "remove from queue" lever via function unwait() below
void deQueue(entity ai_)
{  
ai_.setKey("queuePosition", "0"); // ends the conversation
ai_.restartPatrol();
// reduce other AIs' queue positions
float qpos;
if ((qpos=$ai1.getFloatKey("queuePosition")) > 1) $ai1.setKey("queuePosition", qpos-1);
if ((qpos=$ai2.getFloatKey("queuePosition")) > 1) $ai2.setKey("queuePosition", qpos-1);
if ((qpos=$ai3.getFloatKey("queuePosition")) > 1) $ai3.setKey("queuePosition", qpos-1);
if ((qpos=$ai4.getFloatKey("queuePosition")) > 1) $ai4.setKey("queuePosition", qpos-1);
}

// called by the "remove from queue" lever
void unwait()
{
// remove whoever's at the front of the queue
entity chosenAI;
string targetKey = "";
while (targetKey = $qconv.getNextKey("target", targetKey))
{
	entity nextAI = sys.getEntity($qconv.getKey(targetKey));
	if (nextAI.getFloatKey("queuePosition") == 1)
	{
		chosenAI = nextAI;
		break;
	}
}
if (chosenAI)
{
	deQueue(chosenAI);
	$qconv.setKey("AIsInQueue", $qconv.getFloatKey("AIsInQueue")-1);
}
}

 

 

 

post-29566-0-40578900-1385681053_thumb.jpg

Link to comment
Share on other sites

Great! When I have time to spare I'll try to understand everything and make my own tests! (I paused writing the plot for my FM 'cause I need to know how much controlling of the AI is possible)

$guard.moveToPosition($player1.getOrigin());

Link to comment
Share on other sites

If you want to discuss possibilities without unveiling your plot idea in the forum, feel free to send me a PM. I'm new too but I'm a scripting junkie and I'll be happy to give it a go.

 

NB the setup I gave above is a bit more complex than it needs to be. I started by trying to make a solution that others could use entirely in the editor, which is why I targeted all the participating AI from the conversation entity, and why the script loops through that list of targets several times. But given that I couldn't get around hard-coding the AI names in the script, there's no need for those loops or targets. I might as well have just replaced it all with hard-coded AI names.

Edited by SteveL
Link to comment
Share on other sites

Your script should work for me fine with these loops (more via PM the next days). I printet it out to read it en route. Maybe I got time for a testmap today. I'll be thankful for every scripting help as I last coded simple things with a dos-software about 100 years ago...

$guard.moveToPosition($player1.getOrigin());

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 4 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
×
×
  • Create New...