Page 1 of 1

[Solved] itemActionComponent/secondaryAction problem

Posted: Thu Nov 06, 2014 4:45 pm
by Blichew
There's this ItemAction (base) Component for Item Component on script-reference page:
http://www.grimrock.net/modding/scripti ... nComponent

I was wondering if anyone tried doing something with it - looking through the option it should be possible to twist secondaryAction a bit to achieve something interesting (there's this getBuildUp() and so on) like the longer you hold the button the better the effect. Is this even possible :) ?

:EDIT:

I went a bit different way with:

Code: Select all

			secondaryAction = {function()
				local luck = math.random(10)
				if luck > 2 then
					return "doubleShot0"
				else
					return "doubleShot1"
				end
			end},
I tried also without "{" and "}" on secondaryAction =, still no luck.
Here's whole item definition:
SpoilerShow

Code: Select all

defineObject{
	name = "twostringbow",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/short_bow.fbx",
		},
		{
			class ="Item",
			uiName = "Two-String Bow",
			gfxIndex = 13,
			GfxIndexPowerAttack = 466,
			secondaryAction = function()
				local luck = math.random(10)
				if luck > 2 then
					return "doubleShot0"
				else
					return "doubleShot1"
				end
			end,
			weight = 2.7,
			impactSound = "impact_blade",
			traits = { "bow", "missile_weapon" },
			description = "Short Bow that can spit two arrows at a same time."
		},
		{
			class = "RangedAttack",
			attackPower = 5,
			accuracy = 10,
			Ammo = "arrow",
			attackSound = "swipe_bow",
			cooldown = 2.0,
			baseDamageStat = "dexterity",
			damageType = "physical",
		},
		{
			class = "RangedAttack",         
			name = "doubleShot0",
			uiName = "Tripple Shot",
			Ammo = nil,
			--repeatCount = 1,
			attackPower = 10,
			attackSound = "swipe_special",
			baseDamageStat = "dexterity",
			damageType = "physical",
			chainAction = "doubleShot1",
			chainActionDelay = 0.1,
			cooldown = 4.0,
			energyCost = 5,
			onAttack = function(self, champion, slot, chainIndex)
				hudPrint(champion.name.." shot one extra arrow out of nowhere !")
			end,
		},
		{
			class = "RangedAttack",         
			name = "doubleShot1",
			uiName = "Double Shot",
			Ammo = "arrow",
			--repeatCount = 1,
			attackPower = 10,
			attackSound = "swipe_special",
			baseDamageStat = "dexterity",
			damageType = "physical",
			chainAction = "doubleShot2",
			chainActionDelay = 0.1,
			cooldown = 3.0,
			energyCost = 5,
		},
		{
			class = "RangedAttack",         
			name = "doubleShot2",
	 --     uiName = "Double Shot",
			Ammo = "arrow",
			--repeatCount = 1,
			attackPower = 10,
			attackSound = "swipe_special",
			baseDamageStat = "dexterity",
			damageType = "physical",
	--		cooldown = 3.0,
			energyCost = 5,
		},
	},
}
Looking forward to your ideas :D

Re: itemAction Component/secondaryAction problem

Posted: Thu Nov 06, 2014 11:55 pm
by Blichew
Bumping with my further tries:

:EDIT: Nevermind, it's working now. I don't know what was wrong.

I tried with onAttack funcction of AttackChain:

Code: Select all

		{
			class = "RangedAttack",         
			name = "doubleShot0",
			uiName = "Double/Triple Shot",
			Ammo = "arrow",
			attackPower = 10,
			attackSound = "swipe_special",
			baseDamageStat = "dexterity",
			damageType = "physical",
			chainAction = "doubleShot2",
			chainActionDelay = 0.1,
			cooldown = 4.0,
			energyCost = 5,
			onAttack = function(self, champion, slot, chainIndex)
				if math.random(10) > 2 then
					print("Got lucky:::")
                                        self:setChainAction("doubleShot1")
				else
					print("Unlucky")
				end
			end,
		},
I'm using self:setChainAction(string) because self.go.id returns item id, so self should be this ItemActionComponent of class "RangedAttack"
SpoilerShow
[/code]
defineObject{
name = "twostringbow",
baseObject = "base_item",
components = {
{
class = "Model",
model = "assets/models/items/short_bow.fbx",
},
{
class ="Item",
uiName = "Two-String Bow",
gfxIndex = 13,
GfxIndexPowerAttack = 466,
secondaryAction = "doubleShot0",
weight = 2.7,
impactSound = "impact_blade",
traits = { "bow", "missile_weapon" },
description = "Short Bow that can spit two arrows at a same time."
},
{
class = "RangedAttack",
attackPower = 5,
accuracy = 10,
Ammo = "arrow",
attackSound = "swipe_bow",
cooldown = 2.0,
baseDamageStat = "dexterity",
damageType = "physical",
},
{
class = "RangedAttack",
name = "doubleShot0",
uiName = "Double/Triple Shot",
Ammo = "arrow",
attackPower = 10,
attackSound = "swipe_special",
baseDamageStat = "dexterity",
damageType = "physical",
chainAction = "doubleShot2",
chainActionDelay = 0.1,
cooldown = 4.0,
energyCost = 5,
onAttack = function(self, champion, slot, chainIndex)
if math.random(10) > 2 then
print("Got lucky:::")
self:setChainAction("doubleShot1")
else
print("Unlucky")
end
end,
},
{
class = "RangedAttack",
name = "doubleShot1",
uiName = "Double/Triple Shot",
Ammo = "arrow",
--repeatCount = 1,
attackPower = 10,
attackSound = "swipe_special",
baseDamageStat = "dexterity",
damageType = "physical",
chainAction = "doubleShot2",
chainActionDelay = 0.1,
cooldown = 3.0,
energyCost = 5,
},
{
class = "RangedAttack",
name = "doubleShot2",
uiName = "Triple Shot",
Ammo = "arrow",
--repeatCount = 1,
attackPower = 10,
attackSound = "swipe_special",
baseDamageStat = "dexterity",
damageType = "physical",
-- cooldown = 3.0,
energyCost = 5,
},
},
}
[/code]
Did anyone try messing up with item customization this much :) ?


:EDIT: Nevermind, it's working now. I don't know what was wrong.


So the real question remains: can you modify object properties dynamically or does everything has to be done inside hooks, like onAttack ?

Re: [(partly)Solved] itemActionComponent/secondaryAction pro

Posted: Fri Nov 07, 2014 9:05 am
by petri
Sure you can!

Re: [(partly)Solved] itemActionComponent/secondaryAction pro

Posted: Fri Nov 07, 2014 9:24 am
by Blichew
petri wrote:Sure you can!
:D

to rephrase: in object definition:

Code: Select all

         secondaryAction = function()
            local luck = math.random(10)
            if luck > 2 then
               return "doubleShot0"
            else
               return "doubleShot1"
            end
         end,
this won't work (judging from my observations). Or I'm just doing something wrong ?

Re: [(partly)Solved] itemActionComponent/secondaryAction pro

Posted: Fri Nov 07, 2014 9:27 am
by petri
I meant yes you can change objects properties dynamically. E.g. setSecondaryAction()