Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 25 Vote(s) - 4.44 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Us To Improve the Wiki!
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
RE: Help Us To Improve the Wiki!

I never got around to adding it so i don't think it's there.
05-07-2012, 02:35 AM
Find
Homicide13 Offline
Senior Member

Posts: 323
Threads: 41
Joined: Nov 2010
Reputation: 14
RE: Help Us To Improve the Wiki!

Alright, if you don't mind once I find the time I'll probably add the section and put what you've posted here in it (with proper credit of course).

05-07-2012, 03:01 AM
Find
Theforgot3n1 Offline
Member

Posts: 192
Threads: 20
Joined: Apr 2012
Reputation: 6
RE: Help Us To Improve the Wiki!

Could anyone make a full tutorial on where to place all the home-made particles, sounds, flashbacks, etc.?? Would help A LOT!

Couldn't find on the wiki.

Confusion: a Custom Story - Ch1 for play!
http://www.frictionalgames.com/forum/thread-15477.html
About 50% built.
Delayed for now though!
05-10-2012, 04:45 PM
Website Find
Traggey Offline
is mildly amused

Posts: 3,257
Threads: 74
Joined: Feb 2012
Reputation: 185
RE: Help Us To Improve the Wiki!

(05-10-2012, 04:45 PM)Theforgot3n1 Wrote: Could anyone make a full tutorial on where to place all the home-made particles, sounds, flashbacks, etc.?? Would help A LOT!

Couldn't find on the wiki.
In the Particles, Sound and Flashback folders.
05-19-2012, 02:13 AM
Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
RE: Help Us To Improve the Wiki!

Just updated a few pages. Figured I might try to fill in a few blanks where possible. But I'm stuck on this page:
http://wiki.frictionalgames.com/hpl2/too...tor/bodies


Does anybody know what the body property "Use surface effects" in the model editor does?
(This post was last modified: 06-12-2012, 03:38 AM by Apjjm.)
06-12-2012, 03:34 AM
Find
jens Offline
Frictional Games

Posts: 4,093
Threads: 199
Joined: Apr 2006
Reputation: 202
RE: Help Us To Improve the Wiki!

Tge body should use the material settings for effects, so if this is not checked there will not be any sounds or particles created on impacts etc.
(This post was last modified: 06-12-2012, 06:57 AM by jens.)
06-12-2012, 06:57 AM
Website Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
RE: Help Us To Improve the Wiki!

(08-17-2011, 02:01 AM)Apjjm Wrote: String lists (and hence int and float by reference to localVars) using a delimited string to prevent leaking vars. It might be worth using the wiki page which would contain the implementation to document the functions instead of the code file, because the documentation takes up a massive amount of space and is the main reason i'm using folding regions.

I've been in need of a string list that can be restored from the game session, but i wanted something more flexible and self-contained than what you have provided, and so i took most of your code and converted it into a class with many modifications here and there.

Since returning 0 for "this" or calling the destructor within the constructor is not practical, the string lists are shared when two or more StringList objects are instantiated with the same StringList name, and therefore are capable of erasing each others data if one is not careful. This, however, is not a problem for my use (or anyone that knows what they're doing).

The current code isn't fully tested, but it compiles fine and what has been tested works. Turning everything into a class lets me overload certain operators (which cuts down the amount of code i have to write) and contains everything within its own scope.

//{ StringList
class StringList
{
    //{ Private members
    private string __DELIMITER;
    private string __NAME;
    private string __PREFIX;
    //}

    //{ Constructors
    /*    Best if this constructor is not used, as it'll clutter the save file (or map session) unnecessarily
     *    if multiple StringLists are instantiated using this constructor. Use StringList(string &in) instead.
     */
    StringList()
    {
        // Random name for random stringlists
        string rand;
        this.genRandName(rand);
        StringList(rand);
    }

    StringList(string &in strlist_name)
    {
        // In case people don't know what they're doing!
        if (strlist_name == "")
            this.genRandName(strlist_name);

        // Prepare StringList private members
        this.__PREFIX = "_!strlist!_";
        this.__DELIMITER = "\0";
        this.__NAME = this.__PREFIX + strlist_name;

        // Debugging purposes only; accessing the same StringList shouldn't be a problem,
        // (unless people forget what they're doing!)
        if (GetLocalVarInt(this.__NAME + "_exist") == 0)
            SetLocalVarInt(this.__NAME + "_exist", 1);

        else AddDebugMessage("WARNING: StringList("+this.__NAME+"): A list with the same name already exists!", false);

        /*    No need to set any other local map variables,
         *    in case we're re-using an existing StringList,
         *    else they'll default to 0 or an empty string anyway.
         */
    }
    //}

    //{ Destructor
    /*    This is the only noticable conflict between sharing StringLists.
     *
     *    If the programmer forgets, e.g., that the StringList they're using is within the global scope
     *    and instantiates a new StringList using the same name, the destructor will be called for the local
     *    StringList and it will therefore erase the global StringList's data as well.
     *
     *    They better hope they have debug messages enabled!
     */
    ~StringList()
    {
        // "Destory" (clear) the StringList when no longer in use
        SetLocalVarInt(this.__NAME + "_exist", 0);
        this.clear();
    }
    //}

    //{ Item removal
    void clear()
    {
        SetLocalVarInt(this.__NAME + "_count", 0);
        SetLocalVarString(this.__NAME, "");
    }

    void removeItem(int idx)
    {
        this.takeAt(idx);
    }

    void removeItem(string &in str_item)
    {
        this.opSubAssign(str_item);
    }

    // Removes item at idx from the list and returns it
    string takeAt(int idx)
    {
        if (this.count() == 0)
        {
            AddDebugMessage("WARNING: StringList("+this.__NAME+").takeAt("+idx+"): List is empty; returning empty string!", false);
            return "";
        }

        string new_list = "";
        string op;
        int count = 0;

        string[] str_items;
        this.items(str_items);

        for(int i = 0; i < str_items.length(); i++)
        {
            if(i != idx)
            {
                new_list += str_items[i] + this.__DELIMITER;
                count++;
            }

            else op = str_items[i];
        }

        SetLocalVarInt(this.__NAME + "_count", count);
        SetLocalVarString(this.__NAME, new_list);

        return op;
    }

    //{ Subtract Assignment operator
    // Called when trying to do something like: StringList -= "String to remove"
    StringList@ opSubAssign(string &in str_item)
    {
        string new_list = "";
        int count = 0;

        string[] str_items;
        this.items(str_items);

        for (int i = 0; i < str_items.length(); i++)
        {
            if (str_items[i] != str_item)
            {
                new_list += str_items[i] + this.__DELIMITER;
                count++;
            }
        }

        SetLocalVarInt(this.__NAME + "_count", count);
        SetLocalVarString(this.__NAME, new_list);

        return this;
    }
    //}
    //}

    //{ StringList size
    int count() const
    {
        return GetLocalVarInt(this.__NAME + "_count");
    }

    int length() const
    {
        return this.count();
    }

    int size() const
    {
        return this.count();
    }
    //}

    //{ Item search/retrieval
    int indexOf(string &in str_item)
    {
        int index = -1;

        string[] str_items;
        this.items(str_items);

        for (int i = 0; i < str_items.length(); i++)
        {
            if (str_item == str_items[i])
                return i;
        }

        return index;
    }

    string itemAt(int idx)
    {
        return this.opIndex(idx);
    }

    // private keyword seems to force a void return type;
    // relying on &out instead.
    private void items(string[] &out output) const
    {
        string str = GetLocalVarString(this.__NAME);
        int outputIndex = 0;

        if (!StringContains(str, this.__DELIMITER))
            return;

        uint8 dlm = this.__DELIMITER[0];
        int last = 0;

        for (int i = 0; i < str.length(); i++)
        {
            if (str[i] == dlm)
            {
                int len = i - last;

                if (len >= 0)
                {
                    output.resize(outputIndex+1);
                    output[outputIndex] = StringSub(str,last,len);
                    outputIndex++;
                }

                last = i+1;
            }
        }
    }
    //}

    //{ Add Assignment operator
    // Called when trying to do something like: StringList += "String to be appended"
    StringList@ opAddAssign(string &in str_item)
    {
        // What's the point of adding an empty string?
        if (str_item == "")
        {
            AddDebugMessage("WARNING: StringList("+this.__NAME+")+=: Empty string found; rejecting item!", false);
            return this;
        }

        AddLocalVarInt(this.__NAME + "_count", 1);
        AddLocalVarString(this.__NAME, str_item + this.__DELIMITER);
        return this;
    }

    // Called when trying to do something like: StringList += {"String to be appended", "String to be appended"}
    StringList@ opAddAssign(string[] &in str_items)
    {
        // What's the point of adding an empty list?
        if (str_items.length() == 0)
        {
            AddDebugMessage("WARNING: StringList("+this.__NAME+")+=: Empty string array found; rejecting array!", false);
            return this;
        }

        for (int i = 0; i < str_items.length(); i++)
        {
            if (str_items[i] != "")
            {
                AddLocalVarInt(this.__NAME + "_count", 1);
                AddLocalVarString(this.__NAME, str_items[i] + this.__DELIMITER);
            }

            else AddDebugMessage("WARNING: StringList("+this.__NAME+")+=: Empty string found; rejecting item!", false);
        }

        return this;
    }

    // Called when trying to do something like: StringList += StringList
    StringList@ opAddAssign(const StringList &in str_list)
    {
        // What's the point of adding an empty list?
        if (str_list.count() == 0)
        {
            AddDebugMessage("WARNING: StringList("+this.__NAME+")+=: Empty string list found; rejecting list!", false);
            return this;
        }

        for (int i = 0; i < str_list.count(); i++)
        {
            if (str_list[i] != "")
            {
                AddLocalVarInt(this.__NAME + "_count", 1);
                AddLocalVarString(this.__NAME, str_list[i] + this.__DELIMITER);
            }

            else AddDebugMessage("WARNING: StringList("+this.__NAME+")+=: Empty string found; rejecting item!", false);
        }

        return this;
    }
    //}

    //{ Item/List replacement
    void replace(string &in str_item, string &in with)
    {
        string[] str_items;
        this.items(str_items);

        for (int i = 0; i < str_items.length(); i++)
        {
            if (str_item == str_items[i])
            {
                str_items[i] = with;
                break;
            }
        }
    }

    //{ Assignment operator
    // Called when trying to do something like: StringList = "String to completely replace the list"
    StringList@ opAssign(string &in str_item)
    {
        if (str_item != "")
        {
            SetLocalVarInt(this.__NAME + "_count", 0);
            SetLocalVarString(this.__NAME, "");
            return this.opAddAssign(str_item);
        }

        else
        {
            AddDebugMessage("WARNING: StringList("+this.__NAME+")=: Empty string found; rejecting item!", false);
            return this;
        }
    }

    // Called when trying to do something like: StringList = StringList
    StringList@ opAssign(const StringList &in str_list)
    {
        if (str_list.count() != 0)
        {
            SetLocalVarInt(this.__NAME + "_count", 0);
            SetLocalVarString(this.__NAME, "");
            return this.opAddAssign(str_list);
        }

        else
        {
            AddDebugMessage("WARNING: StringList("+this.__NAME+")=: Empty string list found; rejecting list!", false);
            return this;
        }
    }

    // Called when trying to do something like: StringList[i] = "string to insert at index i"
    void set_opIndex(int idx, string &in str_item)
    {
        if (idx >= 0 && idx < this.count())
            this.replace(this.itemAt(idx), str_item);

        else if (idx == this.count())
            this.opAddAssign(str_item);

        else AddDebugMessage("WARNING: StringList("+this.__NAME+")["+idx+"]=: Index is out of supported range; rejecting assignment!", false);
    }
    //}
    //}

    //{ Equals operator
    // Called when trying to do something like: StringList == StringList
    bool opEquals(const StringList &in compare)
    {
        return (this.__NAME == compare.name());
    }

    // Called when trying to do something like: StringList == "String"
    bool opEquals(string &in compare)
    {
        int idx = this.indexOf(compare);
        return (idx != -1);
    }
    //}

    //{ Index operator
    // Called when trying to do something like: StringList[i]
    string opIndex(int idx) const
    {
        if (this.count() == 0)
        {
            AddDebugMessage("WARNING: StringList("+this.__NAME+")["+idx+"]: List is empty; returning empty string!", false);
            return "";
        }

        string item = "";

        if (idx >= 0 && idx < this.count())
        {
            string[] names;
            this.items(names);

            // if(idx < names.length())
            item = names[idx];
        }

        return item;
    }
    //}

    //{ Shift Left operator
    // Called when trying to do something like: StringList << "String to be appended"
    StringList@ opShl(string &in str_item)
    {
        return this.opAddAssign(str_item);
    }

    // Called when trying to do something like: StringList << {"String to be appended", "String to be appended"}
    StringList@ opShl(string[] &in str_items)
    {
        return this.opAddAssign(str_items);
    }

    // Called when trying to do something like: StringList << StringList
    StringList@ opShl(const StringList &in str_list)
    {
        return this.opAddAssign(str_list);
    }
    //}

    //{ Debugging
    // Print all items to screen and hpl.log
    // raw: should we also print the local map variable string?
    void print(bool raw)
    {
        string[] str_items;
        this.items(str_items);

        if (raw)
        {
            AddDebugMessage(this.rawValue(), false);
            Print("Printing raw value from "+this.__NAME+": " + this.rawValue() + "\n");
        }

        Print("\n\nPrinting items from "+this.__NAME+":\n");
        for (int i = 0; i < str_items.length(); i++)
        {
            AddDebugMessage(i+": "+str_items[i], false);
            Print(i+": "+str_items[i] + "\n");
        }
        Print("\n");
    }
    //}

    //{ StringList property retrieval
    string name() const
    {
        return this.__NAME;
    }

    string rawValue() const
    {
        return GetLocalVarString(this.__NAME);
    }
    //}

    //{ Misc
    // private keyword seems to force a void return type;
    // relying on &out instead.
    private void genRandName(string &out rand)
    {
        string salt = "abcdefghijklmnopqrstuvwxyz1234567890";
        rand = salt[RandInt(0, salt.length() - 1)]
             + salt[RandInt(0, salt.length() - 1)]
             + salt[RandInt(0, salt.length() - 1)]
             + salt[RandInt(0, salt.length() - 1)]
             + salt[RandInt(0, salt.length() - 1)]
             + salt[RandInt(0, salt.length() - 1)]
             + salt[RandInt(0, salt.length() - 1)]
             + salt[RandInt(0, salt.length() - 1)];
        // return rand;
    }
    //}
}
//}

Example code:

PHP Code: (Select All)
StringList string_list("TEST_LIST");

// Add values to the list
string_list += "Test string 1";
string_list += "Test string 2";
string[] string_array = {"Test string 3""Test string 4"};
string_list += string_array;
string_list << "Test string 5"
            
<< ""// empty strings are rejected and so not stored in the list

// Print items and value to screen and hpl.log
string_list.print(true);

// Check if "Test string 1" is found in the list
if (string_list == "Test string 1")
    Print(
"\n\nContains Test string 1\n\n");

// Remove "Test string 1" from the list
string_list -= "Test string 1";

// Print items and value to screen and hpl.log
string_list.print(true); 

Tutorials: From Noob to Pro
(This post was last modified: 08-02-2012, 10:14 PM by Your Computer.)
07-28-2012, 05:40 PM
Website Find
Finzy Offline
Junior Member

Posts: 12
Threads: 3
Joined: Dec 2010
Reputation: 0
RE: Help Us To Improve the Wiki!

Hello, why is the first "minimum required to get a level to load" tutorial deleted from here?:
http://wiki.frictionalgames.com/hpl2/tutorials/start

I could swear it was there before, did the wiki get attacked by spammers?

Also spotted a weirdly titled level editor tutorial:
http://wiki.frictionalgames.com/hpl2/tut...iferorange

Frustrating since I was just thinking of starting to learn the editor. :/
(This post was last modified: 08-04-2012, 03:36 PM by Finzy.)
08-04-2012, 03:33 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
RE: Help Us To Improve the Wiki!

(08-04-2012, 03:33 PM)Finzy Wrote: Hello, why is the first "minimum required to get a level to load" tutorial deleted from here?:
http://wiki.frictionalgames.com/hpl2/tutorials/start

I've restored an older version of that page. It should work now.

The other link posted, i didn't see any real issue with it.

Tutorials: From Noob to Pro
08-04-2012, 04:35 PM
Website Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
RE: Help Us To Improve the Wiki!

Can I post a tutorial of how to make a rope? I know how to do them, and the tutorial in the wiki is... denied?

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
10-26-2012, 04:31 PM
Find




Users browsing this thread: 6 Guest(s)