Class TCastleMoveAttack

Unit

Declaration

type TCastleMoveAttack = class(TCastleBehavior)

Description

Creature that can move around (navigating the 3D world), chasing the enemy, attacking the enemy (by short-range or long-range attack), running away from danger.

Optional dependencies: if present, this behavior will use other behaviors on the same parent:

  • TCastleSoundSource (to play spatial sounds; this creature is silent otherwise),

  • TCastleLiving (to account for the fact that current creature may be dead, or badly wounded; if the TCastleLiving is not present, this creature is assumed indestructible.)

Source: scene/castlelivingbehaviors_moveattack.inc (line 37).

Hierarchy

Show Additional Members:

Overview

Nested Types

Public TState = (...);

Constants

Public DefaultAnimationIdle = 'idle';
Public DefaultAnimationMove = 'move';
Public DefaultAnimationAttack = '';
Public DefaultAnimationFireMissile = '';
Public DefaultAnimationDie = 'die';
Public DefaultAnimationDieBack = '';
Public DefaultAnimationHurt = 'hurt';
Public DefaultAttackTime = 0.0;
Public DefaultAttackMinDelay = 2.0;
Public DefaultAttackMaxDistance = 2.0;
Public DefaultAttackMaxAngle = Pi / 6;
Public DefaultFireMissileTime = 0.0;
Public DefaultFireMissileMinDelay = DefaultAttackMinDelay;
Public DefaultFireMissileMaxDistance = 30.0;
Public DefaultFireMissileMaxAngle = DefaultAttackMaxAngle;
Public DefaultFireMissileHeight = 0.5;
Public DefaultMoveSpeed = 1.0;
Public DefaultRunAwayLife = 0.3;
Public DefaultRunAwayDistance = 10.0;
Public DefaultPreferredDistance = DefaultAttackMaxDistance;
Public DefaultRandomMoveDistance = 10.0;
Public DefaultMaxHeightAcceptableToFall = 1.5;
Public DefaultVisibilityAngle = Pi * 120 / 180;
Public DefaultSmellDistance = 0.0;
Public DefaultRemoveDead = false;

Methods

Protected function GetInternalText: String; virtual;
Protected procedure SetInternalText(const Value: String); virtual;
Protected procedure SetName(const Value: TComponentName); override;
Protected procedure TranslateProperties(const TranslatePropertyEvent: TTranslatePropertyEvent); virtual;
Public procedure CustomSerialization(const SerializationProcess: TSerializationProcess); virtual;
Public procedure SetTransient;
Public procedure AddNonVisualComponent(const NonVisualComponent: TComponent);
Public procedure InsertNonVisualComponent(const Index: Integer; const NonVisualComponent: TComponent);
Public procedure RemoveNonVisualComponent(const NonVisualComponent: TComponent);
Public function NonVisualComponentsIndexOf(const NonVisualComponent: TComponent): Integer;
Public function NonVisualComponentsCount: Integer;
Public function NonVisualComponentsEnumerate: TNonVisualComponentsEnumerator;
Public function ValueIsStreamed: Boolean; virtual;
Public procedure DesignerInfo(const SList: TStrings); virtual;
Public procedure DesignerWarnings(const SList: TStrings); virtual;
Protected procedure BeforeRender( const CameraView: TViewVectors; const ParentParentWorldTransformation: TTransformation); virtual;
Protected procedure ParentChanged; virtual; deprecated 'Use ParentAfterAttach / ParentBeforeDetach or WorldAfterAttach / WorldBeforeDetach';
Protected procedure ParentBeforeDetach; virtual;
Protected procedure WorldAfterAttach; virtual;
Protected procedure WorldBeforeDetach; virtual;
Public procedure BeforeDestruction; override;
Public function World: TCastleAbstractRootTransform;
Protected procedure SetState(const Value: TState); virtual;
Protected procedure ParentAfterAttach; override;
Protected function CanAttachToParent(const NewParent: TCastleTransform; out ReasonWhyCannot: String): Boolean; override;
Protected procedure Attack; virtual;
Protected procedure FireMissile; virtual;
Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public function PropertySections(const PropertyName: String): TPropertySections; override;
Public procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;

Properties

Public property NonVisualComponents [const Index: Integer]: TComponent read GetNonVisualComponents;
Public property IsLoading: Boolean read FIsLoading;
Public property Parent: TCastleTransform read FParent;
Public property ListenWorldChange: Boolean read FListenWorldChange write SetListenWorldChange;
Public property State: TState read FState default stateIdle;
Public property LifeTime: TFloatTime read FLifeTime;
Published property Enemy: TCastleLiving read FEnemy write SetEnemy;
Published property SoundAttackHit: TCastleSound read FSoundAttackHit write SetSoundAttackHit;
Published property SoundAttackStart: TCastleSound read FSoundAttackStart write SetSoundAttackStart;
Published property AnimationIdle: String read FAnimationIdle write FAnimationIdle stored AnimationIdleStored nodefault;
Published property AnimationMove: String read FAnimationMove write FAnimationMove stored AnimationMoveStored nodefault;
Published property AnimationAttack: String read FAnimationAttack write FAnimationAttack stored AnimationAttackStored nodefault;
Published property AnimationFireMissile: String read FAnimationFireMissile write FAnimationFireMissile stored AnimationFireMissileStored nodefault;
Published property AnimationDie: String read FAnimationDie write FAnimationDie stored AnimationDieStored nodefault;
Published property AnimationDieBack: String read FAnimationDieBack write FAnimationDieBack stored AnimationDieBackStored nodefault;
Published property AnimationHurt: String read FAnimationHurt write FAnimationHurt stored AnimationHurtStored nodefault;
Published property AttackMinDelay: Single read FAttackMinDelay write FAttackMinDelay default DefaultAttackMinDelay;
Published property AttackMaxDistance: Single read FAttackMaxDistance write FAttackMaxDistance default DefaultAttackMaxDistance;
Published property AttackTime: Single read FAttackTime write FAttackTime default DefaultAttackTime;
Published property AttackMaxAngle: Single read FAttackMaxAngle write FAttackMaxAngle default DefaultAttackMaxAngle;
Published property AttackDamage: TCastleDamage read FAttackDamage;
Published property FireMissileTime: Single read FFireMissileTime write FFireMissileTime default DefaultFireMissileTime;
Published property FireMissileMinDelay: Single read FFireMissileMinDelay write FFireMissileMinDelay default DefaultFireMissileMinDelay;
Published property FireMissileMaxDistance: Single read FFireMissileMaxDistance write FFireMissileMaxDistance default DefaultFireMissileMaxDistance;
Published property FireMissileMaxAngle: Single read FFireMissileMaxAngle write FFireMissileMaxAngle default DefaultFireMissileMaxAngle;
Published property FireMissileHeight: Single read FFireMissileHeight write FFireMissileHeight default DefaultFireMissileHeight;
Published property MoveSpeed: Single read FMoveSpeed write FMoveSpeed default DefaultMoveSpeed;
Published property RunAwayLife: Single read FRunAwayLife write FRunAwayLife default DefaultRunAwayLife;
Published property RunAwayDistance: Single read FRunAwayDistance write FRunAwayDistance default DefaultRunAwayDistance;
Published property PreferredDistance: Single read FPreferredDistance write FPreferredDistance default DefaultPreferredDistance;
Published property RandomMoveDistance: Single read FRandomMoveDistance write FRandomMoveDistance default DefaultRandomMoveDistance;
Published property MaxHeightAcceptableToFall: Single read FMaxHeightAcceptableToFall write FMaxHeightAcceptableToFall default DefaultMaxHeightAcceptableToFall;
Published property VisibilityAngle: Single read FVisibilityAngle write FVisibilityAngle default DefaultVisibilityAngle;
Published property SmellDistance: Single read FSmellDistance write FSmellDistance default DefaultSmellDistance;
Published property RemoveDead: Boolean read FRemoveDead write FRemoveDead default DefaultRemoveDead;

Description

Nested Types

Public TState = (...);

This item has no description.

Values
  • stateIdle
  • stateMove
  • stateAttack
  • stateFireMissile
  • stateDie
  • stateDieBack
  • stateHurt

Source: scene/castlelivingbehaviors_moveattack.inc (line 40).

Constants

Public DefaultAnimationIdle = 'idle';

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 184).

Public DefaultAnimationMove = 'move';

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 185).

Public DefaultAnimationAttack = '';

Default value of AnimationAttack, empty because it is an optional animation.

Source: scene/castlelivingbehaviors_moveattack.inc (line 186).

Public DefaultAnimationFireMissile = '';

Default value of AnimationFireMissile, empty because it is an optional animation.

Source: scene/castlelivingbehaviors_moveattack.inc (line 187).

Public DefaultAnimationDie = 'die';

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 188).

Public DefaultAnimationDieBack = '';

Default value of AnimationDieBack, empty because it is an optional animation.

Source: scene/castlelivingbehaviors_moveattack.inc (line 189).

Public DefaultAnimationHurt = 'hurt';

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 190).

Public DefaultAttackTime = 0.0;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 192).

Public DefaultAttackMinDelay = 2.0;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 193).

Public DefaultAttackMaxDistance = 2.0;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 194).

Public DefaultAttackMaxAngle = Pi / 6;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 195).

Public DefaultFireMissileTime = 0.0;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 197).

Public DefaultFireMissileMinDelay = DefaultAttackMinDelay;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 198).

Public DefaultFireMissileMaxDistance = 30.0;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 199).

Public DefaultFireMissileMaxAngle = DefaultAttackMaxAngle;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 200).

Public DefaultFireMissileHeight = 0.5;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 201).

Public DefaultMoveSpeed = 1.0;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 203).

Public DefaultRunAwayLife = 0.3;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 204).

Public DefaultRunAwayDistance = 10.0;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 205).

Public DefaultPreferredDistance = DefaultAttackMaxDistance;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 206).

Public DefaultRandomMoveDistance = 10.0;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 207).

Public DefaultMaxHeightAcceptableToFall = 1.5;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 208).

Public DefaultVisibilityAngle = Pi * 120 / 180;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 209).

Public DefaultSmellDistance = 0.0;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 210).

Public DefaultRemoveDead = false;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 212).

Methods

Protected function GetInternalText: String; virtual;

This item is declared in ancestor TCastleComponent.

This item has no description.

Source: base/castleclassutils.pas (line 575).

Protected procedure SetInternalText(const Value: String); virtual;

This item is declared in ancestor TCastleComponent.

This item has no description.

Source: base/castleclassutils.pas (line 576).

Protected procedure SetName(const Value: TComponentName); override;

This item is declared in ancestor TCastleComponent.

This item has no description.

Source: base/castleclassutils.pas (line 577).

Protected procedure TranslateProperties(const TranslatePropertyEvent: TTranslatePropertyEvent); virtual;

This item is declared in ancestor TCastleComponent.

Enumerate all properties that are possible to translate in this component. E.g. in TCastleLabel it will return TCastleLabel.Caption, in TCastleEdit it will return TCastleEdit.Text and TCastleEdit.Placeholder.

Returns only non-empty properties, thus assuming that if current (by convention, English) text is empty, then there is no point in translating it. Moreover descendants may define boolean properties to exclude particular text from translating, e.g. TCastleLabel.CaptionTranslate, TCastleEdit.TextTranslate, TCastleEdit.PlaceholderTranslate.

It is not recursive (it doesn't enumerate children properties). Use global TranslateProperties procedure to call this on a hierarchy of TComponent.

You usually don't want to call this method (it is called by other engine routines). But you may find it useful to override this, if you define new component.

Source: base/castleclassutils.pas (line 598).

Public procedure CustomSerialization(const SerializationProcess: TSerializationProcess); virtual;

This item is declared in ancestor TCastleComponent.

Override this method to call various methods of SerializationProcess, which in turn allows to serialize/deserialize things that are not published. This allows to serialize/deserialize with more freedom, e.g. to serialize/deserialize some private field.

Source: base/castleclassutils.pas (line 610).

Public procedure SetTransient;

This item is declared in ancestor TCastleComponent.

Ignore this component when serializing parent's TCastleUserInterface.Controls list or TCastleTransform.List, and do not show this component in CGE editor. This simply sets csTransient flag in ComponentStyle.

This is useful for children that are automatically managed by the parent, and should not be modified by user code. For example, TCastleCheckbox is internally composed from TCastleImageControl and TCastleLabel children, but we don't want to serialize or even show these children to user.

Note that if you want to prevent this component from serializing as part of TCastleUserInterface.Controls list or TCastleTransform.List, but you still want it to be visible in CGE editor, then make it a "subcomponent" instead, by SetSubComponent(true).

Note that both csSubComponent and csTransient only disable the component serialization as part of parent's lists enumerated by CustomSerialization (see internal TCastleUserInterface.SerializeChildrenEnumerate , TCastleTransform.SerializeChildrenEnumerate, TCastleTransform.SerializeBehaviorsEnumerate).

If you will make the component published in its own property (which is normal for "subcomponents") then it will be serialized anyway, just as part of it's own property (like TCastleScrollView.ScrollArea). So to really avoid serializing a children component make it csSubComponent and/or csTransient, and do not publish it.

Source: base/castleclassutils.pas (line 663).

Public procedure AddNonVisualComponent(const NonVisualComponent: TComponent);

This item is declared in ancestor TCastleComponent.

Add non-visual component to this component. This is used to organize non-visual components in a tree hierarchy, in CGE designs and editor.

See also
NonVisualComponentsCount
Count of components added by AddNonVisualComponent.
NonVisualComponents
Components added by AddNonVisualComponent.
NonVisualComponentsEnumerate
You can enumerate current non-visual components using loop like for C in MyComponent.NonVisualComponentsEnumerate do ....

Source: base/castleclassutils.pas (line 672).

Public procedure InsertNonVisualComponent(const Index: Integer; const NonVisualComponent: TComponent);

This item is declared in ancestor TCastleComponent.

Insert non-visual component to this component. This is used to organize non-visual components in a tree hierarchy, in CGE designs and editor.

See also
NonVisualComponentsCount
Count of components added by AddNonVisualComponent.
NonVisualComponents
Components added by AddNonVisualComponent.
NonVisualComponentsEnumerate
You can enumerate current non-visual components using loop like for C in MyComponent.NonVisualComponentsEnumerate do ....

Source: base/castleclassutils.pas (line 681).

Public procedure RemoveNonVisualComponent(const NonVisualComponent: TComponent);

This item is declared in ancestor TCastleComponent.

Removes the component previously added by AddNonVisualComponent.

Source: base/castleclassutils.pas (line 684).

Public function NonVisualComponentsIndexOf(const NonVisualComponent: TComponent): Integer;

This item is declared in ancestor TCastleComponent.

Index of the previously added non-visual component. Returns -1 if the component was not found.

Source: base/castleclassutils.pas (line 688).

Public function NonVisualComponentsCount: Integer;

This item is declared in ancestor TCastleComponent.

Count of components added by AddNonVisualComponent.

See also
AddNonVisualComponent
Add non-visual component to this component.
NonVisualComponents
Components added by AddNonVisualComponent.
NonVisualComponentsEnumerate
You can enumerate current non-visual components using loop like for C in MyComponent.NonVisualComponentsEnumerate do ....

Source: base/castleclassutils.pas (line 695).

Public function NonVisualComponentsEnumerate: TNonVisualComponentsEnumerator;

This item is declared in ancestor TCastleComponent.

You can enumerate current non-visual components using loop like for C in MyComponent.NonVisualComponentsEnumerate do .... Do not call this method in other contexts, it is only useful for "for..in" construction.

See also
AddNonVisualComponent
Add non-visual component to this component.

Source: base/castleclassutils.pas (line 705).

Public function ValueIsStreamed: Boolean; virtual;

This item is declared in ancestor TCastleComponent.

Whether the current value of this object should be written to the stream. This should be True if anything inside this object should be serialized (which means it has non-default value or "stored" specifier indicates that it should be serialized).

This is used by CastleComponentSerialize, which is used in Castle Game Engine for all serialization.

In simple cases, this just says whether the current value of this object equals to some default value.

The default implementation of this class returns True (so always write).

Descendants that override this to sometimes return False (so no need to write) must be very careful: any addition of a new field requires extending this method, otherwise new field may not be saved sometimes (when all other fields are default). Descentants of such classes must also be aware of it. This check must include everything that is inside this object in JSON, including subcomponents and children objects (as done e.g. by TSerializationProcess.ReadWriteList). In practice, overriding this method is only reasonable for simple classes that will not change much in the future, like TCastleVector3Persistent.

The name of this method is consistent with TPropertyEditor.ValueIsStreamed in LCL.

Source: base/castleclassutils.pas (line 739).

Public procedure DesignerInfo(const SList: TStrings); virtual;

This item is declared in ancestor TCastleComponent.

Override to add information that should be visible at design-time. Call SList.Add for each new line of information.

Source: base/castleclassutils.pas (line 743).

Public procedure DesignerWarnings(const SList: TStrings); virtual;

This item is declared in ancestor TCastleComponent.

Override to add warnings that should be visible at design-time. Call SList.Add for each new warning.

Source: base/castleclassutils.pas (line 747).

Protected procedure BeforeRender( const CameraView: TViewVectors; const ParentParentWorldTransformation: TTransformation); virtual;

This item is declared in ancestor TCastleBehavior.

Event called right before rendering the parent TCastleTransform. Override this if you have to adjust the parent transformation strictly before the rendering.

Compared to adjusting the parent transformation in e.g. Update, adjusting the parent transformation here has advantages:

  1. There's no 1-frame delay between moving the thing that causes the change (like camera) and updating the thing that reacts to it (like a transformation with a billboard).

  2. We adjust transformation before rendering each occurrence of TCastleTransform in the viewport tree. This matters if given TCastleTransform may occur multiple times in the viewport tree, directly or through TCastleTransformReference.

  3. We adjust transformation before each render, so things are OK if given TCastleTransform is present in multiple viewports (see https://castle-engine.io/multiple_viewports_to_display_one_world).

For example, adjusting the TCastleTransform done by the TCastleBillboard is done using this method. The transformation in this case is determined by the camera and parent's parent transformation. The transformation has to be applied without any delay (even a 1-frame delay would be visible, as artifacts caused by billboard not perfectly aligned with the camera would be visible – blending sort along camera direction in sort3D is not perfect if billboard doesn't exactly match camera direction). And the transformation with billboard may be present in multiple viewports and/or multiple times in the same viewport tree.

Parameters
CameraView
Current camera vectors, in world coordinates, used to render the scene now.
ParentParentWorldTransformation

World transformation of the parent of the parent of this behavior. The name is kind of convoluted, but consistent: When the parent of this behavior has exactly one parent TCastleTransform (not zero, not more) then ParentParentWorldTransformation.Transform is equivalent to Parent.Parent.WorldTransform.

Source: transform/castletransform_behavior.inc (line 103).

Protected procedure ParentChanged; virtual; deprecated 'Use ParentAfterAttach / ParentBeforeDetach or WorldAfterAttach / WorldBeforeDetach';

This item is declared in ancestor TCastleBehavior.

Warning: this symbol is deprecated: Use ParentAfterAttach / ParentBeforeDetach or WorldAfterAttach / WorldBeforeDetach

Called after Parent changed, at the end of TCastleTransform.AddBehavior, TCastleTransform.RemoveBehavior.

Source: transform/castletransform_behavior.inc (line 109).

Protected procedure ParentBeforeDetach; virtual;

This item is declared in ancestor TCastleBehavior.

Called before Parent changed, e.g. at the beginning of TCastleTransform.RemoveBehavior.

This is also called at the destruction of behavior (more precisely from BeforeDestruction now). Even in this case, we guarantee that Parent is still valid during this call, and not in half-destroyed state. Before the actual destructor of TCastleBehavior we do BeforeParentDetach and BeforeWorldDetach and set Parent to Nil.

Source: transform/castletransform_behavior.inc (line 122).

Protected procedure WorldAfterAttach; virtual;

This item is declared in ancestor TCastleBehavior.

Called after Parent became part of World. Called only if ListenWorldChange is True.

Source: transform/castletransform_behavior.inc (line 126).

Protected procedure WorldBeforeDetach; virtual;

This item is declared in ancestor TCastleBehavior.

Called before Parent stops being part of World. Called only if ListenWorldChange is True.

This is also called at the destruction of behavior (more precisely from BeforeDestruction now). Even in this case, we guarantee that Parent is still valid during this call, and not in half-destroyed state. Before the actual destructor of TCastleBehavior we do BeforeParentDetach and BeforeWorldDetach and set Parent to Nil.

Source: transform/castletransform_behavior.inc (line 136).

Public procedure BeforeDestruction; override;

This item is declared in ancestor TCastleBehavior.

This item has no description.

Source: transform/castletransform_behavior.inc (line 161).

Public function World: TCastleAbstractRootTransform;

This item is declared in ancestor TCastleBehavior.

Reference to the root transformation (typically matching the TCastleViewport.Items value) corresponding to the parent of this behavior.

May be Nil if the behavior is not yet added to the parent TCastleTransform, or when the TCastleTransform is not yet part of the TCastleAbstractRootTransform (which means that TCastleTransform is not added to the viewport yet). You can use ListenWorldChange and override WorldBeforeDetach, WorldAfterAttach to be notified when this changes.

Source: transform/castletransform_behavior.inc (line 184).

Protected procedure SetState(const Value: TState); virtual;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 154).

Protected procedure ParentAfterAttach; override;

This item has no description. Showing description inherited from TCastleBehavior.ParentAfterAttach.

Called after Parent changed, e.g. at the end of TCastleTransform.AddBehavior.

Source: scene/castlelivingbehaviors_moveattack.inc (line 155).

Protected function CanAttachToParent(const NewParent: TCastleTransform; out ReasonWhyCannot: String): Boolean; override;

This item has no description. Showing description inherited from TCastleBehavior.CanAttachToParent.

Check can this behavior be added to NewParent. When this returns False, it has to set also ReasonWhyCannot. When overriding this, you can use e.g. this code to make sure we are the only behavior of given class:

function TCastleBillboard.CanAttachToParent(const NewParent: TCastleTransform;
  out ReasonWhyCannot: String): Boolean;
begin
  Result := inherited;
  if not Result then Exit;

  if NewParent.FindBehavior(TCastleBillboard) <> nil then
  begin
    ReasonWhyCannot := 'Only one TCastleBillboard behavior can be added to a given TCastleTransform';
    Result := false;
  end;
end;

Source: scene/castlelivingbehaviors_moveattack.inc (line 156).

Protected procedure Attack; virtual;

Actually do the attack indicated by AnimationAttack and AttackTime and other AttackXxx properties. This happens in the middle of AnimationAttack, at the time see AttackTime.

This can happen only if you defined AnimationAttack (it is <> '').

The default implementation here performs a short range attack, if enemy is still within reach (AttackMaxDistance; even if it was within reach at the start of stateAttack state, the enemy could step back, so we need to check AttackMaxDistance again). The damage and knockback are defined by AttackDamage.

Source: scene/castlelivingbehaviors_moveattack.inc (line 170).

Protected procedure FireMissile; virtual;

Actually do the attack indicated by AnimationFireMissile and FireMissileTime and other FireMissileXxx properties. This happens in the middle of AnimationFireMissile, at the time FireMissileTime.

This can happen only if you defined AnimationFireMissile (it is <> '').

The default implementation here creates a new missile using FireMissileFactory, if FireMissileFactory is not Nil.

Source: scene/castlelivingbehaviors_moveattack.inc (line 181).

Public constructor Create(AOwner: TComponent); override;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 214).

Public destructor Destroy; override;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 215).

Public function PropertySections(const PropertyName: String): TPropertySections; override;

This item has no description. Showing description inherited from TCastleComponent.PropertySections.

Section where to show property in the editor.

Source: scene/castlelivingbehaviors_moveattack.inc (line 216).

Public procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;

This item has no description. Showing description inherited from TCastleBehavior.Update.

Continuously occuring event, for various tasks.

Source: scene/castlelivingbehaviors_moveattack.inc (line 217).

Properties

Public property NonVisualComponents [const Index: Integer]: TComponent read GetNonVisualComponents;

This item is declared in ancestor TCastleComponent.

Components added by AddNonVisualComponent.

Source: base/castleclassutils.pas (line 698).

Public property IsLoading: Boolean read FIsLoading;

This item is declared in ancestor TCastleComponent.

Is the component during deserialization now.

Note: We can't use csLoading in ComponentState because in Delphi it is not possible to control it from CastleComponentSerialize.

Source: base/castleclassutils.pas (line 711).

Public property Parent: TCastleTransform read FParent;

This item is declared in ancestor TCastleBehavior.

Parent TCastleTransform of this behavior. Change it by doing TCastleTransform.AddBehavior, TCastleTransform.RemoveBehavior.

Nil if this behavior is not yet added to a parent.

Source: transform/castletransform_behavior.inc (line 191).

Public property ListenWorldChange: Boolean read FListenWorldChange write SetListenWorldChange;

This item is declared in ancestor TCastleBehavior.

Set this to True to receive WorldBeforeDetach, WorldAfterAttach calls.

Source: transform/castletransform_behavior.inc (line 194).

Public property State: TState read FState default stateIdle;

Current state of the creature, automatically changing.

Source: scene/castlelivingbehaviors_moveattack.inc (line 220).

Public property LifeTime: TFloatTime read FLifeTime;

Life, in seconds.

Source: scene/castlelivingbehaviors_moveattack.inc (line 223).

Published property Enemy: TCastleLiving read FEnemy write SetEnemy;

Enemy that is being chased and attacked by this creature. May be Nil, which means that the creature is not chasing anybody.

Source: scene/castlelivingbehaviors_moveattack.inc (line 227).

Published property SoundAttackHit: TCastleSound read FSoundAttackHit write SetSoundAttackHit;

Sound played when short-range attack hits.

Source: scene/castlelivingbehaviors_moveattack.inc (line 230).

Published property SoundAttackStart: TCastleSound read FSoundAttackStart write SetSoundAttackStart;

Played at the start of attack animation, that is when entering stateAttack state. To play a sound when the actual hit happens (at AttackTime) see SoundAttackHit.

This is a sound name from sound repository (see https://castle-engine.io/sound). None by default.

Source: scene/castlelivingbehaviors_moveattack.inc (line 239).

Published property AnimationIdle: String read FAnimationIdle write FAnimationIdle stored AnimationIdleStored nodefault;

An animation of being idle (standing / floating in place). Will be played in a loop.

Source: scene/castlelivingbehaviors_moveattack.inc (line 243).

Published property AnimationMove: String read FAnimationMove write FAnimationMove stored AnimationMoveStored nodefault;

Animation of moving, will be played in a loop.

Source: scene/castlelivingbehaviors_moveattack.inc (line 246).

Published property AnimationAttack: String read FAnimationAttack write FAnimationAttack stored AnimationAttackStored nodefault;

An animation of short-range attacking. Optional, it may be '' if creature doesn't make short-range attack.

Source: scene/castlelivingbehaviors_moveattack.inc (line 250).

Published property AnimationFireMissile: String read FAnimationFireMissile write FAnimationFireMissile stored AnimationFireMissileStored nodefault;

Firing missile animation. Optional, it may be '' if creature doesn't fire missiles.

You can always override TCastleMoveAttack.FireMissile to do pretty much anything you want, and this way treat this as an "alternate attack", not necessarily firing a missile. It's not really required to actually fire a missile — it's only what happens at the default TCastleMoveAttack.FireMissile implementation.

Source: scene/castlelivingbehaviors_moveattack.inc (line 260).

Published property AnimationDie: String read FAnimationDie write FAnimationDie stored AnimationDieStored nodefault;

An animation of dying.

Dying animation is not displayed in a loop, after it runs it's duration we constantly show the final frame. Unless you set RemoveDead to True, then the dead creature will be completely removed from the level.

Source: scene/castlelivingbehaviors_moveattack.inc (line 268).

Published property AnimationDieBack: String read FAnimationDieBack write FAnimationDieBack stored AnimationDieBackStored nodefault;

Alternative optional (may be '') dying animation, used when the creature is killed by hitting it in the back. This may be useful if you want your creature to fall face-down when killed from the back or face-up when killed from the front. If this is defined, then AnimationDie is only used when creature is killed by hitting it from the front. The direction of last hit is taken from LastHurtDirection.

Source: scene/castlelivingbehaviors_moveattack.inc (line 276).

Published property AnimationHurt: String read FAnimationHurt write FAnimationHurt stored AnimationHurtStored nodefault;

Animation when the creature will be hurt.

Source: scene/castlelivingbehaviors_moveattack.inc (line 279).

Published property AttackMinDelay: Single read FAttackMinDelay write FAttackMinDelay default DefaultAttackMinDelay;

Minimum delay between one attack and the other, in seconds. Note that the duration of AnimationAttack also limits how often creature can do an attack (so e.g. setting this to 0.0 doesn't mean that creature can constantly attack, if AnimationAttack takes 1 second then at least this 1 second will have to pass between actual attack hits).

Source: scene/castlelivingbehaviors_moveattack.inc (line 286).

Published property AttackMaxDistance: Single read FAttackMaxDistance write FAttackMaxDistance default DefaultAttackMaxDistance;

Maximum distance between enemy and creature to allow creature to start attack. The distance is measured between enemy (see TCastleMoveAttack.Enemy) and current creature Middle (see TCastleTransform.Middle) points.

Source: scene/castlelivingbehaviors_moveattack.inc (line 294).

Published property AttackTime: Single read FAttackTime write FAttackTime default DefaultAttackTime;

The time point within AnimationAttack at which the short-range attack happens. When exactly happens depends on the virtual TCastleMoveAttack.Attack method implementation, in the base TCastleMoveAttack it is a short-range attack.

Source: scene/castlelivingbehaviors_moveattack.inc (line 303).

Published property AttackMaxAngle: Single read FAttackMaxAngle write FAttackMaxAngle default DefaultAttackMaxAngle;

Since most of the creatures will have their weapon on their front (teeth, shooting hands, claws, whatever), they can attack enemy only when they are facing the enemy.

More precisely, the attack is allowed to start only when the angle between current creature Direction and the vector from creature's Middle to the enemy's Middle (see TCastleTransform.Middle) is <= AttackMaxAngle.

This is in radians.

Source: scene/castlelivingbehaviors_moveattack.inc (line 316).

Published property AttackDamage: TCastleDamage read FAttackDamage;

Attack damage. Used by the creatures that do short-range attack (when AnimationAttack is set).

Source: scene/castlelivingbehaviors_moveattack.inc (line 323).

Published property FireMissileTime: Single read FFireMissileTime write FFireMissileTime default DefaultFireMissileTime;

The time (in seconds) since the AnimationFireMissile start when we actually spawn a missile. By default zero, which means that we spawn the missile right when AnimationFireMissile starts. Must be < than the AnimationFireMissile duration, otherwise we will never reach tthis time and missile will never be fired.

Source: scene/castlelivingbehaviors_moveattack.inc (line 330).

Published property FireMissileMinDelay: Single read FFireMissileMinDelay write FFireMissileMinDelay default DefaultFireMissileMinDelay;

Minimum delay (in seconds) between firing of the missiles. The missile will not be fired if a previous missile was fired within last FireMissileMinDelay seconds. (Even if all other conditions for firing the missile are satisfied.)

Source: scene/castlelivingbehaviors_moveattack.inc (line 338).

Published property FireMissileMaxDistance: Single read FFireMissileMaxDistance write FFireMissileMaxDistance default DefaultFireMissileMaxDistance;

Maximum distance to the enemy to make firing missiles sensible. The creature will only fire the missile if enemy is within this distance. The creature will also try to shorten distance to the enemy, to get within this distance.

Source: scene/castlelivingbehaviors_moveattack.inc (line 346).

Published property FireMissileMaxAngle: Single read FFireMissileMaxAngle write FFireMissileMaxAngle default DefaultFireMissileMaxAngle;

Maximum angle (in radians) between current direction and the direction toward enemy to make firing missiles sensible. The creature will only fire the missile if enemy is within a cone of this angle.

Source: scene/castlelivingbehaviors_moveattack.inc (line 353).

Published property FireMissileHeight: Single read FFireMissileHeight write FFireMissileHeight default DefaultFireMissileHeight;

Height (between Position and Middle, usually: legs and eyes) of the fired missile (see FireMissileFactory).

Source: scene/castlelivingbehaviors_moveattack.inc (line 359).

Published property MoveSpeed: Single read FMoveSpeed write FMoveSpeed default DefaultMoveSpeed;

The moving speed: how much Direction vector will be scaled when moving in csWalk.

Source: scene/castlelivingbehaviors_moveattack.inc (line 365).

Published property RunAwayLife: Single read FRunAwayLife write FRunAwayLife default DefaultRunAwayLife;

Portion of life and distance when the creature decides it's best to run away from the enemy. RunAwayLife is expressed as a fraction of MaxLife. We run if our Life <= MaxLife * RunAwayLife and the distance to the (last seen) enemy is < RunAwayDistance. Set RunAwayLife = 1 to make the creature always try to keep a safe distance from the enemy.

Source: scene/castlelivingbehaviors_moveattack.inc (line 375).

Published property RunAwayDistance: Single read FRunAwayDistance write FRunAwayDistance default DefaultRunAwayDistance;

This item has no description.

Source: scene/castlelivingbehaviors_moveattack.inc (line 377).

Published property PreferredDistance: Single read FPreferredDistance write FPreferredDistance default DefaultPreferredDistance;

The preferred distance between enemy and the creature. The creature will try to walk closer to the enemy if the distance is larger. (If you want to make the creature to also walk father from the enemy when necessary, then set RunAwayLife and RunAwayDistance.)

This should be <= AttackMaxDistance or FireMissileMaxDistance, if you hope to actually perform a short-range or firing missile attack. The creature can attack enemy from AttackMaxDistance or fire missile from FireMissileMaxDistance, but it will walk closer to the enemy if possible — until the distance is PreferredDistance.

Source: scene/castlelivingbehaviors_moveattack.inc (line 393).

Published property RandomMoveDistance: Single read FRandomMoveDistance write FRandomMoveDistance default DefaultRandomMoveDistance;

Distance to point to move to, when creature wanders aimlessly unable to reach the target, but also wanting to move somewhere.

Source: scene/castlelivingbehaviors_moveattack.inc (line 399).

Published property MaxHeightAcceptableToFall: Single read FMaxHeightAcceptableToFall write FMaxHeightAcceptableToFall default DefaultMaxHeightAcceptableToFall;

When considering possible movement, creature is OK to fall down from this height. It should be small enough to not let creature to jump into chasms, but also large enough to enable creature to get down e.g. stairs.

Source: scene/castlelivingbehaviors_moveattack.inc (line 407).

Published property VisibilityAngle: Single read FVisibilityAngle write FVisibilityAngle default DefaultVisibilityAngle;

Creature sees other things (like enemies) only within a cone of this angle. This way, the creature only looks forward, and you can sneak upon a creature from the back. Simply set this to >= 2 * Pi to remove this limit.

Note that the creature also becomes aware of the enemy when it is hurt by a direct attack, regardless of VisibilityAngle. This way if you sneak and attack a creature from the back, it will turn around and fight you.

Creature can also smell others, see SmellDistance.

Source: scene/castlelivingbehaviors_moveattack.inc (line 423).

Published property SmellDistance: Single read FSmellDistance write FSmellDistance default DefaultSmellDistance;

Creature smells other things (like enemies) within a sphere of this radius. This allows to detect enemy regardless of which direction the creature is facing, regardless of whether there is a line of sight to the enemy, regardless if enemy is moving.

This is quite powerful ability to detect enemies, if you set this to something large (by default it's zero). Detecting enemies allows to more accurately/faster attack them and/or run away from them.

Note: If you want the creature to nicely run from behind the corner, be sure to setup good sectors/waypoints in your level.

Source: scene/castlelivingbehaviors_moveattack.inc (line 438).

Published property RemoveDead: Boolean read FRemoveDead write FRemoveDead default DefaultRemoveDead;

Should dead creature instances be automatically freed and thus removed from the viewport. The default False means that corpses lie in the world forever (or until you manually remove them).

Source: scene/castlelivingbehaviors_moveattack.inc (line 444).


Generated by PasDoc 0.17.0.snapshot.