• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

ObjectDefinition

Status
Not open for further replies.
Level 21
Joined
Mar 27, 2012
Messages
3,232
This is a tool to simplify ObjectMerger implementations. You can define objects outside the editor and easily load them for implementation.

Uses:
Saves tons of time.
Safety. You can resave the map to recreate objects. This also counteracts the famous deleting-object-crashes-editor bug since you can just save to fix errors.

Implementing:
Copy this to the map header or a trigger.
JASS:
//! externalblock extension=Lua ObjectMerger $FILENAME$
    //! i require "lua\\ObjectDefinition"
    //! i local t = ProcessFolder("Test")
    //Call custom functions here if needed. Then call ImplementTable.
    //! i ImplementTable(t)
//! endexternalblock

Object file syntax:
field=value

The field names are shown in brackets in JNGP. Example:
F) Stats - Duration - Hero (ahdu)
^In this case it's "ahdu"^

If a field has multiple levels, then you just add the number after it like this:
field3=value

If you set the level to 0, it applies to every level if "alev" exists. Example:
alev=3
field0=value
Turns into:
alev=3
field1=value
field2=value
field3=value
This features is referred to as "fieldn"


raw4=ABCD,ABDX
baseid=hfoo
type=units
uhpm=100
unsf=return loadObjectFieldValue(keytable["lelzz"],"a")-f
lelzz:a=12k
This example creates 2 units based on the footman, with their rawcodes being ABCD and ABDX. It sets the max health for both of them to 100 and the editor suffix to whatever the object "lelzz" has in field "a".
It also sets the field "a" of object "lelzz" to "12k".

Necessary stuff:
raw4=A000,A085,KMGD
If the rawcode hasn't been set the object doesn't get passed to ObjectMerger and thus, doesn't get added to the map. You can still use it for other things though, such as templates.

type=abilities|units|buffs|etc (Pick one)
If a type hasn't been set and the object has raw4s, then ObjectMerger will probably throw errors.

Optional things:
//Comment
Any line that is empty or starts with // is ignored completely.

+stuff
Adds "stuff" to the previous valid line. For previous lines it doesn't consider comments or empty lines.

inherits=parent
Replace parent with an object identifier, such as a rawcode. This copies all fields from the specified object.

field+stuff
Adds "stuff" to the field "field" in current file.

fieldn
Replace n with any number. This sets the value of "field" for level n of the object.
Use 0 to set all levels (only works if "alev" exists).

-f
Any value that ends with "-f" is treated as lua code.
Example use(also uses fieldn):
amcs0=return 25+level*25-f
This sets the mana cost of current objects to 50,75,100,125...
Also, notice how you can use "level" in lua code. The same applies to "raw4".

field("field")
Used in lines that end with "-f". It returns the value of "field" from the current object.

caseValue(table)
Used in lines that end with "-f". Picks a value from the table based on what letter the rawcode ends with. Works properly with multiple rawcodes as well.
Example:
return caseValue({["1"]="Q",["2"]="W",["3"]="E",["4"]="R"})-f


slotability:type=abilities
slotability:abpx=return caseValue({["1"]=0,["2"]=1,["3"]=2,["4"]=3})-f
slotability:abpy=2
slotability:ahky=return caseValue({["1"]="Q",["2"]="W",["3"]="E",["4"]="R"})-f

heroability:arpx=return field("abpx")-f
heroability:arpy=0
heroability:alev=return caseValue({["1"]=3,["2"]=3,["3"]=3,["4"]=1})-f
heroability:aher=1
heroability:arlv=return caseValue({["1"]=1,["2"]=1,["3"]=1,["4"]=6})-f
heroability:arhk=return field("ahky")-f
heroability:aret=return "Learn "..field("name").." - [|cffffcc00Level %d|r]"-f

toggleability:aubx=return field("abpx")-f
toggleability:auby=return field("abpy")-f
toggleability:auhk=return field("ahky")-f

channelability:Ncl60=return caseValue(["1"]="barkskin",["2"]="barkskinon",["3"]="barkskinoff",["4"]="darkconversion"})-f

raw4=return createRaw4f1("A")-f
baseid=ACbl
inherits=slotability,heroability,toggleability
arar=ReplaceableTextures\CommandButtons\BTNBloodLust.blp
Blo10=0.4
Blo20=0.25
Blo30=0.3
abuf0=Bblo
ahdu0=40
adur0=40
acdn0=return 40-level*10-f
aran0=600
amcs0=75
atar0=air,ground,friend,organic,self,neutral
name=return "Bloodlust("..field("ahky")..")"-f
arut=return "Increases a target friendly unit's attack rate by <"..raw4..":ACbl,DataA1,%>% and movement speed by <"..raw4..":ACbl,DataB1,%>%. |n|n|cffffcc00Level 1|r - Cooldown: <"..raw4..":ACbl,Cool1> seconds. |n|cffffcc00Level 2|r - Cooldown: <"..raw4..":ACbl,Cool2> seconds. |n|cffffcc00Level 3|r - Cooldown: <"..raw4..":ACbl,Cool3> seconds."-f
atp10=return "Bloodlust("..field("ahky")..","..level..")"-f
aub10=return "Increases a target friendly unit's attack rate by <"..raw4..":ACbl,DataA1,%>% and movement speed by <"..raw4..":ACbl,DataB1,%>% for <"..raw4..":ACbl,Dur"..level.."> seconds."-f
 

Attachments

  • ObjectDefinition.RAR
    13.5 KB · Views: 35
Level 6
Joined
Jul 30, 2013
Messages
282
very interesting.. :)

maybe i can finally get closer to that dream of not having to keep a gigant blob in git :D
 
Status
Not open for further replies.
Top