Please or Register to create posts and topics.

Animate Buildings

How to make animated buildings  v0.03 by Vickhan QaraNoyan (Melkor)
Preambule: This is a quick tutorial, which is based on some of my posts on the warcraft editor forum, about making animated buildings, I'm not very experimented in it but apparently there is no tutorial of it on the net although it s very similar to the making of special heroes gfx, therefor this tutorial will be soon updated (hopefully) as researches about it progress and if easier methods are found. I'll assume that you have downloaded Wardraft and 278tools and that you already know how to change units gfx.
Extract from maindat.war the #278entry and the gfx of the building you want to edit and convert it into bitmap with the graphics converter of wardraft.
Edit your layout.txt so as to include the new frames in your gfx (similar to heroes editing)
Tips (thanks to Sir Galahad):to change the 2-frames gfx of regular buildings in for example a 10-frames gfx, you only have to change the NUMICONS to 10 and copy the first line of the icon properties (the one for the 1st frame which corresponds to the completed building) 10-2=8 times and then change the number of each icon (from 2 to 9). Then convert back the original bmp (which have only 2 icons) to gfx with wardraft using the new layout.txt. The new gfx will have now 10 frames so when converting the new gfx to bmp again you have now a 10-icons bmp and a already made layout.txt
example for the Orc Barracks for summer tileset:
extract entry 95 to 95.gfx
convert it to 95.bmp and 95.txt
edit 95.txt
you should have:
# (icon) (width) (height) (position in BMP); (X-,Y-Adjust)
      0      95       96  (1,0) - (95,95); 1 0
      1      88       77  (8,115) - (95,191); 8 18
change them to:
# (icon) (width) (height) (position in BMP); (X-,Y-Adjust)
      0      95       96  (1,0) - (95,95); 1 0
      1      88       77  (8,115) - (95,191); 8 18
      2      95       96  (1,0) - (95,95); 1 0
      3      95       96  (1,0) - (95,95); 1 0
      4      95       96  (1,0) - (95,95); 1 0
      5      95       96  (1,0) - (95,95); 1 0
      6      95       96  (1,0) - (95,95); 1 0
      7      95       96  (1,0) - (95,95); 1 0
      8      95       96  (1,0) - (95,95); 1 0
      9      95       96  (1,0) - (95,95); 1 0
save the new file to 95bis.txt
reconvert 95bis.txt and 95.bmp to 95bis.gfx
You have now a gfx for barrack of 10 frames.
Now convert it to anim95.bmp and anim95.txt.
3-Your favorite bmp editor
Change your frames as you want.
Convert back your bitmap into gfx using the new layout.txt and import this gfx into its former slot.
Convert, using d278.exe, the raw 278entry into an editable txt (278.txt for example)
Edit 278.txt
*Creating new entries in 278.txt: when creating a new event or a new prog in 278 you may experiment problems for having it corresponding to the line number of the event. A good way to name these new events in wordpad is to take the number of the last entry listed and go down adding +1 for every line (including the blank line) and then finally add1 to your prog/event/global name (look at the over entries for better understanding). If you already now what buildings do you want to animate you can have the speededitor of wardraft to create specific progs and events for your buildings. Once you created a new Prog and a new event, you can use it for other buildings (simply change the prog pointer in section 1/3 or use the Group/Ungroup functions of the speededitor of wardraft BEFORE editing the 278 entry with 278tools, the speededitor will also create a specific prog for the building) but you will have to do the same number of icons for all the building and they will all have the same animation rate.
All the figures i will use in this tutorial are very likely to change as you modify your 278 file.
Make a new Prog. (fe Prog_12D0) and move it to the program section (2/3)
        Locate the program associated with your building (section 1/3) (if it s not a tower it will probably be Prog_0DA4) and copy its content under Prog-12D0. Then change the pointer of the building in the first section.
for example, let's animate a dragon roost of 4 frames
U71     Prog_0DA4       ; Dragon Roost  --->    U71     Prog_12D0       ; Dragon Roost
        In this prog you should have 7 events (i haven t yet figured out completly what they are corresponding to). If it's a normal building, changing the move event (for example Event_12C0) should be sufficient to make basic animations (if it doesn t work try to change all events corresponding to 12C0). To change this DO NOT change directly event 12C0 (it would alter all the buildings) but create a new global event (fe Global_12D9) and place it in the Event section (3/3), copy the content of 12C0 in this event and add WAIT and SHOW commands (get ones from events of units for example) and change the parameter of the GOTO command at the end so as to create a waiting loop.
You should obtain something like that:
        SHOW            0
        WAIT            10
        SHOW            2
        WAIT            10
        SHOW            3
        WAIT            10
        SHOW            2
        WAIT            10
        GOTO            Global_12D1
Nota Bene: For simple animations, the SHOW command refers to the number of your icon minus 1
(0 is the standard icon, 1 the construction one) and not to the first icon of a group of 5 different angles as in common unit gfxs.
Then, change in Prog_12D0 the parameter of the event.
E3      Global_12C0     ; Move      ----> E3    Global_12D9     ; Move
Convert back your new 278.txt to a raw 278 entry using a278.exe
Import this new file into slot #278 in maindat.war
Now it *SHOULD* work...
known problems:
*The speed editor of wardraft cannot be used for editing 278 entry that have been recompiled with 278 tools so if you want to make simple edition to 278 entry, do it BEFORE the animation of buildings! (Anyway, once you have started editing with 278tools you will quickly find it as good as wardraft speed editor even for simple animations and with much more potentialities for advanced animations).
*During their construction the animation will start after the building has been half built, so the specific "in construction" frame of the batiment will not be shown and you cannot see if a batiment is in his second part of construction or if it is already built.
The towers can actually be animated to aim their targets.
The main differences with other building animations are:
1-War2unit,Udtaed etc...
the main problem was to use sequences of 5 frames like units instead of single frame like other buildings but it can be solved by editing the udta section of puds (with udtaed or war2unit for example):disable the flags IS A BUILDING and ATTACKING TOWER. Of course you must edit every pud you want to play with animated towers or change the default UDTA in maindat.war.
2-Wardraft, notepad, your favorite bmp editor
Make a sequences of 5 copies of the first frame and edit it so as to make a gfx similar to a unit one.
Edit the 278 txt : Create a new event corresponding to the new attack animation. Copy in this event the commands of the attacking event of a unit and edit these as you would do for a unit.
Insert the new gfx and the new 278 entry.
Using these towers as units implied some other modifications in the game: Your peons/peasants cannot repare them.
Other bugs are currently :
During the upgrade to canon or guard tower the frame is not the right one ( i haven t found yet the event for upgrading).
After upgrading from scout tower to canon or guard tower you have to "refresh" the screen by scrolling once to make disapear the first frame.
Without the SHOOT or TASK_WAIT command in 278 the reactions of the towers are quite strange: it fires always at the same place, and the tower can be attacked in hand-to-hand combat near the place where the ball explode (even if it s 8 tiles away from tower).
Some ideas about standardising the exchanges of 278 stuff for warcraft2 editors:
exchanging 278 stuff need currently to replace the whole 278 entry, loosing all the previous changes, or to edit many lines to insert a new event for a single unit.
Why not all of us use the same 278 file where every unit have its own program and its own events and distribute it in txt format so everyone have the same default file.
then for editing special units we only have to send to people only the corresponding events which will replace the events of the unit.
people can then transfert 278 stuff more easily, which can be especially  useful for buildings events.
For building events we can also agree on a single event for their animation during game, by using the same event with many (fe 120) waiting delay of very short time (fe 2 or 3 ticks) each corresponding to a specified frame (0 to 119). All the changes of animations can then be done in gfx (which will all contain 60 frames) by making copies of the same frame in a number proportional to the length of its display and by copying sequences of frames to give to the animation its total length (fe if there is 4 times the same sequence of 30 frames , the animation will last twice longer than an animation with 8*15 frames).
The obvious drawback of this method would be the size of the  gfx which will be quite large for all buildings but this will much simplify exchanges of gfx of buildings as their will be no 278 edition for the user.
We can also do this method only for some building and make the big global event for other buildings, the user would have then to regroup modified buildings with the speededitor of wardraft (which is much simplier than to give directly the whole event).
for comments, suggestions etc...:
Thanks! Tupac Administrator