NPC inventory & AI manipulation

Discussion in 'General Modification' started by Livonya, Oct 25, 2007.

Remove all ads!
  1. Cujo

    Cujo Mad Hatter Veteran

    Joined:
    Apr 4, 2005
    Messages:
    3,636
    Likes Received:
    1
    well if we implemented the handle animal skill, wouldn't that mean your pets listen to you more (maybe even to the point "sick 'him'"), and with no skill they just do what they normally do.
     
  2. Shiningted

    Shiningted I changed this damn title, finally! Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,745
    Likes Received:
    375
    O m G thats a great idea.

    PLUS we could make it synergistical with 'Wild Empathy' (if that doesn't violate the rules). Wild Empathy at low levels is pretty ordinary.

    EDIT: I'll have a look whether the Animal Affinity feat works (give +2 to Handle Animal). If so, that'd be the better choice for adding a bonus to Wild Empathy (in place of 'Ride'). but if we add Handle Animal, we could find all sorts of plot-uses for it.
     
    Last edited: Oct 30, 2007
  3. Livonya

    Livonya Established Member

    Joined:
    Sep 25, 2003
    Messages:
    773
    Likes Received:
    0

    The problem is that you can't talk to your pets during combat.

    There really isn't an effective way to communicate with the pet during combat.

    And there are limits to what kind of commands are possible.

    For instance it is impossible to get any creature to move to a specific point or to a specific PC/NPC during combat.

    You could build a tool that would appear in the radial dial that would allow you to send signals, but then you are getting into the overly complicated.

    With animals the actions you can give are pretty much limited.

    So I am not sure if the effort involved in creating pet tools would be worth the in game value to the player.

    I will post a working system no later than Monday, and then people can play around with it. Once I am done then it will be very, very, very easy for scripters to add/use the system.

    - Livonya
     
  4. Half Knight

    Half Knight Gibbering Mouther

    Joined:
    May 16, 2007
    Messages:
    2,148
    Likes Received:
    1
    That's exactly the way it work as per the rules. Animal companions aren't like familiars, they're no magical creatures (not counting special rules, or feats), but are better than the average creature. A companion start with a few tricks learned (i think it's based on inteligence) like "attack", "wait", "follow", and with Handle animal skill you can teach him more tricks (even more especifics ones) as his master (and thus him) grows in levels.

    I don't want to spoil the fun people, just telling how it work so you can find the better option :)
    If anyone have doubts, i got all the 3º Ed, 3.5 Ed, and even the Player handbook II (also have almost 50 or 60 books of 3º Ed system miscelanea if you want to check something or search some item or anything but mostly of Dragonlance and Forgotten Realms :shrug: )
     
  5. Livonya

    Livonya Established Member

    Joined:
    Sep 25, 2003
    Messages:
    773
    Likes Received:
    0
    That's good because that is about all that can be done.

    There are very few things that can be done when dealing with companions/pets/summoned monsters that are on the player's side.

    On the other hand, when dealing with creatures/companions/pets/summoned monsters that are trying to kill the player... in this case lots can be done.

    An evil Lich could easily control it's skeletons/undead... giving them order like charged, go ranged, hold ground, etc...

    - Livonya
     
  6. Lord_Spike

    Lord_Spike Senior Member Veteran

    Joined:
    Mar 25, 2005
    Messages:
    3,151
    Likes Received:
    1
    Maybe an ill-conceived thought, but would modifying the Command spell for pets work? Then, give it to the pet's owner in the form of an object which allows them to cast it at will on the pet. Make it invisible & non-transferrable, too.
     
  7. Zebedee

    Zebedee Veteran Member Veteran

    Joined:
    Apr 2, 2005
    Messages:
    1,755
    Likes Received:
    0
    I need to read through this thread again. Don't think my brain quite grasped this stuff on the first reading - this is amazing!

    AI scripts which can change on the fly... oh my...


    edit: any noticeable slowdown when running these scripts Liv? We guessed a while back you're on a mainframe, but how about for those of us with lesser systems ;)
     
    Last edited: Oct 31, 2007
  8. Livonya

    Livonya Established Member

    Joined:
    Sep 25, 2003
    Messages:
    773
    Likes Received:
    0
    Here is an update on my current progress.

    It is working fantastic.

    My first AI script manipulator is for a melee NPC.

    Here is what it does so far:

    1) If no enemy targets that are conscious are within 25 feet then it switches to a ranged weapon and switches to a ranged AI strategy (note that range can be changed, I am just using 25 in this example).

    2) If enemy units are within 20 feet the NPC then switches to melee weapon and does one of the following:

    a) if there are friendly units within 10 feet then NPC will attempt Flank if the NPC has the Mobility Feat and if the NPC isn't so damaged that risking an AOO would be stupid

    b) if the NPC is damaged and has some sort of healing potion then it will take a 5' Step and drink potion

    c) if no enemy are within 10 feet then it will Charge on an enemy target beyond 10 feet

    d) if no standing/alive enemy are within 10 feet then it will attack a prone target

    e) if no standing/alive enemy are within 10 feet and a dying or unconcious enemy unit is within 5 feet then it will kill that enemy unit

    f) if the NPC has the Improved Trip Feat then it will attempt a trip


    Anyway, you get the idea.

    I am writing some sample scripts to show what is possible. The above script is sort of an all purpose script, but I am also writing some very specific scripts, and also some randomizer scripts.

    For example I have a script for an evil mage that has undead followers.

    On start of combat he tells his skeletons to ready vs. attack. He then casts an offensive area effect spell and then tells his skeletons to attack at will.

    I still have a lot of work to do, but it is coming along nicely.

    As a check on your imagination. The AI is still limited to what works and doesn't work in the strategy.tab so while this system is a huge improvement, it has serious limits.

    For example there is no way that I know of to force a melee NPC to attack a specific target. Instead, you have to write scripts and AI strategies that should under most situations identify the same target. It doesn't always work in game the way I wish it would, but variation isn't all bad as it does make it seem like the NPCs are making choices.

    Anyway, by Monday I should have enough done to upload the system. I just need to build a good number of example scripts and AI strategies.

    I think this will be a healthy improvement to the game's AI.

    - Livonya


    PS: The real fun will be with spell AI strategies... this will be a massive improvement. I don't even know where to start as so much is possible.
     
  9. Shiningted

    Shiningted I changed this damn title, finally! Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,745
    Likes Received:
    375
    NPCs that can tell the difference between when to shoot, when to charge and when to flank?

    O baby... :dribble: This is fantastic Liv! I'll certainly be using this straight away to give Lord Axer's room a good going over.
     
  10. Livonya

    Livonya Established Member

    Joined:
    Sep 25, 2003
    Messages:
    773
    Likes Received:
    0
    Another update.

    I added in health checks to the general melee script I am putting together.

    So for instance if an NPC doesn't have some sort of cure damage potion, then the NPC will only do certain actions if they have a decent amount of health.

    An example would be Flank. If an NPC has less than 50% of its hit points left then it will not attempt a Flank if they have a threatening enemy unit. No reason to risk an AOO when you are already so badly damaged.

    And if an NPC has the Feat Expertise, the NPC is heavily damaged, and there are friendly units within 10 feet then the NPC will use Expertise.

    I even have some entirely new stuff that I am trying out, like a defensive move. If an NPC has less than 1/3 of its hit points left, no way to heal, and there are several friendly units within 10 feet then the NPC will take a 5' Step and then Ready vs. Approach. The idea being that the NPC tries to stay alive. (hmmm... I will also have to add attack and then take 5' step.... that would be a good defensive move as well... not sure if it will work...)

    At this point I have in at least 2 or 3 actions that no enemy NPC melee unit ever performed before. At the very least it will make for variety.

    So that is all coming along nicely.

    I also have all NPC's telling you what they are doing each round. So for testing purposes the thing they are doing floats above their head. It really helps to test the qualifiers that you are using to run their AI scripts.

    And finally, I have finally figured out a way to approach NPCs detecting area effect spells such as Silence, Stinking Cloud, Greece, and Web. I am not sure what I can get them to do with this information, but certainly I can at the very least have enemy NPCs attempt to dispel these spells.

    I have to spend some time thinking on this one. I really want to figure out how to script for Silence. I've been hunting a solution for that for a long time.

    - Livonya
     
  11. Shiningted

    Shiningted I changed this damn title, finally! Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,745
    Likes Received:
    375
    Liv - have you done anything with OCF_NO_FLEE? I was planning on leaving that off certain monsters / npcs if I think they should flee when threatened / wounded, but am not sure what its parameters are (if any). It opens up other cans of worms like whether they will flee into the distance and indefinitely prolong the combat (anyone who has chased turned ghouls the length of the temple will know what i mean) but the current "every man woman and child stand and fight to the death" situation could do with an overhaul.

    This all sounds great btw ;)
     
  12. Livonya

    Livonya Established Member

    Joined:
    Sep 25, 2003
    Messages:
    773
    Likes Received:
    0
    Yeah, I have played with OCF_NO_FLEE.

    If you have this in place then NPCs just run away when combat starts if they are not actually part of the faction being attacked.

    For example you have 2 different groups of NPCs with different faction ID in an area. Group A does not have OCF_NO_FLEE, but Group B does. If you attack Group B then Group A runs away.

    Not very useful.

    In my own mod I created some cowardly NPCs that run instead of fighting. So you have the option to attack them from a dialog, and when you choose this the NPCs just run away every time you approach them. If you actually enter combat with them then they will fight.

    From my tests OCF_NO_FLEE only works out of combat, but I haven't done every single possible test.

    Right now I am mostly just testing scripts qualifiers. Trying to figure out what they actually do, and which ones crash the game.

    Slow and painful, but I have discovered some fun nuggets.

    - Livonya
     
  13. Allyx

    Allyx Master Crafter Global Moderator Supporter

    Joined:
    Dec 2, 2004
    Messages:
    5,009
    Likes Received:
    255
    I remember some talk of a caravan encounter in which you could decide to help the traders, or a group of bandits a while ago, I think the flee flag would be quite useful in that situation.
     
  14. Shiningted

    Shiningted I changed this damn title, finally! Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,745
    Likes Received:
    375
    Yah, there will be a caravan encounter where you can either help the bandits mug the caravan, or the traders fight off the bandits (or just klill them all).

    That assumes we can get cooperative combat going somehow. We have it atm with the Mad Hermit, but I cheated and briefly attached him to the party for the duration of the combat.

    I also hope tio make the caravan moving so you have to protect them (if you go that route) while they cross a certain distance: get out in front and kill the bandits before they get at the traders (or something). Not sure how to do that - moving traders is easy, moving their wagons is a whole other kettle of sturgeon ;)

    Anyways, lets not get onto that here.
     
  15. Livonya

    Livonya Established Member

    Joined:
    Sep 25, 2003
    Messages:
    773
    Likes Received:
    0
    Just a small update... as I can barely contain my own excitement.

    It is coming along better than I ever imagined it would.

    I am almost completely done with a baseline system.

    I even managed to write a system for passing targets for NPC spell casters from the AI script handler to the spells themselves without having to add specific NPC name data to the spells. This allows for a generic system that is extremely user friendly.

    In short, I have now created a script that will handle targeting for area effect spells by NPC casters.

    When you call the script you can specify the area of effect width, minimum # of enemy units you want to hit, and maximum number of friendly units you are willing to hit.

    So for instance an NPC spell caster wants to cast Fireball. She only wants to cast the spell if she can hit 3 or more enemy units, and she is not willing to hit any friendly units.

    This is what the call looks like: target_area_spell(attachee, 20, 0, 3)

    The script searches for a target. If it find a target that meets those conditions then it records the target and returns a positive for target found.

    The AI strategy then casts Fireball. The Fireball spell then checks for a pre-defined target. If the spell finds a pre-defined target then that becomes the new target.

    So far in my tests it works every time....

    I should be able to post a completed system that is ready to go by Monday with no problem.

    The melee/ranged combat is pretty clean and extremely user friendly. But the spell casting AI routines will require more individualistic control for each NPC, but it is a 100 times better than it was.

    I can honestly say that I think this will make a HUGE difference in the quality of play and challenge level that enemy units will provide.

    Hopefully the transition from my test environment to every day play will go smoothly.

    - Livonya
     
Our Host!