Jump to content

need help with a newly created npc


Guest Yili

Recommended Posts

I made my first npc, a fighter called Yoren, put him in the Copper Coronet, but when i come to collect him i've seen not one but three of them, and every second a new one

appears. (the last time i counted there were about 40) What's more, i can recruit more than one, so now i have in the group Minsc, myself and three Yorens :)

 

Someone can tell me where i messed up?

Link to comment

Right, scripting issue.

 

Use this;

 

IF
OnCreation()
Global("YorenSpawned","LOCALS",0)
THEN
RESPONSE #100
 CreateCreature("Yoren",[coord1.coord2],3)
 SetGlobal("YorenSpawned","LOCALS",1)
END

 

That should work, but I am not awesome at scripting.

 

Icen

Link to comment

Thanks for the quick answer, in the meantime i made a few corrections (i think the problem was in the area file) and reinstalled, now it seems ok, but i'll keep your code in case i'll spawn some other unfortunate character of mine :)

Link to comment

I suggest avoiding OnCreation(), and using a single variable instead (as folks can block OnCreation() calls accidentally when they EXTEND_TOP (or EXTEND_BOTTOM before your mod is installed) without Continue().

 

IF
Global("YorenSpawned","GLOBAL",0) // or AREA 
THEN
RESPONSE #100
 CreateCreature("Yoren",[coord1.coord2],3)
 SetGlobal("YorenSpawned","GLOBAL",1)
END

 

so that the block only runs once, and the variable can be used by other scripting across the game (GLOBAL) or Area (AREA).

 

This avoids all the hassle with folks using/not using Continue().

Link to comment

Thanks a lot Icen, cmorgan you were very helpful.

Needless to say as i am complete beginner i'll need to read a lot scripting

tutorials to understand what's going on.

Link to comment

The IESDP can help, if it is a little cryptic. BG2 Scripting is very simple, everything follows the frame already posted;

 

IF

<Triggers>

THEN

RESPONSE #<Weight>

<actions>

END

 

The weight is the chance that a block of actions will be executed. If I made two RESPONSEs and gave them each a weight of 50, theoretically, it will choose one of them randomly. In practice, it is biased towards the first RESPONSE.

 

I recommend Sim's Complete Scripting Guide located here

 

Icen

Link to comment

Archived

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

×
×
  • Create New...