Skip to content

Commit

Permalink
Merge pull request #77148 from sparr/f_is_controlling_vehicle
Browse files Browse the repository at this point in the history
Add controlling_vehicle EOC condition
  • Loading branch information
Maleclypse authored Oct 20, 2024
2 parents 91af1b1 + e6ca8c3 commit ecbfba8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
10 changes: 7 additions & 3 deletions data/json/ui/structured/structured_speed_vehicle.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@
"width": 27,
"clauses": [
{
"id": "not_driving",
"id": "not_controlling_vehicle",
"widgets": [ "structured_wield_simple", "structured_speed_layout" ],
"condition": { "not": "u_driving" }
"condition": { "not": "u_controlling_vehicle" }
},
{ "id": "driving", "widgets": [ "structured_fuel", "structured_vehicle_speed" ], "condition": "u_driving" }
{
"id": "controlling_vehicle",
"widgets": [ "structured_fuel", "structured_vehicle_speed" ],
"condition": "u_controlling_vehicle"
}
]
},
{
Expand Down
25 changes: 23 additions & 2 deletions doc/EFFECT_ON_CONDITION.md
Original file line number Diff line number Diff line change
Expand Up @@ -875,9 +875,30 @@ You don't wield anything
{ "not": "u_has_weapon" }
```

### `u_controlling_vehicle``npc_controlling_vehicle`
- type: simple string
- return true if alpha or beta talker control a vehicle; Nota bene: NPCs cannot currently operate vehicles

#### Valid talkers:

| Avatar | Character | NPC | Monster | Furniture | Item |
| ------ | --------- | --------- | ---- | ------- | --- |
| ✔️ | ✔️ | ✔️ ||||

#### Examples

```json
"u_controlling_vehicle"
```

true if you do not drive
```json
{ "not": "u_controlling_vehicle" }
```

### `u_driving``npc_driving`
- type: simple string
- return true if alpha or beta talker operate a vehicles; Nota bene: NPCs cannot currently operate vehicles
- return true if alpha or beta talker operate a moving vehicle; Nota bene: NPCs cannot currently operate vehicles

#### Valid talkers:

Expand Down Expand Up @@ -4524,4 +4545,4 @@ Combination of values work as `and`, no matter how they are arranged. This two n
```
```json
"search_data": [ { "category": "weapons", "wielded_only": true } ]
```
```
14 changes: 13 additions & 1 deletion src/condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1558,11 +1558,22 @@ conditional_t::func f_has_weapon( bool is_npc )
};
}

conditional_t::func f_is_controlling_vehicle( bool is_npc )
{
return [is_npc]( dialogue const & d ) {
const talker *actor = d.actor( is_npc );
if( const optional_vpart_position &vp = get_map().veh_at( actor->pos() ) ) {
return actor->is_in_control_of( vp->vehicle() );
}
return false;
};
}

conditional_t::func f_is_driving( bool is_npc )
{
return [is_npc]( dialogue const & d ) {
const talker *actor = d.actor( is_npc );
if( const optional_vpart_position vp = get_map().veh_at( actor->pos() ) ) {
if( const optional_vpart_position &vp = get_map().veh_at( actor->pos() ) ) {
return vp->vehicle().is_moving() && actor->is_in_control_of( vp->vehicle() );
}
return false;
Expand Down Expand Up @@ -2609,6 +2620,7 @@ parsers_simple = {
{"u_can_stow_weapon", "npc_can_stow_weapon", &conditional_fun::f_can_stow_weapon },
{"u_can_drop_weapon", "npc_can_drop_weapon", &conditional_fun::f_can_drop_weapon },
{"u_has_weapon", "npc_has_weapon", &conditional_fun::f_has_weapon },
{"u_controlling_vehicle", "npc_controlling_vehicle", &conditional_fun::f_is_controlling_vehicle },
{"u_driving", "npc_driving", &conditional_fun::f_is_driving },
{"u_has_activity", "npc_has_activity", &conditional_fun::f_has_activity },
{"u_is_riding", "npc_is_riding", &conditional_fun::f_is_riding },
Expand Down

0 comments on commit ecbfba8

Please sign in to comment.