The 3rd Age

The Four Ages mod

The Four Ages mod

Fight for the freedom of Beleriand with the eldar and the elves or enslave them with Angband.

Button for The 3rd AgeButton for The Dwarf HoldsButton for The Elven AllianceButton for Helm's Deep Last HopeButton for GothmogtheOrcButton for BFME+Button for The Four AgesButton for HDR HeadquartersButton for Middle Earth CenterButton for Project Perfect Mod

Become an affiliate!

   

Quick Lists

Top Rated Popular New Updated Last Comments Users

Register and log in to move these advertisements down

Easy reskin and random skin coding

Tutorial for Battle for Middle-earth BFME, Battle for Middle-earth II BFME 2, Battle for Middle-earth II: Rise of the Witch-king ROTWK

Avatar of Radspakr Wolfbane

Radspakr Wolfbane

Category: Code
Level: Intermediate
Created: Monday April 23, 2007 - 20:08
Updated: Tuesday April 24, 2007 - 1:32
Views: 8863
Summary: This is double tutorial that teaches how to use the easy reskin and random unit coding.

Rating

Staff says

3.0

Members say

3.0

Average

3.0/5.0

7 votes

I have been using 2 very useful pieces of code lately that help in randomising units and reskining, so I thought I'd make a double mini tutorial for beginner coders. Hope this helps out those starting off and anyone else.

RandomTexture
The first is probably well known to a lot of experienced coders, the all powerful RandomTexture code. This line of code is used to add random textures to units which is why the Rohirrim units look different. It is a very common code but it can also be used to reskin units without adding a new model or replacing the original art.

First up make your skin. For the purposes of this tutorial I'll use Legolas as an example. Once you've made the skin, add it to the game with the usual method (if you don't know how there are plenty of tutorials here).
Now go to legolas.ini and add the following code to the Draw Module, preferably above the DefaultModel line so it is easy to find.
              
Code
RandomTexture = newtexture.tga 0 originaltexture.tga

The game will now replace the original texture with your new one, without the need to edit a model or create a new one.
To randomise between textures simply add multiple copies as follows:
              
Code
RandomTexture = newtexture.tga 0 originaltexture.tga
RandomTexture = secondtexture.tga 0 originaltexture.tga
RandomTexture = thirdtexture.tga 0 originaltexture.tga


Random Object
I was recently going through the ent coding when I found this. I had known about the Ent variation coding. I found a great use for it so I thought post it up.
This is very simple but very useful code I have often overlooked, as have others, but this code is very useful for randomising hordes, heroes, buildings and units.

The way this code works is setting a unit that can build different units from one button. This allows the different versions of the ents and also the peasants.
It also works for heroes and I imagine also for buildings.
It'ss useful if you want to make alternate versions of a hero or unit and have them randomised.
Rather then just using different skins you can have to very different units or heroes for instance. I used this to build 2 different versions of Thranduil for the Lone Wolf Mod.
One uses a bow the other using melee this also allows you to have different buttons for each version.

I've named the object 'dummy'. First up it's good to have a model there so it will show up in World Builder (the randomisation only happens in the game, in WB you just see the main object).
The ent coding for the object didn't have a buttonimage so make sure you add one so it will show up in Worldbuilder.
If you are making a Hero making sure it has the HERO KindOf.

In the BuildVariation line add the name of the Heroes/Units you want to use.
By adding the Dummy to BuildableHeroes Line in PlayerTemplate.ini it will now randomise between the BuildVariations, or if you are making a unit build the unit from a button.
This should also work for building Hordes (haven't tested that yet) and the coding should also work for units going into a horde. Just add the unit to the horde, which will be good if you want use different animations for a unit, like having some units use a Sword and Shield and others an axe, and possibly combining different tyoes of units in one horde, like Pikes and Melee or Crossbows and Archers.

I should also mention with the BuildVariation units/Heroes if you want the unit to count as the same unit/Hero as the other versions add this line to your coding.
              
Code
EquivalentTo = Dummy

Here is the example code for the main object
              
Code
Object Dummy
Draw = W3DScriptedModelDraw ModuleTag_01
StaticModelLODMode = Yes
DefaultModelConditionState
Model = dummy_skn
Skeleton = dummy_SKL
End
End
; ***DESIGN parameters ***
Side = Elves
; SelectPortrait for Heros is portrait behind skill buttons. HP = HeroPortrait.
SelectPortrait = HPdummy

; ButtonImage for Heros is button image on Hero Select UI to select hero. HI = HeroIcon or HeroImage.
ButtonImage = hidummy

EditorSorting = UNIT
CommandPoints = 0
BuildVariations = dummy01 dummy02
KindOf = HERO PRELOAD SELECTABLE CAN_CAST_REFLECTIONS INFANTRY PATH_THROUGH_EACH_OTHER SCORE THROWN_OBJECT ARMY_SUMMARY ATTACK_NEEDS_LINE_OF_SIGHT
MaxSimultaneousOfType = 1
BuildCost = 2200
BuildTime = DUMMY_BUILDTIME
BountyValue = ROHAN_ENT_BOUNTY_VALUE
End

Comments

Display order: Newest first

drogoth232 - Tuesday July 28, 2009 - 10:29

Thanks Rad I use it for every new model I acquire which has no skin.

The Dark Lord of Mordor - Thursday May 28, 2009 - 20:15

interesting

LinkFan (Banned) - Sunday August 3, 2008 - 11:59

Really Nice tutorial!!! :)

jimiojoe - Sunday October 14, 2007 - 7:54

oooh
i new about the actual code

but i really like what you said : idea of having two different possible hero's
.........
intriguing.....
... :D

Bart (Administrator) - Tuesday April 24, 2007 - 1:32

Nice tutorial, but next time please try to use proper markup, interpunction and capitalisation ;-) I edited it for you.

Go to top

 

"One site to rule them all, one site to find them,
one site to host them all, and on the network bind them."

 
14:32:17