Drop Items

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

Moderator: POL Developer

Post Reply
Daviex
Neophyte Poster
Posts: 39
Joined: Sat Sep 20, 2008 3:53 am
Location: Sicily, Italy

Drop Items

Post by Daviex »

Hey all!

I got new problem with an if that not work...

I need to check if my mount looted something, so i inserted this code:

Code: Select all

  if (mount_who.backpack)
	  foreach oggetto in (EnumerateItemsInContainer(mount_who.backpack))
      MoveObjectToLocation(oggetto, mount_who.x, mount_who.y, mount_who.z, mount_who.realm, MOVEOBJECT_FORCELOCATION);
	  endforeach
  endif
Now, i checked if the mount_who had any object on his pack with .openpack, and it's okay, but it's like it not read any backpack, so i tried to change code to this:

Code: Select all

  var enumItems := EnumerateItemsInContainer(mount_who.backpack);
  if(enumItems.size() != 0)
    foreach oggetto in enumItems
      MoveObjectToLocation(oggetto, mount_who.x, mount_who.y, mount_who.z, mount_who.realm, MOVEOBJECT_FORCELOCATION);
	  endforeach
  endif
To see if there's any object in container, but it give me 0.

I can't find a solution, someone can help me?

Thanks :)
RusseL
Forum Regular
Posts: 375
Joined: Fri Feb 20, 2009 8:30 pm

Re: Drop Items

Post by RusseL »

what is "mount_who" ?
Daviex
Neophyte Poster
Posts: 39
Joined: Sat Sep 20, 2008 3:53 am
Location: Sicily, Italy

Re: Drop Items

Post by Daviex »

mount_who is the NPC to mount.
Korbedda
New User
Posts: 8
Joined: Wed Mar 14, 2012 4:05 pm

Re: Drop Items

Post by Korbedda »

Are you sure the mount has a backpack? The command .openpack creates a new one in case the mount has no backpack, so it is not a good way to check.
Daviex
Neophyte Poster
Posts: 39
Joined: Sat Sep 20, 2008 3:53 am
Location: Sicily, Italy

Re: Drop Items

Post by Daviex »

When it loot, it create a backpack.
RusseL
Forum Regular
Posts: 375
Joined: Fri Feb 20, 2009 8:30 pm

Re: Drop Items

Post by RusseL »

Code: Select all

 print("mount_who="+mount_who);
 print("mount_bp="+mount.who.backpack);

 if (mount_who.backpack)
     foreach oggetto in (EnumerateItemsInContainer(mount_who.backpack))
      MoveObjectToLocation(oggetto, mount_who.x, mount_who.y, mount_who.z, mount_who.realm, MOVEOBJECT_FORCELOCATION);
     endforeach
  endif
add some prints and see what comes
Daviex
Neophyte Poster
Posts: 39
Joined: Sat Sep 20, 2008 3:53 am
Location: Sicily, Italy

Re: Drop Items

Post by Daviex »

mount_who=<appobj:MobileRef>
mount_bp=<appobj:ItemRef>

This is the result of the print...

Any help?
Yukiko
Distro Developer
Posts: 2825
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: Drop Items

Post by Yukiko »

You mentioned you wanted to see if the mount looted something by having it drop everything from its backpack.

I ran your second script and it worked fine. From what I see there's no reason why the first one would not work too.

Did the items get in the mount's pack by actually looting a corpse? Are you sure there are items in the mount's backpack? Forgive me but I didn't quite understand if you saw the items when you used the .openpack command.

Have you tried having your mount fetch something and then check for it in the mount's backpack with your drop items script? If not, try placing some things on the ground and tell your tamed mount to fetch each item. Then run your "drop items" script and see if it drops the items. If it does then I suggest checking your loot script and make sure it is working properly. If your mount doesn't drop any of the items you told it to fetch then try opening its pack with the .openpack command and see if the fetched items are there. If they aren't then perhaps that mount isn't being given a backpack at creation.
Yukiko
Distro Developer
Posts: 2825
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: Drop Items

Post by Yukiko »

OK. I did some quick testing. I wrote a small script to move an item to a NPC's backpack. If the NPC doesn't have a backpack POL won't automatically create one on the NPC and the item doesn't get moved anywhere. So it's possible your mount isn't created with a backpack.

One of the first few lines of code in my tamedAI script checks to make sure the tamed animal has a backpack and if not it creates and equips it with one .

Code: Select all

if(!me.backpack)
    var newbackpack := CreateItemAtLocation(6066, 2, 0, 0xe75,1, _DEFAULT_REALM);
    EquipItem(me, newbackpack);
endif
I suspect your mounts are missing a backpack. Although the printouts seem to show an itemref for one. So I could be wrong.
Daviex
Neophyte Poster
Posts: 39
Joined: Sat Sep 20, 2008 3:53 am
Location: Sicily, Italy

Re: Drop Items

Post by Daviex »

Thanks for help to anyone.

Working so hard, with some prints, etc... I found the problem:

Old scripter, changed the function, and added as primary function a MountNPC and Clean backpack, so when i mounted everytime, it first delete all items on ostard, and after it tried to drop items, already deleted -_-

Thanks so much for the help :)

Bye!!!
Yukiko
Distro Developer
Posts: 2825
Joined: Thu Feb 02, 2006 1:41 pm
Location: San Antonio, Texas
Contact:

Re: Drop Items

Post by Yukiko »

That's odd. I don't think there's any reason why you would need to clean the backpack out and remove it prior to mounting. I don't think items the mount is carrying have any effect on movement, ie. stamina loss, once you mount it.

Anyway, glad you found the problem. Little things like that can drive you crazy.
Post Reply