your current location:首页 > news>From code analysis of the chaos guard ejection mechanism [de] Draconic Evolution (Draconic Evolution)

From code analysis of the chaos guard ejection mechanism [de] Draconic Evolution (Draconic Evolution)

2024-12-10 17:48:48|Myriagame |source:minecraft skins

This tutorial is set by the author's setting without permission.

Disclaimer: Based on 1.12.2, this article only analyzes the author's own analysis. It does not guarantee 100%accurate. Welcome to point out errors or provide suggestions.


Noun link:

Tick ​​(MCMOD) (MCWIKI): The default 20tick per second, which is specifically based on the TPS (Tick Per Second) in the game.

Chaos Guardian ejection: (Java class name: EntityGuardianProjectile.Class)

property:

int Type = 0; (Ejection type value, take a value in the type list above)

EntitylivingBase Target; (The target entity of the ejaculation is usually players)

Entity Shooter;

Float Power; (Power value)

Boolean ischaser; (Whether it is a tracking ammunition is the Boolean value of only two non -non -non -non -two states)

Float heath = 5F; (the health of the ejaculation, that is, the ejaculation can be killed) (The original text is heath, I guess it is wrong)

Type list:

A large fireball with a trajectory has a large range of burning damage

Firebomb = 1; particle color: 0xff, 0x66,0X00.

After hitting the player, send the player to the teleportation ball

Teleport = 2; particle color: 0, 0,0.

Encountered an orange flame tracking bomber in the block explosion (cannot penetrate the wall)

Fire_chaser = 3; particle color: 0xff, 0x66, 0.

Orange energy tracking bombs that can be worn on the wall

Energy_chaser = 4; particle color: 0,0XFF, 0xff.

The red chaos tracking bombs, hitting the target or being killed, split into a mini -tracking bomb, these mini energy bombs will also track players

Chaos_chaser = 5; particle color: 0x44, 0,0.

Mini tracking bombs

Mini_chaos_chaser = 6; particle color: 0x44, 0,0.

Resurrected crystal green charging ball

Ignition_chaarge = 7; particles color: 0xff, 0xff, 0xff.

Three types of damage sources (DamageSources):

Guardian fireball, magic damage, explosion damage

DamageFireball = damageSource ("de.guardianFireball"). SetmagicDamage (). Setexplosion ();

Guardian energy ball, ignorance armor attribute

Damagenergy = damageSource ("" de.guardiannerGyball ").

The guardian chaos ball, the ignorant armor attribute, is absolutely damaged (absolute damage means: cause all damage as a potion (original))

DamageChaos = damageSource ("" de.guardianchaosball ").

Note: After the configuration file is turned on GuardianCank Creation (meaning that chaos guard can kill creation) can cause damage to the creation player (default). This configuration item can double the energy shield according to the energy shield mechanism.

initialization:

If the type of ejaculation is one of them, there is no collision box (noClip) for the other party, that is, you can pass through the wall:

Energy_chaser

Chaos_chaser

Mini_chaos_chaser

Ignition_chaarge

HEATH reduced logic of ejaculation:

When the existence time is greater than 5tick, heath minus the damage caused by the player and the arrow (that is, it can be attacked).

If the arrow causes damage, let the arrow disappear.

The health of life is less than or or equal to the explosion with a radius of 2.

The first tick:

Synchronize Type (ejaculation type value) to the client.

The logic of each ejaculation is performed in each tick:

If there is no target when it is issued, it is centered on the ejaculation itself, and finds the recent players as the goal (including creative players) within the 60 -square range.

If it is a tracker, modify the Motion, and the specific logic:

Double x = (target.posx -POSX) / TDIST;

Double y = (target.posy -posy -1) / tdist;

Double z = (target.posz -POSZ) / TDIST;

// ternary computing symbols

Double speed = type == chaos_chaser? 0.15d: 0.1d;

Motionx /= 1.1;

Motiony /= 1.1;

Motionz /= 1.1;

Motionx += x * speed;

Motiony += y * speed;

Motionz += z * speed;

Motion is a very complicated thing. I do not repeat the specific principle here. If you are interested, you can find the usage yourself.

In general, this code achieves the direction of allowing the ejaculation to move in the player.

Execute movement.

Target check:

GENERICHIT = Check whether the distance between the entity or the distance from the target is less than 1, which meets any of these two conditions. The value is true.

Damage logic:

Firebomb:

Generichit is True, encounters blocks, existence time is more than 600tick or heath less than equal to 0:

Causes an explosion with a radius.

Causes the damage of DamageFireball type of Power * 2 in the biology in the POWER radius.Teleport:

When geneichit is true:

The target touched the target centered on the shooter is randomly transmitted.

Raidie radius:

X: COS (random integer) * 600.

Y: Random integer less than 255.

Z: sin (random integer) * 600.

Cause 10 points of falling damage to the target entity.

GENERICHIT is FALSE and meets the blocks, the existence time is greater than 400tick (20s), the heath is less than equal to 0, one of the three conditions:

disappear.

Fire_chaser:

If the existence time is less than 60tick (3s), the settings are not collided.

Generichit is True, encounters blocks, existence time is greater than 400tick or heath less than equal to 0: causes an explosion of a radius with two grids.

DamageFireball types of Power * 2 in the biological of Power * 2.

Energy_chaser:

GENERICHIT is True, the existence time is greater than 800tick (40s) or heath less than equal to 0:

Damagenergy type damage to Power * 3 in the range of the radius Power.

Chaos_chaser:

GENERICHIT is True, the existence time is greater than 800tick (40s) or heath less than equal to 0:

DamageChaos damage to Power * 3 in the range of the radius Power.

Generate 3 ~ 6 power / 2 mini_chaos_chaser.

Mini_chaos_chaser:

Generichit is True, the existence time is greater than 800tick or heath less than equal to 0:

DamageChaos damage to Power * 3 in the range of the radius Power.

Thank you: