Author Topic: Creatures and Special Abilities  (Read 619 times)

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Creatures and Special Abilities
« on: March 06, 2011, 02:46:56 pm »


               Is there a feat or something that creatures need to use special monster abilities? I am trying to create a tree that shoots bolts and some other special abilities at the PC. I made an immobile creature with an invisibile appearance, and I put it just in front of a static tree. It worked out quite well, and it looks like you are fighting the tree. However the tree will not cooperate. Instead of using the special abilies, it just fights with bare fists. It will not even use the heal ability. I tried using dragon race, since I have made dragons with special abilies, but it did not help. Even adding 40 wizard levels did not help, as it just used one buff, and then tried to fight. I put all the fighting abilties(str, dex, con) low, and the casting abilities(wis, int, chr) high, but no luck. I am stumped.

Could anyone please help me?

Thank you.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Creatures and Special Abilities
« Reply #1 on: March 06, 2011, 02:53:23 pm »


               No creature does not need any ability score (unlike spells granterd from class) to use special abilities.

Your problem is in immobility, the AI doesn't use any spell or special ability if the creature is immobilized and tries just to attack in melee. (I'm solving this for my Community Patch project btw)

Even then the usage of the special ability is still not 100%. Mostly if player reach in melee range, creature starts attacking in melee again. The AI is just stupid. In order to make things work exactly as you want you need script. Either you will make a trigger around three and then you assign to cast the spell to the tree, so no invisible creature is needed or you will make special AI for your invisible creature.

I can help you with the AI, just tell me the name of the special ability and I will provide you the AI script and howto set it. (But still first approach would be better and more "clean")
               
               

               


                     Modifié par ShaDoOoW, 06 mars 2011 - 02:54 .
                     
                  


            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Creatures and Special Abilities
« Reply #2 on: March 06, 2011, 03:31:59 pm »


               Thanks for the help. 'Image

The abilities I'm trying to use are acid bolts and poison bolts, as well as acid breath and poison breath for close range. My scripting abilites are limited, but I can make scripts with the script generator. I thought of the enter area of a trigger script to cast a spell, but it does not include acid or poison bolts, and since this is for high level characters, the other spells did not have much effect when I tried it. Also the script generator does not make script to keep casting the spell while you're still in the area. I even tried an ondeath script to respawn the tree after ten minutes, but it did not work. That's why I tried the invisible creature. 
               
               

               


                     Modifié par Sadira of Tyr, 06 mars 2011 - 03:35 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Creatures and Special Abilities
« Reply #3 on: March 06, 2011, 04:06:16 pm »


               

#include "x2_inc_switches"
#include "nw_i0_generic"

void main()
{
SetCreatureOverrideAIScriptFinished(OBJECT_SELF);
object oEnemy = GetNearestEnemy();
 if(GetIsObjectValid(oEnemy))
 {
 ClearAllActions();
 float fRange = GetDistanceBetween(OBJECT_SELF,oEnemy);
  if(fRange > 8.0)//long distance
  {
   if(GetHasSpell(SPELLABILITY_BOLT_ACID) && GetHasSpell(SPELLABILITY_BOLT_POISON))
   {//has both so choose random one
   ActionCastSpellAtObject(d2() == 2 ? SPELLABILITY_BOLT_ACID : SPELLABILITY_BOLT_POISON,oEnemy);
   return;
   }
   else if(GetHasSpell(SPELLABILITY_BOLT_ACID))
   {
   ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID,oEnemy);
   return;
   }
   else if(GetHasSpell(SPELLABILITY_BOLT_POISON))
   {
   ActionCastSpellAtObject(SPELLABILITY_BOLT_POISON,oEnemy);
   return;
   }
  }
  else//short distance
  {
   if(GetHasSpell(SPELLABILITY_CONE_ACID) && GetHasSpell(SPELLABILITY_CONE_POISON))
   {//has both so choose random one
   ActionCastSpellAtObject(d2() == 2 ? SPELLABILITY_CONE_ACID : SPELLABILITY_CONE_POISON,oEnemy);
   return;
   }
   else if(GetHasSpell(SPELLABILITY_CONE_ACID))
   {
   ActionCastSpellAtObject(SPELLABILITY_CONE_ACID,oEnemy);
   return;
   }
   else if(GetHasSpell(SPELLABILITY_CONE_POISON))
   {
   ActionCastSpellAtObject(SPELLABILITY_CONE_POISON,oEnemy);
   return;
   }
  }
 ActionAttack(oEnemy);
 }
}


ok so go into script editor past this script and save it under some name, since I am author it would be kind to use my prefix like "sh_ai_treeimp" and compile it.

so now you must set this script into your "Tree Imp" '<img'>. Find him in palette or location (if you put him in manually) and set him this variable:

X2_SPECIAL_COMBAT_AI_SCRIPT | string | sh_ai_treeimp

now it should work, test it, I tried it and it worked just fine
               
               

               


                     Modifié par ShaDoOoW, 06 mars 2011 - 04:08 .
                     
                  


            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Creatures and Special Abilities
« Reply #4 on: March 06, 2011, 05:41:04 pm »


               I will try this. Thank you very much. 'Image
               
               

               
            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Creatures and Special Abilities
« Reply #5 on: March 06, 2011, 07:38:32 pm »


               Well, I have tested the script, and it worked great at long range. It fired both bolts in random order. However when I moved closer, it did not use the cones, and when I moved even closer, it started to melee. I am not sure why it would not use the cones, since I put 99 of each one.

I decided that the best solution would be to change the range from 8 to 1. Now it fires the bolts all the time, and kept firing them even at melee range. It works great like this, so I am happy with it.

Thank you very much for your time in helping me Shadooow. 'Image

Oh, and I decided to use your full name for naming the script. I called it shadooowtree_ai. 'Image
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Creatures and Special Abilities
« Reply #6 on: March 06, 2011, 08:14:49 pm »


               

ShaDoOoW wrote...

Your problem is in immobility, the AI doesn't use any spell or special ability if the creature is immobilized and tries just to attack in melee. (I'm solving this for my Community Patch project btw)

Just BTW, I have tracked this issue down and found out that its a bug in hardcoded function GetCreatureTalent* which doesn't return valid talent if the creature is immobile. Nothing I can do with it... But custom AIs that doesnt use this function Jasperre's probably Tony K ? should work.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Creatures and Special Abilities
« Reply #7 on: March 06, 2011, 08:18:49 pm »


               

Sadira of Tyr wrote...

Well, I have tested the script, and it worked great at long range. It fired both bolts in random order. However when I moved closer, it did not use the cones, and when I moved even closer, it started to melee. I am not sure why it would not use the cones, since I put 99 of each one.

Hmm maybe you used a different breaths?

I set it to check for special ability Cone of acid and Cone of poison. If you are using Dragon breath or Mestils acid breath, or anything else it wont work, but I can adjust it for these, just tell me exact name from toolset.
               
               

               
            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Creatures and Special Abilities
« Reply #8 on: March 06, 2011, 11:07:05 pm »


               I did use the dragon breaths the first time, but I checked the script again, and changed the abilities to cone of acid and cone of poison. However it still wouldn't work, so I reduced the range to 1 instead.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Creatures and Special Abilities
« Reply #9 on: March 07, 2011, 12:32:28 am »


               You must be doing something wrong, with default script I provided and those 4 abilities it works fine for me. Maybe that you were changed the abilities on NPC but you haven't modified the script again and didn't restored the range?
               
               

               
            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Creatures and Special Abilities
« Reply #10 on: March 07, 2011, 11:00:01 am »


               I am not sure why it didn't work, but I will check it again. I tried it with the correct bolts and cones. I did notice that the poison bolts had no effect, since the dc was only 20 and our server has turned off the fail save on 1. So I changed the poison bolts to shards bolts, and the poison cones to sonic cones. I don't think that would make a difference, since I checked the constants to make sure I spelled them correctly, and I changed all 4 of them for each range. I could change them back to poison and try it, but I don't think it would matter since I had the correct bolts and cones. I did not reduce the range until I saw that it was not working the way it should have. Maybe it had something to do with the invisible creature I used. I think it is fine the way it is now, so I am going to leave it as it is now.

For some reason, scripts like to mess with me. I have made a lot of scripts, and most of them work fine, but some just don't want to work when they should work. Scripts for spawning placeables or destroying placeables always like to give me troubles, especially when using delay commands.It always seems to frustrate me, but I am getting used to it now. lol