Projectile¶
This is a coroutine that is specifically made to be implemented as part of an enemy action involving a DoDamage call through the use of a projectile attacks towards a player party member if their hp
is above 0.
To check that the coroutine is done, obj
needs to be checked to be null as it will be destroyed at the very end which will eventually change its value to null.
private IEnumerator Projectile(int damage, AttackProperty? property, MainManager.BattleData attacker, int playertarget, Transform obj, float speed, float height, string extraargs, string destroyparticle, string audioonhit, string audiomoving, Vector3 spin, bool nosound)
There is also an overload available that calls the one above with the same parameters except height
which will have a value of 0.0 followed by a yield break:
private IEnumerator Projectile(int damage, AttackProperty? property, MainManager.BattleData attacker, int playertarget, Transform obj, float speed, string extraargs, string destroyparticle, string audioonhit, string audiomoving, Vector3 spin, bool nosound)
Parameters¶
damage
: The damageammount value to send to DoDamageproperty
: The property value to send to DoDamageattacker
: The attacker value to send to DoDamageplayertarget
: The index of theplayerdata
that will be used as the target actor to send to DoDamage. If this is negative or at least the length ofplayerdata
or the battleentity of theplayerdata
is null, the coroutine will end early by destroyingobj
followed by a yield breakobj
: The projectile object's transform that will be moved during the attack. If it has aNoMapColor
tag, it will avoid to change all materials of all SpriteRenderers underobj
tospritemat
(it's possible to do the same without the tag using thekeepcolor
command, see the section below for details)speed
: The meaning depends on if it's less than 1.0 or not:- If it's less than 1.0, this represents a game's frametime fraction that will be added to the
obj
's movement curve progression factor each frame. Effectively, it means thatobj
will move towards the target over the course of (1 / this value) amount of frames so a value of 0.02 meansobj
will be moved over the course of 50.0 frames - If it's at least 1.0, this represent the amount of frames that
obj
will take in its movement curve before reaching the target
- If it's less than 1.0, this represents a game's frametime fraction that will be added to the
height
: If it's 0.0,obj
will be moved using a lerp. If it's not, it will be moved using a BeizierCurve3 with this value being the ymax of the curveextraargs
: An optional list of extra commands that can take effect before or after the DoDamage call. See the section below for more details on the commands and the format. This is optional, a value of null means no commands will take effectdestroyparticle
: The name of the particles under thePrefabs/Particles/
path of the rssources tree to play after the DoDamage call before the projectile gets destroyed. This is optional, a value of null won't play any particlesaudioonhit
: The name of the AudioClip under theAudio/Sounds/
path of the resources tree to play after the DoDamage call before the projectile gets destroyed. This is optional, a value of null won't play any AudioClipaudiomoving
: The name of the AudioClip under theAudio/Sounds/
path of the resources tree to play beforeobj
starts to move on loop until the projectile gets destroyed. If the name is prepanded with a@
, it will not play the AudioClip on loop. The name is resolved after removing all@
in the value to allow this feature to function. This is optional: a value of null or empty string won't play a clipspin
: A multiplier to the game's frametime that controls the angles ofobj
after each frame of movement. The angles gets incremented by the game's frametime * this value each frame. A value of Vector3.zero will cause no angle changesnosound
: If this is true, the DoDamage call will have an overrides value of {NoSound}. If this is false, the DoDamage call will have an overrides value of null
extraargs format¶
This parameter is a ,
separated list of strings each representing a command. Each command is a @
separated list of strings where the first element is the name of the command and the rest are its parameters if any are supplied.
A command can take effect before obj
is moved or after the DoDamage call. Each command gets executed in the order than they appear when the moment of effect is reached.
Here are the different commands available and their parameters
Name | Moment of effect | Parameters | Effect |
---|---|---|---|
wait | Before obj is moved |
|
Yield for a certain amount of seconds |
anim | Before obj is moved |
|
Plays an animation clip on the Animator component of obj |
keepcolor | Before obj is moved |
None | This command will make it so that the material of all SpriteRenderers under obj won't be set to spritemat . NOTE: If obj has a NoMapColor tag, the same effect will occur without the need of this command |
SepPart | After DoDamage call |
|
Destroys a child of obj after a certain amount of seconds ellapsed. Right before the destruction, the transform gets rooted and placed offscreen at 999.0 in y |
resetcam | After DoDamage call | None | Calls SetDefaultCamera |
animhit | After DoDamage call |
|
Plays an animation clip on the Animator component of obj |
destoffscr | After DoDamage call |
|
Causes the audioonhit and destroyparticle effects to take place earlier before setting their value to null so they don't take effect later. After, obj gets moved offscreen past the player party at (-15.0, 0.0, 0.0) using a BeizierCurve3 |
atkdown | After DoDamage call |
|
Calls StatusEffect to inflict AttackDown with visual effect on the target for a certain amount of turns. This command supports not inflicting if the player blocked1 sucessfully or to inflict using a different amount of turns if the player blocked1 |
1: This logic disregard the FRAMEONE modifier which is flags 615 because even regular blocks will count here.
Procedure¶
- playertarget is checked and if it's not in bounds of
playerdata
or if it is, but the battleentity is null, obj is destroyed followed by an early yield break. - The extraargs commands that are set to take effect before obj movement are executed. See the section above for details
- The target position of obj is set to the
playerdata[playertarget]
's position + (0.0, 1.0, -0.2) - Unless a
keepcolor
command was processed or that obj has a tag ofNoMapColor
, all materials of all SpriteRenderers under obj are set tospritemat
- If audiomoving isn't null or empty, an AudioSource is added to obj with the clip set to the resource at
Audio/Sounds/
+ audiomoving (after removing all@
), the volume set to MainManager.soundvolume
and the loop to be true unless audiomoving started with@
where it's false. The clip is then played immediately - obj is moved as described by the parameters section above using the speed, spin and height values
- If
playerdata[playertarget]
'shp
is above 0, the DoDamage call happens with:- attacker: The sent attacker value
- target:
playerdata[playertarget]
- damageammount: The sent damage value
- property: The sent property value
- overrides: null if nosound is false, {NoSound} if it's true
- block:
commandsuccess
- The extraargs commands that are set to take effect after the DoDamage call are executed. See the section above for details
- If destroyparticle isn't null and no
destoffscr
commands were processed, PlayParticle is called to play the destroyparticle particles at the obj's position - If audioonhit isn't null and no
destoffscr
commands were processed, PlaySound is called to play the audioonhit sound - obj is destroyed
- Yield for a frame