Jump to content

Photo

Item Remover


  • Please log in to reply
4 replies to this topic

#1 Sans

Sans

    Hey kid wanna buy hot dogs ?

  • Members
  • Location:Judgement Hall

Posted 23 March 2022 - 08:13 PM

hello everyone. I would like to ask a small script request.

I call it the "Item Remover". The function is quite simple: When the player enter inside a room, a specific item (item ID would be D0) is forcely removed from the inventory forever (it only once per room via ffc. After that the said ffc wouldn't work after going in that room once again.). As results the player will have to find the item once again. The good idea on that would be boss keys especially on a dungeon with more then one boss doors, and boss keys. For example, let's say that your dungeon have at least 50 or 99 floors. And you want to put bosses every 10 floors but you don't want to break the game with the same boss key. And as such you'll may want to have something that removes that boss key from the inventory until you get it once again, and so on. This is something i want to test it out on futures dungeons and such. I don't specially want to remove the boss key from the inventory immediately after opened the boss door, that would be too obivious that something's up on certain parts of dungeon.



#2 TheRock

TheRock

    Go glitches

  • Members

Posted 24 March 2022 - 10:33 AM

Here: D0 is the level number of the DMap. Will work like this: Once you enter room then if the secrets have not been triggered and have boss key then it sets the secrets and gets rid of the boss key. Make sure to make it a room that has it's own secret. Like for example, make a fake room where the player goes to then get rid of the boss key. EDIT I don't know are to compare the values so will need to fix this. EDIT: Will need both the compass and the map before this cause right now it just sets both the Map and Compass and then gets rid of the boss key.

ffc script BossKeyRemove
{
void run(int level)
{

if(!Screen->State[ST_SECRET] ) {
Game->LItems[level] = LI_MAP|LI_COMPASS;
Screen->TriggerSecrets();
Screen->State[ST_SECRET] = true;

}


Waitframe();
}
}

Edited by TheRock, 24 March 2022 - 11:25 AM.


#3 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 24 March 2022 - 12:14 PM

ffc script BossKeyRemove
{
    void run(int level)
    {
        if(level < 0) level = Game->GetCurLevel();
        if(!Screen->State[ST_SECRET])
        {
            Game->LItems[level] &= ~LI_BOSSKEY;
            Screen->TriggerSecrets();
            Screen->State[ST_SECRET] = true;
        }
    }
}
Fixed that for you.
You want to UNSET the bosskey bit, not touch anything to do with the other bits.

The above version works for 2.53, though 2.55 can be a bit cleaner:
ffc script BossKeyRemove
{
    void run(int level)
    {
        if(level < 0) level = Game->GetCurLevel();
        unless(Screen->State[ST_SECRET])
        {
            Game->LItems[level] ~= LI_BOSSKEY;
            Screen->TriggerSecrets();
            Screen->State[ST_SECRET] = true;
        }
    }
}
This only works for boss keys, other items and other level items would need to be their own thing.

#4 TheRock

TheRock

    Go glitches

  • Members

Posted 24 March 2022 - 12:19 PM

Thanks, didn't know how to do that.



#5 Emily

Emily

    Scripter / Dev

  • ZC Developers

Posted 24 March 2022 - 03:44 PM

Thanks, didn't know how to do that.

General bitwise information:

Take the variable as a binary number, all 0s and 1s.

"&" == Bitwise AND. Basically does the same things as "&&", but for each individual bit in the variable.

"|" == Bitwise OR. Basically does the same thing as "||", but ....

"~" == Bitwise NOT. Basically the same as "!", but....

so, yeah, it's really just the boolean operators again, but for each bit in the variable.

 

So, what actually is important here?

In 2.55, "~=" was added; this is just a shortcut that does the same thing as "&= ~()".

To SET a bit, you OR it. So, "var |= BIT_CONSTANT;"

To UNSET a bit, you AND the INVERSE; so, "var &= ~BIT_CONSTANT;", or in 2.55, "var ~= BIT_CONSTANT;"




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users