Having a problem with CreateNPCFromTemplate properties.

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.

Moderator: POL Developer

Post Reply
Yukiko
Distro Developer
Posts: 2825
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Having a problem with CreateNPCFromTemplate properties.

Post by Yukiko »

Hey all,

I am trying to create an NPC with a specific gender but the gender property I set on the struct doesn't seem to work.

Here is the program I am testing with:

Code: Select all

use uo;

program text_command_cnpc(who, textline)

	var props := struct;
	var stuff := SplitWords(textline);
	props.+ name := stuff[1];
	props.+ gender := CInt(stuff[2]);
	props.+ color := 33;
	var loc := TargetCoordinates(who);
	CreateNPCfromTemplate("peasant1", loc.x, loc.y, loc.z, props, who.realm);

endprogram
So when I use the command
cnpc Glen 0
I get the name and colour I have set but the gender sometimes is female. I've tried the program without the CInt() wrapper and even with a CStr() wrapper but I get the same resulrs. Most times I get a male NPC but sometimes I get a female. It doesn't matter whether I specify male or female (0 or 1) I still get semi random results. Any ideas what I might be doing wrong?

Thanks.
gh0sterZA
Neophyte Poster
Posts: 35
Joined: Thu Nov 19, 2015 11:36 am
Location: Cape Town

Re: Having a problem with CreateNPCFromTemplate properties.

Post by gh0sterZA »

Hi

Doubt it is what you are looking for, but all info I have on NPCTemplate is a header from an old script (pol095 era)

regards

Code: Select all

NpcTemplate (string unique templatename)
{
    Name                   (string paperdoll name)
    ObjType                (integer body model type)
    Script                 (string AI script)
    Gender                 (0=male 1=female)
    TrueColor              (int original body skin color)
    Color                  (int current body skin color)
    AR                     (die-string natural armor rating)
    Alignment              ('good' 'neutral' or 'evil)

    [(VitalName)           (die-string value)]
    [VitalName...]
    
    [(AttributeName)       (die-string value)]
    [AttributeName...]
    
    [AttackDelay           (int intrinsic weapon delay in ms {default 0})]
    AttackDamage           (die-string damage for intrinsic weapon)
    AttackAttribute        (string attribute name used for intrinsic weapon)
    [AttackHitSound        (int sound ID for intrinsic weapon {default 0})]
    [AttackMissSound       (int sound ID for intrinsic weapon {default 0})]
    [AttackHitScript       (string script for intrinsic weapon hit)]
    [AttackMinRange        (int intrinsic weapon minimum range {default 0})]
    [AttackMaxRange        (int intrinsic weapon maximum range {default 0})]
    [AttackAnimation       (int animation ID {default 0 (wrestling)})]

    [AttackProjectile...]
    [AttackProjectileAnim...]
    [AttackProjectileType...]
    [AttackProjectileSound...]

    [MaxHp                 (int maximum hitpoints for intrinsic weapon {default 1}]

    [MoveMode              (movemode string {default 'L'})]
    [Privs                 (string privilage) [(more privs)]...]
    [Settings              (string priv set 'on') [(more privs)]...]
    
    [SpeechColor           (int speech color {default 0x3B2})]
    [SpeechFont            (int speech color {default 3})]
    
    [UseAdjustments        (0/1 {default 1})]
    [RunSpeed              (int 0-250 {default dexterity})]
}


User avatar
CWO
POL Expert
Posts: 1159
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: Having a problem with CreateNPCFromTemplate properties.

Post by CWO »

Check your NPC's script for setup parameters. Many of them set parameters randomly inside the script when first created.
Yukiko
Distro Developer
Posts: 2825
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: Having a problem with CreateNPCFromTemplate properties.

Post by Yukiko »

gh0sterZA thanks for the info but what I was trying to do was override the randomization of NPC names and genders upon creation. I need some merchants to be given the same name every time they get spawned in the event they get wiped. My system uses the POL 0.95 merchant node system and my merchants aren't set to invulnerable. So they can be killed in game and if that happens I need certain ones to be given a set name when they are recreated.

Here's part of the definition for the CreateNpcFromTemplate function from the POL docs:
CreateNpcFromTemplate( template, x, y, z, override_properties := 0, realm := _DEFAULT_REALM)
Creates an NPC from a template (found in NPCDESC.CFG).

...

override_properties A Struct with keys as String members and values as appropriate (see notes)

Explanation [of override_properties]:
Notes: override_properties: a structure containing members to override values in the NPC template. This can be used to override built-in properties (facing, color, gender etc) and custom properties ("CProps" = dictionary {key=cpropname value=cpropvalue})
With the override_properties parameter you are given the opportunity to override such things as gender, colour and other items that are predefined in the NPC template. This is a very handy feature of POL. However, when the AI program for an NPC, during the initialization phase of the script, is changing some of the properties as well after the NPC is created it can get in the way of things.

CWO, once again, pointed me in the right direction. I had forgotten that the merchant AI script picks a random gender during init of the NPC.

Thanks.
Post Reply