FORUM ARCHIVED

I need some help with a broken code

Discussion in 'Modding' started by FaustoMartense, Jul 2, 2012.

  1. Hello, I followed some advices and decided to create a variation of the meltdown mod for traps. So far I have several items like this one;

    Code:
    <item name="Boulder Kit I" iconFile="items/explosive_kit_l1.png" level="1">
        <description text="Text."/>
        <potion spell="Boulder Kit I"/>
        <price amount="110" />
    </item>
    I am able to craft the Boulder Kit I but when I use it, the spell do not trigger or the spell values are wrong and do nothing.
    Here is my spellDB:

    Code:
    <!---trap kit sumonner--->
    <spell name="Conjure pressure plate" type="self">
            <effect type="spawn" itemname="Pressure Plate" amount ="1"/>
            </spell>
     
    <spell name="Conjure black powder" type="self">
            <effect type="spawn" itemname="Black Powder" amount="1"/>
            </spell>
     
    <spell name="Conjure brass piping" type="self">
            <effect type="spawn" itemname="Brass Piping" amount="1"/>
            </spell>
     
    <spell name="Conjure verdant potion" type="self">
            <effect type="spawn" itemname="Verdant Potion" amount="1"/>
            </spell>
     
    <spell name="Conjure voltaic cell" type="self">
            <effect type="spawn" itemname="Voltaic Cell" amount="1"/>
            </spell>
         
    <spell name="Conjure iron bolt" type="self">
            <effect type="spawn" itemname="Iron Bolt" amount="1"/>
            </spell>
     
    <spell name="Conjure rock wand" type="self">
            <effect type="spawn" itemname="Rock Wand" amount="1"/>
            </spell>
         
    <spell name="Conjure iron ingot" type="self">
            <effect type="spawn" itemname="Iron Ingot" amount="1"/>
            </spell>
     
    <!---trap kit--->
    <spell name="Boulder Kit I" type="self" icon="skills/skill_thrown_small.png">
            <spell="Conjure pressure plate" effect type="trigger"  percent="70" />
            <spell="Conjure rock wand" effect type="trigger" percent="30" />
            <anim sprite="sprites/sfx/glintA/glintA" frames="5" framerate="60" sfx="ping" />
    </spell>    
    I need the Boulder Kit I to have a chance of giving the different components of the trap. In this case I improvised because there is not a recipe for the boulder trap. So I picked the classic pressure plate and the rock wand.
    If I manage the code to work, I would add the spell that triggers with the mine targeting the player. That way there is a small chance that the mine would explode by accident. (Is there a way to change the susscess rate or it would always respond to the percent rate of the spell?)

    Thanks in advance.
     
  2. Kazeto

    Kazeto Member

    For one, you appear to have raped your XML code pretty violently, since the tag you were supposed to use is "<effect>" and not '<spell="Conjure pressure plate">'. That being said, this is the corrected code:
    Code:
    <!---trap kit--->
    <spell name="Boulder Kit I" type="self" icon="skills/skill_thrown_small.png">
        <effect type="trigger" spell="Conjure pressure plate" percent="70"/>
        <effect type="trigger" spell="Conjure rock wand" percent="30"/>
        <anim sprite="sprites/sfx/glintA/glintA" frames="5" framerate="60" sfx="ping"/>
    </spell>
    And if anything, the percentual chances there are independent from each other, so with it being the way it is now, the possible outcomes are these:

    21% chance to get both items
    49% chance to get only a pressure plate
    9% chance to get only a rock wand
    21% chance to get neither item

    To make it give pressure plate 70% of the time and rock wand whenever it doesn't give you the pressure plate (so that it always gives you something), you need to use the following code:
    Code:
    <!---trap kit--->
    <spell name="Boulder Kit I" type="self" icon="skills/skill_thrown_small.png">
        <effect type="triggerfromlist">
            <option name="Conjure pressure plate"/>
            <option name="Conjure pressure plate"/>
            <option name="Conjure pressure plate"/>
            <option name="Conjure pressure plate"/>
            <option name="Conjure pressure plate"/>
            <option name="Conjure pressure plate"/>
            <option name="Conjure pressure plate"/>
            <option name="Conjure rock wand"/>
            <option name="Conjure rock wand"/>
            <option name="Conjure rock wand"/>
            </effect>
        <anim sprite="sprites/sfx/glintA/glintA" frames="5" framerate="60" sfx="ping"/>
    </spell>
    
    Also, it is possible to change the success rate. But right now, I have to say it lies beyond your capabilities; you'll be able to make it work like that when you have enough experience with fiddling in the code to notice the way to do it on your own (either way, it's a pretty inelegant method right now, due to lack of some hooks that would make it easier to achieve such a thing).

    For now, I recommend taking a look at this site and the tutorials you can find on it:
    http://dredmod.com/wiki/Main_Page
     
    OmniNegro likes this.
  3. OmniaNigrum

    OmniaNigrum Member

    I should sig this. :)
     
    Kazeto likes this.
  4. Kazeto

    Kazeto Member

    Sure, go ahead.
     
    OmniNegro likes this.
  5. Well, pretty much everything related to XML codes is beyond capabilities right now. ;)

    I used Essential DoD Skills II as a base for the spellDB. He used a similar one for the Secret Sword and it worked pretty well for him, it was almost the same. He created spells to conjure items and them put these spells inside the spell he was going to use to "summon" the weapons. I just copied and pasted the code.

    Thanks a lot for the help and coding. :)
     
    Kazeto likes this.
  6. Kazeto

    Kazeto Member

    Don't worry, it becomes easier as you make things. You just need to try, and if anything fails, there's nothing stopping you from asking how to solve a problem just like you did now (if anything, if someone tells you why exactly are some changes supposed to be there, you gain additional knowledge that you might not have reached for on your own).

    I see your point, and I also see where the problem stemmed from - in Essence's "Secret Sword", one of the outcomes appeared always, and the other ones had independent chances to be triggered then. And something like that, while not necessarily bad, isn't optimal as a base for what you are trying to make. Still, it is a good start.

    No problem, feel free to ask if there's anything else. If anything, it's good to get away from my own hell of a code sometimes and look at something less convoluted.
     
    OmniNegro and FaustoMartense like this.
  7. I am not able to make it work. I tried with this one.
    Code:
    <spell name="Boulder Kit I" type="self" icon="skills/skill_thrown_small.png">
        <effect type="triggerfromlist">
            <option name="Conjure pressure plate"/>
            <option name="Conjure pressure plate"/>
            <option name="Conjure pressure plate"/>
            <option name="Conjure pressure plate"/>
            <option name="Conjure pressure plate"/>
            <option name="Conjure rock wand"/>
            <option name="Conjure rock wand"/>
            <option name="Conjure rock wand"/>
            <option name="Conjure rock wand"/>
            </effect>
        <anim sprite="sprites/sfx/glintA/glintA" frames="5" framerate="60" sfx="ping"/>
    </spell>
    And I also tried with the other method for a obligatory pressure plate and optional rock wand but it doesnt work.

    Code:
    <spell name="Boulder Press" type="self" icon="skills/skill_thrown_small.png">
        <effect type="trigger" spell="Conjure pressure plate"/>
        <effect type="trigger" spell="Conjure rock wand" percent="70"/>
        <anim sprite="sprites/sfx/glintA/glintA" frames="5" framerate="60" sfx="ping"/>
    </spell>
    Is my item spawning spell correct?

    Code:
    <spell name="Conjure rock wand" type="self">
            <effect type="spawn" itemname="Rock Wand" amount="1"/>
    </spell>
    I failed for two hours, I do not know what is failing.
     
  8. Ruigi

    Ruigi Will Mod for Digglebucks

    try spawnitemfromlist rather than spawn, and add Rock Wand as an option.

    general rule of thumb is to copy/paste something that you KNOW will work, and then edit it so that it works the way you want. It's easier to backtrack your mistake that way.
     
    Kazeto likes this.
  9. Frelus

    Frelus Member

    I do not know, but since spells have to be copied into the mod, I think you have to copy the rock wand data into your itemDB, too.
    That's the only thing I can think of right know, but as kazeto can tell you, I am only a *very* amateur modder.

    Edit: Ah damn, or not.
     
  10. I will try changing to spawnitemfromlist later. I am not sure about adding the items again in my itemDB, I think that would cause some items to duplicate.

    Anyway I think I am passing the torch to SHiLLySiT (Meltdown´s creator)... aparently modding is not for me. :/
     
  11. Essence

    Essence Will Mod for Digglebucks

    Don't do that! Persevere! We're all rooting for you. No, seriously, don't give up now!
     
    Syphonix likes this.
  12. Syphonix

    Syphonix Member

    I agree. Don't give in! You can do it!
     
  13. D´awww. So much love.

    I will give it a try, maybe I will ditch this crafting mod in favor of a skill tree. I still need to find a nice theme.
     
  14. Essence

    Essence Will Mod for Digglebucks

    Skills are by far the funnest thing to mod. Ignore Bergstrom when he tries to tell you otherwise. :p
     
  15. OmniaNigrum

    OmniaNigrum Member

    99% or more of the coders out there would be *Happy* for you to blatantly steal their code to do what you want. You can safely ignore anyone who thinks that they actually own the XML for the game. We have a modding section of these forums for a reason. Even if you only mod an existing mod, that is still a mod.

    And I pledge to rant and rave on anyone who says otherwise and is actually serious. I really doubt it will happen.

    You can make any mod you want using code snippets from any or even all existing mods. If anyone objects, we can Evergreen it and laugh our asses off. :p
     
    Frelus likes this.
  16. I messed a little with an Imaginary Gunslinger tree and it was very fun but when I have the first two spells I clicked Delete in notepad+ expecting the file to Close... of course it deleted all. I got frustrated and put the idea aside.

    It is really difficult and frustrating, but you get to appreciate a lot more all the cool mods out there.


    EDIT: (Just read OmniNegro´s reply) If anything fails, I already got a cool quote from Kazeto haha.
     
    Kazeto and OmniNegro like this.
  17. I am still encountering the same problem no matter which code I try. I used Ninjitsu, Paladinner and the Odious Puffball item as references, but even when the code works for them, it is not working for me.

    I tried a lot of methods, directly and indirectly. I tried to make one item casts a spell to summon one item directly, it did not work, then added a trigger for another spell with spawnfromlist for more optional items. Still not working.
    So far I tried a lot of variations of spawn, spawnitemfromlist, spawnatlocation but nothing seems to work. What Am I doing wrong? I am using codes that worked in others mods, I even copied the Odious Puffball spell to summon the item I want directly, but nothing works.

    Any idea?
     
  18. Kazeto

    Kazeto Member

    Post the code used for the spells, and we'll tell you what's wrong.

    You can either use the [.code] [/.code] tags (remove the dot if you want them to work), upload your spellDB.xml file, or upload the whole mod-in-progress. Any of those is fine, since whatever is wrong is most likely located in that file.
     
  19. I uploaded all the mod in progress. Please note that the current spellDB do not show all my attempts, just the last, since the coding mutated several times without success.

    It also have a spellDBORIGINAL that was a previous attempt.

    What is really puzzling me if the fact that I could not trigger something as simple as a summoning one item with a spell linked to another item. I tried giving the item the tag potion, food, mushroom but neither worked.

    I will appreciate the help :) thanks a lot in advance.
     

    Attached Files:

  20. Kazeto

    Kazeto Member

    Here is a slightly cleaned-up version. I removed all the weird things that somehow managed to slip themselves past your guard, and you can try checking if it works (though you'd have to comment out the triggers that call non-existent spells from "itemDB.xml".

    The whole thing is untested (it's 1 A.M. there, and I don't have time to get through the process of launching the game and finding traps), but it should work. Either way, it's not that different from the previous code, really.

    Code:
    <spellDB>
    
    <!--trap kit sumonner-->
    <spell name="Conjure Pressure Plate" type="self">
        <effect type="spawn" itemname="Pressure Plate" amount="1"/>
    </spell>
    
    <spell name="Conjure Black Powder" type="self">
        <effect type="spawn" itemname="Black Powder" amount="1"/>
    </spell>
    
    <spell name="Conjure Conjure Brass Piping" type="self">
        <effect type="spawn" itemname="Brass Piping" amount="1"/>
    </spell>
    
    <spell name="Conjure Verdant Potion" type="self">
        <effect type="spawn" itemname="Verdant Potion" amount="1"/>
    </spell>
    
    <spell name="Conjure Voltaic Cell" type="self">
        <effect type="spawn" itemname="Voltaic Cell" amount="1"/>
    </spell>
    
    <spell name="Conjure Rock Wand" type="self">
        <effect type="spawn" itemname="Rock Wand" amount="1"/>
    </spell>
    
    <spell name="Conjure Iron Ingot" type="self">
        <effect type="spawn" itemname="Iron Ingot" amount="1"/>
    </spell>
    
    <!--trap kit-->
    <spell name="Dwarven IED" type="self">
        <description text="Summon Dwarven IED pieces."/>
        <effect type="spawn" itemname="Pressure Plate" amount="1"/>
        <effect type="trigger" spell="Dwarven IED II" />
        <anim sprite="sprites/sfx/glintA/glintA" frames="5" framerate="60" sfx="ping" />
        </spell>
    
    <spell name="Dwarven IED II" type="self">
        <effect type="spawnitemfromlist">
            <option name="Pressure Plate"/>
            <option name="Pressure Plate"/>   
            <option name="Black Powder"/> 
            </effect>
        </spell>
    
    <spell name="Crude Blade" type="self" >
        <effect type="spawnitematlocation" itemname="Pressure Plate" amount="1"/>
        <effect type="trigger" spell="Crude Blade II" />
        <anim sprite="sprites/sfx/glintA/glintA" frames="5" framerate="60" sfx="outtake2a" />
        </spell>
    
    <spell name="Crude Blade II" type="self">
        <effect type="spawnitemfromlist">
            <option name="Pressure Plate"/>
            <option name="Pressure Plate"/>   
            <option name="Iron Ingot"/> 
            </effect>
        </spell>
    
    <spell name="Toxic" type="self" >
        <effect type="spawnitematlocation" itemname="Pressure Plate" amount="1"/>
        <effect type="trigger" spell="Toxic II" />
        <anim sprite="sprites/sfx/glintA/glintA" frames="5" framerate="60" sfx="outtake2a" />
        </spell>
    
    <spell name="Toxic II" type="self">
        <effect type="spawnitemfromlist">
            <option name="Pressure Plate"/>
            <option name="Pressure Plate"/>   
            <option name="Brass Piping"/>
            <option name="Verdant Potion"/>
            </effect>
        </spell>
    
    </spellDB>
     
    OmniNegro likes this.