1. For issues you find with the Switch and Console releases, please follow this link and give as much detail as possible. This is the speediest way to get info to Pipeworks and get a hotfix in the works.
    Dismiss Notice

tAPI Coding Help Required

Discussion in 'General Mod Discussion' started by KingKirmit, Feb 6, 2015.

  1. KingKirmit

    KingKirmit Golem

    Hi, so in short I am making a mod for my brother and require a little help with the coding of a magic staff.

    The staff is called "Sunlight Staff", the item works fine except for im having trouble with making it shoot the correct projectile.

    Now im not sure if i even need to be shooting a custom projectile or what the coding is for this, just stating that now :p

    Pretty much he wants the staff to shoot a "beam of light" like the Shadowbeam Staff only yellow, does not bounce off terrain, and is a straight beam like a constant laser. I hope you all understand what i mean by this.

    SIDE NOTE - If anyone knows how to set the distance the projectile will travel before dispersing that would be great too :)

    I have my .json files for both the staff and projectile and the .cs for the projectile as well.

    I would really appreciate the help and so would my brother.

    Much Thanks,
    Last edited: Feb 6, 2015
  2. KingKirmit

    KingKirmit Golem

    Reserved(you never know)
  3. Sin Costan

    Sin Costan Eye of Cthulhu

    I've been trying to do what you're trying to do, looking through the decompiled Projectile AI for Heat Ray projectile, still can't seem to make it work. I don't know if this helps but you can make your own Heat Ray projectile with this code.

        "displayName": "Generic Laser",
        "size": [8, 8],
        "aiStyle": 48,
        "friendly": true,
        "hostile": false,
        "tileCollide": true,
        "ignoreWater": true,
        "magic": true,
        "penetrate": -1,  //Cleaner infinite penetration
        "maxUpdates": 100
        //No time left means it won't run out of time
    And for the projectile png, you can just have it as an 8x8 picture that is all transparent because AI style 48 makes the dust that form the laser. And if you want it to keep firing, you should have the item values as something like:

        "displayName": "Laser Weapon",
        "size": [10,10],
        "maxStack": 1,
        "value": [0,2,0,0],  
        "rare": 7,
        "tooltip": ["A Laser Weapon"],
        "useStyle": 5,
        "useAnimation": 10,
        "useTime": 2,
        "useSound": 15,
        "noMelee": true,  
        "magic": true,  
        "damage": 80,
        "shoot": "<YourModName>:GenericLaser",
        "shootSpeed": 15,
        "mana": 5,
        "autoReuse": true,
            "items": { "Dirt Block": 1 },
            "creates": 1  
    I hope this helps a little bit.
    Last edited: Feb 7, 2015
  4. KingKirmit

    KingKirmit Golem

    Thanks alot! :) this has helped me quite a bit, the ONLY problem now is with the dust disappearing after shooting continually for a few seconds.

    BUT I'm ALOT closer than I was before :) So thanks again!
  5. Sin Costan

    Sin Costan Eye of Cthulhu

    No problem, if you need any help with making any other projectiles, you can refer to my mod here, although it is still a work in progress.