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

[Solved] Making a projectile go through workshops/ladders

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

  1. Frikman

    Frikman Bison Rider

    Messages:
    162
    Hi, I've been making some experiments with custom classes and I have this guy who can shoot fire-orb-projectile-things, but said things don't go through workshops or ladders like arrows or other projectiles do. Is there a tag or something that lets arrows go through workshops/ladders or do I have to edit them to let the new projectile pass through?
     

    Attached Files:

  2. 8x

    8x Elimination Et Choix Traduisant la Realité Forum Moderator Staff Alumni Tester
    1. The Young Blood Collective - [YB]

    Messages:
    1,325
    Do these simply die when they touch the blobs or do they deliver damage to the ladders and workshops?

    I'm no specialist on this, but I'd say you have to make it colide with blobs under the Flesh tag, checking for teams as well. You surely have already done it, but check Arrow.as, compare the code and how it behaves with your projectile code and behaviour.
     
    Last edited: Aug 9, 2016
    blackjoker77777 and makmoud98 like this.
  3. Osmal

    Osmal Bison Rider Donator
    1. [Server] Sandbox Reborn

    Messages:
    13
    Hey Frikman. You could also just check if the blob has collisions, just use 'blob.isCollidable()'.
    Something like

    bool doesCollideWithBlob( CBlob@ this, CBlob@ blob )
    {
    return (blob.isCollidable() || blob.getTeamNum() != this.getTeamNum());
    }
     
    Last edited: Aug 9, 2016
    blackjoker77777 and makmoud98 like this.
  4. jimmyzoudcba

    jimmyzoudcba Haxor Tester

    Messages:
    274
    DK a lot, but I think check the ladder code. Should be stuff helpful.
     
  5. Frikman

    Frikman Bison Rider

    Messages:
    162
    It's still kinda buggy and hits trees from time to time, but I changed the collision lines to the following.
    Code:
    bool doesCollideWithBlob( CBlob@ this, CBlob@ blob )    // not used by engine - collides = false
    {
        return (this.getTeamNum() != blob.getTeamNum() || (blob.getShape().isStatic() && blob.hasTag("flesh") && !blob.getShape().getConsts().platform));
    }
     
  6. blackjoker77777

    blackjoker77777 Haxor Tester
    1. Zen Laboratories

    Messages:
    441
    What's written over there is interpreted as the following:
    The firebolt collides with a blob if:
    • The team number of the attacker differs from the victim-blob team.
    OR (please focus on this or, and you'll understand what I'm getting at).
    • The blobs' shape is static and it has the tag "flesh" and if the shape constant platform is set to false.
    So basically if one of the above two main conditions was true, that function would simply return true as well.
    That means if any blob with a different (hostile) team number is attacked with that firebolt, then the condition No.1 is confirmed and the 2nd one is ignored leading to damaging that blob whenever it has a different team number; so such a solution won't actually solve the issue of it damaging workshops and/or ladders (same goes for any blob with a different team number; such as catapults, mines, etc).
    The easiest way to get it working the way you'd want it to, is to keep it simple yet effective (basically what 8x suggested).
    Something like this, would hopefully do the trick.
    So that you're checking if it has the "flesh" tag (and hence it's either a builder, knight, archer, a migrant, a trader; or maybe a shark, a bison, a fish or even a chicken) and making sure it's not a teammate.
    Anyway, this solution is a viable one if you just want that weapon to attack living targets; it won't do you any good if you want it to demolish catapults or ballistas; you said that you want them to have a similar behavior to the one arrows have (and bomb arrows attack such machineries).
    So in case you ever want to do it this way (or attack other custom blobs), feel free to do a similar thing to this:
    upload_2016-8-11_1-9-41.png
    Or you could even do it this way, if you want to get rid of the Tag checking (just giving a few solutions/suggestions, you're the one responsible for picking what sounds like the most convenient one).
    upload_2016-8-11_1-18-26.png
    I hope this helps.
    @Edit: Osmals' solution works as well; but as you've already mentioned, it would lead to having the firebolts damaging every collidable blob, including trees.
     
    Last edited: Aug 11, 2016
    Frikman likes this.
  7. Frikman

    Frikman Bison Rider

    Messages:
    162
    Thanks @blackjoker77777 ! Your explanation helped me understand some things about the projectile itself. In the end, this is how the code looks like
    Code:
    bool doesCollideWithBlob( CBlob@ this, CBlob@ blob )
    {
    return (this.getTeamNum() != blob.getTeamNum() && blob.hasTag("flesh")) || blob.hasTag("ZP") || blob.hasTag("dead") || blob.hasTag("enemy");
    //the tags checked by "OR" conditions are used on the game mode
    }
     
    blackjoker77777 likes this.