Scenario:
PC encounters a coffin within a Tomb, they then cast "Raise Dead" on the coffin.
After the Raise Dead or Resurection is cast.
I need to detect wether or not the coffin is Open, if it IS Create an NPC next to the coffin.
So I guess I need somesort of GetSpellCastAt type function, or OnSpellCastAt type event.
Can someone help with this please.
CreatObject when a PC casts a spell at an Object
Débuté par
Quilistan
, juil. 20 2010 12:20
#1
Posté 20 juillet 2010 - 12:20
#2
Guest_ElfinMad_*
Posté 20 juillet 2010 - 08:19
Guest_ElfinMad_*
Sounds like you already have it figured out.
In pseudocode:
int spell = GetLastSpell
if(spell == raise_dead && GetIsOpen)
{
createobject();
}
And put your script in the on spell cast at event.
In pseudocode:
int spell = GetLastSpell
if(spell == raise_dead && GetIsOpen)
{
createobject();
}
And put your script in the on spell cast at event.
#3
Posté 20 juillet 2010 - 08:30
Check the on spell cast at field in the script set. I think it's not possible to do it to a placeable since they don't have that event.
If I rember only creature got that event. So you take a creature, set its appearance to a coffin, put a walkmesh cutter around the coffin so it can't be moved. Set your coffin on unbumpable. And work on the script wich is in the On spell cast at field of that creature that you turned into a coffin.
In the event you make a statement (an if ) and you use the function GetSpellCastAt to get the ID of the spell that was cast on your coffin.
If it's the correct spell, you can create your resurected guy. Since the coffin will be a creature, you'll have to use tricks for the open/close states.
If I rember only creature got that event. So you take a creature, set its appearance to a coffin, put a walkmesh cutter around the coffin so it can't be moved. Set your coffin on unbumpable. And work on the script wich is in the On spell cast at field of that creature that you turned into a coffin.
In the event you make a statement (an if ) and you use the function GetSpellCastAt to get the ID of the spell that was cast on your coffin.
If it's the correct spell, you can create your resurected guy. Since the coffin will be a creature, you'll have to use tricks for the open/close states.
#4
Guest_ElfinMad_*
Posté 20 juillet 2010 - 08:44
Guest_ElfinMad_*
Nope, placeables do have the on spell cast at script. IIRC the trees in Elanee's skymirror subplot in the OC use this event. A script could be ripped from there.
#5
Posté 20 juillet 2010 - 09:02
What I am sure is that only creature and Ipoint can cast spell.
And you can't assign a command to an object to cast at something that isn't a creature.
And you can't assign a command to an object to cast at something that isn't a creature.
#6
Posté 20 juillet 2010 - 03:29
You can use OnSpellCastAt event on a placeable...
More important is the question, does the raise dead spell allow for being cast on a placeable?
More important is the question, does the raise dead spell allow for being cast on a placeable?
Modifié par Freeze01, 20 juillet 2010 - 03:30 .
#7
Posté 20 juillet 2010 - 03:44
Onspellcastat get the ID of the spell casted at. If you got that event, you're good. Any spell can be casted on it.
#8
Posté 20 juillet 2010 - 04:48
Thanks guys for you replies. I thought I had remember seening something like this, but only looked in the script editor for it. Totally forgot to look in the events on the placeable, which is strange because like I posted I thought of that (just didn't think to look.). Your post will go a long way to help anyway though.
Thank you
Thank you
#9
Posté 21 juillet 2010 - 02:06
Thanks everyone, here is what I came up with incase someone else needs this. Not sure of the best way to post code on these forums, but here goes my shot. (Please educate me if someone knows a better way to post this. I used nwscript in brackets. )
[nwscript]
//Put this in the OnSpellCastAt event
#include "nw_i0_generic"
void CreateObjectVoid(int nObjectType, string sTemplate, location lLoc, int bUseAppearAnimation = FALSE)
{
CreateObject(nObjectType, sTemplate, lLoc, bUseAppearAnimation);
}
void main()
{
int nSpell = GetLastSpell();
object oCoffin = GetObjectByTag("drog_coffin");
if ((nSpell == SPELL_RAISE_DEAD && GetIsOpen(oCoffin)) || (nSpell == SPELL_RESURRECTION && GetIsOpen(oCoffin)))
{
object oTarget = GetWaypointByTag("wp_drog_raise");
location lTarget = GetLocation(oTarget);
location lTarget2 = GetLocation(oCoffin);
DelayCommand(0.9, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectNWN2SpecialEffectFile("fx_craft_self"), lTarget));
DelayCommand(1.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "stone_drogaxe", lTarget));
}
}
[/nwscript]
[nwscript]
//Put this in the OnSpellCastAt event
#include "nw_i0_generic"
void CreateObjectVoid(int nObjectType, string sTemplate, location lLoc, int bUseAppearAnimation = FALSE)
{
CreateObject(nObjectType, sTemplate, lLoc, bUseAppearAnimation);
}
void main()
{
int nSpell = GetLastSpell();
object oCoffin = GetObjectByTag("drog_coffin");
if ((nSpell == SPELL_RAISE_DEAD && GetIsOpen(oCoffin)) || (nSpell == SPELL_RESURRECTION && GetIsOpen(oCoffin)))
{
object oTarget = GetWaypointByTag("wp_drog_raise");
location lTarget = GetLocation(oTarget);
location lTarget2 = GetLocation(oCoffin);
DelayCommand(0.9, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectNWN2SpecialEffectFile("fx_craft_self"), lTarget));
DelayCommand(1.0, CreateObjectVoid(OBJECT_TYPE_CREATURE, "stone_drogaxe", lTarget));
}
}
[/nwscript]
Modifié par Quilistan, 21 juillet 2010 - 02:11 .
#10
Posté 21 juillet 2010 - 05:15
Why did you make a CreateObjectVoid function?
#11
Guest_ElfinMad_*
Posté 21 juillet 2010 - 07:26
Guest_ElfinMad_*
I think CreateObject returns an object which may cause a problem with its use with DelayCommand. The void wrapper would fix that. My guess anyway.
#12
Posté 21 juillet 2010 - 07:42
Yes it has to do with the Delay timer, if I remember right it didn't work normal(or at all) with a delay with out creating the CreateObjectVoid function.
I don't have a huge understanding of creating the functions, so that one is cut and pasted form another script I have that spawns creatures on a delay. I think Loudent2 had helped me with that one.
Many times I do things, only because of my limited understanding.
I don't have a huge understanding of creating the functions, so that one is cut and pasted form another script I have that spawns creatures on a delay. I think Loudent2 had helped me with that one.
Many times I do things, only because of my limited understanding.
#13
Posté 21 juillet 2010 - 09:33
#include "nw_i0_2q4luskan"
That include file has a void createobject function made by the OEI people.
It is located in the nwn2 install campaign folder you can copy it into your module folder or campaign folder - it will not work unless you do that afaik . . .
That include file has a void createobject function made by the OEI people.
It is located in the nwn2 install campaign folder you can copy it into your module folder or campaign folder - it will not work unless you do that afaik . . .





Retour en haut






