Totems

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Totems

Post by gundamwing84 »

heya guys.

im having a little problem with totems.

when you open up a totem everything is fine, it follows commands and what not. and when you tell it to release it goes back to being a totem item and drops on the ground.

is there a way to make it so that the totem item once released, returns to your backpack?(the script for totems is below).

Code: Select all

use os;
use uo;
use cfgfile;
use vitals;

include "include/client";
include "include/objtype";
include "include/utility";
include "include/spawn";

program totem (who, totem)
	if (!ReserveItem (totem))
		SendSysMessage (who, "You can't use this right now.");
		return;
	endif
	
	if (!totem.movable)
		SendSysMessage (who, "You can't use this while its locked down!");
		return;
	endif

	var npctemplate := GetObjProperty (totem, "critter");
	if (!npctemplate)
		SendSysMessage (who, "There's a problem with this totem.  Contact a GM.");
		return;
	endif

	if (GetObjProperty (totem, "broken"))
		SendSysMessage (who, "It seems to be broken.");
		return;
	endif

	set_critical (1);
		var it := SpawnNPCAtLocation (npctemplate, who.x - 1, who.y + 1, who.z);
		if (!it)
			it := SpawnNPCAtLocation (npctemplate, who.x + 1, who.y + 1, who.z);
			if (!it)
				SendSysMessage (who, "Error creating creature - try a different location.");
				return;
			endif
		endif

		SetObjProperty (it, "totem", totem.objtype );
		SetObjProperty (it, "totemcolor", totem.color );
		SetObjProperty (it, "master", who.serial );
		
		if (GetObjProperty (totem, "totemdeaths"))
			SetObjProperty (it, "totemdeaths", GetObjProperty (totem, "totemdeaths"));
		endif

		if (GetObjProperty (totem, "ownerserial"))
			SetObjProperty (it, "ownerserial", GetObjProperty (totem, "ownerserial"));
			SetObjProperty (it, "ownername", GetObjProperty (totem, "ownername"));
			SetObjProperty (it, "oldname", GetObjProperty (totem, "oldname"));
		endif

		it.setmaster (who);
		it.script := "::tamed";
		it.name := totem.name;
		it.color := GetObjProperty (totem, "critcolor");
  		it.graphic := GetObjProperty (totem, "critgraphic");
		if ( GetObjProperty (totem, "totemhp"))
			SetVital (it, "Life", CINT (GetObjProperty (totem, "totemhp") * 100));
		endif

		PlaySoundEffect (who, SFX_SPELL_DISPEL);
		PlayStationaryEffect (it.x, it.y, it.z, FX_SMOKE, 0xA, 0xA );
		DestroyItem (totem);
		RestartScript (it);

	set_critical (0);
endprogram
Also another thing. with ride able totems, everything is fine when u mount them, but when u dismount them, the totem's colour(hue) changes back to origional colour. :(

is there way to set it so that the colour doesnt change on dismount.

any help is appreciated,
Mat :)
Polytropon
New User
Posts: 19
Joined: Wed Sep 15, 2010 9:47 pm

Re: Totems

Post by Polytropon »

It's pretty easy. You should move it with the function MoveItemToContainer and send it to character.backpack.
In fact, it's so easy that I believe you have no idea of what you are doing. :) It should also be on a different script (this script is intended for creating the mount and you want to place it in the one that creates the totem).


As for the color, if you are using the mounts.inc library from the distro, it seems that it does try to retrieve the color from the mount-item in the line:

animal.color := mount.color;

but the problem is that it never stored it when the creature was mounted and the color turns to be "error" (also called "0"). Thank you for making me notice that, so I correct it in my shard :)
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Re: Totems

Post by gundamwing84 »

ahhh thanks. yeah i am pretty new to scripting. i couldnt start a script if my life depended on it, but i like modifying scripts. i just wasnt sure were to start.

thanks =]
mat
Post Reply