overpy icon indicating copy to clipboard operation
overpy copied to clipboard

Optimize elements

Open Zezombye opened this issue 4 years ago • 0 comments

This is a list of optimizations that lower the element count as the cost of runtime. If they lower the element count but do not cause a runtime cost, they are listed in #33. To enable these optimizations, use the #!optimizeForSize compiler directive.

Vectors:

  • [ ] vect(0,0,0) -> Vector.UP-Vector.DOWN
  • [ ] vect(X,0,0) -> Vector.LEFT*X
  • [ ] vect(0,X,0) -> Vector.UP*X
  • [ ] vect(0,0,X) -> Vector.FORWARD*X
  • [ ] vect(1,0,1) -> Vector.LEFT+Vector.FORWARD (and all other combinations)
  • [ ] vect(-1,1,0) -> Vector.RIGHT+Vector.UP (and all other combinations)

Colors:

  • [ ] rgba(0,0,0,0) -> null (only in texts)
  • [ ] Color.BLUE -> null (only in effects)

Positions:

  • [ ] X.getPosition() -> X (when expecting a vector and not a player)

Replace, when possible, 0 by false or null, 1 by true, and vect(0,0,0) by false or null:

  • [ ] function "Wait Until", arg 2
  • [ ] function "Set Knockback Dealt", arg 2
  • [ ] function "Set Knockback Received", arg 2
  • [ ] function "Progress Bar Hud Text", arg "Value"
  • [ ] function "Progress Bar In World Text", arg "Value"
  • [ ] function "custom color", arg 0
  • [ ] function "custom color", arg 1
  • [ ] function "custom color", arg 2
  • [ ] function "custom color", arg 3
  • [ ] function "string slice", arg 2
  • [ ] function "string slice", arg 3
  • [ ] function 'Angle Difference', arg 1 (angle) of type float
  • [ ] function 'Angle Difference', arg 2 (angle) of type float
  • [ ] function 'Arctangent In Degrees', arg 1 (numerator) of type float
  • [ ] function 'Arctangent In Degrees', arg 2 (denominator) of type float
  • [ ] function 'Arctangent In Radians', arg 1 (numerator) of type float
  • [ ] function 'Arctangent In Radians', arg 2 (denominator) of type float
  • [ ] function 'Direction From Angles', arg 1 (horizontalAngle) of type float
  • [ ] function 'Direction From Angles', arg 2 (verticalAngle) of type float
  • [ ] function 'Is In View Angle', arg 3 (viewAngle) of type float
  • [ ] function 'Players in View Angle', arg 3 (viewAngle) of type float
  • [ ] function 'Players Within Radius', arg 2 (radius) of type unsigned float
  • [ ] function 'Raise To Power', arg 2 (value) of type float
  • [ ] function 'Sorted Array', arg 2 (valueRank) of type Object
  • [ ] function 'Angle Between Vectors', arg 1 (vector) of type Direction
  • [ ] function 'Angle Between Vectors', arg 2 (vector) of type Direction
  • [ ] function 'Closest Player To', arg 1 (center) of type Position
  • [ ] function 'Cross Product', arg 1 (value) of type Vector
  • [ ] function 'Cross Product', arg 2 (value) of type Vector
  • [ ] function 'Direction Towards', arg 1 (startPos) of type Position
  • [ ] function 'Direction Towards', arg 2 (endPos) of type Position
  • [ ] function 'Distance Between', arg 1 (startPos) of type Position
  • [ ] function 'Distance Between', arg 2 (endPos) of type Position
  • [ ] function 'Dot Product', arg 1 (value) of type Vector
  • [ ] function 'Dot Product', arg 2 (value) of type Vector
  • [ ] function 'Farthest Player From', arg 1 (center) of type Position
  • [ ] function 'Horizontal Angle From Direction', arg 1 (direction) of type Direction
  • [ ] function 'Horizontal Angle Towards', arg 2 (position) of type Position
  • [ ] function 'Is In Line of Sight', arg 1 (startPos) of type Position | Player
  • [ ] function 'Is In Line of Sight', arg 2 (endPos) of type Position | Player
  • [ ] function 'Is In View Angle', arg 2 (location) of type Position
  • [ ] function 'Local Vector Of', arg 1 (worldVector) of type Vector
  • [ ] function 'Nearest Walkable Position', arg 1 (position) of type Position
  • [ ] function 'Normalize', arg 1 (vector) of type Vector
  • [ ] function 'Players Within Radius', arg 1 (center) of type Position
  • [ ] function 'Ray Cast Hit Normal', arg 1 (startPos) of type Position
  • [ ] function 'Ray Cast Hit Normal', arg 2 (endPos) of type Position
  • [ ] function 'Ray Cast Hit Player', arg 1 (startPos) of type Position
  • [ ] function 'Ray Cast Hit Player', arg 2 (endPos) of type Position
  • [ ] function 'Ray Cast Hit Position', arg 1 (startPos) of type Position
  • [ ] function 'Ray Cast Hit Position', arg 2 (endPos) of type Position
  • [ ] function 'Speed Of In Direction', arg 2 (direction) of type Direction
  • [ ] function 'Vector Towards', arg 1 (startPos) of type Position
  • [ ] function 'Vector Towards', arg 2 (endPos) of type Position
  • [ ] function 'Vertical Angle From Direction', arg 1 (direction) of type Direction
  • [ ] function 'Vertical Angle Towards', arg 2 (position) of type Position
  • [ ] function 'Add Health Pool To Player', arg 3 (maxHealth) of type unsigned float
  • [ ] function 'Apply Impulse', arg 2 (direction) of type Direction
  • [ ] function 'Apply Impulse', arg 3 (speed) of type float
  • [ ] function 'Create Beam Effect', arg 3 (startPosition) of type Position
  • [ ] function 'Create Beam Effect', arg 4 (endPosition) of type Position
  • [ ] function 'Create Effect', arg 4 (position) of type Position
  • [ ] function 'Damage', arg 3 (amount) of type float
  • [ ] function 'Create Icon', arg 2 (position) of type Position
  • [ ] function 'Play Effect', arg 4 (position) of type Position
  • [ ] function 'Play Effect', arg 5 (radius) of type unsigned float
  • [ ] function 'Heal', arg 3 (amount) of type float
  • [ ] function 'Set Aim Speed', arg 2 (turnSpeedPercent) of type unsigned float
  • [ ] function 'Set Damage Dealt', arg 2 (damageDealtPercent) of type unsigned float
  • [ ] function 'Set Damage Received', arg 2 (damageReceivedPercent) of type unsigned float
  • [ ] function 'Set Facing', arg 2 (direction) of type Direction
  • [ ] function 'Set Healing Dealt', arg 2 (healingDealtPercent) of type unsigned float
  • [ ] function 'Set Healing Received', arg 2 (healingReceivedPercent) of type unsigned float
  • [ ] function 'Set Jump Vertical Speed', arg 2 (jumpVerticalSpeedPercent) of type unsigned float
  • [ ] function 'Set Max Health', arg 2 (healthPercent) of type unsigned float
  • [ ] function 'Set Player Health', arg 2 (amount) of type unsigned float
  • [ ] function 'Set Slow Motion', arg 1 (speedPercent) of type unsigned float
  • [ ] function 'Start Accelerating', arg 2 (direction) of type Direction
  • [ ] function 'Start Accelerating', arg 3 (rate) of type unsigned float
  • [ ] function 'Start Accelerating', arg 4 (maxSpeed) of type unsigned float
  • [ ] function 'Start Camera', arg 2 (eyePosition) of type Position
  • [ ] function 'Start Camera', arg 3 (lookAtPosition) of type Position
  • [ ] function 'Start Camera', arg 4 (blendSpeed) of type unsigned float
  • [ ] function 'Start Damage Modification', arg 3 (damagePercent) of type unsigned float
  • [ ] function 'Start Damage Over Time', arg 3 (duration) of type unsigned float
  • [ ] function 'Start Damage Over Time', arg 4 (damagePerSecond) of type unsigned float
  • [ ] function 'Start Facing', arg 2 (direction) of type Direction
  • [ ] function 'Start Facing', arg 3 (turnRate) of type unsigned float
  • [ ] function 'Start Heal Over Time', arg 3 (duration) of type unsigned float
  • [ ] function 'Start Heal Over Time', arg 4 (healingPerSecond) of type unsigned float
  • [ ] function 'Start Healing Modification', arg 3 (healingPercent) of type unsigned float
  • [ ] function 'Start Throttle In Direction', arg 2 (direction) of type Direction
  • [ ] function 'Start Throttle In Direction', arg 3 (magnitude) of type unsigned float
  • [ ] function 'Start Transforming Throttle', arg 2 (xAxisScalar) of type unsigned float
  • [ ] function 'Start Transforming Throttle', arg 3 (yAxisScalar) of type unsigned float
  • [ ] function 'Start Transforming Throttle', arg 4 (relativeDirection) of type Direction

Applied optimizations

Click to show

Replace, when possible, 0 by false or null, 1 by true, and vect(0,0,0) by false or null:

  • [x] Rule conditions, arg 1 (value) of type Object | Array
  • [x] Rule conditions, arg 3 (value) of type Object | Array
  • [x] function 'Add', arg 1 (value) of type float | Vector
  • [x] function 'Add', arg 2 (value) of type float | Vector
  • [x] function 'Ammo', arg 2 (clip) of type unsigned int
  • [x] function 'Append To Array', arg 2 (value) of type Object | Object[]
  • [x] function 'Array', arg 1 ([0]) of type Object | Array
  • [x] function 'Array Contains', arg 2 (value) of type Object
  • [x] function 'Array Slice', arg 2 (startIndex) of type unsigned int
  • [x] function 'Array Slice', arg 3 (count) of type unsigned int
  • [x] function 'Compare', arg 1 (value) of type Object | Array
  • [x] function 'Compare', arg 3 (value) of type Object | Array
  • [x] function 'Custom String', arg 2 ({0}) of type Object
  • [x] function 'Custom String', arg 3 ({1}) of type Object
  • [x] function 'Custom String', arg 4 ({2}) of type Object
  • [x] function 'Divide', arg 1 (value) of type float | Vector
  • [x] function 'If-Then-Else', arg 2 (then) of type Object | Array
  • [x] function 'If-Then-Else', arg 3 (else) of type Object | Array
  • [x] function 'Index Of Array Value', arg 2 (value) of type Object
  • [x] function 'Is Objective Complete', arg 1 (number) of type unsigned int
  • [x] function 'Max', arg 1 (value) of type float
  • [x] function 'Max', arg 2 (value) of type float
  • [x] function 'Max Ammo', arg 2 (clip) of type unsigned int
  • [x] function 'Min', arg 1 (value) of type float
  • [x] function 'Min', arg 2 (value) of type float
  • [x] function 'Modulo', arg 1 (value) of type float
  • [x] function 'Modulo', arg 2 (value) of type unsigned float
  • [x] function 'Objective Position', arg 1 (number) of type unsigned int
  • [x] function 'Players In Slot', arg 1 (slot) of type unsigned int
  • [x] function 'Random Integer', arg 1 (min) of type int
  • [x] function 'Random Integer', arg 2 (max) of type int
  • [x] function 'Remove From Array', arg 2 (value) of type Object | Array
  • [x] function 'String', arg 2 ({0}) of type Object
  • [x] function 'String', arg 3 ({1}) of type Object
  • [x] function 'String', arg 4 ({2}) of type Object
  • [x] function 'Subtract', arg 1 (value) of type float | Vector
  • [x] function 'Subtract', arg 2 (value) of type float | Vector
  • [x] function 'Value In Array', arg 2 (index) of type unsigned int
  • [x] function 'Vector', arg 1 (x) of type float
  • [x] function 'Vector', arg 2 (y) of type float
  • [x] function 'Vector', arg 3 (z) of type float
  • [x] function 'Attach Players', arg 3 (offset) of type Position
  • [x] function 'Big Message', arg 2 (header) of type Object
  • [x] function 'Chase Global Variable At Rate', arg 2 (destination) of type float | Vector
  • [x] function 'Chase Global Variable At Rate', arg 3 (rate) of type float
  • [x] function 'Chase Global Variable Over Time', arg 2 (destination) of type float | Vector
  • [x] function 'Chase Global Variable Over Time', arg 3 (duration) of type float
  • [x] function 'Chase Player Variable At Rate', arg 3 (destination) of type float | Vector
  • [x] function 'Chase Player Variable At Rate', arg 4 (rate) of type float
  • [x] function 'Chase Player Variable Over Time', arg 3 (destination) of type float | Vector
  • [x] function 'Chase Player Variable Over Time', arg 4 (duration) of type float
  • [x] function 'Create Dummy Bot', arg 3 (slot) of type int
  • [x] function 'Create Dummy Bot', arg 4 (position) of type Position
  • [x] function 'Create Dummy Bot', arg 5 (facing) of type Direction
  • [x] function 'Create Effect', arg 5 (radius) of type unsigned float
  • [x] function 'Create HUD Text', arg 6 (sortOrder) of type float
  • [x] function 'Create In-World Text', arg 2 (header) of type Object
  • [x] function 'Create In-World Text', arg 3 (position) of type Position
  • [x] function 'Create In-World Text', arg 4 (scale) of type float
  • [x] function 'Destroy Dummy Bot', arg 2 (slot) of type int
  • [x] function 'For Global Variable', arg 2 (rangeStart) of type float
  • [x] function 'For Global Variable', arg 3 (rangeStop) of type float
  • [x] function 'For Global Variable', arg 4 (step) of type float
  • [x] function 'For Player Variable', arg 3 (rangeStart) of type float
  • [x] function 'For Player Variable', arg 4 (rangeStop) of type float
  • [x] function 'For Player Variable', arg 5 (step) of type float
  • [x] function 'Modify Global Variable', arg 3 (value) of type Object | Array
  • [x] function 'Modify Global Variable At Index', arg 2 (index) of type unsigned int
  • [x] function 'Modify Global Variable At Index', arg 4 (value) of type Object | Array
  • [x] function 'Modify Player Score', arg 2 (score) of type int
  • [x] function 'Modify Player Variable', arg 4 (value) of type Object | Array
  • [x] function 'Modify Player Variable At Index', arg 3 (index) of type unsigned int
  • [x] function 'Modify Player Variable At Index', arg 5 (value) of type Object | Array
  • [x] function 'Modify Team Score', arg 2 (score) of type int
  • [x] function 'Set Ability Charge', arg 3 (chargeCount) of type unsigned int
  • [x] function 'Set Ability Cooldown', arg 3 (cooldown) of type unsigned float
  • [x] function 'Set Ability Resource', arg 3 (resourcePercent) of type unsigned float
  • [x] function 'Set Ammo', arg 2 (clip) of type unsigned int
  • [x] function 'Set Ammo', arg 3 (ammo) of type unsigned int
  • [x] function 'Set Global Variable', arg 2 (value) of type Object | Array
  • [x] function 'Set Global Variable At Index', arg 2 (index) of type unsigned int
  • [x] function 'Set Global Variable At Index', arg 3 (value) of type Object | Array
  • [x] function 'Set Gravity', arg 2 (gravityPercent) of type unsigned float
  • [x] function 'Set Match Time', arg 1 (time) of type unsigned int
  • [x] function 'Set Max Ammo', arg 2 (clip) of type unsigned int
  • [x] function 'Set Max Ammo', arg 3 (ammo) of type unsigned int
  • [x] function 'Set Move Speed', arg 2 (moveSpeedPercent) of type unsigned float
  • [x] function 'Set Objective Description', arg 2 (header) of type Object
  • [x] function 'Set Player Score', arg 2 (score) of type int
  • [x] function 'Set Player Variable', arg 3 (value) of type Object | Array
  • [x] function 'Set Player Variable At Index', arg 3 (index) of type unsigned int
  • [x] function 'Set Player Variable At Index', arg 4 (value) of type Object | Array
  • [x] function 'Set Projectile Gravity', arg 2 (projectileGravityPercent) of type unsigned float
  • [x] function 'Set Projectile Speed', arg 2 (projectileSpeedPercent) of type unsigned float
  • [x] function 'Set Respawn Max Time', arg 2 (time) of type unsigned int
  • [x] function 'Set Status', arg 4 (duration) of type unsigned float
  • [x] function 'Set Team Score', arg 2 (score) of type int
  • [x] function 'Set Ultimate Charge', arg 2 (chargePercent) of type unsigned float
  • [x] function 'Set Weapon', arg 2 (weapon) of type unsigned int
  • [x] function 'Skip', arg 1 (numberOfActions) of type unsigned int
  • [x] function 'Skip If', arg 2 (numberOfActions) of type unsigned int
  • [x] function 'Small Message', arg 2 (header) of type Object
  • [x] function 'Start Forcing Player Position', arg 2 (position) of type Position
  • [x] function 'Start Forcing Spawn Room', arg 2 (room) of type unsigned int
  • [x] function 'Start Forcing Throttle', arg 2 (minForward) of type unsigned float
  • [x] function 'Start Forcing Throttle', arg 3 (maxForward) of type unsigned float
  • [x] function 'Start Forcing Throttle', arg 4 (minBackward) of type unsigned float
  • [x] function 'Start Forcing Throttle', arg 5 (maxBackward) of type unsigned float
  • [x] function 'Start Forcing Throttle', arg 6 (minSideways) of type unsigned float
  • [x] function 'Start Forcing Throttle', arg 7 (maxSideways) of type unsigned float
  • [x] function 'Start Modifying Hero Voice Lines', arg 2 (pitchScalar) of type unsigned float
  • [x] function 'Start Scaling Barriers', arg 2 (scale) of type unsigned float
  • [x] function 'Start Scaling Player', arg 2 (scale) of type unsigned float
  • [x] function 'Teleport', arg 2 (position) of type Position
  • [x] function 'Wait', arg 1 (time) of type unsigned float

Zezombye avatar Oct 31 '20 09:10 Zezombye