MissionScript does not work (destroy inventory!)

The best and quickest support by a group of top-notch editing specialists, guaranteed!

Moderator: Forum Guards

MissionScript does not work (destroy inventory!)

Postby DxPlayer » Sat Jan 08, 11 7:56 pm

Hello!
I'm trying to make a mission script for Deranged mod that removes the player inventory items at the first game map (player receives Pistol, Prod and medkit), but it doesn't seen to be working!

Here is the code:
Code: Select all
class DerangedMissionScript expands MissionScript;

var DRHuman DRPlayer;

function FirstFrame()
{
   DRPlayer = DRHuman(GetPlayerPawn());
   
   Super.FirstFrame();
   
   if (localURL == "54_Deranged_Training")
      {
         DRPlayer.DRKillInventory();
      }
}


DRKillInventory function is at player class (DRHuman) and it is like this:

Code: Select all
function DRKillInventory()
{
local inventory anItem;

//Original from ResetPlayerToDefaults() in DeusExPlayer class!

while(Inventory != None)
   {
      anItem = Inventory;
      DeleteInventory(anItem);
      anItem.Destroy();
      if (DeusExRootWindow(rootWindow) != None)
      DeusExRootWindow(rootWindow).hud.belt.ClearBelt();
      GiveInitialInventory();
   }
}


Any ideas? :(
Last edited by DxPlayer on Sat Jan 08, 11 8:07 pm, edited 5 times in total.
User avatar
DxPlayer
Regular
 
Posts: 488
Joined: Sun Jan 25, 09 6:31 pm
Location: Brazil

Postby ~ô¿ô~Nobody~ » Sat Jan 08, 11 9:11 pm

The Inventory is a linked list of inventory items.

if you want to delete all items, you need to iterate though the whole list.. just like you do it with the pawnlist.
..means you need a loop

Code: Select all
local Inventory inv;
local Inventory anItem;

inv=Inventory;

while(inv != none)
{
anItem=inv;
inv=inv.Inventory;
DeleteInventory(anItem);
anItem.Destroy();
}

if (DeusExRootWindow(rootWindow) != None)
      DeusExRootWindow(rootWindow).hud.belt.ClearBelt();
     
GiveInitialInventory();



That should do the job..
THe order in the loop is like it is because you cannot get the next item if you destroy the current before.

The clear belt and GiveInitialInventory (if you want to use that) doesn't need to be in the loop
Last edited by ~ô¿ô~Nobody~ on Sat Jan 08, 11 9:12 pm, edited 2 times in total.
Nobody is perfect...
------------------------------
Longc[A]t wrote:I still think Dae is a russian spambot.

~[A]Daedalus~ wrote:There will be a day when my patience goes away and you, along with all who rant with you, will get banned.

ô¿ô¥[GODZ]¥NOCHANC wrote:I can ban any one I want ANY time I want. You have no rights here.
User avatar
~ô¿ô~Nobody~
Alpha
 
Posts: 2520
Joined: Fri Dec 31, 04 3:20 pm
Location: Proclarush Taonas

Postby DxPlayer » Sat Jan 08, 11 10:14 pm

Thanks man, But no success!

I don't know where do that Pistol, Prod and Medkit come from! ResetPlayer() at DeusExPlayer indeed give it to the Player, but only if a bool is set to true!

The line that leads the player (DRHuman) to the map is it:

Code: Select all
   Player.StartNewGame(DRGameInfo(Player.Level.Game).StartMap $ "?Class=" $ PlayerClasses[portraitIndex]);


But I don't get out is ResetPlayer(True) being activated somehow.

I think there are two possibilities:

-Code do not work and player got that inventory from dx.dx
-MissionScript.FirstFrame() is faster than whatelse is giving the player the inventory and deletes a nule inventory, wich is replaced by the unwanted one.
User avatar
DxPlayer
Regular
 
Posts: 488
Joined: Sun Jan 25, 09 6:31 pm
Location: Brazil

Postby DxPlayer » Mon Jan 10, 11 3:05 am

I got it working, thanks to Wccc:

First I forgot to start the timer at the Mission Script:
Code: Select all
function Timer()
{
   Super.Timer();
}


It initialized the script into the map, however I was still getting the inventory.

Then he recommended me changing == to ~= in level name check:

Code: Select all
if (localURL ~= "54_Deranged_Training")
      {
         DRPlayer.DRKillInventory();
      }


That made the script check the map's name not case sensitive, and so those lines were executed.

Suggested by Nobody and Wccc, I changed the DRKillInventory() function to this, however I am pretty sure the old one should work since I got the script working:

Code: Select all

function DRKillInventory()
{
   local inventory i;
//Suggested by Nobody and Wccc:

   forEach AllActors(class'inventory', i)
      {
         if (i.owner == self && i.class != class'DeusEx.NanoKeyRing')
         {
            i.Destroy();
         }
      }
}


Thx guys!
Last edited by DxPlayer on Mon Jan 10, 11 3:09 am, edited 1 time in total.
User avatar
DxPlayer
Regular
 
Posts: 488
Joined: Sun Jan 25, 09 6:31 pm
Location: Brazil


Return to Editing issues

Who is online

Users browsing this forum: No registered users and 22 guests