Hiring party member(s) script - SOLVED

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
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: Huge script request - new party member(s)

Post by Drakkan »

JKos wrote: Feel free to improve and develop it further.
Jkos in case you will be around, please could you somehow add to the script following condition --- in case there are some free "slots" for champion (means for example champ 2-4 are disabled), then defined party member will automatically join in some of these slots instead replacing some champion (if not say by script).

And please if you can modify following code:

Code: Select all

   champions.script.defineChampion(champ) -- define new champion
   champions.script.storeChampion(party.party:getChampion(2)) --store champion 2
   champions.script.loadChampion('Test Man',party.party:getChampion(2)) -- replace champion 2 with ''Test Man'
What I need if some champ is joing party, he will replace another champion based on name, not on champion number. I have problem with these numbers in general, because player could move party members around, so script could eventual replace incorrect champion. So script should tell for example: if there are no free slots,then replace champion Drakkan, with new defined champion Jkos.

Thanks
D.
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: Huge script request - new party member(s)

Post by JKos »

Well that's pretty easy, just add these helper functions to champions script entity:

Code: Select all

function getChampionByName(name)
	for i=1,4 do
		if party.party:getChampion(i):getName() == name then
			return party.party:getChampion(i)
		end
	end
	return false
end

function getDisabledChampion()
	for i=1,4 do
		if not party.party:getChampion(i):getEnabled() then
			return party.party:getChampion(i)
		end
	end
	return false
end
and then you can do something like this:

Code: Select all

...
	champions.script.defineChampion(champ)
	local freeSlot = champions.script.getDisabledChampion()
	if freeSlot then
		champions.script.loadChampion('Test Man',freeSlot)
	else
		hudPrint("No room for a new champion.")
	end
or

Code: Select all

	local champ = champions.script.getChampionByName('Drakkan')
	champions.script.loadChampion('Test Man',champ)
replaces Drakkan with Test Man
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: Huge script request - new party member(s)

Post by msyblade »

You're such a ninja, JKos. Thanks from the lot of us.

4 Kudos awarded!
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: Huge script request - new party member(s)

Post by JKos »

Just for heads up, I'm currently making a GUI for recruiting champions, not quite ready yet but here are some images for you.

No champion selected
SpoilerShow
Image
Champion selected
SpoilerShow
Image
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: Huge script request - new party member(s)

Post by Drakkan »

JKos wrote:Just for heads up, I'm currently making a GUI for recruiting champions, not quite ready yet but here are some images for you.
impressive ! Hope you will finish this before christmas :) and in case you will have some time can you make some easy GUI as was in LOG1 for hiring new champion when there are already four in the party ? (with some easy function to drop all items from "kicked" member)
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
Eleven Warrior
Posts: 745
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Huge script request - new party member(s)

Post by Eleven Warrior »

God that's so awesome Jkos as Drakkan said +2 Man this will be totally awesome thxs for the update :)
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: Huge script request - new party member(s)

Post by JKos »

Here is the first release version with demo dungeon:
https://github.com/JKos/log2doc/archive/master.zip

Unzip to somewhere and move the /Champions folder to your /Legend of Grimrock 2/Dungeons folder

Sorry for the messy GUI code, could be much cleaner.
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
Eleven Warrior
Posts: 745
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Huge script request - new party member(s)

Post by Eleven Warrior »

As Mysblade say 10 Kuddos. This is awesome Jkos and I am adding this to my mod. The things I can do with system will be totally cool eg: You would need to recruit a new champ to complete a level etc... Very good work man :) I am sure Drakkan will love this to yeah. I checked the dungeon out and there are 2 Scripts that call for scripts outside of the editor, there was a problem before with this that in a normal game it crashed, it think that's what it use to do?

This script allows for easy champ adding as well cool :)

The only thing is what are you going to add this awesome work? I assume it will be cool :) Anyway thanks, and I am glad your still with this community. :mrgreen:
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: Huge script request - new party member(s)

Post by Drakkan »

Eleven Warrior wrote: there was a problem before with this that in a normal game it crashed, it think that's what it use to do?
this was alredy solved in one of the previous patch, so no prob. And even if yes you can easily just copy the script from outside to "inside " script :)

JKos
I made some first tries and it is working precisely as I wished, you have my huge thanks. This is one of last pieces I am missing to my mod. In case you would want improve this script a little is - the only problem I can now see is with starting champion items - I think it´s perfectly ok, that new champion just replace old one with whole inventory, however what if I want new champion with already some items equipped ?

Not sure if there is some other solution that just to rewrite script from Log1 that all items from old champion will be dropped on ground, while you define starting items for new champ (which maybe could be by some implementation of starting items script inside champion script ? Not sure if possible, would welcome any ideas.
here is easy script for starting items written by Sutekh
viewtopic.php?f=22&t=8342&p=84331&hilit ... ems#p84331
as for original "drop" script from Log1 I think you are aware where to look because I think you cooperated with thomson on it with original grimwidgets ?
Ps: another solution in my mind would be just spawning starting items for new champion on the ground before party. this could be much more easy regarding scripting.
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Re: Huge script request - new party member(s)

Post by Mysterious »

Jkos good work man :) 10 Kudos??? What is a Kudo if you don't mind me asking? I guess that's the scoring system here? I think I just asked a stupid question, but ill stick my neck out lol.
Post Reply