Jump to content

MyNPC [CD_STATE_NOTVALID]


Harutsune

Recommended Posts

Hi,

 

I'm making my first NPC, not a complicated one, so he's going fine interjecting now and then. There's a problem I have with him interjecting and giving the action back to the PC. I want him to interject after a certain statement an NPC does, resulting in two replies/choices for the PC whom of the both to kick out AND one of them going hostile on the other one either way (i.e. NPC attacks MyNPC after being kicked and opposite). I'm not a gifted coder, so things I see or try may be limited, but everything I tried resulted in MyNPC going hostile.

So I tried something I found somewhere (it's easy to remember you read something, but very hard to remember where, if you're lurking thru three modder-forums), to give the action back to the PC. Reply two works perfectly (AND he wins the fight), but the first one leaves me with 'no valid links or replies'. Out of ideas again..

 

INTERJECT KORGANJ 35 korgan_trickedus

== HaruJ IF ~IsValidForPartyDialogue("Haru")~ THEN

~you knew...~

== KORGANJ IF ~IsValidForPartyDialogue("Haru")~ THEN

~pah...~

== HaruJ IF ~IsValidForPartyDialogue("Haru")~ THEN

~wah, choose...~

END

++ ~PC kicks Korgan...~ EXTERN KORGANJ wasser_kickout

++ ~PC kicks Haru...~ DO ~SetGlobal("KickedOut","LOCALS",1) EquipMostDamagingMelee()Enemy()Attack("Korgan")~ EXIT

 

APPEND KORGANJ

IF ~~ THEN BEGIN wasser_kickout

SAY ~AAHR, take you with me..!!!~ ~SetGlobal("KickedOut","LOCALS",1) EquipMostDamagingMelee()Enemy()Attack("Haru")~ END

END

 

So how do I transfer the action to the PC? And what makes the Append not work? Is there a way around this problem? As I said, I'm pretty new to IE-coding and not really gifted, so any help would be really appreciated.

Link to comment
Guest jastey*

Your code:

APPEND KORGANJ
IF ~~ THEN BEGIN wasser_kickout
SAY ~AAHR, take you with me..!!!~ ~SetGlobal("KickedOut","LOCALS",1) EquipMostDamagingMelee()Enemy()Attack("Haru")~ END
END

 

should be

APPEND KORGANJ
IF ~~ THEN BEGIN wasser_kickout
SAY ~AAHR, take you with me..!!!~ 
IF ~~ THEN DO ~SetGlobal("KickedOut","LOCALS",1) EquipMostDamagingMelee()Enemy()Attack("Haru")~ EXIT
END
END //(APPEND)

 

What exactly do you mean with "ransfer the action to the PC"?

 

-jastey

Link to comment

I am sorry, but I still do not understand what you mean to accomplish.

 

Are you saying that you would like to script the PC's actions? Are you saying that you would like the NPCs to attack the PC? Are you saying that you would like to make a journal entry?

Link to comment

Works perfectly!!!

Thank you very much, Jastey (and forget about that question..).

Nice to see that I was on the right track, with a 'minor omission' *g*.

 

May I please continue with another problem I have (should possibly be the last major one)?

This one is a Fighter (9) / Assassin (10) whom I'd like to have some progressing Innates. It's very easy to give him some Innates but those won't progress/grow. Everything I read about kits sounds pretty complicated, is it possible to alter a copy of his .2da and just reassign it to his creature? Or should I better try a script which asks for Level / levelup and assigns spells manually? I'd really like to avoid a kit cause I like that second-career-thing...

 

 

edit: @ Berelinde

Sorry for my pooor english...

I want him to interject Korgan after his ex-friend 'waterdrinker?' is dead, they taunt another, leaving the PC with two choices: kicking out one or the other - it's done.

btw. a journal entry is a good idea, thx.

Link to comment
Guest jastey*

For that question I am no help at all. (Maybe you'd like to consider changing the topic title, so people with the needed know-how also look in here.) Glad the other thing workes now.

 

Welcome to G3, btw. :(

Link to comment

Define "progressing innates". Innate abilities should progress in power/abilities exactly in the same way as spells do, that is via level-defined extended headers. Or perhaps you'd only like to gain new abilities with levels? That can be easily achieved with a script that checks the level and gives him new innates, however if you're running a completely new kit (which doesn't seem to be the case since you said he's F9/A10, which on its own seems a little odd since secondary class can only be a base one not a Kit but whatever) you can easily assign a new CLAB* file to it and add your abilities there. Perhaps if you elaborated on your problem a bit more I would be able to offer further help.

Link to comment

That's the point, I don't want him to be a new kit cause I like that second career (and making one is far too complicated for me, now). So I tried to assign a modifcated CLAB-file using Near Infinity but failed. Seems the file has to be registered somewhere before, but I don't have an idea 'where' nor how to do such thing using WeiDU.

 

What I want is to give him one innate from start (invisible 1xd from L10), one at L15 (undetectable) and maybe some more per-day-uses every two or three levels. If I could solve this via CLAB I believe everything would turn out fine almost 'automatically' (as long as the spells are right), because that's the way Bioware does it.. the spells cast a message when achieved, they behave like innates do..

 

..but thinking about scripting this is pretty scary for me - so many traps out there, but if I could take a look at some working code I would learn it. Is there an NPC out there which uses such script?

Link to comment
So I tried to assign a modifcated CLAB-file using Near Infinity but failed.
You can not assign a character specific CLAB* file, they correspond to kits listed in kitlist.2da
..but thinking about scripting this is pretty scary for me - so many traps out there, but if I could take a look at some working code I would learn it. Is there an NPC out there which uses such script?
Scripts are one of the easiest parts of modding as long as you don't need to do something complicated like battle behaviour and cutscenes (these aren't that hard but rather take time and some consideration). I'm sure many mods make such use of scripts so I can't really point you in a specific direction but I can give you an example myself.

 

First you need a script of your own, just make [scriptname].baf and later use COMPILE [scriptname].baf in WeiDU (baf file is a normal text file). Of course you have to assign this script (best as an override script) to your .cre files, you can do this with any creature editor more or less. Ok so basically you have your own script then and the way to do it would be something like this:

IF
 Level(Myself, 10)
 Global("gotspellatlvl10","LOCALS",0)
THEN
 RESPONSE #100
ApplySpellRES("yourspell", Myself)
SetGlobal("gotspellatlvl10","LOCALS",1)
END

 

This would apply the spell to you (one that gives you an innate ability) at level 10 and set the local variable to 1 so it only happens once. You can do the same for any other level. Althout it might be better to use LevelGT(Myself, XY), I'm not exactly sure what happens if you gain 2 or more levels at once, it might skip the check so that's more sure way of doing it.

Link to comment

That sounds good (I should never say 'easy') but there must be more actions to script.

- first I give MyNPC that spell AND a use-per-day

- second I give him another use-per-day

- third I give him another spell etc.

(that's how I did it using NI)

 

Meanwhile I was looking thru 'Malthis' cause he gains abilities via script, they used 'AddSpecialAbility' three times in a row - I remember him having three innates of that type after the next rest AND gaining those displayed the usual message. I know the spells are customized, so they have to be registered before, but I'm not going to use custom spells (the only one mine has, he has from creation and it is BG1-style 'detect alignment'). That said will this action be the one and only I will have to use?

 

From IESDP-Action-List:

279 AddSpecialAbility(S:ResRef*)

Adds an innate ability onto the target. Displays a Player1 has gained a special ability: "Ability."

 

Hm, I'm going to ignore that 'player1'-thing cause I read 'Malthis has gained..' (sorry, never played it in english). In the CLAB they differenciate between 'apply' and 'gain' a spell/ability - won't I have to do this too?

 

btw. I'm compiling scripts via WeiDU/tp2 already, an override-script is assigned. The whole creature is well setup as the tp2 is (limited to the things I do, of course), giving innates to him is the last thing to do on the .cre. ;)

Link to comment
That said will this action be the one and only I will have to use?
Well if you use AddSpecialAbility() you'd probably have to rest first but if you use ApplySpellRES() you gain it right away but have to make a separate spell for it (which could also include the "X has gained Y" text). I haven't tried this but if you say so that's probably how it is. It doesn't really matter what function you use, for all it matters you can even use ReallyForceSpell(), in the end all of it should have the same effect.

 

That sounds good (I should never say 'easy') but there must be more actions to script.
If you need more actions just copy-paste that block I wrote (with your modifications) and make a similar one for every condition. (Some can be combined but I wouldn't bother.)
Link to comment

..always wondering *g* (so many ways..). ;)

 

I'd like to use AddSpecialAbility cause I had to take original spells, but lurking thru the innates I found so many others that I have to be uncertain about their usage. So to be sure I will have to make all the spells myself, setting them to innate and level 0 (or 1?) in every instance. Does AddSpellRes work for both purposes, giving a new spell and giving another per-day-use? What does ReallyForceSpell? For me it sounds like a player is forced to cast a spell (he probably doesn't have). And how would you apply the 'X has gained Y'-message to the spell itselves, via .tp2?

 

I'm going to give it a try this way (have to make the spell and some housework before of course):

 

IF
LevelGT(Myself, 11)
Global("spell_12","LOCALS",0)
THEN
RESPONSE #100
AddSpellRes("HaruSp_5") // Invisibility
SetGlobal("spell_12","LOCALS",1)
END

 

Setting variables this way made everything work before, is there a reason to prefere incrementation? Even if there was a two-level-difference this should come true some time (imvho), cause it only asks 'are you better than that?' and then disables - am I wrong?

Link to comment
Does AddSpellRes work for both purposes, giving a new spell and giving another per-day-use?
AddSpellRES() does not exist, not in BG2 as far as I know. You seem to be unclear as to what I was aiming at. If you don't use AddSpecialAbility() and decide for a spell that is applied/cast like with ApplySpellRES() or ForceSpell() you will have to create 1) your spell/innate that you want to add and 2) another "spell" which has "Give Spell" or "Give Innate Ability" effect in its extended header. That means 2 *.spl files for each spell/ability you're adding. Of course in doing so you gain the ability immediately and can also add "Display String" effect in the extended header. The method you use is up to you, the second one takes more work but is more customizable.

 

So to be sure I will have to make all the spells myself, setting them to innate and level 0 (or 1?) in every instance.
You only need to set level to 1 if you intend to use HaveSpell() functions in your script, otherwise the game crashes. If you don't then it's not neccessary.

 

IF
LevelGT(Myself, 11)
Global("spell_12","LOCALS",0)
THEN
RESPONSE #100
AddSpellRes("HaruSp_5") // Invisibility
SetGlobal("spell_12","LOCALS",1)
END

 

Setting variables this way made everything work before, is there a reason to prefere incrementation? Even if there was a two-level-difference this should come true some time (imvho), cause it only asks 'are you better than that?' and then disables - am I wrong?

You should note that my previous example was incorrect, I accidently switched OR and AND parts. On second look there is really no way to group things in such a manner, the language does not allow for that much freedom in conditions so you'll have to make a separate block for each time you gain an ability. I have deleted it due to my stupidity, so ignore what you saw. ;) More to the point however, if the conditions were correct IncrementGlobal() would be neccessary to insure that it evaluates at each step. For a single condition, the use of SetGlobal() is sufficient if not better. Moreover with the use of LevelGT() the ammount of levels gained at a time is unimportant, it might have worked with Level() but like I said, this is a sure way of doing it.
Link to comment

Meanwhile I accidently compiled the script in its previous form and it worked absolutely seemless: ;)

 

IF
LevelGT(Myself, 9)
Global("spell_10","LOCALS",0)
THEN
RESPONSE #100
AddSpecialAbility("SPIN118") // Unsichtbarkeit
SetGlobal("spell_10","LOCALS",1)
END

 

I made him levelup and after I left the char-screen I got a 'ping' and the message 'char's got SA', it was under F12 and available and he could cast it - perfect. I've noted most if not all numbers of the other versions of the other spells I want to give him later, so I'll make it trial+error testing which one's working.

 

I think I understand what you say about AddSpellRes(etc), but I think I'll limit myself to the existing innates, this time. Did I get you right that spell-level doesn't matter for innates?

 

 

btw. Thank you very much for your help!! ;);)

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...