Page 1 of 1

npc template?

Posted: Thu Jun 14, 2012 6:52 am
by gundamwing84
hey guys, i was just making this script for moving an npc around inside a house, and it doesnt seem to work correctly ~.~ i cant figure out how to determine a specific npc template only(so that characters cant be moving around all mobiles).
i was hoping for a helping hand :P
here is what i have so far:

Code: Select all

////////////////////
///move a vendor
/////////////////////

function MoveVendor(parms)
	var sign := parms[1];
	var character := parms[2];
	
	var homeinfo := GetObjProperty (sign, "homeinfo");
	if (!homeinfo)
		return;
	endif
	
	if (!IsAOwner (sign, character))
		if (!character.cmdlevel)
			return;
		else
			SendSysMessage (character, "Command level override", font := _DEFAULT_TEXT_FONT, color := MESSAGE_COLOR_MESSAGE);
		endif
	endif
	
	if (!IsInsideTheHouse(character, sign))
		return;
	endif
	
	SendSysMessage(character, "Please select a vendor to move", font := _DEFAULT_TEXT_FONT, color := MESSAGE_COLOR_MESSAGE);
	var vend := Target(character);
	if (!IsInside (character, sign, vend))
		return;
	else
		if (vend.npctemplate == "playermerchant")
			SendSysMessage(character, "Please select where you would like your vendor", font := _DEFAULT_TEXT_FONT, color := MESSAGE_COLOR_MESSAGE);
			var targ := TargetCoordinates(character);
			if (!IsInside (character, sign, targ))
				SendSysMessage(character, "you can only target inside your house!", font := _DEFAULT_TEXT_FONT, color := MESSAGE_COLOR_MESSAGE);
				return;
			else
				SendSysMessage(character, "moved", font := _DEFAULT_TEXT_FONT, color := MESSAGE_COLOR_MESSAGE);
				MoveObjectToLocation( vend, targ.x, targ.y, targ.z, targ.realm, MOVEOBJECT_FORCELOCATION );
				return;
			endif
		else
			SendSysMessage (character, "The gods feel you shouldnt have this power...", font := _DEFAULT_TEXT_FONT, color := MESSAGE_COLOR_MESSAGE);
			return;
		endif
	endif

endfunction
as you can see ive written if (vend.npctemplate == "playermerchant") but i cant seem to move npcs only still, is there a better way to define this?

please and thankyou :)

Re: npc template?

Posted: Thu Jun 14, 2012 7:38 am
by garyglitter
From what I can see it will only let players move around npcs that have the template 'playermerchant'. The .npctemplate is exactly how you want to do this, as well as a prop on the npc flagging just WHO can move him.

Re: npc template?

Posted: Thu Jun 14, 2012 3:49 pm
by RusseL
var vend := Target(character);
print("template="+vend.npctemplate);

and look at output :)
as i understand your question - it should help you ;)

Re: npc template?

Posted: Thu Jun 14, 2012 8:56 pm
by gundamwing84
AHA! thanks russel that really helped me debug this! ill definately remember that for future purposes :)

the if statement ended up as this:

Code: Select all

if (vend.npctemplate == ":housevendor:playermerchant")
thanks for the help, much appreciated :)

Re: npc template?

Posted: Fri Jun 15, 2012 6:17 pm
by Yukiko
Thought I'd add my two coppers worth to clarify the issue here.

When an NPC is defined in a package you need to include the package name when you are referencing it. Those familiar with The World of Dreams (and Sanctuary) scripts are used to this. Most of the NPCs in pre-99 official POL Distros were defined in one large NPCDesc.cfg file in \pol\config which made it a little simpler to reference them. With the new Distro 0.99 organization you'll need to remember to include the package name when creating or referencing an NPC, as most if not all, are defined in packages under the brainai package.