FORUM ARCHIVED

Of Keys and Crates

Discussion in 'Modding' started by Alistaire, Apr 28, 2013.

  1. Alistaire

    Alistaire Member

    I'm having a hard time trying to make this work; getting dummy buffs from 2 potions that, when they both exist, trigger a spell that drops an item from a list.

    How to?

    ----

    My current todo-list looks like this, maybe it helps a bit more;

    - Make a stackable buff "keys" (key)
    - Make a stackable buffs for each series of "crates" (crate_1, crate_2, crate_3)
    - Both buffs are activated upon consuming the key or crate (potion spell="key")
    - When a key buff meets any series of crate buffs, remove both and cast a spell (if statements all over)
    - The spell spawns an item on the player's location (spawnitemfromlist)
    - After the item is spawned, it picks it back up (grabitem)
     
  2. Kazeto

    Kazeto Member

    The easiest way is to make both the "key" and the "crate" triggers dependant on the existence of the opposite buffs.

    If there is a "key" buff, then instead of triggering the "crate" buff the "crate" trigger would give you the item and consume the "key" buff.
    If there is no "key" buff, then the "crate" trigger gives you the "crate" buff.
    And the same thing happens the other way around - if there are no "crate" buffs (a chain of checks from the "key" trigger, starting likely from the most "valuable" one unless you want to have fun with making it so that having more than just one "crate" buff active when "key" triggers opens a random one, in which case it is slightly more tedious but still nothing to despair over) then you simply get a "key" buff.
    And if there are any "crate" buffs, then one of them (either the most valuable/whichever or a random one) is opened and the related "crate" buff is taken down.

    After that it is simple, as you wrote. So unless you have problems with the existence of the code itself (or rather lack of it, and lack of time to magic it up), I don't see where the problem would be.
     
  3. Alistaire

    Alistaire Member

    Well I do currently have this;

    http://pastebin.com/LkNmD5Ah

    But the problem is that sometimes the crates aren't removed, and sometimes the keys aren't detected by the crates..
     
  4. Kazeto

    Kazeto Member

    Give me about 10 hours from now (I'm going to work in about 15 minutes) and I'll take a serious look at it. Well, unless someone more sane decides to do it in the meantime, but considering I'm the only person to reply to this post it's not likely.
     
  5. Kazeto

    Kazeto Member

    So, looking at the code you have uploaded, I ask this:

    Wouldn't it be better to have the usage of keys/crates simply trigger the check at the start and leave it at that (only keys and crates exist, so keys can trigger crates and crates can trigger keys, only you'd have to change the "triggering hub" from the keys' triggering spell into a "triggering chain" to make it non-abusable), instead of keys' triggering spell triggering itself (sort of) until the day of apocalypse and beyond that, and doing it precisely every two turns?
    Also, why do the "crate checking" and "key checking" functions require stacks of 0 crates/keys to work?

    That being said, I can simply give you a rewrite of your code that would work, but I dare take a guess that you would prefer to get it done yourself and simply be pointed into the right direction (for the sense of achievement and satisfaction from it and such).
     
  6. Alistaire

    Alistaire Member

    Well, I'm sorry but I have no clue. I tried checking only when the keys/crates were used, but it didn't do anything. (Well obviously I did it wrong then, but oh well)
     
  7. Kazeto

    Kazeto Member

    Once again, give me a few hours. You'll get the code rewrite when I'm finished with today's tasks. I will edit this post then and post the link, so just check it even if there are no new posts.


    Edit:
    Here is the code I promised. I had no time to test it so approach with caution, but unless I did something stupid it ought to work:

    http://pastebin.com/TZyTz8As
     
    Alistaire likes this.
  8. Alistaire

    Alistaire Member

    It does the same things wrong;

    > If there's multiple crate buffs, it uncrates all of them with only one key
    > If there's only one key and you use a crate, it doesn't remove the key buff

    In my script I added a stop to uncrating multiple crates by checking if the key buff is still there. That is one fix, of course, but the stuff with crate buffs staying active after they should be removed is annoying.
     
    Kazeto likes this.
  9. Kazeto

    Kazeto Member

    I made a minor change to the whole thing (it counts as "something stupid", now that I think about it - goes with not being able to do even rudimentary tests due to simple lack of time), and it should work better now. Please try again - the link is the same, I simply edited the pastie.
     
  10. Alistaire

    Alistaire Member

    Well, it worked when I tested it.. Thanks!