Activate Item without selecting target
#1
Posté 27 août 2011 - 04:08
#2
Posté 27 août 2011 - 04:16
#3
Posté 27 août 2011 - 04:22
And why isn't that next to activate item?
Modifié par henesua, 27 août 2011 - 04:24 .
#4
Posté 27 août 2011 - 07:13
henesua wrote...
thanks
And why isn't that next to activate item?
Because the toolset sorts its list..
#5
Posté 27 août 2011 - 09:04
#6
Posté 28 août 2011 - 09:32
activate item is not just for unique power you see, you might have a regular item, on which every time it is activated, a counter is incremented, and on the 256th use say, something happens. but the item had a bogstandard power.
i guess what i'm trying to say (quite inexpertly i might add) is that the to are not mutually exclusive, and the different monikers are there because they are different things alltogether.
#7
Posté 28 août 2011 - 05:36
On the other hand they do give a different text string to the player.
#8
Posté 28 août 2011 - 06:29
henesua wrote...
... Does anyone know how to differentiate in a script between which one was used?
That is not hard.
int Spell = GetSpellId();
where
ACTIVATE_ITEM =368
ACTIVATE_ITEM_SELF= 413
ACTIVATE_ITEM_L = 697
ACTIVATE_ITEM_T = 759
Keep in mind that the unique powers are still a spell(Per the engine) that all run the same inpact script: NW_S3_ActItem01 . All the script does is change the spell into a module signaled event.
#9
Posté 28 août 2011 - 08:24
Lightfoot8 wrote...
int Spell = GetSpellId();
where
ACTIVATE_ITEM =368
ACTIVATE_ITEM_SELF= 413
ACTIVATE_ITEM_L = 697
ACTIVATE_ITEM_T = 759
Interesting, I was unaware of that because I have not tackled custom spells yet. For my item activation scripts I have been using the following:
int nEvent =GetUserDefinedItemEventNumber(); if (nEvent ==X2_ITEM_EVENT_ACTIVATE) // do stuff
So using your method I guess that I will be able to differentiate between types of activation as follows:
"Spell" on Item Integer
Activate Item 368
Activate Item [Long Range] 697
Activate Item [Touch] 759
Unique Power 368
Unique Power Self Only 415
But that integer is the spell ID and NOT a User Defined Event Number
Modifié par henesua, 28 août 2011 - 08:25 .
#10
Posté 28 août 2011 - 08:38
int nEvent =GetUserDefinedItemEventNumber();
if (nEvent ==X2_ITEM_EVENT_ACTIVATE)
// do stuff
Just for the reasion that I do not know when if ever the spell ID gets cleared. I would hate to see a PC pick up an item and it fire its activate spell event just because someone just used a unique power somwhere.
#11
Posté 28 août 2011 - 08:44
I tried to distinguish between the activation types using the method you described but it did not work. Item activation in my mod triggers a tag based script.
To test this out I wrote a script associated with an object that had all the methods of activation and both of the two unique powers. Here it is:
#include "x2_inc_switches"
void main()
{
int nEvent =GetUserDefinedItemEventNumber();
if (nEvent ==X2_ITEM_EVENT_ACTIVATE)
{
object oPC = GetItemActivator();
object oItem = GetItemActivated();
object oTarget = GetItemActivatedTarget();
int nAct = GetSpellId();
SendMessageToPC(oPC, "Activating "+GetName(oItem));
SendMessageToPC(oPC, "Targeting "+GetName(oTarget));
SendMessageToPC(oPC, "ID of Activation "+IntToString(nAct));
}
}
For every type of activation I got a -1 for the spell ID. I suppose that the activation script does not qualify as a "spell script", and so there is no spell id.
#12
Posté 28 août 2011 - 09:21
#13
Posté 28 août 2011 - 09:26
If this is really something you want to do, you can modify the NW_S3_ActItem01 script to the following.
void main()
{
object oItem = GetSpellCastItem();
object oTarget = GetSpellTargetObject();
location lLocal = GetSpellTargetLocation();
SetLocalInt(oItem,"LAST_SPELL_CAST",GetSpellId());
SignalEvent(GetModule(), EventActivateItem(oItem, lLocal, oTarget));
}
then you can use the following.
#include "x2_inc_switches"
void main()
{
int nEvent =GetUserDefinedItemEventNumber();
if (nEvent ==X2_ITEM_EVENT_ACTIVATE)
{
object oPC = GetItemActivator();
object oItem = GetItemActivated();
object oTarget = GetItemActivatedTarget();
int nAct = GetLocalInt(oItem,"LAST_SPELL_CAST");
SendMessageToPC(oPC, "Activating "+GetName(oItem));
SendMessageToPC(oPC, "Targeting "+GetName(oTarget));
SendMessageToPC(oPC, "ID of Activation "+IntToString(nAct));
}
}
Or however you wish to do it. I ma sure you get the Idea.
#14
Posté 28 août 2011 - 09:27
EDIT: just a note here. The reason it was not working is that the GetSpellId function has to be running on the PC. So if you did not want to do it by modifying the inpact script you could alway just make sure that the script was running on the activator of the item. Or even wrap the event up as a command and assign it to the PC.
Here is an example of the last option.
#include "x2_inc_switches"
void ItemAct()
{
object oPC = GetItemActivator();
object oItem = GetItemActivated();
object oTarget = GetItemActivatedTarget();
int nAct = GetSpellId();
SendMessageToPC(oPC, "Activating "+GetName(oItem));
SendMessageToPC(oPC, "Targeting "+GetName(oTarget));
SendMessageToPC(oPC, "ID of Activation "+IntToString(nAct));
}
void main()
{
int nEvent =GetUserDefinedItemEventNumber();
if (nEvent ==X2_ITEM_EVENT_ACTIVATE)
{
AssignCommand(GetItemActivator(),ItemAct());
}
}
Modifié par Lightfoot8, 28 août 2011 - 10:04 .
#15
Posté 28 août 2011 - 10:59
#16
Posté 29 août 2011 - 04:12
Activate: 428
Activate (Long): 697
Activate (Touch): 795
Unique(self): 413
Unique (Range): 386





Retour en haut







