Aller au contenu

Photo

item scripting prob


  • Veuillez vous connecter pour répondre
17 réponses à ce sujet

#1
delmetry

delmetry
  • Members
  • 11 messages
i am trying to create an effect of a book that when used will start a conversation.  I have had problems trying to get it to work so i search and searched an found that u cant have a conversation on and item so i was trying to have the book create and invisible placeable that will fire the conversation.  I can get the item to create the placeable but cant get the placeable to become invisible or the conversation to fire.  Please help here is the code that im using. Oh and this script is run by a unique power self on the book

#include "x2_inc_switches"
#include "x0_i0_position"
location GetStepOppositeLocation(object oTarget);
  effect invs;
   object book;
void main()
{
    int nEvent = GetUserDefinedItemEventNumber();    //Which event triggered this
    object oPC;                                                           //The player character using the item
    object oItem;                                                        //The item being used
    object oSpellOrigin;                                               //The origin of the spell
    object oSpellTarget;                                              //The target of the spell
    int iSpell;                                                             //The Spell ID number
    //Set the return value for the item event script
    // * X2_EXECUTE_SCRIPT_CONTINUE - continue calling script after executed script is done
    // * X2_EXECUTE_SCRIPT_END - end calling script after executed script is done
    int nResult = X2_EXECUTE_SCRIPT_END;
    switch (nEvent)
    {
        case X2_ITEM_EVENT_ONHITCAST:
            // * This code runs when the item has the 'OnHitCastSpell: Unique power' property
            // * and it hits a target(if it is a weapon) or is being hit (if it is a piece of armor)
            // * Note that this event fires for non PC creatures as well.
            oItem  =  GetSpellCastItem();               // The item triggering this spellscript
            oPC = OBJECT_SELF;                            // The player triggering it
            oSpellOrigin = OBJECT_SELF ;               // Where the spell came from
            oSpellTarget = GetSpellTargetObject();  // What the spell is aimed at
            //Your code goes here
            break;
        case X2_ITEM_EVENT_ACTIVATE:
// * This code runs when the Unique Power property of the item is used or the item
// * is activated. Note that this event fires for PCs only
            oPC   = GetItemActivator();                 // The player who activated the item
            oItem = GetItemActivated();               // The item that was activated
           /// ActionStartConversation(oPC,"mgbook_conv", TRUE, TRUE);
           CreateObject(OBJECT_TYPE_PLACEABLE, "mageguildbookinv", GetStepOppositeLocation(oPC),FALSE,"magebookinv");
                 AssignCommand(GetObjectByTag("magebookinv"),ApplyEffectToObject
           (DURATION_TYPE_PERMANENT,EffectInvisibility(INVISIBILITY_TYPE_IMPROVED),GetObjectByTag("magebookinv")));
                AssignCommand(GetObjectByTag("magebookinv"), ActionStartConversation(oPC, "mgbook_conv", TRUE));
            //Your code goes here
            break;
        case X2_ITEM_EVENT_EQUIP:
            // * This code runs when the item is equipped
            // * Note that this event fires for PCs only
            oPC = GetPCItemLastEquippedBy();        // The player who equipped the item
            oItem = GetPCItemLastEquipped();         // The item that was equipped
            //Your code goes here
            break;
        case X2_ITEM_EVENT_UNEQUIP:
            // * This code runs when the item is unequipped
            // * Note that this event fires for PCs only
            oPC    = GetPCItemLastUnequippedBy();   // The player who unequipped the item
            oItem  = GetPCItemLastUnequipped();      // The item that was unequipped
            //Your code goes here
            break;
        case X2_ITEM_EVENT_ACQUIRE:
            // * This code runs when the item is acquired
            // * Note that this event fires for PCs only
            oPC = GetModuleItemAcquiredBy();        // The player who acquired the item
            oItem  = GetModuleItemAcquired();        // The item that was acquired
            //Your code goes here
            break;
        case X2_ITEM_EVENT_UNACQUIRE:
            // * This code runs when the item is unacquired
            // * Note that this event fires for PCs only
            oPC = GetModuleItemLostBy();            // The player who dropped the item
            oItem  = GetModuleItemLost();            // The item that was dropped
            //Your code goes here
            break;
       case X2_ITEM_EVENT_SPELLCAST_AT:
            //* This code runs when a PC or DM casts a spell from one of the
            //* standard spellbooks on the item
            oPC = OBJECT_SELF;                          // The player who cast the spell
            oItem  = GetSpellTargetObject();        // The item targeted by the spell
            iSpell = GetSpellId();                         // The id of the spell that was cast
                                                                    // See the list of SPELL_* constants
            //Your code goes here
            //Change the following line from X2_EXECUTE_SCRIPT_CONTINUE to
            //X2_EXECUTE_SCRIPT_END if you want to prevent the spell that was
            //cast on the item from taking effect
            nResult = X2_EXECUTE_SCRIPT_CONTINUE;
            break;
    }
    //Pass the return value back to the calling script
    SetExecutedScriptReturnValue(nResult);
}
 location GetStepOppositeLocation(object oTarget)
{
    float fDir = GetFacing(oTarget);
    float fAngleOpposite = GetOppositeDirection(fDir);
    return GenerateNewLocation(oTarget,
                               DISTANCE_TINY,
                               fDir,
                               fAngleOpposite);
}
 

#2
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Easiest way to do this, make a new blueprint using the "Invisible Object" found under the Misc drop down. Give it the tag you want and the conversation you want. Then your chunk of code should look like this:


case X2_ITEM_EVENT_ACTIVATE:
// * This code runs when the Unique Power property of the item is used or the item
// * is activated. Note that this event fires for PCs only
oPC   = GetItemActivator();                 // The player who activated the item
oItem = GetItemActivated();               // The item that was activated
location lLoc = GetLocation(oPC);
object oBook = CreateObject(OBJECT_TYPE_PLACEABLE, "mageguildbookinv", lLoc, FALSE, "magebookinv");

AssignCommand(oPC, ActionStartConversation(oBook, "", TRUE));
break;

Good luck.

Modifié par GhostOfGod, 16 mai 2012 - 10:07 .


#3
Failed.Bard

Failed.Bard
  • Members
  • 774 messages
I usually just have the PC converse with themselves for items, but it depends entirely what sort of effect you're trying to achieve with the conversation if that's a valid method in this instance.

#4
delmetry

delmetry
  • Members
  • 11 messages
i have tried to have the pc converse with themselves but it woulnt work from the book. This is the code i had used

AssignCommand(oPC, ActionStartConversation(oPC, "mgbook_conv", TRUE));

#5
delmetry

delmetry
  • Members
  • 11 messages
ill try yours now ghost

#6
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

delmetry wrote...

i have tried to have the pc converse with themselves but it woulnt work from the book. This is the code i had used


AssignCommand(oPC, ActionStartConversation(oPC, "mgbook_conv", TRUE));



AssignCommand(oPC,ClearAllActions());
AssignCommand(oPC, ActionStartConversation(oPC, "mgbook_conv", TRUE));

#7
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
hmm, I just a s simple obvious thought.

If you used one of the cep equipable books, you could start the conversation onEquip and unequip the book on conversation end.

#8
delmetry

delmetry
  • Members
  • 11 messages
ghost and light...neither will still work...i even tried ghosts in a new mod. with no haks and nothing

#9
delmetry

delmetry
  • Members
  • 11 messages
also ghost i had to declare location iLoc and object oBook or else i was getting errors..just fyi

#10
delmetry

delmetry
  • Members
  • 11 messages
hmm ill take a look at that light

#11
delmetry

delmetry
  • Members
  • 11 messages
sigh...i made a copy of the equipable book renamed it made a new script to match the books tag and added the conversation script that the pc talks to himself to the on equip part and still nothing

#12
delmetry

delmetry
  • Members
  • 11 messages
nm guys i figured it out...omg im dumb...the conversation was invalid cause i had it just saying test and another saying done...never had a response in them...i had just thought of it out of nowhere... can u tell im just getting back into this after 5 years..lol....thank you all for your help you were all great

#13
GhostOfGod

GhostOfGod
  • Members
  • 863 messages

GhostOfGod wrote...
location lLoc = GetLocation(oPC);
object oBook = CreateObject(OBJECT_TYPE_PLACEABLE, "mageguildbookinv", lLoc, FALSE, "magebookinv");

delmetry wrote...

also ghost i had to declare location iLoc and object oBook or else i was getting errors..just fyi


???

Modifié par GhostOfGod, 17 mai 2012 - 12:33 .


#14
delmetry

delmetry
  • Members
  • 11 messages
I had to declare them before the switch or i was getting error on the next case

#15
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
Oooohh. Cause it's a switch/case. Duh. I'm just so used to doing it if/then style I didn't even think of it. Sorry bout that.

#16
delmetry

delmetry
  • Members
  • 11 messages
No biggie i knew what it was right away

#17
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Ok I just tested this, You will need to change the name of the convo to match yours. I also could not remember if books equipted in the right or left hand. You may have to change that to the other hand. The main question if it still does not work is if the PC is getting the "convo" message.

#include "x2_inc_switches"


void main()
{
    object oPC;
    object oItem;
    int nEvent = GetUserDefinedItemEventNumber();
    switch (nEvent)
    {


        case X2_ITEM_EVENT_EQUIP:
            oPC = GetPCItemLastEquippedBy();
            oItem = GetPCItemLastEquipped();
            SendMessageToPC(oPC,"convo");
            if(!GetLocalInt(oPC,"Already_Reading"))
               AssignCommand(oPC,ActionStartConversation(oPC,"book",TRUE));
            else
              SetLocalInt(oPC,"Already_Reading",FALSE);
            break;

        case X2_ITEM_EVENT_UNEQUIP:
            oPC = GetPCItemLastUnequippedBy();
            oItem = GetPCItemLastUnequipped();
             if (IsInConversation(oPC))
             {
                AssignCommand(oPC,ActionEquipItem(oItem,INVENTORY_SLOT_LEFTHAND));
                SendMessageToPC(oPC,"You Must Finish Reading First");
                SetLocalInt(oPC,"Already_Reading",TRUE);
            }
    }
}


EDIT: ooops, corrected a line.

Modifié par Lightfoot8, 17 mai 2012 - 02:14 .


#18
delmetry

delmetry
  • Members
  • 11 messages
light ty for the testing u did the scripting we did was fine. i went with the equipable book. it was my test conversation that was the problem. i had two different options that had no responses under them so it wasnt working