Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion code/rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,8 @@ RulesClass::RulesClass(void) :
UpgradeEliteSound(VOC_NONE),
VoxUnitPromoted(VOX_NONE),
VeteranFlashTimer(0),
EliteFlashTimer(0)
EliteFlashTimer(0),
ComesNearWaypointDistance(CELL_LEPTON_W * 5)
{
/// nothing
}
Expand Down Expand Up @@ -1332,6 +1333,7 @@ bool RulesClass::General(CCINIClass const & ini)
EngineerCaptureLevel = (float)ini.Get_Float(GENERAL, "EngineerCaptureLevel", EngineerCaptureLevel);
EngineerDamage = (float)ini.Get_Float(GENERAL, "EngineerDamage", EngineerDamage);
TalkBubbleTime = int(TIMER_SECOND * ini.Get_Float(GENERAL, "TalkBubbleTime", TalkBubbleTime * (1.0f/TIMER_SECOND)));
ComesNearWaypointDistance = ini.Get_Int(GENERAL, "ComesNearWaypointDistance", ComesNearWaypointDistance);
return(true);
}
return(false);
Expand Down Expand Up @@ -2650,6 +2652,7 @@ void RulesClass::Serialize(SaveStreamClass & stream)
stream.Serialize(VoxUnitPromoted);
stream.Serialize(VeteranFlashTimer);
stream.Serialize(EliteFlashTimer);
stream.Serialize(ComesNearWaypointDistance);
}


Expand Down
5 changes: 5 additions & 0 deletions code/rules.h
Original file line number Diff line number Diff line change
Expand Up @@ -2291,4 +2291,9 @@ class RulesClass
*/
int VeteranFlashTimer;
int EliteFlashTimer;

/*
* Distance in leptons to consider "close enough" for TEVENT_NEAR_WAYPOINT.
*/
int ComesNearWaypointDistance;
};
4 changes: 3 additions & 1 deletion code/tevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@

#include "tevent.h"

#include "_rules.h"
#include "building.h"
#include "builtype.h"
#include "globals.h"
#include "house.h"
#include "incdec.h"
#include "rules.h"
#include "savestream.h"
#include "scenario.h"
#include "sun.h"
Expand Down Expand Up @@ -299,7 +301,7 @@ bool TEventClass::operator () (TEventType event, HouseClass const * house, Objec
else if (Event == TEVENT_NEAR_WAYPOINT) {
if (event != Event) return(false);
Coord waypoint_coord(Scen->Get_Waypoint_Coord(Data.Value));
if (object->Distance(waypoint_coord) > (CELL_LEPTON_W*5)) {
if (object->Distance(waypoint_coord) > Rule->ComesNearWaypointDistance) {
return(false);
}
return(true);
Expand Down
22 changes: 22 additions & 0 deletions manual/changes/comes-near-waypoint-distance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: Make the Comes near waypoint distance configurable
category: feature
release: 0.3.0
targets:
- type: key
id: ComesNearWaypointDistance
effect: added
- type: event
id: TEVENT_NEAR_WAYPOINT
effect: changed
- type: format
id: save-games
effect: changed
credit:
- JoyfulShush
- Rampastring
---

`ComesNearWaypointDistance` in `[General]` sets how near an object must come to a waypoint for the Comes near waypoint trigger event to be satisfied. It is written in leptons; raise it to satisfy the event from farther away, or lower it to require the object closer.

Credits to Rampastring for their original Vinifera implementation for this feature.
19 changes: 19 additions & 0 deletions manual/content/keys/comesnearwaypointdistance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
key: ComesNearWaypointDistance
summary: Distance in leptons from a waypoint within which the Comes near waypoint trigger event is satisfied.
when_omitted:
kind: value
value: "1280"
note: Five cells.
---

`ComesNearWaypointDistance` sets how near the tagged object must come to the named waypoint for the [Comes near waypoint](/mapping/events/tevent-near-waypoint/) trigger event to be satisfied. An object at this distance or nearer satisfies it; one farther away does not. Raising the value satisfies the event from farther away, and lowering it requires the object to come closer.

```ini title="rules.ini"
[General]
ComesNearWaypointDistance=2560 ; the event is satisfied within ten cells of the waypoint
```

Write the distance in [leptons](/glossary/#lepton), the engine's unit of distance. One cell is 256 leptons, so `512` reaches two cells. A value written as a cell count is read as that many leptons: `5` reaches five leptons, not five cells.

With a value of `0`, only an object whose center coincides with the waypoint's center satisfies the event. Any value below `0` leaves the event unsatisfied for every object.
6 changes: 4 additions & 2 deletions manual/content/scripting/events/34.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
type: event
id: TEVENT_NEAR_WAYPOINT
title: Comes near waypoint
summary: Satisfied when the tagged object finishes a move into a cell, or lands in one, within five cells of the named waypoint.
summary: Satisfied when the tagged object finishes a move into a cell, or lands in one, within `ComesNearWaypointDistance` of the named waypoint, five cells by default.
valid_values:
- A waypoint the scenario places. For a waypoint that is not placed, the result is unpredictable.
caveats:
- The event is offered each time the object finishes moving into a cell, and when it lands after a parachute drop or a fall. An object that stands still near the waypoint, including one placed there when the scenario starts, does not satisfy the event until it moves.
- Infantry and vehicles make the offer as they move. Aircraft do not.
- The distance is measured in a straight line from the object's center to the center of the waypoint's cell, and height counts toward it. When the waypoint's cell lies under a bridge, or under one that has been destroyed, the distance is measured from the height of the bridge deck.
- The distance compared with [`ComesNearWaypointDistance`](/keys/comesnearwaypointdistance/) is measured in a straight line from the object's center to the center of the waypoint's cell, and height counts toward it. When the waypoint's cell lies under a bridge, or under one that has been destroyed, the distance is measured from the height of the bridge deck.
- The event tests only the tagged object, whatever house owns it.
- On a persistent tag, the event stays marked once it is satisfied. A persistent trigger holding only this event therefore fires on every later offer the tag receives, wherever the object has moved.
related:
- type: system
id: trigger-springing
- type: key
id: ComesNearWaypointDistance
---
18 changes: 18 additions & 0 deletions manual/data/ini-keys.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5262,6 +5262,24 @@ ColorSpeed:
source: code/ptype.cpp
guard: null
level: ParticleTypeClass
ComesNearWaypointDistance:
key: ComesNearWaypointDistance
scopes:
- applies_to:
- global rules
file: rules.ini
section:
kind: literal
name: General
value_type: integer
status: generated
_provenance:
default_candidate: null
declared_in: RulesClass
member: ComesNearWaypointDistance
source: code/rules.cpp
guard: null
level: RulesClass
CompEasyBonus:
key: CompEasyBonus
scopes:
Expand Down
2 changes: 1 addition & 1 deletion manual/site/scripts/check-render.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const cases = [
['mapping/actions/taction-change-house/index.html', ['Change House', 'Hands every infantry, vehicle, aircraft and structure']],
['mapping/actions/taction-play-anim/index.html', ['Parameters', 'Animation', 'Waypoint', 'INI example', '[Actions]', '<TriggerID>=1,41,0,<Animation>']],
['mapping/missions/tmission-play-anim/index.html', ['Animation', 'Loop count']],
['mapping/events/tevent-near-waypoint/index.html', ['Comes near waypoint', 'within five cells of the named waypoint', 'INI example', '<TriggerID>=1,34,0,<Waypoint>']],
['mapping/events/tevent-near-waypoint/index.html', ['Comes near waypoint', 'of the named waypoint, five cells by default', 'INI example', '<TriggerID>=1,34,0,<Waypoint>']],
['mapping/missions/tmission-loop/index.html', ['Jump to line', 'one-based']],
['internals/class-hierarchy/index.html', ['Object and type system', 'Primary runtime hierarchy', 'Type-definition hierarchy', 'AbstractTypeClass', 'code/abstype.h']],
['internals/radio/index.html', ['Radio contact protocol', 'Contact state', 'Messages and responses', 'Compute_CRC', 'code/radio.cpp']],
Expand Down
Loading