trait help please

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

trait help please

Post by bongobeat »

I ve defined a trait used for special wepons:
but I ve done something wrong with the skills. I wanted that at 3rd level and at 5th level there is a bonus in accuracy of 25 only with a special weapon. Now when the champion equip the weapon, even if he don't have the skill, he got the accuracy bonus (50)

what is wrong?

the skill:
SpoilerShow

Code: Select all

defineSkill{
	name = "modernweapon",
	uiName = "Ancient Weapons",
	priority = 170,
	icon = 90,
	description = "Allow the use of ancient weapons that are based or were found in ancient civilisation sites.",
	traits = { [3] = "mweapon_expert", [5] = "mweapon_mastery" },
}
the traits:
SpoilerShow
defineTrait{
name = "mweapon_expert",
uiName = "Ancient Weapons Expert",
icon = 43,
description = "You are expert in ancient weapons and can now shoot with an additional 25% accuracy with any ancient weapons.",
onComputeAccuracy = function(champion, weapon, attack, attackType, level)
if weapon and weapon:hasTrait("modern") then return 25 end
end,
}
SpoilerShow
defineTrait{
name = "mweapon_mastery",
uiName = "Ancient Weapons Master",
icon = 43,
description = "You are master in ancient weapons and can now shoot with an additional 50% accuracy with any ancient weapons.",
onComputeAccuracy = function(champion, weapon, attack, attackType, level)
if weapon and weapon:hasTrait("modern") then return 50 end
end,
}
and finally the item with the trait:
SpoilerShow

Code: Select all

defineObject{
	name = "grenade_launcher",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/repeater.fbx",
		},
		{
			class = "Item",
			uiName = "Drakonic Shooter",
			description = "A powerful Dwarvish weapon based on ancient technology. Also known as the \"Dragon Mooth\" for its ability to throw fast explosive projectiles.",
			gfxIndex = 337,
			gfxIndexPowerAttack = 97,
			impactSound = "impact_blunt",
			weight = 4.4,
			secondaryAction = "grenade",
			traits = { "modern" },
		},
		{
			class = "FirearmAttack",
			attackPower = 150,
			cooldown = 6,
			attackSound = "gun_shot_small",
			ammo = "pellet",
			requirements = { "modernweapon", 2 },
			range = 20,
			repeatCount = 4,
			repeatDelay = 0.12,
			jamChance = 0,
			backfireChance = 0,
		},
		{
			name = "grenade",
			uiName = "Explosive Projectile",
			class = "FirearmAttack",
			range = 30,
			attackPower = 450,
			cooldown = 6,
			attackSound = "gun_shot_cannon",
			ammo = "grenade",
			requirements = { "modernweapon", 3 },
			jamChance = 0,
			backfireChance = 0,
			gameEffect = "Fires A Rapid Explosive Projectile.",
			onAttack = function(self)
				party.party:shakeCamera(0.7, 0.3)
				local dust = party:spawn("particle_system")
				dust.particle:setParticleSystem("wall_fire_impact")
				dust:setWorldPositionY(dust:getWorldPositionY() + 1.3)	
			end,
		},
	},
}
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
User avatar
Dr.Disaster
Posts: 2876
Joined: Wed Aug 15, 2012 11:48 am

Re: trait help please

Post by Dr.Disaster »

just a thought: does the onComputeAccuracy hook parameter "level" represent "skillLevel"?

In case it does not and "level" is either zero or nil the hooks might activate regardless of skill level.
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: trait help please

Post by bongobeat »

thanks, you are right!

I forgot to make the condition of the level! :roll:

Code: Select all

	onComputeAccuracy = function(champion, weapon, attack, attackType, level)
		if level > 0 then
	if weapon and weapon:hasTrait("modern") then return 25 end
	end
end,
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
Post Reply