Jump to content

Spawning NPC .cre with gear dependent on level?


ericp07

Recommended Posts

Hello,

 

When my joinable NPC joins the party, part of her script assigns her XP close to that of the PC. Her base .cre is 8th level (ranger), and the script will place her at the appropriate level from 8th to 21st. I'd like to know if it's possible to also ensure that she appears with gear that's appropriate to a character of the level at which she begins play. I wasn't sure how to look this up in the forum search, so I ask it here. If anyone is willing to point me in the right direction, even if to point me to a discussion of this with examples, I'd greatly appreciate it! It would also be very helpful if anyone can suggest how powerful such items as weapons and armor should be within the above range of levels.

 

TIA for any assistance!

Happy modding and happy holidays,

Eric

Link to comment
I think cmorgan's Aran might have some scripting like that - check his forum.

 

Thanks! I was trying to recall where I'd seen a discussion about it recently. Makes sense that it would be there, as I've been checking out a lot of stuff in that forum :)

 

[Edit] I found two topic discussions that might give me the information I need for this. I'll see what the appropriate coding method is for setting this up in my NPC's .baf, and proceed accordingly. [/Edit]

 

- E

Link to comment

OK, now I have code that will give my NPC better gear at two cutoff levels (and there's probably a more efficient way to code it than what I've got). If this is reasonable, she'll begin play with +2 weapons and armor for levels up to 11th, then swap out for +3 gear for levels 12 through 23.

 

The axe is her off-hand weapon, and this script handles that item and her armor. She begins play with a custom scimitar +2 that has special properties as her main weapon. This item will be upgraded on two occasions, when certain conditions have been met, represented by a priest of her faith finding her and "blessing" the weapon (whereupon a script will replace the item with the more powerful version).

 

In Meleryn's script file (EP#Mel.baf), her joining script sets her XP fairly close to that of Player1, after which I've placed the code to equip her according to her level. I still don't have a good sense of what gear is appropriate to what level ranges, so I've set it up like so:

 

IF
 Global("EP#MelWeaponCheck","GLOBAL",0)
 HasItem("ax1h03","EP#Mel") // She carries a +2 axe at lower levels
 AND (2)
 CheckStatGT(Player1,11,LEVEL) // She's past the first threshold for improved weapons
 CheckStatLT(Player1,24,LEVEL) // She isn't past the second threshold yet
THEN
 RESPONSE #100
 TakeItemReplace("ax1h17","ax1h03","EP#Mel") // Replace axe +2 with axe +3
 SetGlobal("EP#MelWeaponCheck","GLOBAL",0)
END

IF
 Global("EP#MelArmorCheck","GLOBAL",0)
 HasItem("leat03","EP#Mel") // She has leather +2
 CheckStatGT("Player1",11,LEVEL) // She's past the first threshold for improved armor
 CheckStatLT("Player1",24,LEVEL) // She isn't past the second threshold yet
THEN
 RESPONSE #100
 TakeItemReplace("leat07","leat03","EP#Mel") // Replace leather +2 with leather +3
 SetGlobal("EP#MelArmorCheck","GLOBAL",0)
END

 

Instead of assigning (or creating) more powerful gear upgrades at the second threshold (such as leather +5 or axe +5), I figure the party will have found suitably powerful items to give her by that point. This allows for the possibility of gaining items that may not have higher enchantment values, but that have other properties that make them equivalent in power.

 

Still not thrilled with my threshold levels, so I welcome input especially on that point. Now I have to ask a naive question: why do we set the global variable to 0 at the end of the script block, instead of (for example) 1? It looks right when I follow the flow of the script check, but it also looks strange to me, if the value begins at 0. That leads me to also ask: is there a more efficient way to code this? Any changes that would improve the set-up?

 

Thanks and happy modding,

Eric

Link to comment

Set it to one :) That way it only runs once. Right now, if Player1's level is between 12 and 23 inclusive, these two blocks run. The way it is set up now, it keeps scanning every run through the .bcs, instead of firing once. If you provide a link to where you got the "0" -> "0", I'll fix it in the posted code, or explain...

 

"Player1" does not need "" as it is not a DV, but an object label. I'd switch that to target "EP#Mel", all around, and test.

 

The only way I can think of to optimize the version up is to put it in the summoned "improve her stuff" priest's .bcs or .dlg so that it doesn't come into existence until the priest shows up to do the upgrade. The version you have above is as streamlined as I can think of... if this is just for the initial upgrade script, I would tuck this into whatever block you are using for the experience adjustment, too, so it happens when whichever block evaluates true setting her experience.

Link to comment
Set it to one :) That way it only runs once. Right now, if Player1's level is between 12 and 23 inclusive, these two blocks run. The way it is set up now, it keeps scanning every run through the .bcs, instead of firing once. If you provide a link to where you got the "0" -> "0", I'll fix it in the posted code, or explain...

 

"Player1" does not need "" as it is not a DV, but an object label. I'd switch that to target "EP#Mel", all around, and test.

 

The only way I can think of to optimize the version up is to put it in the summoned "improve her stuff" priest's .bcs or .dlg so that it doesn't come into existence until the priest shows up to do the upgrade. The version you have above is as streamlined as I can think of... if this is just for the initial upgrade script, I would tuck this into whatever block you are using for the experience adjustment, too, so it happens when whichever block evaluates true setting her experience.

 

I got the code from Aran Whitehand's forum pages, and yeah, I thought setting the value to 1 in the THEN portion would be correct. I've now made that change, and replaced Player1 with EP#Mel (in quotes, as this is her DV). Testing to follow sometime soon.

 

So, if I place this code at the appropriate places in Meleryn's spawning script, will the level thresholds still need to remain as I have them currently coded, or will that be assumed due to the placement of the code?

 

The scimitar-upgrading priest's .baf is only just begun, and I'll need to fix up the code, as it currently looks like:

 

// Script file for Sudeiman Rein (for conditions and triggers) - EP#Sudei.baf

IF
  Global("EP#SudeiExists","GLOBAL",1)
  Global("EP#GaveDagnir3","GLOBAL",0)
  See(EP#Mel)
  CombatCounter(0)
  !See([ENEMY])
THEN
  RESPONSE #100
	  SetGlobal("EP#GaveDagnir3","GLOBAL",1)
	  MoveToObject(EP#Mel)
	  Dialogue(EP#Mel)
END

 

What was I thinking? *L* Clean-up is definitely in order for this one ;) Here, I suppose I'll use EP#GaveDagnir3 to represent his having upgraded the scimitar to the +3 version, and then I'll have to write another block, using EP#GaveDagnir5 to represent his having upgraded to the +5 version (and I'll need to restrict the +5 item to ToB, but I don't know yet how to do that). But I don't much care for "EP#GaveDagnirX", so I'll likely rename the variable.

 

Thanks, and please give me any more feedback that will help me lock this down and carry on with development :laugh:

 

- E

Link to comment

Will look soon, but i can say with a 10 second glance, Dialog() already does a MoveToPlayer(), so you don't need it -

 

Dialog = move to and initiate talk

 

StartDialogNoSet = anywhere, no movement towards player

 

will go repair code shown!

Link to comment
Will look soon, but i can say with a 10 second glance, Dialog() already does a MoveToPlayer(), so you don't need it -

 

Dialog = move to and initiate talk

 

StartDialogNoSet = anywhere, no movement towards player

 

will go repair code shown!

 

Understood, and thanks!

- E

Link to comment

Now I think I should reduce Meleryn's starting off-hand axe to a +1 weapon, as she already starts with a +2 main weapon that has special abilities. +2 leather doesn't look unreasonable, though, and the only other item she starts with is her Unicorn Pendant and some arrows. Maybe a non-magical composite longbow would round her out. I'd still like to include better gear in case she joins the party at higher levels.

 

Happy modding,

Eric

Link to comment

Archived

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

×
×
  • Create New...