Page 5 of 8

Re: Hiring party member(s) script - SOLVED

Posted: Wed Mar 18, 2015 8:00 am
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 :)

Re: Hiring party member(s) script - SOLVED

Posted: Thu Mar 19, 2015 9:37 pm
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

Re: Hiring party member(s) script - SOLVED

Posted: Thu Mar 19, 2015 11:21 pm
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)

Re: Hiring party member(s) script - SOLVED

Posted: Fri Mar 20, 2015 3:30 am
by Isaac
Eleven Warrior wrote:...
c:insertItem(1,spawn("dagger").item)

It makes a new dagger, then adds it.

Re: Hiring party member(s) script - SOLVED

Posted: Fri Mar 20, 2015 5:50 am
by Eleven Warrior
Thxs Isaac mate :) I think that should be added to Jkos forum

Re: Hiring party member(s) script - SOLVED

Posted: Mon Mar 23, 2015 2:34 am
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 ?

Re: Hiring party member(s) script - SOLVED

Posted: Mon Mar 23, 2015 2:38 am
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?

Re: Hiring party member(s) script - SOLVED

Posted: Mon Mar 23, 2015 10:22 am
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.

Re: Hiring party member(s) script - SOLVED

Posted: Mon Mar 23, 2015 1:01 pm
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.

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

Posted: Mon Mar 23, 2015 7:36 pm
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