/////////////////////////////////////////////
//
// created by Greyfort
// 12.18.2010
//
// multi targeting
// ac_multarg
/////////////////////////////////////////////
// include files here
///////////////////////////////////////////////////////////////////////////////
void main()
{
int iScriptBug=0;
object oItem =GetItemActivated();
object oPC = GetItemActivator();
//get and set item target
object oTarget=GetItemActivatedTarget();
SetLocalObject(oItem,"itm_target",oTarget);
//get and set item location targeted;
location lTargLoc=GetItemActivatedTargetLocation();
SetLocalLocation(oItem,"itm_targ_loc",lTargLoc);
/////////////////////////////////////////////////////////////
// fire targeted object script here unique power
////////////////////////////////////////////////////////////
if(oTarget != oPC )//&& GetIsObjectValid(oTarget)==TRUE)
{
//
if(GetObjectType(oTarget) !=OBJECT_TYPE_CREATURE && GetObjectType(oTarget) !=OBJECT_TYPE_PLACEABLE
&& GetObjectType(oTarget) !=OBJECT_TYPE_ITEM && GetObjectType(oTarget) !=OBJECT_TYPE_DOOR )
{
// target location script fired here
SendMessageToPC(oPC,"Target location script fired");
AssignCommand(oPC,ClearAllActions(TRUE));
AssignCommand(oPC,ActionJumpToLocation(lTargLoc) );
}
// preform action on target objects creatures,placeables see Lexicon object types
if(GetObjectType(oTarget) ==OBJECT_TYPE_CREATURE && GetIsObjectValid(oTarget)==TRUE )
{
// CREATURE script
SendMessageToPC(oPC,"Target CREATURE script fired");
}
if(GetObjectType(oTarget) ==OBJECT_TYPE_PLACEABLE && GetIsObjectValid(oTarget)==TRUE )
{
// PLACEABLE script
SendMessageToPC(oPC,"Target PLACEABLE script fired");
}
if(GetObjectType(oTarget) ==OBJECT_TYPE_ITEM && GetIsObjectValid(oTarget)==TRUE)
{
// ITEM script
SendMessageToPC(oPC,"Target ITEM script fired");
}
if(GetObjectType(oTarget) ==OBJECT_TYPE_DOOR && GetIsObjectValid(oTarget)==TRUE)
{
// DOOR script
SendMessageToPC(oPC,"Target DOOR script fired");
}
iScriptBug=1;
}//end of unique power
/////////////////////////////////////////////////////////////
// fire targeted object unique power self
////////////////////////////////////////////////////////////
if(oTarget == oPC && GetIsObjectValid(oTarget)==TRUE )
{
// perform action on player character usuing item
SendMessageToPC(oPC,"Target SELF script fired");
iScriptBug=1;
}//end of unique power self
/////////////////////////////////////////////////////////////
// not a valid object
// note this fires even if location is valid. so not to have
// error text apear iScriptBug=0 is needed.
// just // lines 14,60,70 to see what I'm talking about
////////////////////////////////////////////////////////////
if( GetLocation(oTarget)!= lTargLoc && GetIsObjectValid(oTarget)==FALSE && iScriptBug==0 )
{
// error text apears
SendMessageToPC(oPC,"Not a Valid object Target script fired");
}
}//end of script
here is script source useing just funtions. SetLocalObject(oItem,"itm_target",oTarget);, and SetLocalLocation(oItem,"itm_targ_loc",lTargLoc); are not used in this script they are another way to keep track of things wich could allow you to fire other scripts etc. Also the iScriptBug=1; is best after a script is fired ware I put it on line 60 was just quick to show it stoped the error message from apearing. what this means is if oTarget meets none of the if statement iScriptBug=0 which means not a valid target object.
This would be better way:
/////////////////////////////////////////////////////////////
// fire targeted object script here unique power
////////////////////////////////////////////////////////////
if(oTarget != oPC )//&& GetIsObjectValid(oTarget)==TRUE)
{
//
if(GetObjectType(oTarget) !=OBJECT_TYPE_CREATURE && GetObjectType(oTarget) !=OBJECT_TYPE_PLACEABLE
&& GetObjectType(oTarget) !=OBJECT_TYPE_ITEM && GetObjectType(oTarget) !=OBJECT_TYPE_DOOR )
{
// target location script fired here
SendMessageToPC(oPC,"Target location script fired");
AssignCommand(oPC,ClearAllActions(TRUE));
AssignCommand(oPC,ActionJumpToLocation(lTargLoc) );
iScriptBug=1;
}
// preform action on target objects creatures,placeables see Lexicon object types
if(GetObjectType(oTarget) ==OBJECT_TYPE_CREATURE && GetIsObjectValid(oTarget)==TRUE )
{
// CREATURE script
SendMessageToPC(oPC,"Target CREATURE script fired");
iScriptBug=1;
}
if(GetObjectType(oTarget) ==OBJECT_TYPE_PLACEABLE && GetIsObjectValid(oTarget)==TRUE )
{
// PLACEABLE script
SendMessageToPC(oPC,"Target PLACEABLE script fired");
iScriptBug=1;
}
if(GetObjectType(oTarget) ==OBJECT_TYPE_ITEM && GetIsObjectValid(oTarget)==TRUE)
{
// ITEM script
SendMessageToPC(oPC,"Target ITEM script fired");
iScriptBug=1;
}
if(GetObjectType(oTarget) ==OBJECT_TYPE_DOOR && GetIsObjectValid(oTarget)==TRUE)
{
// DOOR script
SendMessageToPC(oPC,"Target DOOR script fired");
ActionStartConversation(oPC,"name of canversation",TRUE,FALSE);
iScriptBug=1;
}
}//end of unique power
I also forgot to add your question about spawning a conversation after abject targeted I gave example in the // DOOR script that will start the conversation with PC so they can choose what they want to do with the door.
Modifié par Greyfort, 19 décembre 2010 - 04:26 .