It seems that you're using an outdated browser. Some things may not work as they should (or don't work at all).
We suggest you upgrade newer and better browser like: Chrome, Firefox, Internet Explorer or Opera

I want to create a script that loots an area. Basically, the AI should follow the rules that normal players would and be quick. However I have stumbled upon several obstacles:

The function PickUpItem
You can use this without knowing where the item is or if it even exists. I've seen one person stack thousands of rows with this functions, but the problems however are:
1. Each PickUpItem requires time. I have a decent computer and a script with 1000+ rows of PickUpItem calls took 50 seconds to complete.
2. If someone else in the party picks up the item, the script gets stuck on one PickUpItem.
3. It doesn't care about restrictions like traps or locks, and simply picks up the item from anywhere.
4.There are few associated triggers to check whether there is an item nearby. You can check if an item is inside a container or in range of a creature with a "script name" though, but this doesn't cover all bases.

Trapped and locked objects:
There is no way to know if an object is trapped or locked from a normal AI script. You can use Detected, Disarmed, Unlocked on the trapped/unlocked objects though, but not from the AI script.

Please let me know if I am wrong about any of this.

My plan to proceed is:
1. Edit a bunch of trap scripts, and check for Detected, Disarmed, Unlocked, then add a global variable attributed to the objects using it. That way, you can from a normal AI script, check if a lock is locked or trap is trapped or detected by checking the global variables. For only locked containers or doors, create new scripts, and load them in existing area scripts.

2. Split the AI script into scripts for each area to speed up the script. Load these scripts whenever entering a new area.

3. Check for ground traps nearby and disarm them. Don't let anyone loot anything before that.
4. Loot containers first. If there are containers with items, dropped items cannot be picked up. Deal with traps and locked objects before picking up the items.

5. Loot creatures with a "script name" if they are in range and dead.

6. Generally pick up items that could have been dropped by creatures with no "script name".

7. Pick up potentially dropped items that were picked up but immediately dropped because inventory was full.

This way algorithm would probably make the script act more human. I am also considering an easier solution:

1-2: Same as above.

3. Have a thief script for finding traps and disarming and unlocking only. Let that thief clear the area before looting.

4. Loot the area by using one big list of PickUpItem . Add a little extra PickUpItem so that the items are picked up in one go from a container or object.

What do you think? One problem with both approaches is when someone in the party picks up an item that another player wants to pick up. That could cause the script to freeze. Maybe only one person should be able to loot at a time, or maybe Player1 can delegate who loots what with GiveOrder and ReceiveOrder, but that seems very complicated.
Post edited January 14, 2013 by potato_head