casting spells at objects

Moderator: Event DM

Post Reply
User avatar
Alphonse
Master Sage
Posts: 5302
Joined: Wed Nov 03, 2004 8:26 am
Location: GMT

casting spells at objects

Post by Alphonse » Thu Jun 30, 2005 1:54 pm

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()?
fremen
Squire of Babble
Posts: 46
Joined: Fri Jul 02, 2004 6:53 pm

Post by fremen » Thu Jun 30, 2005 10:29 pm

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().
User avatar
Alphonse
Master Sage
Posts: 5302
Joined: Wed Nov 03, 2004 8:26 am
Location: GMT

Post by Alphonse » Thu Jun 30, 2005 10:32 pm

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?
fremen
Squire of Babble
Posts: 46
Joined: Fri Jul 02, 2004 6:53 pm

Post by fremen » Thu Jun 30, 2005 10:45 pm

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.
fremen
Squire of Babble
Posts: 46
Joined: Fri Jul 02, 2004 6:53 pm

Post by fremen » Thu Jun 30, 2005 10:50 pm

oh and for fireball it would be

Code: Select all

AssignCommand(oOriginWP, ActionCastSpellAtLocation(SPELL_FIREBALL, lTargetLoc, METAMAGIC_NONE, TRUE));
User avatar
Jonezie
Team Member; Retired with Honors
Posts: 3905
Joined: Wed Jun 09, 2004 7:05 am
Location: Melbourne (GMT +10)

Post by Jonezie » Thu Jun 30, 2005 11:53 pm

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.
User avatar
Mistcaller
Team Member; Retired with Honors
Posts: 5477
Joined: Sun Feb 09, 2003 3:42 pm
Location: Athens, Greece (GMT +2)

Post by Mistcaller » Fri Jul 01, 2005 12:00 am

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. :)
User avatar
Alphonse
Master Sage
Posts: 5302
Joined: Wed Nov 03, 2004 8:26 am
Location: GMT

Post by Alphonse » Fri Jul 01, 2005 6:42 am

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:
User avatar
Jonezie
Team Member; Retired with Honors
Posts: 3905
Joined: Wed Jun 09, 2004 7:05 am
Location: Melbourne (GMT +10)

Post by Jonezie » Fri Jul 01, 2005 6:58 am

I don't think there's a projectile trap for hellball. You'd have to use the invisible object. :wink:
User avatar
Alphonse
Master Sage
Posts: 5302
Joined: Wed Nov 03, 2004 8:26 am
Location: GMT

Post by Alphonse » Fri Jul 01, 2005 7:01 am

Jonezie wrote:I don't think there's a projectile trap for hellball.

Shhhhh. Its supposed to be a surprise

*wanders off whistling nonchalontly*
User avatar
Jonezie
Team Member; Retired with Honors
Posts: 3905
Joined: Wed Jun 09, 2004 7:05 am
Location: Melbourne (GMT +10)

Post by Jonezie » Fri Jul 01, 2005 7:06 am

Err...healball? That's what I said, yeah...
User avatar
Papainhell
Sage
Posts: 2138
Joined: Wed Oct 01, 2003 1:09 am
Timezone: Time?
Location: Kodiak, Alaska (for now)
Contact:

Post by Papainhell » Sun Jul 03, 2005 4:14 pm

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:
Image
Playing as:
Master Odel Helmsplitter
Odel Helmsplitter- Hammer Fist Stylist, monk of The Order of The Dragon.
Post Reply