Title: Definition changes in types · Issue #7 · ModDota/TypeScriptDeclarations · GitHub
Open Graph Title: Definition changes in types · Issue #7 · ModDota/TypeScriptDeclarations
X Title: Definition changes in types · Issue #7 · ModDota/TypeScriptDeclarations
Description: Due to how the engine works in Dota, some type definitions need to include "undefined" or "void" as an exit option. This occurs when the result is not something that you want to change, but rather, tell the engine to change nothing. It o...
Open Graph Description: Due to how the engine works in Dota, some type definitions need to include "undefined" or "void" as an exit option. This occurs when the result is not something that you want to change, but rather,...
X Description: Due to how the engine works in Dota, some type definitions need to include "undefined" or "void" as an exit option. This occurs when the result is not something that you want to...
Opengraph URL: https://github.com/ModDota/TypeScriptDeclarations/issues/7
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Definition changes in types","articleBody":"Due to how the engine works in Dota, some type definitions need to include \"undefined\" or \"void\" as an exit option. This occurs when the result is not something that you want to change, but rather, tell the engine to change nothing. It occurs mainly on conditional changes, such as client/server checks, or conditional occurrences. I'll detail the following functions with an example.\r\n\r\n**CastFilterResultTarget**: should be changed from \"UnitFilterResult\" to \"UnitFilterResult | undefined\".\r\nExample: Checking for a nearby allied unit in radius, which can only be done by the server. In this case, we must do `if (!IsServer()) return;` to exit from the client. The filter works regardless of the client's definition.\r\nExample:\r\n```ts\r\nCastFilterResultTarget(target: CDOTA_BaseNPC): UnitFilterResult | undefined\r\n {\r\n if (!IsServer()) return;\r\n\r\n // Always apply on enemies according to the unit filter\r\n if (target.GetTeamNumber() != this.caster.GetTeamNumber())\r\n {\r\n return UnitFilter(target, this.GetAbilityTargetTeam(), this.GetAbilityTargetType(), this.GetAbilityTargetFlags(), this.caster.GetTeamNumber());\r\n }\r\n else // Check on allies for disable help\r\n {\r\n if (PlayerResource.IsDisableHelpSetForPlayerID(target.GetPlayerOwnerID(), this.caster.GetPlayerOwnerID()))\r\n {\r\n return UnitFilterResult.FAIL_DISABLE_HELP;\r\n } \r\n\r\n return UnitFilter(target, this.GetAbilityTargetTeam(), this.GetAbilityTargetType(), this.GetAbilityTargetFlags(), this.caster.GetTeamNumber()); \r\n }\r\n }\r\n```\r\n\r\n**ParticleManager.SetParticleControlEnt's attachment argument:** should be changed from \"string\" to \"string | undefined\". This is due to some particles requiring the usage of SetParticleControlEnt, but the attachment is ABSORIGIN_FOLLOW, which has no attachment.\r\nExample: Sven's God's Strength CP1 will only work with SetParticleControlEnt (for some weird reason...), but is set on the origin. It is used correctly in this form:\r\n```ts\r\nParticleManager.SetParticleControlEnt(this.particle_cast_fx, 1, this.caster, ParticleAttachment.ABSORIGIN_FOLLOW, undefined, this.caster.GetAbsOrigin(), true)\r\n```\r\n\r\n**CheckState()**: should be changed from \"Partial\u003cRecord\u003cModifierState, boolean\u003e\u003e\" to \"Partial\u003cRecord\u003cModifierState, boolean\u003e\u003e | undefined\". This is to allow cases where you no longer want to define any state. Returning true or false applies the effect on you (e.g. Invisibility, stunned) based on the priority of other modifier, which may ignore them. Instead, not returning anything (or returning undefined) lets the engine simply ignore this state.\r\nExample: \r\n```ts\r\nCheckState(): Partial\u003cRecord\u003cModifierState, boolean\u003e\u003e | undefined\r\n {\r\n if (this.proc_attack)\r\n {\r\n return {[ModifierState.CANNOT_MISS]: true}\r\n }\r\n }\r\n```\r\n\r\n**GetActivityTranslationModifiers()**: Should be changed from \"string\" to \"string | void\". This is due to the fact that sometimes you do not want any translation modifiers to be applied at all.\r\nExample: Night Stalker only applies the \"hunter_night\" translation at night, otherwise applies no translation:\r\n```ts\r\nGetActivityTranslationModifiers(): string | void\r\n {\r\n if (this.ShouldModifierBeActive())\r\n {\r\n return \"hunter_night\";\r\n }\r\n \r\n return;\r\n }\r\n```\r\n\r\n**GetModifierPreAttack_CriticalStrike()**: Should be changed from \"number\" to \"number | void\". Returning 0 still causes heroes that have critical strike animations (such as Phantom Assassin, Wraith King, Juggernaut) to proc those, which makes no sense if they're not actually proccing crits. Simply returning resolves this.\r\nExample:\r\n```ts\r\nGetModifierPreAttack_CriticalStrike(event: ModifierAttackEvent): number | void\r\n {\r\n // Does not apply on allies, buildings or wards\r\n if (event.target.GetTeamNumber() == this.parent.GetTeamNumber() || event.target.IsBuilding() || event.target.IsOther()) return;\r\n\r\n // some more irrelevant crit calculation logic....\r\n }\r\n```\r\n","author":{"url":"https://github.com/JoyfulShush","@type":"Person","name":"JoyfulShush"},"datePublished":"2020-11-08T10:25:07.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/7/TypeScriptDeclarations/issues/7"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c99c6caa-d927-8c7a-3705-94b3124fc3fb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E510:23BCE:17903A:1E370E:698E623E |
| html-safe-nonce | 2c73f61f90a40fb22d74432badcaeeff0d9d29998bc4d1b9a122f145750f14c0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNTEwOjIzQkNFOjE3OTAzQToxRTM3MEU6Njk4RTYyM0UiLCJ2aXNpdG9yX2lkIjoiNzMzMzUzMzYyNDgxNjM1OTAyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 4556ead5f08c2def77a9f53752a055356c467015f9b4f3391f320e660a34886b |
| hovercard-subject-tag | issue:738435375 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/ModDota/TypeScriptDeclarations/7/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1a61cde69e124b696df2e22fa884acf0cb7e4477967f0618d5b80b99d9c87be2/ModDota/TypeScriptDeclarations/issues/7 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1a61cde69e124b696df2e22fa884acf0cb7e4477967f0618d5b80b99d9c87be2/ModDota/TypeScriptDeclarations/issues/7 |
| og:image:alt | Due to how the engine works in Dota, some type definitions need to include "undefined" or "void" as an exit option. This occurs when the result is not something that you want to change, but rather,... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JoyfulShush |
| hostname | github.com |
| expected-hostname | github.com |
| None | 666e30cc1de8ebdf458084bf731e95deba4f074a5008f91b50803aa9a71e3725 |
| turbo-cache-control | no-preview |
| go-import | github.com/ModDota/TypeScriptDeclarations git https://github.com/ModDota/TypeScriptDeclarations.git |
| octolytics-dimension-user_id | 10570389 |
| octolytics-dimension-user_login | ModDota |
| octolytics-dimension-repository_id | 234397978 |
| octolytics-dimension-repository_nwo | ModDota/TypeScriptDeclarations |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 234397978 |
| octolytics-dimension-repository_network_root_nwo | ModDota/TypeScriptDeclarations |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f2d67bd549813f8aceb31f205ebdb434e9d46d38 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width