casting spells at objects
Moderator: Event DM
casting spells at objects
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()?
Iwant to set up a trigger that fires a spell, at itself.
What do i need to put in the arguements for the castspell()?
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 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().
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...
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.
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));
oh and for fireball it would be
Code: Select all
AssignCommand(oOriginWP, ActionCastSpellAtLocation(SPELL_FIREBALL, lTargetLoc, METAMAGIC_NONE, TRUE));
- Jonezie
- Team Member; Retired with Honors
- Posts: 3905
- Joined: Wed Jun 09, 2004 7:05 am
- Location: Melbourne (GMT +10)
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.
Otherwise, you could use a similar setup to what was suggested above, but with an invisible object placeable instead of a waypoint.
- Mistcaller
- Team Member; Retired with Honors
- Posts: 5477
- Joined: Sun Feb 09, 2003 3:42 pm
- Location: Athens, Greece (GMT +2)
fireball was just an example. Its not the spell I'm actually going to be usingJonezie 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.

- Papainhell
- Sage
- Posts: 2138
- Joined: Wed Oct 01, 2003 1:09 am
- Timezone: Time?
- Location: Kodiak, Alaska (for now)
- Contact:
Here ya go:
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 
yep, spelled invisible wrong
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)));
}
}

yep, spelled invisible wrong


Playing as:
Master Odel Helmsplitter
Odel Helmsplitter- Hammer Fist Stylist, monk of The Order of The Dragon.