Ask a simple question, get a simple answer
Re: Ask a simple question, get a simple answer
Isaac!
Many thanks!
Everything happened as planned!
Many thanks!
Everything happened as planned!
- zimberzimber
- Posts: 432
- Joined: Fri Feb 08, 2013 8:06 pm
Re: Ask a simple question, get a simple answer
This didn't work for me either.Liam.Ducray wrote:1. Isn´t it possible to create a character-level requirement for weapons in the LUA file? Like i.e. Character must be at least level 4 to hold a Sabre.
I tried the command "requiredLevel = X," as written on the official page, but it does not work.
You can prevent the player from using an item if certain requirements are not met in the 'onAttack' hook.
Code: Select all
onAttack = function(self,champion,slot)
if champion:getLevel < 3 then
champion:showAttackResult("Can't Use", "AccuracySymbol")
return false
end
end,
Only melee and firearm attacks have pierce.2. Isn´t it possible to give the parameters "knockback" and "pierce" to ranged weapons? As I tried, the editor spelled error messages upon testplay.
There is no "knockback" parameter. Did you mean powerAttackTemplate = "knockback" ?
You can use the 'onAttack' and 'onPostAttack' hooks to modify the item based on the ammunition item currently held by the champion.3. Isn´t it possible to give Ammunition a "damageType" like i.e. fire ? I created my own Flaming Crossbow Bolts, and of course they are supposed to deal fire damage.
But again, the editor gave me the "invalid component property"-error messages upon testplay.
onAttack to modify the item with extra stats for the attack, and increase the stack by one if current stack count is 1 so you can still access it from the onPostAttack
onPostAttack to revert the item back to its original state based on the ammo item, and then reduce the stack count of the ammo item by one.
My asset pack [v1.10]
Features a bit of everything!
Features a bit of everything!
-
- Posts: 4
- Joined: Sun Feb 19, 2017 11:23 am
Re: Ask a simple question, get a simple answer
Okay, I tried the onAttack command on a test object within the items.lua, but then I was unable to open my project. The editor says:
something´s missing?
Yes, I meant the powerAttackTemplate "knockback". I assume it works with melee only?
And point 3 I totally don´t understand No clue where to put the code and how to define the onAttack and onPostAttack commands correctly
the full code is:items.lua:96: function arguments expected near '<'
Code: Select all
defineObject{
name = "sling",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/sling.fbx",
},
{
class = "Item",
uiName = "Sling",
description = "A primitive sling to accelerate rocks",
gfxIndex = 44,
impactSound = "impact_blunt",
weight = 0.5,
traits = { "missile_weapon" },
},
{
class = "RangedAttack",
attackPower = 7,
cooldown = 4,
damageType = "physical",
attackSound = "swipe",
ammo = "rock",
onAttack = function(self, champion, slot)
if champion:getLevel < 2 then
champion:showAttackResult("Can't Use", "AccuracySymbol")
return false
end
end,
},
},
tags = { "weapon", "weapon_missile" },
}
Yes, I meant the powerAttackTemplate "knockback". I assume it works with melee only?
And point 3 I totally don´t understand No clue where to put the code and how to define the onAttack and onPostAttack commands correctly
- zimberzimber
- Posts: 432
- Joined: Fri Feb 08, 2013 8:06 pm
Re: Ask a simple question, get a simple answer
You forgot the brackets after getLevel in this line:
powerAttackTemplate gives the item a pre-defined secondary attack.
"knockback" is a melee attack that knocks monsters it hits back.
Take a look at this for some more info - https://www.youtube.com/watch?v=7L8Epms ... e=youtu.be
onAttack and onPostAttack are two functions that can be defined for every component that adds an attack to an item. (MeleeAttack, RangedAttack, ThrowAttack, FirearmAttack)
You defined them exactly like the way you defined the code that didn't work for you. (You were just missing brackets)
Here's an example:
onAttack happens before the attack executes, so with it you can cancel an attack or have it modify the item.
onPostAttack happens after the attack was made, so you can use it to revert changes done to the item, or apply certain effects.
Code: Select all
if champion:getLevel < 2 then
"knockback" is a melee attack that knocks monsters it hits back.
Take a look at this for some more info - https://www.youtube.com/watch?v=7L8Epms ... e=youtu.be
onAttack and onPostAttack are two functions that can be defined for every component that adds an attack to an item. (MeleeAttack, RangedAttack, ThrowAttack, FirearmAttack)
You defined them exactly like the way you defined the code that didn't work for you. (You were just missing brackets)
Here's an example:
Code: Select all
onAttack = function(self, champion, slot, chainIndex)
if champion:getHealth() < champion:getMaxHealth() then
hudPrint("User is wounded, cannot use this weapon")
return false
end
end,
onPostAttack = function(self, champion, slot)
champion:damage(20,"pure")
end
onPostAttack happens after the attack was made, so you can use it to revert changes done to the item, or apply certain effects.
My asset pack [v1.10]
Features a bit of everything!
Features a bit of everything!
-
- Posts: 4
- Joined: Sun Feb 19, 2017 11:23 am
Re: Ask a simple question, get a simple answer
Thanks for the explanation. Most of it works for now.
Another quick question that came up: Isn´t the command "causeCondition" working on weapons? I tried the following:
but the result is an error message upon testplay.
Anyone knows how to bypass this?
cheers
Another quick question that came up: Isn´t the command "causeCondition" working on weapons? I tried the following:
Code: Select all
{
class = "FirearmAttack",
name = "hellfire",
uiName = "Hellfire",
gameEffect = "Fires rapidly 4 concussive bullets filled with pure magma.",
energyCost = 25,
attackPower = 16,
cooldown = 6,
attackSound = "gun_shot_large",
ammo = "pellet",
knockback = true,
repeatCount = 4,
repeatDelay = 0.2,
damageType = "fire",
causeCondition = "burning",
conditionChance = 40,
},
Anyone knows how to bypass this?
cheers
- zimberzimber
- Posts: 432
- Joined: Fri Feb 08, 2013 8:06 pm
Re: Ask a simple question, get a simple answer
Here is the scripting reference - http://www.grimrock.net/modding/scripting-reference/
And another page containing some more up-to-date functions - https://github.com/JKos/log2doc/wiki/Class-list
If a component doesn't have something like setPierce but has setCauseCondition,then it can't accept accuracy but can accept caused conditions.
In your case, firearms can't accept causedCondition, because thats how the component works.
If you still want a firearm to cause a condition, you can have the onPostAttack function shoot an invisible high velocity projectile that on hit causes a condition, but it will get applied even if you miss.
And another page containing some more up-to-date functions - https://github.com/JKos/log2doc/wiki/Class-list
If a component doesn't have something like setPierce but has setCauseCondition,then it can't accept accuracy but can accept caused conditions.
In your case, firearms can't accept causedCondition, because thats how the component works.
If you still want a firearm to cause a condition, you can have the onPostAttack function shoot an invisible high velocity projectile that on hit causes a condition, but it will get applied even if you miss.
My asset pack [v1.10]
Features a bit of everything!
Features a bit of everything!
- Zo Kath Ra
- Posts: 937
- Joined: Sat Apr 21, 2012 9:57 am
- Location: Germany
Re: Ask a simple question, get a simple answer
Put a script entity called script_entity_1 in your dungeon.Liam.Ducray wrote:1. Isn´t it possible to create a character-level requirement for weapons in the LUA file? Like i.e. Character must be at least level 4 to hold a Sabre.
I tried the command "requiredLevel = X," as written on the official page, but it does not work.
Put this code in script_entity_1:
Code: Select all
function removeItem(champion, slot)
local item_slot = party.party:getChampionByOrdinal(champion):getItem(slot)
local item_mouse = getMouseItem()
if (item_mouse == nil) then
-- there was no item in the slot when we equipped the sword
-- item_slot = sword
setMouseItem(item_slot)
party.party:getChampionByOrdinal(champion):removeItemFromSlot(slot)
else
-- there already was an item in the slot
-- item_slot = sword
-- item_mouse = old item
-- put the sword in the mouse cursor
setMouseItem(item_slot)
party.party:getChampionByOrdinal(champion):removeItemFromSlot(slot)
-- put the old item back in the champion's inventory
party.party:getChampionByOrdinal(champion):insertItem(slot, item_mouse)
end
end
Code: Select all
defineObject{
name = "fighters_long_sword",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/long_sword.fbx",
},
{
class = "Item",
uiName = "Fighter's Longsword",
gfxIndex = 84,
gfxIndexPowerAttack = 430,
impactSound = "impact_blade",
weight = 3.2,
description = "This longsword is only for fighters.",
traits = { "light_weapon", "sword" },
onEquipItem = function(self, champion, slot)
if (slot == ItemSlot.Weapon) or (slot == ItemSlot.OffHand) then
if (champion:getClass() ~= "fighter") then
hudPrint("This longsword can only be equipped by fighters!")
delayedCall("script_entity_1", 0, "removeItem", champion:getOrdinal(), slot)
end
end
end
},
{
class = "MeleeAttack",
attackPower = 16,
accuracy = 0,
cooldown = 3.7,
swipe = "horizontal",
requirements = { "light_weapons", 1 },
powerAttackTemplate = "thrust",
},
},
tags = { "weapon" },
}
if (champion:getClass() ~= "fighter") then
with
if (champion:getLevel() < 4) then
- zimberzimber
- Posts: 432
- Joined: Fri Feb 08, 2013 8:06 pm
Re: Ask a simple question, get a simple answer
I got two questions:
1) Is there a way to create a 'distortion' effect similar to this:
2) How do I make projectiles travel in a horizontal (or any other 1-89 degree angle from one of the main directions) path?
1) Is there a way to create a 'distortion' effect similar to this:
2) How do I make projectiles travel in a horizontal (or any other 1-89 degree angle from one of the main directions) path?
My asset pack [v1.10]
Features a bit of everything!
Features a bit of everything!
- Zo Kath Ra
- Posts: 937
- Joined: Sat Apr 21, 2012 9:57 am
- Location: Germany
Re: Ask a simple question, get a simple answer
Artifacts of Mightzimberzimber wrote: 2) How do I make projectiles travel in a horizontal (or any other 1-89 degree angle from one of the main directions) path?
level: The Crypt
in the center, there's a room with a blob that moves the way you want
it's implemented with a timer that runs every frame and changes the blob's position
(the blob's velocity is 0)
if you wanted to do this with something that isn't a particle system, e.g. an arrow, you'd also have to change the arrow's rotation
Re: Ask a simple question, get a simple answer
Good afternoon!
Please tell me how to do:
1) Because the wall (daemon_head_1) flies spell (any) with an interval of every 5 seconds
2) Because the wall (daemon_head_1) flies spell (any) upon activation of the trigger
Please tell me how to do:
1) Because the wall (daemon_head_1) flies spell (any) with an interval of every 5 seconds
2) Because the wall (daemon_head_1) flies spell (any) upon activation of the trigger