[WIP] Combined custom content thread

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

Re: [WIP] Combined custom content thread

Post by akroma222 »

Hey Drakkan!
Of course I have the time and I'm always in the mood for making cool weapon stuff ;)
1. Yes - Akromas sword of divine slaughter used a name condition (champ needs to be named akroma :lol: )/ class condition should be even easier

2. Yes, already got these scripts working (also requires Minmay's trait manager script) so we dont remove traits champions already have onUnequip - will post all this tomorrow

3. Maybe... this wasn't possible (as far as I know) for LoG1, I am hoping it is for LoG2 (I put a request in for a return false for onEquip/onUnequip hooks). Otherwise it is entirely possible someone else may have come up with a solution for this. Either way if it is out there then I will post it here :)

4. Yes, already got Life Leech scripts working and damaging the wielder is a simple change in script (in fact the next axe I am converting does exactly this so this is first on the list)
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: [WIP] Combined custom content thread

Post by akroma222 »

Just posted a new simpler script for Life Leech
and scripts for weapons that damage the champ onMonsterHit
and for weapons needing a champion with a specific name
Swords and Axes are nearly done

I will also post a party timer script I gotten working...
Basically I have just added a Counter and Timer component to the party,
have it trigger on start and print the counter value each second...
I believe it is not affected by timescaling between levels so I imagine it could serve as a core timer
Paste it into init.lua

credits to John and Bilchew viewtopic.php?f=22&t=8004&p=82061&hilit ... mer#p82061
SpoilerShow

Code: Select all

defineObject{
       name = "party",
       baseObject = "party",
       components = {
		{
		class = "Counter",
		name = "partycounter",
		},	
          	{
             	class = "Timer",
		name = "partytimer",
		timerInterval = 1.0,
		triggerOnStart = true,
		onActivate = function(self)
			self.go.partycounter:increment()
			local v = self.go.partycounter:getValue()
			return hudPrint("Time = "..v.."")
		end
          	},
	}
    }

--hudPrint("The time is "..partycounter:getValue().."")
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: [WIP] Combined custom content thread

Post by Drakkan »

Hi akroma
I am trying to make the name weapon working, however cannot figure it out. I just place dagger item in my item.lua and when I load editor it crash with --- "(" expected near yourWeaponEquip
I suppose just some wrong syntaxes ?


Code: Select all

defineObject{
	name = "drakkan_dagger",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/dagger.fbx",
		},
		{
			class = "Item",
			uiName = "Drakkan Dagger",
			gfxIndex = 10,
			gfxIndexPowerAttack = 415,
			impactSound = "impact_blade",
			weight = 0.8,
			projectileRotationX = 90,
			projectileRotationY = 90,
			description = "A vicious looking dagger, which is effective in close combat as well as from a distance. The dagger is the favorite weapon of many a rogue.",
			traits = { "light_weapon", "dagger" },
onEquipItem =
function yourWeaponEquip(self, champion, slot)
   local name = champion:getName()
   if slot == 1 or slot == 2 then 
      if name == "Drakkan" then
         hudPrint(""..name.." has equipped a "..name.." only weapon.")
      else
            champion:removeItemFromSlot(slot)
            spawn("..your weapon.."",party.level,party.x,party.y,party.facing, party.elevation)
            playSound("item_drop")
            hudPrint("Only a champ named Drakkan can use this weapon...")
        end
   end
end

onUnequipItem =
function yourWeaponUnequip(self, champion, slot)
   local name = champion:getName()
   if slot == 1 or slot == 2 then 
      if name == "Drakkan then
         --- do things here if you need to
                end
   end
end
		},
		{
			class = "MeleeAttack",
			attackPower = 7,
			accuracy = 5,
			cooldown = 2.5,
			swipe = "vertical",
			attackSound = "swipe_light",
			powerAttackTemplate = "throw",
		},
	},
	tags = { "weapon" },
}
Breath from the unpromising waters.
Eye of the Atlantis
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: [WIP] Combined custom content thread

Post by minmay »

Drakkan wrote:

Code: Select all

onUnequipItem =
function yourWeaponUnequip(self, champion, slot)
...
onEquipItem =
function yourWeaponEquip(self, champion, slot)
Why are you trying to give these functions two different identifiers each? That doesn't make any sense.
Change it to

Code: Select all

onEquipItem =
function(self, champion, slot)
and

Code: Select all

onUnequipItem =
function (self, champion, slot)
In the future, you might find the Lua reference manual useful. It includes the syntax.
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
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: [WIP] Combined custom content thread

Post by Drakkan »

minmay wrote:
Drakkan wrote:

Code: Select all

onUnequipItem =
function yourWeaponUnequip(self, champion, slot)
...
onEquipItem =
function yourWeaponEquip(self, champion, slot)
Why are you trying to give these functions two different identifiers each? That doesn't make any sense.
Change it to

Code: Select all

onEquipItem =
function(self, champion, slot)
and

Code: Select all

onUnequipItem =
function (self, champion, slot)
In the future, you might find the Lua reference manual useful. It includes the syntax.
ok I got working onequip item function. However when add also unequip like below, its crashing with -- } expected to close { at line 9 near onUneqipItem
I am lost with these syntaxes ://

Code: Select all

defineObject{
	name = "drak_dagger",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/dagger.fbx",
		},
		{
			class = "Item",
			uiName = "Drak Dagger",
			gfxIndex = 10,
			gfxIndexPowerAttack = 415,
			impactSound = "impact_blade",
			weight = 0.8,
			projectileRotationX = 90,
			projectileRotationY = 90,
			description = "A vicious looking dagger, which is effective in close combat as well as from a distance. The dagger is the favorite weapon of many a rogue.",
			traits = { "light_weapon", "dagger" },
onEquipItem =
function(self, champion, slot)
   local name = champion:getName()
   if slot == 1 or slot == 2 then 
      if name == "Drakkan" then
         hudPrint(""..name.." has equipped his rapier.")
      else
            champion:removeItemFromSlot(slot)
            spawn("drak_dagger",party.level,party.x,party.y,party.facing, party.elevation)
            playSound("item_drop")
            hudPrint("Only a champ named Drakkan can use this weapon...")
      end
   end
end
onUnequipItem =
function(self, champion, slot)
   local name = champion:getName()
   if slot == 1 or slot == 2 then 
      if name == "Drakkan" then
         --- do things here if you need to
                end
   end
end
		},
		{
			class = "MeleeAttack",
			attackPower = 7,
			accuracy = 5,
			cooldown = 2.5,
			swipe = "vertical",
			attackSound = "swipe_light",
			powerAttackTemplate = "throw",
		},
	},
	tags = { "weapon" },
}
Breath from the unpromising waters.
Eye of the Atlantis
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: [WIP] Combined custom content thread

Post by minmay »

Drakkan wrote:ok I got working onequip item function. However when add also unequip like below, its crashing with -- } expected to close { at line 9 near onUneqipItem
I am lost with these syntaxes ://
In a table definition you have to separate fields with commas. You did not add a comma after the onEquipItem field.
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
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: [WIP] Combined custom content thread

Post by Drakkan »

minmay wrote:
Drakkan wrote:ok I got working onequip item function. However when add also unequip like below, its crashing with -- } expected to close { at line 9 near onUneqipItem
I am lost with these syntaxes ://
In a table definition you have to separate fields with commas. You did not add a comma after the onEquipItem field.
I will remember that. thanks alot for advices minmay !
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: [WIP] Combined custom content thread

Post by Drakkan »

Hiu akroma, just in case you are still working on some fancy weapons here is my up-to-date wish list :)

1. Weapon (for example axe) which when equiped will give champion some trait
2. some two weapons which when used together (dagger / sword...) will get some additional bonuses (either sword or dagger)
3. magic staff which can cast force field spell (10 charges)
4. weapon which has some secondary attack, which could be used only once per day (perhaps some timer usage together with one charge / automatic recharge after this timer run out ?)
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: [WIP] Combined custom content thread

Post by akroma222 »

Hey!
Yes im back from my Grimrock holiday now (played through Wizardry 8 again :lol: )
Thanks for helping out minmay!
I will definitely get to your weapons Drakkan, but first I have to read through the asset pack scripting and also the new threads on the forum.
Some are easy and will put them up shortly, couple of them not sure how to do yet but I am sure I will find out how ;)
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: [WIP] Combined custom content thread

Post by akroma222 »

akroma222 wrote:Thanks specialKatana, good to see you're still around ;)

Here we have your Staff of Fireballs (using willpower as the damage bonus)
SpoilerShow

Code: Select all

defineObject{
       name = "staff_fireballs",
       baseObject = "base_item",
       components = {
       	{
             class = "Model",
             model = "assets/models/items/acolyte_staff.fbx",
        },
	{
             	class ="Item",
             	uiName = "Staff of Fireballs",
             	gfxIndex = 340,
        	weight = 2.7,
             	impactSound = "impact_blunt",
             	traits = { "stave", "light_weapon" },
             	secondaryAction = "fireBall",
             	description = "A fiery staff designed by the archmage specialKatana"
        },
        {
             	class = "MeleeAttack",
             	attackPower = 13,
             	accuracy = 5,
             	swipe = "vertical",
             	attackSound = "swipe_special",
             	cooldown = 3.5,
             	baseDamageStat = "willpower",
             	damageType = "fire",
		causeCondition = "burning",
		conditionChance = 30,
             	requirements = {"light_weapons" ,1},
        },
        {
             	class = "CastSpell",
             	name = "fireBall",
		uiName = "Fireball",
             	charges = 9,
             	cooldown = 4.0,
             	energyCost = 30,
             	spell = "fireball",
             	requirements = { "fire_magic", 1},
        },
        }
    }
and here is a version that shoots multiple fireballs as a special attack :twisted:
(although all fireballs follow the same trajectory.. have not got around to changing that yet)
SpoilerShow

Code: Select all

defineObject{
       name = "staff_fireballs",
       baseObject = "base_item",
       components = {
       	{
             class = "Model",
             model = "assets/models/items/acolyte_staff.fbx",
        },
	{
             	class ="Item",
             	uiName = "Staff of Fireballs",
             	gfxIndex = 340,
        	weight = 2.7,
             	impactSound = "impact_blunt",
             	traits = { "stave", "light_weapon" },
             	secondaryAction = "fireBall1",
             	description = "A fiery staff designed by the archmage specialKatana"
        },
        {
             	class = "MeleeAttack",
             	attackPower = 13,
             	accuracy = 5,
             	swipe = "vertical",
             	attackSound = "swipe_special",
             	cooldown = 3.5,
             	baseDamageStat = "willpower",
             	damageType = "fire",
		causeCondition = "burning",
		conditionChance = 30,
             	requirements = {"light_weapons" ,1},
        },
        {
             	class = "CastSpell",
             	name = "fireBall1",
		uiName = "Volley of Flames",
		chainAction = "fireBall2",
		chainActionDelay = 0.3,
             	charges = 9,
             	cooldown = 4.0,
             	energyCost = 30,
             	spell = "fireball",
             	requirements = { "fire_magic", 1},
        },
	{
             	class = "CastSpell",
             	name = "fireBall2",
		uiName = "Fireball",
		chainAction = "fireBall3",
		chainActionDelay = 0.3,
             	spell = "fireball",
        },
	{
             	class = "CastSpell",
             	name = "fireBall3",
		uiName = "Fireball",
             	spell = "fireball",
        },
        }
    }
EDIT - note this staff does not have a different icon for full/empty charges - if it did you would need to add emptyGfxIndex = (number) in the castSpell component.

Enjoy :D
Akroma
For the staff with force field - ^^here is a script for a similar item, you just need to change fireball to forcefield, and the charges from 9 to 10.
#4 Im unsure about as I assume the easiest way to do something like that would be to use some of the game time checking functions and I have not played around with them yet
#1 and #2 I am going to work on now as a single example - #2 is a great idea!! :D
Post Reply