ChargeAtPlayer¶
Charges at the player with attacking set to true during the movement towards the player (this will allow an Enemy to initiate a battle with the advantage if it collides with the player and all conditions are met to start a battle with the advantage).
Frequency meaning¶
None.
DoBehavior¶
If returntoheight is true, the entity.height is set to a lerp from the existing one to entity.initialheight with a factor of 0.1.
Finally, a ChargeAtPlayer coroutine is started and set to behaviorroutine.
ChargeAtPlayer¶
This is a private coroutine specific to this behavior. It receives the behavior type and a cooldown time (the actioncooldown) in frames that would have been used to smoothly return the entity.height to entity.initialheight, but in practice, it's always 0.0 which disables this feature. The coroutine call is assigned to behaviorroutine which allows the NPCControl to stop it if needed.
- entity.
rigidis unlocked with LockRigid(false) - The
Findsound is played on the entity - StopForceMove is called on the entity
- entity.animstate is set to
Chaseunless entity.heightis higher than 0.1 where the value is set toAirTackle - If the entity is
onground, Jump is called on it - entity.
emoticonidis set to 2 (the red !) - entity.
emoticoncolldownis set to 300.0 - 0.25 seconds are yielded
- entity.
overrideonlyflipis set to false attackingis set to true- MoveTowards is called on the entity with its
speedmultiplier, new animstate set earlier for the walkstate,Idlefor the stopstate ignoring the y component. The position is the player's + the direction from the player to this NPCControl normalised * 1.5. That position is however limited to a radius whose center is the entity.startposand the radius beingradiuslimit. Essentially, this moves the NPCControl to slightly undeshoot the player when going towards it - entity.
detectis ensured to be created - DetectDirection is called on the entity using the player position
- As long as the entity.
forcemoveis ongoing and the entity.hitwallis false:- entity.
emoticonidis set to 2 (the red !) - entity.
emoticoncolldownis set to 5.0 - If entity.
initialheightis above 0.1, entity.heightis set to a lerp from entity.initialheightto 0.25 with a factor of (the x/z square distance between this NPCControl and entity.forcetarget) / (the x/z square distance between entity.startposand entity.forcetarget). NOTE: the math is likely incorrect, but the main point here is the NPCControl lowers faster as the player is further away from it and slows down as it gets closer - A frame is yieled
- entity.
- A frame is yieled
- entity.
spriteangles are set to the return of a FlipAngle call on the entity attackingis set to false- entity.
overrideonlyflipis set to false - StopForceMove is called on the entity with the
Idletargetstate - If the entity is
onground, Jump is called on it - 0.2 seconds are yieled
- All frames are yieled until entity.
ongroundgoes to true - A frame is yielded
- Some dead code is present here where the entity.
heightwould be lerped towards entity.initialheight, but this is never applicable in practice because the passed cooldown isactioncooldownwhich is always 0.0 here - A frame is yielded
- entity.
heightis set to entity.initialheight - StopForceBehavior is called