Releasing a Totem

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

Releasing a Totem

Post by gundamwing84 »

Hey guys, i was wondering how i would set this script so that when you release a totem, it returns to your backpack, rather than just dropping to the floor where it was?

here is the if statement for it

Code: Select all

	if (totem)
		set_critical (1);
		var it := CreateItemAtLocation (me.x, me.y, me.z, totem, 1, me.realm);
		if (!it)
			say ("*Argh*");
			set_critical (0);
			return;
		endif

		it.decayat := 0;
		it.movable := 1;
		it.name := me.name;
		it.usescript := ":dundee:totem";
		it.color := CINT (GetObjProperty (me, "totemcolor"));
		SetObjProperty (it, "critter", me.npctemplate);
		if (GetObjProperty (it, "color"))
			SetObjProperty (it, "critcolor", GetObjProperty (it, "color"));
		else
			SetObjProperty (it, "critcolor", me.color);
		endif
		SetObjProperty (it, "critgraphic", me.graphic);
		SetObjProperty (it, "totemhp", CINT (GetVital (me, "Life")/100));

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

		Drop ();
		PlaySoundEffect (me, SFX_SPELL_DISPEL);
		PlayStationaryEffect (me.x, me.y, me.z, FX_SMOKE, 0xA, 0xA, 0, me.realm);
		KillMe ();
		set_critical(0);
		return;
	endif
any help is appreciated :)
mr bubbles
Grandmaster Poster
Posts: 120
Joined: Thu Jan 18, 2007 2:34 am

Re: Releasing a Totem

Post by mr bubbles »

Try changing this line

Code: Select all

 var it := CreateItemAtLocation (me.x, me.y, me.z, totem, 1, me.realm);
to

Code: Select all

// As im not sure if the owner is declared earlier in your script
var owner := SystemFindObjectBySerial( GetObjProperty (me, "ownerserial"));
var it := CreateItemInBackpack( owner, totem, 1 );
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Re: Releasing a Totem

Post by gundamwing84 »

ok when saying "release" the totems just go onto "say ("*Argh*");", they dont return to my backpack :( im not sure whats causing that :s

Code: Select all

	if (totem)
		set_critical (1);
		// As im not sure if the owner is declared earlier in your script
		var owner := SystemFindObjectBySerial( GetObjProperty (me, "ownerserial"));
		var it := CreateItemInBackpack( owner, totem, 1 );
		if (!it)
			say ("*Argh*");
			set_critical (0);
			return;
		endif
mr bubbles
Grandmaster Poster
Posts: 120
Joined: Thu Jan 18, 2007 2:34 am

Re: Releasing a Totem

Post by mr bubbles »

gundamwing84 wrote:ok when saying "release" the totems just go onto "say ("*Argh*");", they dont return to my backpack im not sure whats causing that :s
Means 'it' isnt being created successfully. Most Probably because 'owner' can't be found.

Does the totem have the "ownerserial" on it? If so then maybe you have to do

var owner := SystemFindObjectBySerial( CInt(GetObjProperty (me, "ownerserial")));

If that fails then add some Print() to see what's happening. I would do it like this

Code: Select all

// As im not sure if the owner is declared earlier in your script
Print("ownerserial : "+GetObjProperty (me, "ownerserial"));
var owner := SystemFindObjectBySerial( GetObjProperty (me, "ownerserial"));
Print("owner ref : "+owner);
var it := CreateItemInBackpack( owner, totem, 1 );
Print("it ref : "+it);
Agata
Journeyman Poster
Posts: 63
Joined: Sun Oct 30, 2011 6:33 am

Re: Releasing a Totem

Post by Agata »

ownerserial is for .own'ed items. You need the master property

Code: Select all

if (totem)
      set_critical (1);
      // As im not sure if the owner is declared earlier in your script
      var owner := SystemFindObjectBySerial( GetObjProperty (me, "master"));
      var it := CreateItemInBackpack( owner, totem, 1 );
      if (!it)
         say ("*Argh*");
         set_critical (0);
         return;
      endif
gundamwing84
Grandmaster Poster
Posts: 178
Joined: Tue Sep 08, 2009 1:57 am

Re: Releasing a Totem

Post by gundamwing84 »

Thankyou very much agata that done the trick! thanks to both of you for all the help, much appreciated :)
Post Reply