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
Eleven Warrior
Posts: 745
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Hiring party member(s) script - SOLVED

Post by Eleven Warrior »

Hi Jkos. Ok all I want to do is when the Game loads up the player does not choose any champs the are already done. In my mod I need 4 Rattling champs to start straight up with. I don't need the gui to activate I just need 4 Rattling champs at the beginning with 0 level, names, classes and some other things like traits, food, health, energy etc.... So how do I use your code to have a instant party without using the gui interface mate?

Your demo mod uses this to choose champs:

Code: Select all

-- Call this function to show the gui
function enable()
	champions.script.setStore(self.go.id)
	if champions.script.hasChampions() then
		champions.script.showGui(true)
	end
end
All I need is for the game to start with the 4 rattling of various classes ect, but no giu or picking the champ(s)

Thxs for help on this man :)
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: Hiring party member(s) script - SOLVED

Post by JKos »

I don't think that you need this script for that, it's really easy with native champion methods:

Code: Select all

local c = party.party:getChampion(1)
--Champ 1
c:setName('Nice Champ')
c:setClass('fighter')
c:gainExp(6000)
c:setPortrait('assets/textures/portraits/human_female_04.tga')
c:trainSkill('heavy_weapons',4)
c:setBaseStat('strength',10)

--Champ 2
local c = party.party:getChampion(2)
c:setName('Another Champ')
c:setClass('wizard')

..etc
it's all documented in here: https://github.com/JKos/log2doc/wiki/Ob ... s#champion
- 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: Hiring party member(s) script - SOLVED

Post by Eleven Warrior »

Thxs for that. When I try to add a Item to a slot nothing happens except error (bad argument) eg:

c:insertItem('1, long_sword')
Is this wrong?

Edit: Ok I worked it out:
c:insertItem(1,dagger_1.item)

How do I fix this problem? If I add dagger_2 instead of dagger_1 it wont work because there is no dagger_2 in the editor only dagger_1. Am I doing this wrong Jkos? why not just: c:insertItem(1,dagger.item)
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Hiring party member(s) script - SOLVED

Post by Isaac »

Eleven Warrior wrote:...
c:insertItem(1,spawn("dagger").item)

It makes a new dagger, then adds it.
User avatar
Eleven Warrior
Posts: 745
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Hiring party member(s) script - SOLVED

Post by Eleven Warrior »

Thxs Isaac mate :) I think that should be added to Jkos forum
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Hiring party member(s) script - SOLVED

Post by AndakRainor »

Isaac wrote:
Eleven Warrior wrote:...
c:insertItem(1,spawn("dagger").item)

It makes a new dagger, then adds it.
I have a problem with this insertItem function : the editor just stops the preview without crashing. If I click again on "play" the item is correctly added. Any one else has got this issue ?
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Hiring party member(s) script - SOLVED

Post by Isaac »

What happens if you comment out --c:insertItem(1,spawn("dagger").item) ?
(Aside from no dagger, of course.)

*Also: This always happens, alternating success with halts?

What happens in the preview, if you type c:insertItem(1,spawn("dagger").item) into the console?
** c must be defined first; c = party.party:getChampion(2)

Try this instead:

Code: Select all

c:insertItem(1,party:spawn("dagger").item)
Does the preview still halt?
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Hiring party member(s) script - SOLVED

Post by AndakRainor »

If commented out, the preview continues normally.
It always happens when not commented.
Oddly, if I use the console, it works correctly whitout halting the preview.
It will be hard to debug with no trace when the preview just halts with no error message. Never saw it before.
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Hiring party member(s) script - SOLVED

Post by Isaac »

AndakRainor wrote:If commented out, the preview continues normally.
It always happens when not commented.
Oddly, if I use the console, it works correctly whitout halting the preview.
It will be hard to debug with no trace when the preview just halts with no error message. Never saw it before.
At this point, I think we would need to see the whole script.
User avatar
Duncan1246
Posts: 404
Joined: Mon Jan 19, 2015 7:42 pm

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

Post by Duncan1246 »

JKos wrote:Try this: in demo dungeon add these lines to the end of champion_recruit_1

Code: Select all

....
function setStartingParty()
	champions.script.setStore(self.go.id)
	champions.script.loadChampion('Minotaur With really long name',party.party:getChampion(1))
	champions.script.loadChampion('Lab Rat',party.party:getChampion(2))
	champions.script.loadChampion('Test Woman',party.party:getChampion(3))
end
delayedCall(self.go.id,0.1,'setStartingParty')
Hope you got the idea.
I tried your method, and (yes, again :? ) I got an issue "attempt to call field 'setGameFlag' (line 231 in champions.lua)". Several attempts further, I return to the demo dungeon ... and the same thing happens. I see that others guys here seems to have no problem at all, but the demo would works and it don't.
In case, what I have done in my mod :
  • Add a line in init.lua: import "mod_assets/jkos/init_champions.lua"
    Put file jkos in mod_assets
    Modify init_champions to define champions (and only that)
    Put an instance of champions_recruit.script in the mod, but it seems to be unnecessary in your last version?
    Create a script calling external champions.script
    Connect reccruit script to a button to call it like in your demo... and crash (but editor keeps working)
Sorry for the mess... :mrgreen:
Duncan
The Blue Monastery (LOG1)
download at:http://www.nexusmods.com/grimrock/mods/399/?

Finisterrae(LOG2)
download at:http://www.nexusmods.com/legendofgrimrock2/mods/61/?
Post Reply