Weapon Definitions - component issues

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
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Weapon Definitions - component issues

Post by akroma222 »

Hey all :)
So now that the WIP scripting ref has been released Ive decided to start converting custom content over to the new system.
I have started with a basic knife and I am having problems with a couple of the component properties.
I have tried to redefine the LoG2 throwing knife as a melee attack knife (as in LoG1)
SpoilerShow

Code: Select all

defineObject{
		name = "knife",
		baseObject = "throwing_knife",
		components = {
		{
			class = "Model",
			model = "mod_assets/models/knife.fbx",
		},
		{
			class ="Item",
			uiName = "Knife",
			gfxAtlas = "mod_assets/textures/items.tga",
			gfxIndex = 47,
			weight = 0.7,
			--primaryAction = "MeleeAttack",
			impactSound = "impact_blade",
			traits = { "daggers" },
			description = "A blunt, rusty knife probably used for scaling fish."
		},
		{
			class = "ItemAction",
			requirements = {"light_weapons",2},
			requirementsText = "Light Weapons 2 (Daggers)",
			coolDownTime = 3.0
		},
		{
			class = "MeleeAttack",
			attackPower = 5,
			accuracy = 0,
			swipe = "horizontal",
			attackSound = "swipe",
			baseDamageStat = "dexterity",
			damageType = "physical",
		},
   }
}
Issues
-With primaryAction commented out, the knife will perform an attack - but will do nothing if primary action is not commented out.
-the editor doesnt mind requirements = {"light_weapons",2}, but I can still attack with the knife even with light weapons skill =1.
-the editor does not like requirementsText (and will not list the weapon requirements under the weapon name at the top .... http://ge.tt/6BvSvH32/v/0)
-the editor does not like coolDownTime either... and cool down time is not affected when I change its value.

Prozail has corrected the code! Thank you :D
SpoilerShow

Code: Select all

    defineObject{
          name = "knife",
          baseObject = "base_item",
          components = {
          {
             class = "Model",
             model = "assets/models/items/knife.fbx",
          },
          {
             class ="Item",
             uiName = "Knife",
             --gfxAtlas = "you can set your own",
             gfxIndex = 47,
             weight = 0.7,
             impactSound = "impact_blade",
             traits = { "daggers", "light_weapon" },
             description = "A blunt, rusty knife probably used for scaling fish."
          },
          {
             class = "MeleeAttack",
             attackPower = 5,
             accuracy = 0,
             swipe = "horizontal",
             attackSound = "swipe",
             cooldown = 3.0,
             baseDamageStat = "dexterity",
             damageType = "physical",
             requirements = {"light_weapons" ,2},
             gameEffect = "A test text you can set.",
          },
       }
    }
Akroma
Last edited by akroma222 on Sun Nov 02, 2014 7:54 am, edited 1 time in total.
User avatar
Prozail
Posts: 158
Joined: Mon Oct 27, 2014 3:36 pm

Re: Weapon Definitions - component issues

Post by Prozail »

I made a few changes to your definition.
SpoilerShow

Code: Select all

defineObject{
      name = "knife",
      baseObject = "base_item",
      components = {
      {
         class = "Model",
         model = "assets/models/items/knife.fbx",
      },
      {
         class ="Item",
         uiName = "Knife",
         --gfxAtlas = "you can set your own",
         gfxIndex = 47,
         weight = 0.7,
         impactSound = "impact_blade",
         traits = { "daggers", "light_weapon" },
         description = "A blunt, rusty knife probably used for scaling fish."
      },
      {
         class = "MeleeAttack",
         attackPower = 5,
         accuracy = 0,
         swipe = "horizontal",
         attackSound = "swipe",
         cooldown = 3.0,
         baseDamageStat = "dexterity",
         damageType = "physical",
         requirements = {"light_weapons" ,2},
         gameEffect = "A test text you can set.",
      },
   }
}
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Weapon Definitions - component issues

Post by akroma222 »

Brilliant!! works as intended... Thank you Prozail :D

After work I will change up the original post to reflect your correct item definition
I will also post further work and Q&A with weapon definitions here

Thanks again!
Akroma
User avatar
Doridion
Posts: 256
Joined: Tue Jun 10, 2014 9:23 pm

Re: Weapon Definitions - component issues

Post by Doridion »

Thx Prozail ! Seen that little issues with coins gives you experience, gratz ^^ Sticked for help in the superthread ;)
User avatar
THOM
Posts: 1280
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Weapon Definitions - component issues

Post by THOM »

Is there any way to exchange swipe = "horizontal", with the flurry swipe (the one, that does three hits)?

The only way I can see is to use powerAttackTemplate = "flurry", but with that you can't use your own attack-definitions (definitions seems to be hardcoded). If I knew the correct swipe-animation, it would be fine, I think. But something like swipe = "flurry", doesn't work...
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Weapon Definitions - component issues

Post by minmay »

swipe = "flurry" does give you the Flurry of Slashes swipe. The Flurry of Slashes swipe is simply a horizontal swipe for the first attack in the chain, a vertical swipe for the second attack in the chain, and a horizontal attack for every further attack in the chain. So if you're using it on a weapon without a chain attack it will be the same as a horizontal swipe. If you want alternating horizontal and vertical swipes, just call setSwipe() in the onAttack hook. For example, here's the LoG2 Whirlwind Blade's onAttack, which changes the swipe used on every attack:

Code: Select all

onAttack = function(self,champion,slot,chainIndex)
-- 50% chance of each of the two swipes that we didn't just do
if (math.random() > 0.5) then
	self:setSwipe((self:getSwipe() == "vertical") and "horizontal" or "vertical")
else
	self:setSwipe((self:getSwipe() == "thrust") and "horizontal" or "thrust")
end
	champion:modifyFood(0.5) -- food cost for this many attacks is annoyingly high so reduce it
end,
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
THOM
Posts: 1280
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Weapon Definitions - component issues

Post by THOM »

Aha, okay. But what is an "attack in the chain"? Do I have to define an attack-chain if I want to have this 3time-slash?
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Weapon Definitions - component issues

Post by minmay »

THOM wrote:Aha, okay. But what is an "attack in the chain"? Do I have to define an attack-chain if I want to have this 3time-slash?
The "repeatCount" field in the component definition, or ItemActionComponent:setRepeatCount(), makes the action repeat several times at an interval of repeatDelay. It's what Flurry of Slashes and the Repeater's special attack do.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
THOM
Posts: 1280
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Weapon Definitions - component issues

Post by THOM »

Ah - got it! Thanks a lot.
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
Post Reply