Ok so i havent done much of a search to go through what tutorials have been posted but i thought that i would start this thread so ppl can understand the item related code more easily. I will try to make this comprehensive but it may be a work in progress for a while. Also feel free to contribute!
Ok,
There are 3 levels of an item
ItemBlueprint {
Abilities = {
AbilityBlueprint{
Buffs{
BuffBlueprint{ }
}
}
}
}
Item Blueprint is the data that is refered to when you click purchase at the shop. It contains information about tooltips, Display name, item description and item icon. Note that alot of these are repeated in the higher levels.
Ability Blueprint is the code that initiates an action. Ability blueprints contain information about the ability type (the action which causes the ability like an aura or targeted or on use) icon displayed when an ability is active.
BuffBlueprint performs an action for a given duration. Ie modifies health or mana speed etc.
____________________________________________
Ok so a simple item to start off with ItemBluePrint (using scaled helm) I will break down this as much as i can as a basic overview:
Name = 'Item_Helm_010',
Referal Name, each item must have a different name
DisplayName = '<LOC ITEM_Helm_0000>Scaled Helm',
Name on Tooltip. Notice - LOC ITEM_Helm_0000 - must be diffent for each new tooltip, ie you could change it to LOC ITEM_Helm_0100
GetManaBonus = function(self) return Buffs['Item_Helm_010'].Affects.MaxEnergy.Add end,
Self update function for tooltip display of max mana ([GetManaBonus]).
GetManaRegenBonus = function(self) return Buffs['Item_Helm_010'].Affects.EnergyRegen.Add end,
see above, but for mana per second. Notice how both of these are '.Add' .
It can be: GetManaRegenBonus = function(self) return math.floor(Buffs['Item_Helm_030'].Affects.EnergyRegen.Mult * 100) end, for buff affects which use the mult = function.
Tooltip = {
Bonuses = {
'<LOC ITEM_Helm_0001>+[GetManaBonus] Mana', -- What is shown of tooltip using [GetManaBonus] function
'<LOC ITEM_Boot_0012>+[GetManaRegenBonus] Mana Per Second', -- See above, but for mana regen
},
},
Mesh = '/meshes/items/chest/chest_mesh', -- (Mesh used for ingame animation. I am not sure what this one is so i couldnt give you an example)
Animation = '/meshes/items/chest/Animations/chest_Idle_anim.gr2', -- (see above but this refers to the animation)
MeshScale = 0.10, -- the size of the item in the animation
Icon = 'NewIcons/Helm/Helm5', -- icon file used for the icon, this can be different for abilities an buffs but i recommend that they be the same as the item.
____________________________________________
Other functions that should be called here are:
InventoryType = 'Achievement', - Can also be Clickables, havent tried inventory yet.
Useable = true, - If you want the item to be able to be activated add this line
___________________________________________
Abilities can be called from outside an itemblueprint if necessary if you need i will go into this later. Also an ablity may be called by more than one item, more on this with in the use item section. Multiple abilities may be added to a single item
Abilities = {
AbilityBlueprint {
Name = 'Item_Helm_010',
Name of the ability, abilities may be named differently to the item or even be present in a seperate part of the file or different file altogether as long as the are called correctly. I will try to add this in later.
AbilityType = 'Quiet', (ie effects occur on when the ability is added to the unit)
Other ability types include 'Aura', TargetedUnit, WeaponProc, ArmorProc, Instant
FromItem = 'Item_Helm_010',
Only required if you want the ability loaded upon equiping or using the item. If you use a function to call the ability this line is not required
Icon = 'NewIcons/Helm/Helm5',
See earlier
*Note: this is a passive ability i will go into on use items etc in a bit. These add a number of new lines of code.
____________________________________________________
Ok as per abilities buffs may be called from outside the itemblueprint once again more on this later. Also multiple buffs may applied by the same item.
Buffs = {
BuffBlueprint {
Name = 'Item_Helm_010',
See previous, once again the buff name may be different to the item name
BuffType = 'GLYPHMAGIC',
Used for shared abilities, my understanding of this is limited
Debuff = false,
Whether the buff applies a negative effect that can be removed with dispel
EntityCategory = 'ALLUNITS',
Which units the buff is able to affect
Stacks = 'ALWAYS',
Whether the buff may stack or replace
Duration = -1,
Time the buff is active for (-1 is permanent).
Affects = {
MaxEnergy = {Add = 525, AdjustEnergy = false},
EnergyRegen = {Add = 4},
},
Affects, this is the meat of the buff and applies appropriate effects. I will list avaliable variables later (these can be found in hook/lua/sim/buffaffects.lua)
}
},
}
},
}
Ok so that was a passive item, now onto an on use item. I will bold the important parts of the code for these item types.
For on use items, you use the same Itemblueprint functions however a few more a required.
For example i will use Holy Symbol of Purity (/hook/lua/common/items/achievement_items.lua)
ItemBlueprint {
Name = 'AchievementPure',
DisplayName = '<LOC ITEM_Achievement_0012>Symbol of Purity',
Description = '<LOC ITEM_Achievement_0013>Use: Purge all negative effects. Cannot use while stunned or frozen.',
GetHealthBonus = function(self) return Buffs['AchievementPure_Buff'].Affects.MaxHealth.Add end,
Tooltip = {
Bonuses = {
'<LOC ITEM_Chest_0003>+[GetHealthBonus] Health',
},
},
Mesh = '/meshes/items/chest/chest_mesh',
Animation = '/meshes/items/chest/Animations/chest_Idle_anim.gr2',
MeshScale = 0.10,
Icon = '/NewIcons/AchievementRewards/HolysymbolofPurity',
InventoryType = 'Achievement',
GetMaxRange = function(self) return Ability['AchievementPure'].RangeMax end,
GetEnergyCost = function(self) return Ability['AchievementPure'].EnergyCost end,
GetCastTime = function(self) return Ability['AchievementPure'].CastingTime end,
GetCooldown = function(self) return Ability['AchievementPure'].Cooldown end, - required for tooltip
Useable = true, - allows activation of the item by clicking
Abilities = {
AbilityBlueprint {
Name = 'AchievementPure',
AbilityType = 'Instant', - required for casting, note that there still is a casting time
AbilityCategory = 'USABLEITEM',
TargetAlliance = 'Ally', - This tells the ability which alliance to allow targeting of. Fairly self explanatory. May be Ally, Enemy or Any
Cooldown = 30,
CastingTime = 0, - Above 0 for a non instant cast item
CanCastWhileMoving = true, - may be false if you want casting to stop demigod movement
EnergyCost = 0, - increase for item to cost mana on use
NotSilenceable = true, - not required but can be used if you think that the item should not be silenceable
InventoryType = 'Achievement',
Audio = {
OnStartCasting = {Sound = 'Forge/ITEMS/snd_item_conjure',},
OnFinishCasting = {Sound = 'Forge/ITEMS/Achievement/snd_item_achievement_AchievementPure',},
OnAbortCasting = {Sound = 'Forge/ITEMS/snd_item_abort',},
}, - sounds produced during casting
OnStartAbility = function(self, unit, params)
Buff.RemoveBuffsByDebuff(unit, true)
AttachEffectsAtBone( unit, EffectTemplates.Items.Achievement.HolySymbolActivate, -2 )
end, - see further down for the function explinations. This is required however for activation of an effect on item use
FromItem = 'AchievementPure',
Icon = '/NewIcons/AchievementRewards/HolysymbolofPurity',
},
AbilityBlueprint {
Name = 'AchievementPure_Buff',
AbilityType = 'Quiet',
FromItem = 'AchievementPure',
Icon = 'NewIcons/Hand/Hand1',
Buffs = {
BuffBlueprint {
Name = 'AchievementPure_Buff',
BuffType = 'PURITYBUFF',
Debuff = false,
EntityCategory = 'ALLUNITS',
Stacks = 'ALWAYS',
Duration = -1,
Affects = {
MaxHealth = {Add = 250, AdjustHealth = true},
},
},
},
}
},
}
Ok so now you have an on use item, to apply a new ability or buff to the targeted unit you should change this code:
OnStartAbility = function(self, unit, params)
Buff.RemoveBuffsByDebuff(unit, true)
AttachEffectsAtBone( unit, EffectTemplates.Items.Achievement.HolySymbolActivate, -2 )
end,
Note that the current code removes debuffs by the debuff = true, tag. AttachEffects at bone plays an animation on use.
To apply new buffs following target aquisition replace the middle two lines with the following code (this is how you call abilities and buffs that are not part of the itemblueprint.)
Buff.ApplyBuff( target, 'BuffName01', unit )
To apply new abilities on target aquistion use
Abil.AddAbility(target, 'AbilityName01', true)
Note the part in brackets. Target may also be self, or where a loop is used, v. 'AbilityName01'/'BuffName01' are the names of the ability or buff you want applied. Finally Buffs require 'unit' as a target while abilities are enabled with a boolean.
Variables (buff affects):
So now you should be able to make both passive and items (if you guys want some more examples please ask!). So now i will go into the variables avalible for buff affects. So if we go back to the buff code:
BuffBlueprint {
Name = 'AchievementPure_Buff',
BuffType = 'PURITYBUFF',
Debuff = false,
EntityCategory = 'ALLUNITS',
Stacks = 'ALWAYS',
Duration = -1,
Affects = {
MaxHealth = {Add = 250, AdjustHealth = true},
},
},
The affects have been bolded because this causes the changes most items cause.
ie Maximum health will be increased by 250 and health pool will be adjusted by the maximum health amount.
Other variables include:
Health - health pool
MaxHealth- Total Health
Regen - Health regen
RateOfFire - Attack speed
DamageBonus - Auto Attack damage bonus
DamageRadius - applies cleave damage to radius
DamageSplash - similar to above not completely sure on the difference
MaxRadius - Weapon Range
MoveSlowCap - Minimum slow that may be applied
Interrupt - note this must be a boolean ( ie Interupt = (bool = true)) - this is pentinence interupt
Stun - think eribus mass charm effect. has interupt built in
Freeze - think tb frost nova. has interupt built in
MaxEnergy - Max Mana
Energy - Mana pool
EnergyRegen - Mana Regen Rate
SpellCostMult - adjust the energy cost of an ability
DamageReturn - returns a set amount of damage to the attacker on being autoattack
LifeSteal - as per name
Feedback - not sure on this one
CaptureTime - adjusts capture time on flags, mostly used for map setup
DeathPenaltyMult - death penalty time
DamageTakenMult - adjusts the amount of damage taken. Ie Bulkwark
WeaponsEnable - disables weapons, useful for animations
MetaRadius - Meta is small unit knockback, this defines the area around attacked unit which will be thrown
MetaAmount - This determines the damage multiplier applied to meta'ed infantry
Evasion - as per name
VisionRadius - Applies a vision radius around target or summoned unit (tracking bug)
Invincible - Oaks shield
Absorption - QOT shield
Armor - as per name
Cloak - Applies invisibilty
Silence - Works similar to interupt use (bool = true)
Ok i am off to bed. I will write up some function information later . Will also write up how to add new characters, units, textures. Teleport code and how to select units around target.
________________________________________________________________
Questions:
Before i start, it will still prbly take you about 20 hours to get farmiliar with the game code. Guides will just help your understanding once you understand how the lua interacts.
Ok onto the questions
1. Please explain why some close brackets have a comma.
Answer:
As far as i know, everything must have a comma unless it is closing a blueprint or is part of a function.
Please correct me if i am wrong.
2. Add effects to exsisting abilities --- Please Define. Do you mean show how targeting is done? To add different effects is already written in there the first part of the guide (see abilitytype).
Anyway since you wanted to know how to add interupt to spike wave i will do that in a bit (edit now post2)
Ability Types
Ok all of the below will require these functions added to the AbilityBlueprint:
TargetAlliance = 'Ally', 'Enemy', 'Any' --Who you want to target
TargetCategory = 'HERO', 'MINION', 'ALLUNITS', 'STRUCTURES' and i think 'GRUNT' But this might be incorrect. There are a number of others but they should be the ones most ppl need.
Below is the specific code for each ability category
Aura
AbilityType = 'Aura'
AuraPulseTime = 3 How often you want to apply the buff to targets in radius.
AffectRadius = 1, How big do you want the aura to be. 15 is the standard ranged AA distance
TargetedUnit - for auras you need these bits of code to the ability blueprint:
AbilityCategory = 'USABLEITEM',
TargetingMethod = 'AREAARGETED','ALLYSTRUCTURE', 'HOSTILETARGETED' - common ones. This one needs an individual discussion.
WeaponProc
Difficult to explain with comments. Effectively the following will apply the buff to the target 18% of the time when an AA lands.
WeaponProcChance = 18,
WeaponProcChanceRanged = 18,
OnWeaponProc = function(self, unit, target, damageData)
if not target:IsDead() then
Buff.ApplyBuff(target, 'AchievementDOT', unit)
end
end,
ArmorProc
Similar to weapon proc
ArmorProcChance = 18,
OnArmorProc = function(self, unit, target, damageData)
if not target:IsDead() then
Buff.ApplyBuff(target, 'AchievementDOT', unit)
end
end,
Instant
AbilityCategory = 'USABLEITEM',
CastingTime = #,
EnergyCost = #,
Where # is a number
Ok now to build a new ability for an example.
See example below as to how to change an ability to an item and add new buffs (post 2)
_______________________________________________________________
3.Add buff/debuff effects to exsisting abilities
See above
4. Which program should you use to edit lua
I am using SciTE. I was freeware and works well for me. even has a debugger!
Will continue further with the tutorial based on feedback and more questions.
Exx
____________________________________________________________
How to add items to the shop so you can try them out.
I will use my mod to do this there is a version of 1.8 beta avalible that you can grab from the ftp. Credit to mr rappard for the Item tree shop and achievement shop mods.
The advantage of this is that both have been combined and now function together so you can test your items as achivement or shop items, and there is free space in both shops. Ai will not pick the new items.
For achievement items:
Open Demigod\bindata\mods\FavorMod\UGBShop08_exx_ShopLayout.lua
Open Demigod\bindata\mods\FavorMod\hook\units\ug\b\ugbshop08\ugbshop08_exx_unit.bp
Code: c++
- #Scroll to here
-
- #AchievementSwarm
- AchievementSwarm = {
- Cost = 1, #NOTE: change this value to change cost of item. (Achivement shop will charge achivement points)
- ItemBP = 'AchievementSwarm',
- },
- #copy and paste
- #AchievementSwarm
- AchievementSwarm = {
- Cost = 1,
- ItemBP = 'AchievementSwarm',
- },
- #AchievementSwarm
- AchievementSwarm = {
- Cost = 1,
- ItemBP = 'AchievementSwarm',
- },
- #replace new shop item with your item name
- #AchievementSwarm
- AchievementSwarm = {
- Cost = 1,
- ItemBP = 'AchievementSwarm',
- },
- #YourNewItem
- YourNewItem= {
- Cost = 1,
- ItemBP = 'YourNewItem',
- },
Save ugbshop08_exx_unit.bp
goto ugbshop08_exx_shoplayout.lua
[code = "c++"]
{ 'AchievementSwarm', '',},
# change to:
{ 'AchievementSwarm', 'YourNewItemName',},
[/code]
Save
Your new item will now be in the forth tab bottom right corner.
For other shops:
goto the respective shop tab. And do as per achivement items.
Note The standard shop tabs can be found at: Demigod\bindata\mods\FavorMod\hook\units\ug\b\.
shop02Mod = chest
shop03Mod = gloves
shop04Mod = helm
shop05Mod = Artifact - (not sure if this tab works in this version)
shop06Mod = Trinket Shop
shop07Mod = Consumables
shop08Mod = dont use. (achivement items, may cause conflicts)
shop09Mod= General
shop10Mod= Boots
Cheers,
Exx