Page 1 of 1

casting spells at objects

PostPosted: Thu Jun 30, 2005 1:54 pm
Author: Alphonse
Ok. I dont do much scripting so this is probably a very easy answer.

Iwant to set up a trigger that fires a spell, at itself.

What do i need to put in the arguements for the castspell()?

PostPosted: Thu Jun 30, 2005 10:29 pm
Author: fremen
what kind of spell? If it's something like magic missle where do you want it to originate from?

I also think that if a trigger is going to cast it at itself you need to use: ActionCastSpellAtLocation().

PostPosted: Thu Jun 30, 2005 10:32 pm
Author: Alphonse
fremen wrote:what kind of spell? If it's something like magic missle where do you want it to originate from?

I also think that if a trigger is going to cast it at itself you need to use: ActionCastSpellAtLocation().


that was the one i was planning to use. I was wondering about the parameters to use for that. What would i use for a fireball spell?

PostPosted: Thu Jun 30, 2005 10:45 pm
Author: fremen
well if the target is the trigger itself using two waypoints would probably be easier to get the origin and the target of the spell set just right.

I'm at work so this probably won't work but it should be close...

Code: Select all
object oOriginWP = GetObjectByTag("ORIGIN_WP");
object oTargetWP = GetObjectByTag("TARGET_WP");
location lTargetLoc = GetLocation(oTargetWP);
AssignCommand(oOriginWP, ActionCastSpellAtLocation(SPELL_MAGIC_MISSILE, lTargetLoc, METAMAGIC_NONE, TRUE));


The only thing that I can think that would be a problem is that you may not be able to use a waypoint as the origin. I mean can you add an action to a waypoint or more specifically can it cast a spell? If not you can create an invisible creature instead of a waypoint.

PostPosted: Thu Jun 30, 2005 10:50 pm
Author: fremen
oh and for fireball it would be
Code: Select all
AssignCommand(oOriginWP, ActionCastSpellAtLocation(SPELL_FIREBALL, lTargetLoc, METAMAGIC_NONE, TRUE));

PostPosted: Thu Jun 30, 2005 11:53 pm
Author: Jonezie
Waypoints can't cast spells, so the previous script wouldn't work, no. If you wanted a fireball, the easiest thing to do would probably be using the projectile traps. Those are in the standard palette under triggers-> traps. Basically, when you trip the trap, the nearest object with the same tag as the trap casts the spell at the person who triggered it.

Otherwise, you could use a similar setup to what was suggested above, but with an invisible object placeable instead of a waypoint.

PostPosted: Fri Jul 01, 2005 12:00 am
Author: Mistcaller
Also, if you want to set the DC of the spell, you have to modify the corresponding "save" (fort, will, ref) OF the placeable. Doesnt make much sense, but this is how it works. :)

PostPosted: Fri Jul 01, 2005 6:42 am
Author: Alphonse
Jonezie wrote:Waypoints can't cast spells, so the previous script wouldn't work, no. If you wanted a fireball, the easiest thing to do would probably be using the projectile traps. Those are in the standard palette under triggers-> traps. Basically, when you trip the trap, the nearest object with the same tag as the trap casts the spell at the person who triggered it.

Otherwise, you could use a similar setup to what was suggested above, but with an invisible object placeable instead of a waypoint.


fireball was just an example. Its not the spell I'm actually going to be using :twisted:

PostPosted: Fri Jul 01, 2005 6:58 am
Author: Jonezie
I don't think there's a projectile trap for hellball. You'd have to use the invisible object. :wink:

PostPosted: Fri Jul 01, 2005 7:01 am
Author: Alphonse
Jonezie wrote:I don't think there's a projectile trap for hellball.



Shhhhh. Its supposed to be a surprise

*wanders off whistling nonchalontly*

PostPosted: Fri Jul 01, 2005 7:06 am
Author: Jonezie
Err...healball? That's what I said, yeah...

PostPosted: Sun Jul 03, 2005 4:14 pm
Author: Papainhell
Here ya go:
Code: Select all
void main()
{
//  Target of spell
object oTarget = GetEnteringObject();
location lTargetLoc = GetLocation(oTarget);
    if (!GetIsPC(oTarget)){
        //  Make an invisible object to cast the spell
        object oCaster = CreateObject(OBJECT_TYPE_PLACEABLE, "spellcaster", lTargetLoc);
            //  Casting of spell and removal of invisable object
            AssignCommand(oCaster, ActionCastSpellAtLocation(SPELL_EPIC_HELLBALL, lTargetLoc, METAMAGIC_ANY, TRUE, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
            AssignCommand(oCaster, ActionWait(6.0));
            AssignCommand(oCaster, ActionDoCommand(DestroyObject(oCaster)));
            }

}


Also you need to make an invisible object w/ a ResRef of: spellcaster and make sure change the objects Reflex save to something like 50 :twisted:


yep, spelled invisible wrong :wink: