Tutorial How to add tomes to your map easily

Prozix

New Member
Reaction score
7
Prerequisite:
  • Jass Newgen pack
Today I decided to start using Grimex's ObjectMerger. For a tutorial about how to use the object merger follow this link.

I wanted to add tomes to my map without having to click a thousand times and do boring repetitive tasks.

I will post the code first so you can have a look at it. If you have some programming experience and you are familiar with textmacros you will probably see how it works.

Adding the tomes

JASS:
//! textmacro CreateTome takes I, BTNX, BTNY, ICONPATH, STATSTRING, AMOUNT, AGI, INT, STR, HOTKEY, STOCK, REPLENISH, COST
	//! external ObjectMerger w3a AIgm AT$I$ abpx $BTNX$ abpy $BTNY$ aart "$ICONPATH$" Iagi 1 $AGI$ Iint 1 $INT$ Istr 1 $STR$ ansf "(+$AMOUNT$)" anam "Item $STATSTRING$ Gain"
	//! external ObjectMerger w3t tdx2 IT$I$ iabi AT$I$ ubpx $BTNX$ ubpy $BTNY$ iico "$ICONPATH$" isel 1 igol $COST$ isto $STOCK$ istr $REPLENISH$ uhot $HOTKEY$ unam "Tome of $STATSTRING$ +$AMOUNT$ ($HOTKEY$)" utip "Purchase Tome of $STATSTRING$ +$AMOUNT$ ($HOTKEY$)" utub "Permanently increases the $STATSTRING$ of the Hero by $AMOUNT$ when used."
//! endtextmacro
//! runtextmacro CreateTome("01", "0", "0", "ReplaceableTextures\CommandButtons\BTNTome.blp", "Strength", "2", "0", "0", "2", "Q", "9", "1", "200")
//! runtextmacro CreateTome("02", "0", "1", "ReplaceableTextures\CommandButtons\BTNTome.blp", "Strength", "10", "0", "0", "10", "A", "9", "3", "900")
//! runtextmacro CreateTome("03", "0", "2", "ReplaceableTextures\CommandButtons\BTNTome.blp", "Strength", "100", "0", "0", "100", "Z", "9", "5", "8000")
//! runtextmacro CreateTome("04", "1", "0", "ReplaceableTextures\CommandButtons\BTNTome.blp", "Agility", "2", "2", "0", "0", "W", "9", "1", "200")
//! runtextmacro CreateTome("05", "1", "1", "ReplaceableTextures\CommandButtons\BTNTome.blp", "Agility", "10", "10", "0", "0", "S", "9", "3", "900")
//! runtextmacro CreateTome("06", "1", "2", "ReplaceableTextures\CommandButtons\BTNTome.blp", "Agility", "100", "100", "0", "0", "X", "9", "5", "8000")
//! runtextmacro CreateTome("07", "2", "0", "ReplaceableTextures\CommandButtons\BTNTome.blp", "Intelligence", "2", "0", "2", "0", "E", "9", "1", "200")
//! runtextmacro CreateTome("08", "2", "1", "ReplaceableTextures\CommandButtons\BTNTome.blp", "Intelligence", "10", "0", "10", "0", "D", "9", "3", "900")
//! runtextmacro CreateTome("09", "2", "2", "ReplaceableTextures\CommandButtons\BTNTome.blp", "Intelligence", "100", "0", "100", "0", "C", "9", "5", "8000")


If you place this in your maps header (press F4 to go to the Trigger Editor and click on your map's name), save your map and reopen it. It will have added 9 tomes and 9 abilities. NOTE: If you have created objects that use these codes AT00-AT09 or IT00-IT09 it will replace those objects.

How does it work?
If you wan't to add a tome you have to execute a "runtextmacro" command.
example:
JASS:
//! runtextmacro CreateTome("09", "2", "2", "ReplaceableTextures\CommandButtons\BTNTome.blp", "Intelligence", "100", "0", "100", "0", "C", "9", "5", "8000")

  • 09 - This is what will be added to AT.. and IT..: passing "09" as the first parameter creates the codes AT09 for the ability and IT09 for the item
  • 2 - The next parameter is the X position for the item when placed in a shop
  • 2 - The third parameter is the Y position for the item when placed in a shop
  • "Replacable....blp" - This is the icon path
  • Intelligence - This will be used as a string in the names and descriptions of your abilities and items
  • 100 - This is the amount that is added when the item is used by a hero
  • 0 - This is the amount of Agility that is added (you can only add one attribute with this macro, if you try to add more the descriptions won't be correct, the stats will apply to a buying hero)
  • 100 - Amount of Intelligence added
  • 0 - Amount of Strength added
  • C - This is the hotkey for the tome when placed in a shop
  • 9 - The maximum stock number
  • 5 - Replenish time (in shop)
  • 8000 - This is the price of the tome

Yay I created a lot of tomes... wait, I need a shop to sell them :eek:

No worries my friend, the next line of code merges a nice little Tome Shop into your map
NOTE: Make sure you have no object using this code: nT00 if you do, change the code some you are not using.
JASS:
//! external ObjectMerger w3u ngme nT00 uico "ReplaceableTextures\CommandButtons\BTNBookOfSummoning.blp" umdl "buildings\other\BookOfSummoning\BookOfSummoning.mdl" usca 1.50 usei IT01,IT02,IT03,IT04,IT05,IT06,IT07,IT08,IT09 ides "Sells various Tomes." unam "Tome Shop"


If you have any questions about the ObjectMerger you can
  • Read the manual in your jassnewgen directory (jassnewgenpack5d\grimext\GrimexManual.html)
  • Follow the link at the top of my post
If you have any questions about TextMacros

If there is something else you want to know, you know what to do
  1. Use the search function
  2. If that didn't help, post your question

This concludes my semi-tutorial (I wasn't sure what kind of thread this was, template, snippet or tutorial) If you you have suggestions how I could improve my tutorial please post them.

~Prozix
 

Azlier

Old World Ghost
Reaction score
461
A small note about memory leaks. It involves tomes, so I suppose it's somewhat related.

When a tome is used, it leaks. The same applies to any item that is used up and any powerup, as well. In fact, it also leaves useless models on screen. These cause lag in numbers.
 

Romek

Super Moderator
Reaction score
963
Change the Lime Green text to another colour please.
 

Prozix

New Member
Reaction score
7
A small note about memory leaks. It involves tomes, so I suppose it's somewhat related.

When a tome is used, it leaks. The same applies to any item that is used up and any powerup, as well. In fact, it also leaves useless models on screen. These cause lag in numbers.
You are comepletely right. You can easily fix this however by creating a trigger that triggers when a unit sells an item that checks if the sold item is a Tome and make it remove the sold Tome if you did.
JASS:

I'm not sure what trigger event is triggered when a hero Picks up a Tome but you can create a trigger that destroys a picked up Tome too.

Romek said:
Change the Lime Green text to another colour please.
Why? I like it.
 

Azlier

Old World Ghost
Reaction score
461
>creating a trigger that triggers when a unit sells an item that checks if the sold item is a Tome and make it remove the sold Tome if you did.

Include a script that does that in the first post. That'd be good.

I also think that the Lime color should have never been implemented in the first place.
 

Prozix

New Member
Reaction score
7
Woohooo that would be my first rep+ ever I guess.

I think i'm going to change the lime to some warm and soft colour and add a jass script to remove bought tomes. But not now as I have karate lessons in 32 minutes.
 

Prozix

New Member
Reaction score
7
Wooh that was a long karatee lesson ^^

Removing tomes snippet, no explenation :p
JASS:
scope CleanUpPowerUps initializer Init
globals
    private integer array POWERUP_IDS
    private integer NR_OF_POWERUPS = 0
endglobals

private function AddPowerUp takes integer itemId returns nothing
    set POWERUP_IDS[NR_OF_POWERUPS] = itemId
    set NR_OF_POWERUPS = NR_OF_POWERUPS + 1
endfunction

//=======================EDIT THIS================================
private function InitializePowerUps takes nothing returns nothing
    //tomes
    call AddPowerUp('IT01')
    call AddPowerUp('IT02')
    call AddPowerUp('IT03')
    call AddPowerUp('IT04')
    call AddPowerUp('IT05')
    call AddPowerUp('IT06')
    call AddPowerUp('IT07')
    call AddPowerUp('IT08')
    call AddPowerUp('IT09')
endfunction
//=======================END OF EDIT================================

private function Actions takes nothing returns nothing
    local item usedItem = null
    local integer id
    local integer i
    local boolean isPowerUp
    local eventid evId = GetTriggerEventId()
    if (evId == EVENT_PLAYER_UNIT_USE_ITEM or evId == EVENT_PLAYER_UNIT_PICKUP_ITEM) then
        set usedItem = GetManipulatedItem()
    elseif evId == EVENT_PLAYER_UNIT_SELL_ITEM then
        set usedItem = GetSoldItem()
    endif
    if not(usedItem == null) then
        set id = GetItemTypeId(usedItem)
        set i = 0
        set isPowerUp = false
        loop
            if id==POWERUP_IDS<i> then
                set isPowerUp = true
                set i=NR_OF_POWERUPS
            endif
            set i = i + 1
            exitwhen i&gt;=NR_OF_POWERUPS
        endloop
        if isPowerUp then
            call PolledWait(0.01)
            call RemoveItem(usedItem)
        endif
    endif
endfunction
//===========================================================================
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_USE_ITEM)
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SELL_ITEM)
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_PICKUP_ITEM)
    call TriggerAddAction(t, function Actions)
    call InitializePowerUps()
endfunction
endscope
</i>


+

the new coloured and better object merger textmacros:
JASS:
//tomes
//! textmacro CreateTome takes I, BTNX, BTNY, ICONPATH, STATCOLOUR, STATSTRING, AMOUNT, AGI, INT, STR, HOTKEY, STOCK, REPLENISH, COST
	//! external ObjectMerger w3a AIgm AT$I$ abpx $BTNX$ abpy $BTNY$ aart &quot;$ICONPATH$&quot; Iagi 1 $AGI$ Iint 1 $INT$ Istr 1 $STR$ ansf &quot;(+$AMOUNT$)&quot; anam &quot;Item $STATSTRING$ Gain&quot;
	//! external ObjectMerger w3t tdx2 IT$I$ iabi AT$I$ ubpx $BTNX$ ubpy $BTNY$ iico &quot;$ICONPATH$&quot; isel 1 igol $COST$ isto $STOCK$ istr $REPLENISH$ uhot $HOTKEY$ unam &quot;Tome of $STATSTRING$ +$AMOUNT$&quot; utip &quot;Purchase Tome of |cff$STATCOLOUR$$STATSTRING$|r +$AMOUNT$ |cffffcc00($HOTKEY$)|r&quot; utub &quot;Permanently increases the |cff$STATCOLOUR$$STATSTRING$|r of the Hero by |cffffcc00$AMOUNT$|r when used.&quot;
//! endtextmacro
//! runtextmacro CreateTome(&quot;01&quot;, &quot;0&quot;, &quot;0&quot;, &quot;ReplaceableTextures\CommandButtons\BTNScrollOfHealing.blp&quot;,    &quot;ffaaaa&quot;, &quot;Strength&quot;,     &quot;2&quot;,   &quot;0&quot;,   &quot;0&quot;,   &quot;2&quot;,   &quot;Q&quot;, &quot;9&quot;, &quot;1&quot;, &quot;200&quot;)
//! runtextmacro CreateTome(&quot;02&quot;, &quot;0&quot;, &quot;1&quot;, &quot;ReplaceableTextures\CommandButtons\BTNScrollOfHealing.blp&quot;,    &quot;ff5555&quot;, &quot;Strength&quot;,     &quot;10&quot;,  &quot;0&quot;,   &quot;0&quot;,   &quot;10&quot;,  &quot;A&quot;, &quot;9&quot;, &quot;3&quot;, &quot;900&quot;)
//! runtextmacro CreateTome(&quot;03&quot;, &quot;0&quot;, &quot;2&quot;, &quot;ReplaceableTextures\CommandButtons\BTNScrollOfHealing.blp&quot;,    &quot;ff0000&quot;, &quot;Strength&quot;,     &quot;100&quot;, &quot;0&quot;,   &quot;0&quot;,   &quot;100&quot;, &quot;Z&quot;, &quot;9&quot;, &quot;5&quot;, &quot;8000&quot;)
//! runtextmacro CreateTome(&quot;04&quot;, &quot;1&quot;, &quot;0&quot;, &quot;ReplaceableTextures\CommandButtons\BTNScrollOfTownPortal.blp&quot;, &quot;aaddaa&quot;, &quot;Agility&quot;,      &quot;2&quot;,   &quot;2&quot;,   &quot;0&quot;,   &quot;0&quot;,   &quot;W&quot;, &quot;9&quot;, &quot;1&quot;, &quot;200&quot;)
//! runtextmacro CreateTome(&quot;05&quot;, &quot;1&quot;, &quot;1&quot;, &quot;ReplaceableTextures\CommandButtons\BTNScrollOfTownPortal.blp&quot;, &quot;55ee55&quot;, &quot;Agility&quot;,      &quot;10&quot;,  &quot;10&quot;,  &quot;0&quot;,   &quot;0&quot;,   &quot;S&quot;, &quot;9&quot;, &quot;3&quot;, &quot;900&quot;)
//! runtextmacro CreateTome(&quot;06&quot;, &quot;1&quot;, &quot;2&quot;, &quot;ReplaceableTextures\CommandButtons\BTNScrollOfTownPortal.blp&quot;, &quot;00ff00&quot;, &quot;Agility&quot;,      &quot;100&quot;, &quot;100&quot;, &quot;0&quot;,   &quot;0&quot;,   &quot;X&quot;, &quot;9&quot;, &quot;5&quot;, &quot;8000&quot;)
//! runtextmacro CreateTome(&quot;07&quot;, &quot;2&quot;, &quot;0&quot;, &quot;ReplaceableTextures\CommandButtons\BTNScrollOfProtection.blp&quot;, &quot;aaaadd&quot;, &quot;Intelligence&quot;, &quot;2&quot;,   &quot;0&quot;,   &quot;2&quot;,   &quot;0&quot;,   &quot;E&quot;, &quot;9&quot;, &quot;1&quot;, &quot;200&quot;)
//! runtextmacro CreateTome(&quot;08&quot;, &quot;2&quot;, &quot;1&quot;, &quot;ReplaceableTextures\CommandButtons\BTNScrollOfProtection.blp&quot;, &quot;5555ee&quot;, &quot;Intelligence&quot;, &quot;10&quot;,  &quot;0&quot;,   &quot;10&quot;,  &quot;0&quot;,   &quot;D&quot;, &quot;9&quot;, &quot;3&quot;, &quot;900&quot;)
//! runtextmacro CreateTome(&quot;09&quot;, &quot;2&quot;, &quot;2&quot;, &quot;ReplaceableTextures\CommandButtons\BTNScrollOfProtection.blp&quot;, &quot;0000ff&quot;, &quot;Intelligence&quot;, &quot;100&quot;, &quot;0&quot;,   &quot;100&quot;, &quot;0&quot;,   &quot;C&quot;, &quot;9&quot;, &quot;5&quot;, &quot;8000&quot;)

//tomeshop <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile    :)" loading="lazy" data-shortname=":)" />                 UnitTomeshop00
//! external ObjectMerger w3u ngme nT00 uico &quot;ReplaceableTextures\CommandButtons\BTNBookOfSummoning.blp&quot; umdl &quot;buildings\other\BookOfSummoning\BookOfSummoning.mdl&quot; usca 1.50 usei IT01,IT02,IT03,IT04,IT05,IT06,IT07,IT08,IT09 ides &quot;Sells various Tomes.&quot; unam &quot;Tome Shop&quot;

JASS:
//HealingPotions AP01-AP05, IP01-IP05
//! textmacro CreateHealingPotion takes I, BTNX, BTNY, ICONPATH, AMOUNT, HOTKEY, STOCK, REPLENISH, CHARGES, COOLDOWN, COST
    //! external ObjectMerger w3a AIh1 AP$I$ abpx $BTNX$ abpy $BTNY$ aart &quot;$ICONPATH$&quot; Ihpg 1 $AMOUNT$ acdn 1 $COOLDOWN$ ansf &quot;(+$AMOUNT$)&quot; anam &quot;Item Healing&quot;
    //! external ObjectMerger w3t phea IP$I$ iabi AP$I$ ubpx $BTNX$ ubpy $BTNY$ iico &quot;$ICONPATH$&quot; igol $COST$ iuse $CHARGES$ isto $STOCK$ istr $REPLENISH$ isst 0 uhot $HOTKEY$ unam &quot;Potion of Healing |cff00bb00+$AMOUNT$|r&quot; utip &quot;Purchase Potion of Healing |cff00bb00+$AMOUNT$|r |cffffcc00($HOTKEY$)|r&quot; utub &quot;Heals |cff00bb00$AMOUNT$|r hit points when used, has |cffffcc00$CHARGES$|r charges&quot;
//! endtextmacro
//! runtextmacro CreateHealingPotion(&quot;01&quot;, &quot;0&quot;, &quot;0&quot;, &quot;ReplaceableTextures\CommandButtons\BTNPotionGreenSmall.blp&quot;, &quot;50&quot;, &quot;Q&quot;, &quot;20&quot;, &quot;5&quot;, &quot;5&quot;, &quot;5&quot;, &quot;50&quot;)
//! runtextmacro CreateHealingPotion(&quot;02&quot;, &quot;1&quot;, &quot;0&quot;, &quot;ReplaceableTextures\CommandButtons\BTNPotionGreenSmall.blp&quot;, &quot;100&quot;, &quot;W&quot;, &quot;20&quot;, &quot;10&quot;, &quot;10&quot;, &quot;10&quot;, &quot;250&quot;)
//! runtextmacro CreateHealingPotion(&quot;03&quot;, &quot;2&quot;, &quot;0&quot;, &quot;ReplaceableTextures\CommandButtons\BTNPotionGreen.blp&quot;, &quot;500&quot;, &quot;E&quot;, &quot;20&quot;, &quot;15&quot;, &quot;10&quot;, &quot;10&quot;, &quot;1250&quot;)
//! runtextmacro CreateHealingPotion(&quot;04&quot;, &quot;3&quot;, &quot;0&quot;, &quot;ReplaceableTextures\CommandButtons\BTNPotionGreen.blp&quot;, &quot;4000&quot;, &quot;R&quot;, &quot;20&quot;, &quot;20&quot;, &quot;5&quot;, &quot;15&quot;, &quot;7250&quot;)

//ManaPotions AP05-AP06, IP05-IP06
//! textmacro CreateManaPotion takes I, BTNX, BTNY, ICONPATH, AMOUNT, HOTKEY, STOCK, REPLENISH, CHARGES, COOLDOWN, COST
    //! external ObjectMerger w3a AIm1 AP$I$ abpx $BTNX$ abpy $BTNY$ aart &quot;$ICONPATH$&quot; Ihpg 1 $AMOUNT$ acdn 1 $COOLDOWN$ ansf &quot;(+$AMOUNT$)&quot; anam &quot;Item Healing&quot;
    //! external ObjectMerger w3t pman IP$I$ iabi AP$I$ ubpx $BTNX$ ubpy $BTNY$ iico &quot;$ICONPATH$&quot; igol $COST$ iuse $CHARGES$ isto $STOCK$ istr $REPLENISH$ isst 0 uhot $HOTKEY$ unam &quot;Potion of Mana |cff9999ff+$AMOUNT$|r&quot; utip &quot;Purchase Potion of Mana |cff9999ff+$AMOUNT$|r |cffffcc00($HOTKEY$)|r&quot; utub &quot;Replenishes |cff9999ff$AMOUNT$|r mana points when used, has |cffffcc00$CHARGES$|r charges&quot;
//! endtextmacro
//! runtextmacro CreateManaPotion(&quot;05&quot;, &quot;0&quot;, &quot;1&quot;, &quot;ReplaceableTextures\CommandButtons\BTNPotionBlueSmall.blp&quot;, &quot;50&quot;, &quot;A&quot;, &quot;20&quot;, &quot;5&quot;, &quot;5&quot;, &quot;5&quot;, &quot;40&quot;)
//! runtextmacro CreateManaPotion(&quot;06&quot;, &quot;1&quot;, &quot;1&quot;, &quot;ReplaceableTextures\CommandButtons\BTNPotionBlueSmall.blp&quot;, &quot;100&quot;, &quot;S&quot;, &quot;20&quot;, &quot;10&quot;, &quot;10&quot;, &quot;10&quot;, &quot;200&quot;)
//! runtextmacro CreateManaPotion(&quot;07&quot;, &quot;2&quot;, &quot;1&quot;, &quot;ReplaceableTextures\CommandButtons\BTNPotionBlueBig.blp&quot;, &quot;500&quot;, &quot;D&quot;, &quot;20&quot;, &quot;15&quot;, &quot;10&quot;, &quot;10&quot;, &quot;1000&quot;)
//! runtextmacro CreateManaPotion(&quot;08&quot;, &quot;3&quot;, &quot;1&quot;, &quot;ReplaceableTextures\CommandButtons\BTNPotionBlueBig.blp&quot;, &quot;4000&quot;, &quot;F&quot;, &quot;20&quot;, &quot;20&quot;, &quot;5&quot;, &quot;15&quot;, &quot;5000&quot;)

//Potionshop
//! external ObjectMerger w3u ngme nP00 uico &quot;ReplaceableTextures\CommandButtons\BTNPotionGreenSmall.blp&quot; umdl &quot;Doodads\LordaeronSummer\Props\CauldronWithHeads\CauldronWithHeads.mdl&quot; usca 1.50 usei IP01,IP02,IP03,IP04,IP05,IP06,IP07,IP08,IP09 ides &quot;Sells various Potions.&quot; unam &quot;Potion Shop&quot;


That's it ^^
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top