PDA

View Full Version : Changing NPC Name / Lastname


NatedogEZ
08-13-2013, 09:15 AM
I can change a NPCs name with ...


$npc->TempName("Uber guy");



But is there a way to change the NPCs last name without crashing the zone?


$npc->CastToClient()->ChangeLastName("");


That works... but the next time I #repop it will always crash the zone.

Any help would be awesome, thank you!

lerxst2112
08-13-2013, 10:07 AM
Haven't looked at the code, but considering NPCs are not clients, that looks pretty iffy to me.

wolfwalkereci
08-13-2013, 11:20 AM
Why not use the "#" command to do it?
Is there a reason you are using perl to handle something like this because I cant think of a reason why I would.

Kingly_Krab
08-13-2013, 11:46 AM
Temporary last names so he can dynamically change their last names without having to actually edit the NPC's last name to be 'permanent'.

Tabasco
08-13-2013, 02:31 PM
This may or may not work for your purposes, but I ran into a similar issue when trying to dynamically set last names.
I knew what it needed to be at spawn time and it varied by spawn only so I'm not changing last names while the mob is alive and active.

If you look at mod_functions.cpp you can just put something in NPC::mod_prespawn and manipulate the NPC in a number of ways before it's actually spawned which, at the time, was the only place you could change the last name outside of the database.

I'm using it to throw random 'boss' mobs into spawns that have been killed 1 or more times and the last name represents a difficulty meter.


strn0cpy(lastname, bosstag.c_str(), sizeof(lastname));
TempName("DYNBOSS");


From there a perl script takes over.

NatedogEZ
08-13-2013, 06:20 PM
Thanks Tabasco I think I can work with that.