Aller au contenu

Photo

Cast a spell from creature's HB - Please Help {RESOLVED}


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

#1
Morbane

Morbane
  • Members
  • 1 883 messages
 void main()
{
object oCaster = OBJECT_SELF;
object oTarget = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, oCaster); AssignCommand(oCaster, ActionCastSpellAtObject(SPELL_BLESS, oTarget, METAMAGIC_ANY, TRUE, 20, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
}

The above code does not seem to work - what am I missing here?:pinched:

Modifié par Morbane, 20 septembre 2011 - 01:49 .


#2
The Fred

The Fred
  • Members
  • 2 516 messages
It should work, but you might need to ClearAllActions() first. Also, you shouldn't need to assign the command if it's the caller doing the casting (which it is, in this case), but that shouldn't matter too much.

#3
Morbane

Morbane
  • Members
  • 1 883 messages
Thanks Fred - that got it going

#4
Morbane

Morbane
  • Members
  • 1 883 messages
void main()
{
object oCaster = OBJECT_SELF;

object oTarget = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, oCaster);

if(!GetIsObjectValid(oTarget))
{
SendMessageToPC(GetFirstPC(),"DEBUG: invalid target!");
}

ClearAllActions();

ActionCastSpellAtObject(Spell_Ability_Soul_Suck, oTarget, METAMAGIC_ANY, TRUE, 20, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
}

After the main PC dies the companions are not getting noticed by the spell - help please

#5
Dann-J

Dann-J
  • Members
  • 3 161 messages
Two things come to mind:

- When a player dies, it may no longer be considered a valid object. If the dead PC cast the spell, then using them (oCaster) as the origin of the GetNearest search might not work once they are dead.

- Spell effects sometimes end when the caster dies. I know this to be true for custom AOEs (I had to completely rewrite the caltrops spell scripts because of it), and quite possibly other AOEs as well.

#6
Morbane

Morbane
  • Members
  • 1 883 messages
void main()
{
object oCaster = OBJECT_SELF;

object oTarget = GetNearestCreature(CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY, oCaster, 1, CREATURE_TYPE_IS_ALIVE, TRUE);
if(GetIsObjectValid(oTarget))
{
ClearAllActions();
ActionCastSpellAtObject(SPELL_BLESS, oTarget, METAMAGIC_ANY, TRUE, 20, PROJECTILE_PATH_TYPE_DEFAULT, TRUE);
}
else
{
SendMessageToPC(GetFirstPC(),"DEBUG: invalid target!");//delete this message after you get it working properly
}
}
Thanks to ShaDoOoW