Author Topic: vector question  (Read 334 times)

Legacy_DM_Vecna

  • Hero Member
  • *****
  • Posts: 501
  • Karma: +0/-0
vector question
« on: September 15, 2010, 01:04:24 am »


               I am trying to implement some of the C.R.A.P. scripts into my new pw project but I am having an issue with this vector script. I changed the item that triggers this from spell cast to item activate. I am nto sure if that could be the source of the problem . But it is saying I dont have line of sight when there is nothing in between the pc and the item targeted. Let me know if anyone sees anything I do not. I am not to used to this function "if(!LineOfSightVector(vPC, vTarget))".


void awa_UsePlayerWidget(object oPC, object oPlayerWidget){location lPawLoc = GetItemActivatedTargetLocation();object oTarget = GetItemActivatedTarget();object oPit = GetNearestObjectToLocation(OBJECT_TYPE_PLACEABLE, GetItemActivatedTargetLocation());int nType = GetObjectType(oTarget);int nJump = (nType == 0 && GetIsJumpProbable());
int nSpikes = GetIsObjectValid(GetItemPossessedBy(oPC, "crpi_ironspikes"));int nRope = GetIsObjectValid(GetItemPossessedBy(oPC, "crpi_rope"));int nGrapRope = GetIsObjectValid(GetItemPossessedBy(oPC, "crpi_graprope"));int nMallet = GetIsObjectValid(GetItemPossessedBy(oPC, "crpi_spk_mallet"));
int nOpen = ((nType == OBJECT_TYPE_DOOR || OBJECT_TYPE_PLACEABLE) && GetIsOpen(oTarget));int nHiddenCompartment = (GetObjectType(oTarget) == OBJECT_TYPE_PLACEABLE && GetLocalInt(oTarget, "DOOR") != 1);
AWA_DEBUG("tag_playerwidget: 1");
    //:::::::::::::::::::::::::::CHECK LINE OF SIGHT::::::::::::::::::::::::::::::::    //(exclude doors because they report incorrectly)    vector vPC = GetPosition(oPC);    vector vTarget;    if(nType != OBJECT_TYPE_DOOR)    {        AWA_DEBUG("awa_inc_paw - awa_UsePlayerWidget: oTarget's name = "+GetName(oTarget));        AWA_DEBUG("awa_inc_paw - awa_UsePlayerWidget: oPC's name = "+GetName(oPC));        if(nType == 0)        {        vTarget = GetPositionFromLocation(lPawLoc);        AWA_DEBUG("awa_inc_paw - awa_UsePlayerWidget: object type is invalid (0)");        }        else vTarget = GetPosition(oTarget);        if(!LineOfSightVector(vPC, vTarget))        {        AWA_DEBUG("awa_inc_paw - awa_UsePlayerWidget: no line of sight");        FloatingTextStringOnCreature("No line of sight", oPC, FALSE);        //DisplayText("No line of sight");        return;        }    } 
               
               

               


                     Modifié par DM_Vecna, 15 septembre 2010 - 12:06 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
vector question
« Reply #1 on: September 15, 2010, 01:56:43 am »


               Change this:

if(nType == 0) vTarget = GetPositionFromLocation(lPawLoc);

To this:

if(nType == -1) vTarget = GetPositionFromLocation(lPawLoc);

I think. Hope that helps.
               
               

               
            

Legacy_DM_Vecna

  • Hero Member
  • *****
  • Posts: 501
  • Karma: +0/-0
vector question
« Reply #2 on: September 15, 2010, 08:44:22 am »


               problem solved. The item I was implementing used the property cast spell: Unique Power due to the vector usage in its functions. In this case I am supposeing that OBJECT_SELF becomes the item instead of the activator. Thus the line in my on mod activate script needed to change from

int nRet =  ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),OBJECT_SELF);

to

int nRet =  ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oItem),GetItemActivator());



Everything still works with the new format so other mod builders might want to use this. that way both activate item and unique power properties will work. '<img'>