How to remove party members, and how to change loot based on skill?

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
ratman
Posts: 158
Joined: Fri Jan 10, 2020 1:13 am

How to remove party members, and how to change loot based on skill?

Post by ratman »

My mod is going to start off as a single player mod (you will be able to recruit followers later :D), so I want a script that removes all party members except one, in case the player forgets or just decides to use more than one.
Secondly, I have made a custom skill called 'looting' that supposedly changes the quantity and quality of the loot you receive, but I don't know how I would do this.
Thanks for any help!
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: How to remove party members, and how to change loot based on skill?

Post by Isaac »

A few questions:
  • How do you plan to add PCs later?
  • Does your mod use GrimTK?
  • How should the mod handle multiple PC?—just delete at random? Delete after the first? Store their extra PCs for later recruitment?
As for the loot... If you create a loot table to dynamically spawn loot, you can use the skill level to select from higher and lower quality loot. Alternatively (and I think perhaps better), you can use the skill to modify new loot when it is first picked up, or acquired. For example, if the player finds a common dagger, the dagger could be examined on the mouse cursor, or when added into inventory, then destroyed, with the improved item immediately spawned as replacement.
User avatar
ratman
Posts: 158
Joined: Fri Jan 10, 2020 1:13 am

Re: How to remove party members, and how to change loot based on skill?

Post by ratman »

Does your mod use GrimTK?
Yes.
How do you plan to add PCs later?
I haven't planned it all out yet, but it will probably be a mercenary or something in a tavern, and one of the dialogue options(using GrimTK), will be to hire them for a certain amount of money, depending on there starting level. I will probably modify the toorum script from MinAssets.
How should the mod handle multiple PC?—just delete at random? Delete after the first? Store their extra PCs for later recruitment?
I will probably add them to the party with an item that when used opens a GrimTK dialogue page with a few options, one of them being to fire them, which will remove them from the party and re-enable the model and dialogue of them back at the tavern, in case the player wants them back.
As for the loot... If you create a loot table to dynamically spawn loot, you can use the skill level to select from higher and lower quality loot. Alternatively (and I think perhaps better), you can use the skill to modify new loot when it is first picked up, or acquired. For example, if the player finds a common dagger, the dagger could be examined on the mouse cursor, or when added into inventory, then destroyed, with the improved item immediately spawned as replacement.
Sorry I don't know much about scripting at all- how would I do this?

edit- I am also trying to make something like the ratling_warg_pair, except with a zarchton and a spider. In the game it walks around fine, but after one attack they both stop moving and don't attack, but the animation for both still plays. Is there an easy way to make this work?
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: How to remove party members, and how to change loot based on skill?

Post by Isaac »

ratman wrote: Sun Aug 02, 2020 5:30 pm
How do you plan to add PCs later?
I haven't planned it all out yet, but it will probably be a mercenary or something in a tavern
Sorry I don't know much about scripting at all-
In this case, I meant technically (in Lua script) how you intend to add them.

edit- I am also trying to make something like the ratling_warg_pair, except with a zarchton and a spider. In the game it walks around fine, but after one attack they both stop moving and don't attack, but the animation for both still plays. Is there an easy way to make this work?
The Zarchton has a leap-attack and backward evasion, the spider doesn't. This causes a few problems; the first with the dynamicObstacle component, the second is because the two monsters can end up on separate tiles if (when) the Zarchton dodges the player—but the two would still behave like they are on the same tile.

Here is a drop-in replacement for the paired group.

Code: Select all

defineObject{
	name = "paired_spider",
	baseObject = "spider",
	components = {
		{
			class = "Monster",
			meshName = "spider_mesh",
			hitSound = "spider_hit",
			dieSound = "spider_die",
			hitEffect = "hit_goo",
			capsuleHeight = 0.2,
			capsuleRadius = 0.8,
			health = 450,
			exp = 225,
			traits = { "animal" },
			onInit --This replaces the Zarchton's custom brain with a generic one. This prevents the leap attacks and evasion. 
					= function(self) for obj in self.go.map:entitiesAt(self.go.x, self.go.y) do
										if obj.brain and not obj.id == self.go.id then 
										   obj:removeComponent('brain')
										   obj:createComponent('MeleeBrain', 'brain')
										end
									end	
								end,
			onDie -- This restores the Zarchton's custom brain once the spider dies, and there is no longer a group.
					= function(self) for obj in self.go.map:entitiesAt(self.go.x, self.go.y) do
									    if obj and obj.name == 'zarchton' then
										   obj:removeComponent('brain')
										   obj:createComponent('ZarchtonBrain', 'brain')	
									    end
									end    
								end,
		},
	},
}

defineObject{
	name = "zarchton_spider_pair",
	baseObject = "base_monster_group",	
	components = {
		{
			class = "MonsterGroup",
			monsterType = {"paired_spider","zarchton"},
			count = 2,						
		},
	},
}
*This can be improved with custom, alternate animations for each; used while in the group. This could prevent their movements clipping each other as they attack, and walk around.
User avatar
Khollik
Posts: 171
Joined: Tue Aug 29, 2017 6:44 pm
Location: France

Re: How to remove party members, and how to change loot based on skill?

Post by Khollik »

ratman wrote: Sat Aug 01, 2020 5:28 pm so I want a script that removes all party members except one, in case the player forgets or just decides to use more than one.
Hello Ratman

I don't know if there is a way to remove party members, but you can use champion:setEnabled() function in a script to disable them. That's how I did in my last mod (with a floortrigger to the script). For instance, this disable all the champs but the first one:

Code: Select all

function disablechamps()
for i =2,4 do
party.party:getChampion(i):setEnabled(false)
end
Hope that can help.

Cheers
Khollik
User avatar
ratman
Posts: 158
Joined: Fri Jan 10, 2020 1:13 am

Re: How to remove party members, and how to change loot based on skill?

Post by ratman »

@ Khollik: Thanks, this will also be helpful for recruiting party members, instead of creating a character I can just modify the one already there.

@ Isaac: Thanks, your version of the zarchton/spider works.
In this case, I meant technically (in Lua script) how you intend to add them.
Like I said above, I will probably edit Minmays toorum mode.
Post Reply