Page 1 of 1
Drop Items
Posted: Sat Dec 08, 2012 2:58 am
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

Re: Drop Items
Posted: Sat Dec 08, 2012 3:46 am
by RusseL
what is "mount_who" ?
Re: Drop Items
Posted: Sat Dec 08, 2012 4:50 am
by Daviex
mount_who is the NPC to mount.
Re: Drop Items
Posted: Sun Dec 09, 2012 4:08 am
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.
Re: Drop Items
Posted: Mon Dec 10, 2012 3:38 am
by Daviex
When it loot, it create a backpack.
Re: Drop Items
Posted: Mon Dec 10, 2012 5:15 am
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
Re: Drop Items
Posted: Mon Dec 10, 2012 11:10 am
by Daviex
mount_who=<appobj:MobileRef>
mount_bp=<appobj:ItemRef>
This is the result of the print...
Any help?
Re: Drop Items
Posted: Tue Dec 11, 2012 5:33 am
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.
Re: Drop Items
Posted: Tue Dec 11, 2012 6:09 am
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.
Re: Drop Items
Posted: Tue Dec 11, 2012 6:26 am
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!!!
Re: Drop Items
Posted: Thu Dec 13, 2012 5:08 am
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.