User Tag List

Results 1 to 8 of 8

Thread: Collision Detection

  1. #1
    Octorok Lelouche Vi Britannia's Avatar
    Join Date
    Oct 2015
    Location
    Britannia - Area 11
    Posts
    173
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    945
    Level
    10
    vBActivity - Bars
    Lv. Percent
    67.04%

    Collision Detection

    Simple question. How do I script detecting the collision of an lweapon and an enemy so that I can trigger an effect on impact?
    Lost my wings and grew 8 tentacles... I've seen enough Hentai to know where this is going....

  2. #2
    Octorok Lelouche Vi Britannia's Avatar
    Join Date
    Oct 2015
    Location
    Britannia - Area 11
    Posts
    173
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    945
    Level
    10
    vBActivity - Bars
    Lv. Percent
    67.04%
    Anyone have an idea? I've been looking at Tamamo / Mero's Bombchus Script for clues on how to do this. Basically, I'm trying to create arrows that trigger effects on impact like a Bomb Explosion or Fire.
    Lost my wings and grew 8 tentacles... I've seen enough Hentai to know where this is going....

  3. #3
    Its your boi, Guzma! mrz84's Avatar
    Join Date
    Jun 2001
    Location
    Randomness
    Age
    37
    Posts
    5,705
    Mentioned
    220 Post(s)
    Tagged
    9 Thread(s)
    vBActivity - Stats
    Points
    11,041
    Level
    31
    vBActivity - Bars
    Lv. Percent
    10.06%
    Ya know, that's something I've considered for my quest, but since I got 0 XP in my script skill, I was gonna look around for something for that. No luck so far though.
    My Quotes and other siggy stuff.
    *Bar-Buddies updates whenever-also can email comics upon request*
    MP:89
    Playing: Final Fantasy XIV

  4. #4
    Octorok Lelouche Vi Britannia's Avatar
    Join Date
    Oct 2015
    Location
    Britannia - Area 11
    Posts
    173
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    945
    Level
    10
    vBActivity - Bars
    Lv. Percent
    67.04%
    Thanks to ZoriaRPG, I've learned how to have hold out weapons. All I need now is working collision detection, and I've got the basis for more than half my use items.
    Lost my wings and grew 8 tentacles... I've seen enough Hentai to know where this is going....

  5. #5
    The Timelord
    QDB Manager
    ZC Developer
    ZoriaRPG's Avatar
    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,351
    Mentioned
    110 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    4,495
    Level
    21
    vBActivity - Bars
    Lv. Percent
    15.78%
    Code:
    int q; int w; npc n; lweapon l;
    for ( q = Screen->NumLWeapons(); q > 0; q-- ) {
        l = Screen->LoadLWeapon(q);
        for ( w = Screen->NumNPCs(); w > 0; w-- ){
            n = Screen->LoadNPC(w);
            if ( Collision(l,n) ) //Do things;
        }
    }
    Like that, or in some similar manner with var declarations in whatever style you want, or with array indices when that's more appropriate.

  6. #6
    Octorok Lelouche Vi Britannia's Avatar
    Join Date
    Oct 2015
    Location
    Britannia - Area 11
    Posts
    173
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    945
    Level
    10
    vBActivity - Bars
    Lv. Percent
    67.04%
    Okay, I hate to ask this but if you have time, can you explain how it works? It looks like we're tracking the number of active lweapons and NPC's, but is this going to trigger if say I make the on collision effect a bomb blast, and the target is a wall?
    Lost my wings and grew 8 tentacles... I've seen enough Hentai to know where this is going....

  7. #7
    OBEY GOVERNMENT GOD ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,779
    Mentioned
    256 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,685
    Level
    32
    vBActivity - Bars
    Lv. Percent
    96.94%
    Basically, you just check for collisions by brute force with a script, which is probably in your global script. So you iterate over all the lweapons and see if that one is one you want to handle by a custom script or not, then if it is you then have to iterate through all the enemies to see if it collides or not. If it does, then you just add in your desired behavior.

    Code:
    lweapon lw;
    npc e;
    int lwCount = Screen->NumLWeapons();
    int n = Screen->NumNPCs();
    
    for (int i=1;i <= lwCount; i++ ) { //loop through all lweapons on screen
        l = Screen->LoadLWeapon(i);
        if(l->Type == MEGA_BOMB_YO) { // ...filter out whatever lweapon you are looking for.
          for (int j=1; j < n; j++) {
              e = Screen->LoadNPC(w);
              if ( Collision(l,e) )  {
                 // they collided
             }
          }
       }
    }
    If the target is a wall you can just check for combo data/flags on the map instead of enemies. Same thing, except you don't loop through all the combos on screen and instead just check against 4 at most. std.zh has CombaAt(x,y) to get the combo indices for this.
    "Protocols of the Learned Elders of Zion" (British Royal Institute, 1906)
    "The International Jew: The World's Foremost Problem" �Henry Ford
    "Dope Inc. - Britain Opium War Against The U.S." (LaRouche; Konstandinos Kalimtgis; David Goldman; Jeffrey Stienberg, 1978)
    "Fundamental Laws: A Report of the 68th Convocation of the Rose Cross Order" 1916
    "War is a Racket" �Major General Smedley Butler
    "The Secret Destiny of America" �Manly P. Hall
    "A Strategy for Israel in the Nineteen Eighties" Oded Yinon (English Translation)
    The WWI Conspiracy: Part 1 - Part 2 - Part 3 "A New World Order"
    The War You Don't See
    Psywar

    �The modern theory of the perpetuation of debt has drenched the earth with blood, and crushed its inhabitants under burdens ever accumulating.� �Thomas Jefferson
    �It is well enough that the people of the nation do not understand our banking and monetary system for, if they did, I believe there would be a revolution before tomorrow morning.� �Henry Ford
    �Man will ultimately be governed by God or by tyrants.� �Benjamin Franklin

    This post contains the official Gleeok� seal of approval. Look for these and other posts in an area near you.

  8. #8
    Octorok Lelouche Vi Britannia's Avatar
    Join Date
    Oct 2015
    Location
    Britannia - Area 11
    Posts
    173
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    945
    Level
    10
    vBActivity - Bars
    Lv. Percent
    67.04%
    And here is where the fun begins. So I can set up that for loop inside my global script to track collisions. Then I should have the individual effects in the individual weapon scripts. Is this correct? I can reference variables used by the global script in item scripts?
    Lost my wings and grew 8 tentacles... I've seen enough Hentai to know where this is going....

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social