1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Hey Guest, is it this your first time on the forums?

    Visit the Beginner's Box

    Introduce yourself, read some of the ins and outs of the community, access to useful links and information.

    Dismiss Notice

question about this code in KnightLogic

Discussion in 'Modding Help' started by Shadowblitz16, Aug 16, 2017.

Thread Status:
Not open for further replies.
  1. Shadowblitz16

    Shadowblitz16 Ballista Bolt Thrower

    Messages:
    158
    does anybody know what this code does in KnightLogic.as?
    Code:
    void TakeItem(CBlob@ this, const string &in name)
    {
        CBlob@ carried = this.getCarriedBlob();
        if (carried !is null)
        {
            if (carried.getName() == name)
            {
                carried.server_Die();
                return;
            }
        }
    
        CBitStream reqs, missing;
        AddRequirement(reqs, "blob", name, "Bombs", 1);
        CInventory@ inv = this.getInventory();
    
        if (inv !is null)
        {
            if (hasRequirements(inv, reqs, missing))
            {
                server_TakeRequirements(inv, reqs);
            }
            else
            {
                warn("took a bomb even though we dont have one! KnightLogic.as");
            }
        }
        else
        {
            warn("our inventory was null! KnightLogic.as");
        }
    }
    
    and do I need to add additional code to handle my new bombs?

    EDIT: this seems to have normal bomb references too
    Code:
    void onAddToInventory(CBlob@ this, CBlob@ blob)
    {
        const string itemname = blob.getName();
        if (this.isMyPlayer() && this.getInventory().getItemsCount() > 1)
        {
            for (uint j = 1; j < bombTypeNames.length; j++)
            {
                if (itemname == bombTypeNames[j])
                {
                    SetHelp(this, "help inventory", "knight", "$Help_Bomb1$$Swap$$Help_Bomb2$         $KEY_TAP$$KEY_F$", "", 2);
                    break;
                }
            }
        }
    
        if (this.getInventory().getItemsCount() == 0 || itemname == "mat_bombs")
        {
            for (uint j = 0; j < bombTypeNames.length; j++)
            {
                if (itemname == bombTypeNames[j])
                {
                    this.set_u8("bomb type", j);
                    return;
                }
            }
        }
    }
    
     
  2. most likely you need to add your bombs in KnightCommon.as arrays
    bombNames
    bombIcons
    bombTypeNames
     
  3. Shadowblitz16

    Shadowblitz16 Ballista Bolt Thrower

    Messages:
    158
    nope already did that.
    they are in the exact order as well
    --- Double Post Merged, Aug 23, 2017, Original Post Date: Aug 17, 2017 ---
    this can be closed I don't think they have anything to do with adding new bombs
     
Thread Status:
Not open for further replies.