npc template?

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

Moderator: POL Developer

Post Reply
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

npc template?

Post 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 :)
garyglitter
New User
Posts: 13
Joined: Wed May 16, 2012 5:19 pm

Re: npc template?

Post 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.
RusseL
Forum Regular
Posts: 375
Joined: Fri Feb 20, 2009 8:30 pm

Re: npc template?

Post by RusseL »

var vend := Target(character);
print("template="+vend.npctemplate);

and look at output :)
as i understand your question - it should help you ;)
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Re: npc template?

Post 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 :)
Yukiko
Distro Developer
Posts: 2825
Joined: Thu Feb 02, 2006 1:41 pm

Re: npc template?

Post 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.
Post Reply