Aller au contenu

Photo

CommandUseAbility


  • Veuillez vous connecter pour répondre
9 réponses à ce sujet

#1
Kilrogg_

Kilrogg_
  • Members
  • 296 messages
I'm trying to get a hostile mage to cast a spell on non-interactive+neutral wild sylvans upon getting attacked by the player. I want this spell to then trigger UT_TeamGoesHostile and SetObjectInteractive.

I was able to catch the EVENT_TYPE_ATTACKED on the mage when the player attacks her, however CommandUseAbility doesn't seem to do anything. I know the mage has Heal (via the AI package she uses), so I used the following script to test if she would heal herself when i hit her, but she doesn't. The script does fire though. I also tried manually adding the Heal spell on the creature template just in case.

Is there a better way to do this? I still haven't figured out the part where I would need to catch that the sylvan received the Heal spell and then fire the 'come to life' script.

 case EVENT_TYPE_ATTACKED:
         {
             object oCreature = GetEventCreator(ev); // creature being attacked (the mage)
             {
                
                    CommandUseAbility(10104, OBJECT_SELF);
                    DisplayFloatyMessage(oCreature, "fired", FLOATY_MESSAGE, 16777215, 2.0);

             }
             break;

Modifié par Kilrogg_, 30 mai 2010 - 05:45 .


#2
TimelordDC

TimelordDC
  • Members
  • 923 messages
I believe CommandUseAbility adds the command to the queue so it is possible that the mage is already executing a command when this command is added?

If that is the case, you could try using a ClearAllCommands or ClearCurrentCommand (you will have to check the exact function names) and then using the CommandUseAbility call.



If you want to do what you want, you can simply play some VFXs on the sylvans (as if the mage is casting on them) and bring them to life.

#3
Kilrogg_

Kilrogg_
  • Members
  • 296 messages
ClearAllCommands works, but I don't think I'm using CommandUseAbility correctly. ClearAllCommands has an object parameter that determines who is getting its command queue cleared, but I just noticed CommandUseAbility only specifies the target, not who is casting the ability.



My understanding of events and scripts is still a bit unclear, but unless I'm mistaken there is nothing in the above script that tells the game who CommandUseAbility is for (also oCreature in this case is actually the attacker, not the attackee).

#4
Craig Graff

Craig Graff
  • Members
  • 608 messages
You need to be using WR_AddCommand (or just AddCommand).

#5
Kilrogg_

Kilrogg_
  • Members
  • 296 messages
Thanks Craig, that worked.

Another question though. Ultimately I'm trying to have this mage to bring two Sylvans to life, but i want the player to be able to prevent this if they are good enough, by not letting the mage cast (the player is a rogue so he has stuns).

I'm using the script below, and I thought it would make the mage cast on the first sylvan when first attacked, then on the second attack it would cast on the second sylvan, but its only ever triggering the first spell so my if statement doesn't seem to work. I grabbed the Do Once part from the template in the toolset.

case EVENT_TYPE_ATTACKED:
{
object oCreature = GetEventCreator(ev); // player
object oSylvan1 = GetObjectByTag("frozen_sylvan1");
object oSylvan2 = GetObjectByTag("frozen_sylvan2");
command oCommand1 = CommandUseAbility(300001,oSylvan1);//invisible heal
command oCommand2 = CommandUseAbility(300001,oSylvan2);//invisible heal
{
int nDoOnce = GetLocalInt(OBJECT_SELF, "DO_ONCE");
if(nDoOnce == 0)
{
WR_AddCommand(OBJECT_SELF, oCommand1);
DisplayFloatyMessage(oCreature, "fired sylvan ONE", FLOATY_MESSAGE, 16777215, 2.0);
SetLocalInt(OBJECT_SELF, "DO_ONCE", 1);
}
if(nDoOnce == 1)
{
WR_AddCommand(OBJECT_SELF, oCommand2);
DisplayFloatyMessage(oCreature, "fired sylvan TWO", FLOATY_MESSAGE, 16777215, 2.0);
SetLocalInt(OBJECT_SELF, "DO_ONCE", 2);
}
}
break;


Also I'm not even sure yet how I'm going to catch the fact that the mage has cast on either sylvan in order to turn them interactive/hostile... any suggestions there? Maybe there's an entirely different and easier way of doing things?

Modifié par Kilrogg_, 31 mai 2010 - 01:27 .


#6
Craig Graff

Craig Graff
  • Members
  • 608 messages
There is no DO_ONCE local variable unless you add one in a 2da. Instead you could use CREATURE_DO_ONCE_A, although CREATURE_COUNTER_1 would be more appropriate for your purposes.

As for catching the ability usage, that would typically be done in the spellscript that you are calling for your custom ability (the invisible heal). Or you could try EVENT_TYPE_SPELLCASTAT in the creature script of the sylvans.

Modifié par Craig Graff, 31 mai 2010 - 02:27 .


#7
Guest_dewkl_*

Guest_dewkl_*
  • Guests
Is it possible to give commands to other objects? I have an operator checking if health is below a specific value at the EVENT_TYPE_DAMAGED case. If it's below 50, I want another creature to use heal on it. It gets that creature within a maximum range, then gives the command. I thought this would be simpler compared to having another creature constantly check for the health of nearby creatures.

CommandUseAbility seems to be restricted to the object that is calling it, so do I need to use something else entirely? Any ideas to what I can use?

PS: hope I'm not hijacking anything here. kilrogg's issue appears to be solved (?).

Modifié par dewkl, 03 juin 2010 - 04:59 .


#8
Kilrogg_

Kilrogg_
  • Members
  • 296 messages
As Craig said (and as you can see in my script above), you need to use WR_AddCommand. CommandUseAbility can't be used directly to add something to the creature's queue since as you said it doesn't know who is casting the ability.



As long as you do the following it should work fine:



1) Get the creature that's supposed to cast the heal by tag

2) Define what the heal command is going to be using CommandUseAbility

3) Add the command from #2 to #1's queue using WR_AddCommand




#9
Guest_dewkl_*

Guest_dewkl_*
  • Guests
Ah, of course. I don't know how I managed to miss that part. Thanks for the help.

Modifié par dewkl, 03 juin 2010 - 03:27 .


#10
Guest_dewkl_*

Guest_dewkl_*
  • Guests
Does the creature have to actually know the command/spell that is being performed? If so, will adding the spell to the creature resource help? I'm trying to make a spider perform a heal spell, so maybe that's why it doesn't work for me. I could use ApplyEffectOnObject, but would that fire even if the creator (the creator parameter in the function) is dead?

Edit: It seems so. I also didn't think of that it takes spell power and all that into the equation when doing a heal, so a spider healing won't heal much at all. Guess I will have to find another solution for this. I could just use HealCreature, but AddCommand doesn't seem to be very dependable even with the "override" value, which would make the timing off. Edit2: It's dependable enough. Consider this solved.

Modifié par dewkl, 03 juin 2010 - 04:36 .