Page 1 of 1

CreateNpcFromTemplate - problem with override_properties

Posted: Thu Feb 08, 2007 11:08 am
by dr_bliss
This is a few lines of my script's source code:

Code: Select all

    var mnoznik:= RandomInt(GetEffectiveSkill(who, SKILLID_NECROMANCY) - NpcResist)/100;
    if(mnoznik<=0)
        mnoznik:=0.01;
    endif
    var newStats:=newStatistics(npcConfigElem,mnoznik);
    var creature:=CreateNpcFromTemplate(template, trup.x, trup.y, trup.z, [b]newStats[/b]);
    print(creature);
newStatistics function code:

Code: Select all

function newStatistics(npc,m)
    var newStat:= struct;
    newStat.+Color:=1109; newStat.+trueColor:=1109;
    newStat.+STR:=Cint(m*npc.STR); newStat.+INT:=Cint(m*npc.INT); newStat.+DEX:=Cint(m*npc.DEX);
    return newStat;
endfunction
The returned newStat is correct (its struct, for example:
NewStat: struct{ Color = 1109, DEX = 70, INT = 10, STR = 18, trueColor = 1109 } )

And as a "creature" is returned error:

Code: Select all

error{ errortext = "Parameter 4 must be a Struct or Integer(0), got Struct" }
Its very strange and I dont know what is wrong, because I've never tried to use override_properties... I know how to create NPC with changed stats in other way, but i will prefer to do this using ovverride_properties parameter for CreateNpcFromTemlate() command.

Please, help me a little...

Thanks in advance.

Posted: Thu Feb 08, 2007 12:42 pm
by Yukiko
In this line:

Code: Select all

var creature:=CreateNpcFromTemplate(template, trup.x, trup.y, trup.z, [b]newStats[/b]); 
there are the brackets and the b and /b inside of them. I assume that was intended to bold the text for the purpose of this post and that those don't exist in your script.

Posted: Fri Feb 09, 2007 2:55 am
by dr_bliss
I assume that was intended to bold the text for the purpose of this post and that those don't exist in your script.
Yes, of course.

Posted: Thu Dec 27, 2007 3:57 am
by Zgryt
I have the same problem... Did you do something with that? Is there any way to make that work?

Posted: Thu Dec 27, 2007 7:09 am
by coltain
If You use 095 try putting an array instead struct

a struct type (as I recall) is needed for 097