public

Rpg Maker Developers Group

Simple enough for a child, powerful enough for a developer

2 Followers

MZ Typescript and overriding Game_Actor class

BMM Archive · July 15, 2026

Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.

Original Source

  • Original title: MZ Typescript and overriding Game_Actor class
  • Original author: myarichuk
  • Original date: October 12, 2021
  • Source thread: https://forums.rpgmakerweb.com/threads/typescript-and-overriding-game_actor-class.141205/
  • Source forum path: Game Development Engines > RPG Maker Javascript Plugins > Learning Javascript

Summary

Hey everyone, I am thinking of extending Game_Actor class like this; it seems to work in a simple play-testing project without any dependencies. However, being a noob in Javascript and in RPG Maker, I am a bit worried this would conflict with the way some plugins are "injecting" their code into core scripts. What do you think of this approach? Is this viable? Or perhaps I am overcomplicating things? (for the reference, I am using an awesome project template from here: https://github.com/xuyanwen2012/rmmz-plugins-starter)

Archived First Post

Hey everyone,
I am thinking of extending Game_Actor class like this; it seems to work in a simple play-testing project without any dependencies. However, being a noob in Javascript and in RPG Maker, I am a bit worried this would conflict with the way some plugins are "injecting" their code into core scripts.
What do you think of this approach? Is this viable? Or perhaps I am overcomplicating things?
(for the reference, I am using an awesome project template from here: https://github.com/xuyanwen2012/rmmz-plugins-starter)

JavaScript:
export class Game_Actor_Ex extends Game_Actor {
   constructor(actorId: number){
      super(actorId);
  
      var windowDynamic = (window as any);
      //this is needed so JsonEx.makeDeepCopy() will be able to properly instantiate the derived class
      if(!windowDynamic["Game_Actor_Ex"])
         windowDynamic["Game_Actor_Ex"] = Game_Actor_Ex;
   }

   public changeEquip(slotId: number, item: RPG.EquipItem): void {
      super.changeEquip(slotId, item);
      if(item)
         console.log('hello from change Equip! equip event, slotId = ' + slotId + ' item = ' + item.name);
      else
         console.log('hello from change Equip! unequip event, slotId = ' + slotId);
   }
}

export class Game_Actors_Ex extends Game_Actors {
   actor(actorId: number): Game_Actor {
      if ($dataActors[actorId]) {
         if (!this._data[actorId]) {
            this._data[actorId] = new Game_Actor_Ex(actorId);
         }
         return this._data[actorId];
      }
      return null as any;
   }
}

Game_Actors.prototype = Game_Actors_Ex.prototype;

Downloads / Referenced Files

Log in to download

Log in, then follow the RPG Maker Developers Group to see these download links.

Log in to download
Creator Claims / Removal

If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.

#rpg-maker-archive#js-learning

Replies (0)

No replies yet.

0 replies 1 view

Log in to reply.

User Avatar