Jump to content

Home

Scripting Q: Adding items to corpse in fuel depot on peragus


ermo

Recommended Posts

I'm trying to figure out how to fire a script that changes the inventory on

the corpse that T3-M4 finds in the far end of the fuel-depot on peragus

(module 103per according to the whereami armband).

 

I need to change the deadly sonic mines in the inventory to (at most) strong

sonic mines. I've thought about adding a hook to my own script in the

decompiled k_103enter script from 103PER_s.rim. Is that the correct place to

fire my own script? If not, what are my options? Did I miss something really obvious?

 

This is what I have so far (I'm not getting any messages when I enter the area with T3-M4 for the first time):

 

// k_103enter.nss
// renamed original k_103enter.ncs to 103per_enter.ncs
void main()
{
   SendMessageToPC(GetFirstPC(), "Inside k_103enter script");
   // launch the original enter script
   ExecuteScript("103per_enter", OBJECT_SELF);
   // launch additional scripts
   ExecuteScript("d20_103per", OBJECT_SELF);
}

/* FileName: d20_103per.nss
* Author: ermo
* Description: Spawn 3 Strong sonic mines instead of 3 Deadly sonic mines
*              on the corpse found by T3-M4 in the fuel depot on Peragus
*              in module 103per. With the new traps.2da, the DC of deadly
*              mines is too high at this point in the game...
*/

object D20GetPlaceableAt(float x, float y, float z)
{
   vector myVec = Vector();
   // set coordinates 
   myVec.x = x;
   myVec.y = y;
   myVec.z = z;
   // orientation doesn't matter
   location l = Location(myVec, 0f);

   return GetNearestObjectToLocation(OBJECT_TYPE_PLACEABLE, l);
}

void main() 
{
   SendMessageToPC(GetFirstPC(), "Executing d20_103per.ncs");
   string deadlySonicMine = "g_i_trapkit015";
   string strongSonicMine = "g_i_trapkit024";    

   object oFuelDepotCorpse = D20GetPlaceableAt(-30.3477, 45.9924, 11.9125);

   if (oFuelDepotCorpse != OBJECT_INVALID)
   {
       object oCurrentItem = GetFirstItemInInventory(oFuelDepotCorpse);
       string sTag;
       while (oCurrentItem != OBJECT_INVALID)
       {
           // so far, I just want to know the contents of the inventory...
           sTag = GetTag(oCurrentItem); 
           SendMessageToPC(GetFirstPC(), sTag);
           oCurrentItem = GetNextItemInInventory(oFuelDepotCorpse);
       }
   } 
   else 
   { 
       SendMessageToPC(GetFirstPC(), "Couldn't find corpse :("); 
   }
}

Link to comment
Share on other sites

I'm trying to figure out how to fire a script that changes the inventory on

the corpse that T3-M4 finds in the far end of the fuel-depot on peragus

(module 103per according to the whereami armband).

 

I need to change the deadly sonic mines in the inventory to (at most) strong

sonic mines. I've thought about adding a hook to my own script in the

decompiled k_103enter script from 103PER_s.rim. Is that the correct place to

fire my own script? If not, what are my options? Did I miss something really obvious?

 

The Area OnEnter script should work to use for something like this. However, as far as I can see the OnEnter script assigned to 103PER is a_hk50_unspawn, not k_103enter, for some peculiar reason. Try replacing that one instead.

 

As for the rest of your scripts I can't spot anything obviously wrong with them at a quick glance.

 

Though personally I would use GetItemPossessor on one of the mines instead of the location thing for simplicity's sake to get the corpse, since they only are available from that container in the area. But your method should work just as well. :)

Link to comment
Share on other sites

The Area onspawn script should work to use for something like this.

However, as far as I can see the OnEnter script assigned to 103PER is

a_hk50_unspawn, not k_103enter, for some peculiar reason. Try replacing

that one instead.

(...)

personally I would use GetItemPossessor

 

I looked at GetItemPossessor, but managed to forget about it again. Hm.

Could come in quite handy for identifying containers with unique datapads.

Actually, I think I've just decided to make it my default way of identifying

those containers.

 

And 'OnEnter' script? Ooooh. The 103PER.rim static area info file. Nice.

 

Learned something new and I'm all set to go now - thanks a bunch :)

 

*polite bow in the general direction of stoffe*

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...