Code Monkey home page Code Monkey logo

typescriptaddontemplate's Introduction

ModDota template

A template for Dota 2 Custom Games built with modern technologies.

This tutorial explains how to set up and use the template.

The template includes:

Getting Started

  1. Clone this repository or, if you're planning to have a repository for your custom game on GitHub, create a new repository from this template and clone it instead.
  2. Open the directory of your custom game and change name field in package.json file to the name of your addon name.
  3. Open terminal in that directory and run npm install to install dependencies. You also should run npm update once in a while to get tool updates.

After that you can press Ctrl+Shift+B in VSCode or run npm run dev command in terminal to compile your code and watch for changes.

Contents:

  • [src/common]: TypeScript .d.ts type declaration files with types that can be shared between Panorama and VScripts
  • [src/vscripts]: TypeScript code for Dota addon (Lua) vscripts. Compiles lua to game/scripts/vscripts.
  • [src/panorama]: TypeScript code for panorama UI. Compiles js to content/panorama/scripts/custom_game

--

  • [game/*]: Dota game directory containing files such as npc kv files and compiled lua scripts.
  • [content/*]: Dota content directory containing panorama sources other than scripts (xml, css, compiled js)

--

  • [scripts/*]: Repository installation scripts

Continuous Integration

This template includes a GitHub Actions workflow that builds your custom game on every commit and fails when there are type errors.

typescriptaddontemplate's People

Contributors

ark120202 avatar dependabot[bot] avatar doctorgester avatar happyfeedfriends avatar kk233 avatar perryvw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

typescriptaddontemplate's Issues

Modifier with independent Stacks

Here is my solution for a modifier with independent stacks.

export default class modifier_independent_stacks extends BaseModifier {
    stack_times: number[] = []
    OnStackCountChanged(oldCount: number) {
        if (!IsServer()) return;
        if (oldCount< this.GetStackCount()) {
            let addedCount = this.GetStackCount()-oldCount;
            let time = GameRules.GetGameTime();
            let duration = this.GetDuration();
            let end_time = time + duration;
            for (let i=0; i<addedCount; i++) {
                this.stack_times.push(end_time);
            }
            Timers.CreateTimer(duration, ()=>{
                this.stack_times = this.stack_times.filter(t=>t!=end_time);
                if (!CBaseEntity.IsNull.call(this as any)) { // or !(this as any).IsNull()
                    this.SetStackCount(this.stack_times.length);
                }
            });
        }
    }
}

P.S.: The end time is stored consciously. (instead of the apply time)
So other things know until when X stacks are applied...

where is main.vmap file?

i want open it with Hammar,but i cant find it in content.
in game i find main.vpk ,how should i use it?

More accurate String Types

It would be nice if parameters and return values of type string would have more accurate types.

Examples:
     AbilityName (FindAbilityByName, GetAbilityName)
     ModifierName (RemoveAllModifiersOfName, GetIntrinsicModifierName)
     ItemName (AddItemByName, FindItemInInventory, HasItemInInventory)
     EffectName (GetEffectName, GetStatusEffectName)

Extending the API

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;
        GetTalent(talentName: string): number;
        HasShard(): boolean,
        GetMissingMana(): number,
        GetAllAbilities(): CDOTABaseAbility[];
        HasTalent(talentName: string): boolean;
        GetTalent(talentName: string): number;
        FindItemByName(itemName: string): CDOTA_Item | undefined;
        RemoveItemByName(itemName: string): void;
        IsRoshan(): boolean;
        HasShard(): boolean;
    }
    interface CScriptParticleManager {
        FireParticle(particleName:string, particleAttach: ParticleAttachment, owner: CBaseEntity|undefined): void;
    }
    interface CDOTA_Buff {
        IsNull(): boolean;
    }
    interface CDOTA_PlayerResource  {
        GetAllPlayers() : CDOTAPlayer[],
    }

}

CDOTA_BaseNPC.GetAllAbilities = function() {
    let abilities: CDOTABaseAbility[] = [];
    for (let i=0; i<DOTA_MAX_ABILITIES; i++) {
        let ability = this.GetAbilityByIndex(i);
        if (ability) {
            abilities.push(ability);
        }
    }
    return abilities;
}
CDOTA_BaseNPC.HasTalent = function (talentName: string) {
    let talent = this.FindAbilityByName(talentName)
    return talent ? talent.GetLevel()>0 : false;
}
CDOTA_BaseNPC.GetTalent = function (talentName: string) {
    let talent = this.FindAbilityByName(talentName);
    return talent ? talent.GetSpecialValueFor("value") : 0;
}
CDOTA_BaseNPC.HasShard = function() {
    return this.HasModifier("modifier_item_aghanims_shard");
}
CDOTA_BaseNPC.GetMissingMana = function() {
    return this.GetMaxMana() - this.GetMana();
}
CDOTA_BaseNPC.FindItemByName = function(itemName: string) {
    for (let slot=0; slot<=16; slot++) {
        const item = this.GetItemInSlot(slot);
        if (item) return item;
    }
    return undefined;
}
CDOTA_BaseNPC.RemoveItemByName = function(itemName: string) {
    const item = this.FindItemByName(itemName);
    if (item) this.RemoveItem(item);
}
CDOTA_BaseNPC.IsRoshan = function() {
    return this.GetName() == "npc_dota_roshan";
}
CScriptParticleManager.FireParticle = function(particleName: string, particleAttach: ParticleAttachment, owner: CBaseEntity | undefined) {
    let particle = ParticleManager.CreateParticle(particleName, particleAttach, owner);
    ParticleManager.ReleaseParticleIndex(particle);
}
CDOTA_PlayerResource.GetAllPlayers = function() {
    const players = new Array<CDOTAPlayer>();
    for (let i=0; i<DOTA_MAX_PLAYERS; i++) {
        if (PlayerResource.IsValidPlayer(i)) {
            const player = PlayerResource.GetPlayer(i);
            if (player) players.push();
        }
    }
    return players;
}

P.S.: I import the extended_api-file in the GameMode.ts-file. (import "./utils/extended_api";)

Missing ApplyDamageOptions

This is the definition of ApplyDamage:

declare function ApplyDamage(options: ApplyDamageOptions): number;

It would be nice to be able to look up what should be inside ApplyDamageOptions:
https://moddota.com/api/#!/vscripts?search=ApplyDamage

ApplyDamageOptions
    victim: CDOTA_BaseNPC
    attacker: CDOTA_BaseNPC
    damage: float
    damage_type: DAMAGE_TYPES
    damage_flags?: DOTADamageFlag_t
    ability?: CDOTABaseAbility

Watch task doesn't run on startup by default

When opening VSCode, it is required to remember to run the Watch task (CTRL+SHIFT+B), or any changes done are not committed and will not appear in the game, which can cause confusion.

Add the task definition to make VSCode run this task on this template when it is launched.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.