Title: Extending the API · Issue #8 · ModDota/TypeScriptAddonTemplate · GitHub
Open Graph Title: Extending the API · Issue #8 · ModDota/TypeScriptAddonTemplate
X Title: Extending the API · Issue #8 · ModDota/TypeScriptAddonTemplate
Description: It would be nice to have a file for extending the API. Here is a example for extending CDOTA_BaseNPC: export {} declare global { interface CDOTA_BaseNPC { GetAllAbilities(): CDOTABaseAbility[]; HasTalent(talentName: string): boolean; Get...
Open Graph Description: It would be nice to have a file for extending the API. Here is a example for extending CDOTA_BaseNPC: export {} declare global { interface CDOTA_BaseNPC { GetAllAbilities(): CDOTABaseAbility[]; Has...
X Description: It would be nice to have a file for extending the API. Here is a example for extending CDOTA_BaseNPC: export {} declare global { interface CDOTA_BaseNPC { GetAllAbilities(): CDOTABaseAbility[]; Has...
Opengraph URL: https://github.com/ModDota/TypeScriptAddonTemplate/issues/8
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Extending the API","articleBody":"It would be nice to have a file for extending the API.\r\nHere is a example for extending `CDOTA_BaseNPC`:\r\n```typescript\r\nexport {}\r\ndeclare global {\r\n interface CDOTA_BaseNPC {\r\n GetAllAbilities(): CDOTABaseAbility[];\r\n HasTalent(talentName: string): boolean;\r\n GetTalent(talentName: string): number;\r\n HasShard(): boolean,\r\n GetMissingMana(): number,\r\n GetAllAbilities(): CDOTABaseAbility[];\r\n HasTalent(talentName: string): boolean;\r\n GetTalent(talentName: string): number;\r\n FindItemByName(itemName: string): CDOTA_Item | undefined;\r\n RemoveItemByName(itemName: string): void;\r\n IsRoshan(): boolean;\r\n HasShard(): boolean;\r\n }\r\n interface CScriptParticleManager {\r\n FireParticle(particleName:string, particleAttach: ParticleAttachment, owner: CBaseEntity|undefined): void;\r\n }\r\n interface CDOTA_Buff {\r\n IsNull(): boolean;\r\n }\r\n interface CDOTA_PlayerResource {\r\n GetAllPlayers() : CDOTAPlayer[],\r\n }\r\n\r\n}\r\n\r\nCDOTA_BaseNPC.GetAllAbilities = function() {\r\n let abilities: CDOTABaseAbility[] = [];\r\n for (let i=0; i\u003cDOTA_MAX_ABILITIES; i++) {\r\n let ability = this.GetAbilityByIndex(i);\r\n if (ability) {\r\n abilities.push(ability);\r\n }\r\n }\r\n return abilities;\r\n}\r\nCDOTA_BaseNPC.HasTalent = function (talentName: string) {\r\n let talent = this.FindAbilityByName(talentName)\r\n return talent ? talent.GetLevel()\u003e0 : false;\r\n}\r\nCDOTA_BaseNPC.GetTalent = function (talentName: string) {\r\n let talent = this.FindAbilityByName(talentName);\r\n return talent ? talent.GetSpecialValueFor(\"value\") : 0;\r\n}\r\nCDOTA_BaseNPC.HasShard = function() {\r\n return this.HasModifier(\"modifier_item_aghanims_shard\");\r\n}\r\nCDOTA_BaseNPC.GetMissingMana = function() {\r\n return this.GetMaxMana() - this.GetMana();\r\n}\r\nCDOTA_BaseNPC.FindItemByName = function(itemName: string) {\r\n for (let slot=0; slot\u003c=16; slot++) {\r\n const item = this.GetItemInSlot(slot);\r\n if (item) return item;\r\n }\r\n return undefined;\r\n}\r\nCDOTA_BaseNPC.RemoveItemByName = function(itemName: string) {\r\n const item = this.FindItemByName(itemName);\r\n if (item) this.RemoveItem(item);\r\n}\r\nCDOTA_BaseNPC.IsRoshan = function() {\r\n return this.GetName() == \"npc_dota_roshan\";\r\n}\r\nCScriptParticleManager.FireParticle = function(particleName: string, particleAttach: ParticleAttachment, owner: CBaseEntity | undefined) {\r\n let particle = ParticleManager.CreateParticle(particleName, particleAttach, owner);\r\n ParticleManager.ReleaseParticleIndex(particle);\r\n}\r\nCDOTA_PlayerResource.GetAllPlayers = function() {\r\n const players = new Array\u003cCDOTAPlayer\u003e();\r\n for (let i=0; i\u003cDOTA_MAX_PLAYERS; i++) {\r\n if (PlayerResource.IsValidPlayer(i)) {\r\n const player = PlayerResource.GetPlayer(i);\r\n if (player) players.push();\r\n }\r\n }\r\n return players;\r\n}\r\n```\r\n\r\nP.S.: I import the `extended_api`-file in the `GameMode.ts`-file. (`import \"./utils/extended_api\";`)","author":{"url":"https://github.com/GniLudio","@type":"Person","name":"GniLudio"},"datePublished":"2021-11-24T15:39:13.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/8/TypeScriptAddonTemplate/issues/8"}
| 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:aebebbc8-a28e-9337-e6ae-259729329e31 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C29A:3AB83:12090B9:17AC11E:698D7C68 |
| html-safe-nonce | f3ad8a01f0e867f8d99eb09f08963b9e210b73ee87a5d9829cc98e07757b91d9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMjlBOjNBQjgzOjEyMDkwQjk6MTdBQzExRTo2OThEN0M2OCIsInZpc2l0b3JfaWQiOiIyODU0MDM1ODk0ODYzNDk0MjQ4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c4d3d9a6e875063ff147c92066cad4594151ac180a679b92a173338857955c54 |
| hovercard-subject-tag | issue:1062578109 |
| 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/TypeScriptAddonTemplate/8/issue_layout |
| twitter:image | https://opengraph.githubassets.com/77e58721a3bfe8712b20bce64b5f7f23b4689128e7eab92bb72291cef5dc32f3/ModDota/TypeScriptAddonTemplate/issues/8 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/77e58721a3bfe8712b20bce64b5f7f23b4689128e7eab92bb72291cef5dc32f3/ModDota/TypeScriptAddonTemplate/issues/8 |
| og:image:alt | It would be nice to have a file for extending the API. Here is a example for extending CDOTA_BaseNPC: export {} declare global { interface CDOTA_BaseNPC { GetAllAbilities(): CDOTABaseAbility[]; Has... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | GniLudio |
| hostname | github.com |
| expected-hostname | github.com |
| None | c0818105fa276287e9369cfdefa0a0fa7953719791ceff9b94d69623c0a4fe8a |
| turbo-cache-control | no-preview |
| go-import | github.com/ModDota/TypeScriptAddonTemplate git https://github.com/ModDota/TypeScriptAddonTemplate.git |
| octolytics-dimension-user_id | 10570389 |
| octolytics-dimension-user_login | ModDota |
| octolytics-dimension-repository_id | 231253304 |
| octolytics-dimension-repository_nwo | ModDota/TypeScriptAddonTemplate |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 231253304 |
| octolytics-dimension-repository_network_root_nwo | ModDota/TypeScriptAddonTemplate |
| 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 | 715890fa442134f528fb422ab338c0ad55c7a025 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width