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

Making an AI/zombie destroy tile blocks

Discussion in 'Modding Help' started by Frikman, Aug 1, 2016.

  1. Frikman

    Frikman Bison Rider

    Messages:
    162
    Hello, I've been working with "Smart Zombies" by Aphelion and there's this small issue about them: they don't target tile blocks (namely, stone or wood blocks). When I asked him about it, he said it was something complicated so I should ask about it here. So, on their scripts they have this kind of lines
    Code:
    void onInit(CBlob@ this)
    {
        TargetInfo[] infos;
    
        {
            TargetInfo i("player", 1.0f, true, true); // identifier, priority (0.0 - 1.0), is the identifier a tag or name (true = tag, false = name), can see through walls (true = yes, false = no)
            infos.push_back(i);
        }
    
    Said lines determine what blobs they'll target and what priority they have, but that's what they'll target, blobs. As far as I know wood and stone blocks are not exactly blobs, so adding a line for targeting them doesn't help at all.

    Does anyone know how I could make the zombies target tile blocks? Here are the scripts for a zombie, most of them work the same way.
     

    Attached Files:

    Pirate-Rob likes this.
  2. Pirate-Rob

    Pirate-Rob Haxor Staff Alumni Tester

    Messages:
    270
    If it were me doing it, I'd probably raycast a line or two between the zombie and it's target, then make the zombie damage any blocks it finds in the line/s.
    You could also just scan the tiles around the zombie and check if any of the tiles are constructed type, then get the zombie to start damaging those.
    I don't think you'll be able to use the targeting code found in 'smart zombies' at all for destroying blocks.
     
  3. Frikman

    Frikman Bison Rider

    Messages:
    162
    So this means I need a new script that scans for player constructed blocks or it should be put somewhere inside the existing code? the "vanilla" AI from Eanmig has some lines that make zombies break blocks by checking tas like "blocks sword" and then setting the server to hit nearby blocks. It was really broken on some balance aspects, and I couldn't port it at all to Aphelion's AI
     
  4. Pirate-Rob

    Pirate-Rob Haxor Staff Alumni Tester

    Messages:
    270
    I can imagine it'd probably be put somewhere like onTick, but with a timer to stop it from running every tick and cause lag. So you could either put it in a new script, or whatever script is there I suppose? Putting it in a new script will allow you to set a tickrate though.