???nOBodY??? 30 Posted April 29, 2015 (edited) Advanced Collision Detectionby ???nOBodY???Introduction# This script aims to extend the default engine's control over collision detection.# Simply put when two bitmaps cross paths, the .dll takes over for RM, so that it's done# faster and more efficiently than if RM were to do so itself (by a lot).Features# -Pixel-based Collision Detection# -Rectangle-based Collision DetectionScriptLatest Version[VX] Advanced Collision Detection v1.2 (pastebin link)[ACE] Advanced Collision Detection v1.2 (pastebin link) CollisionDetection.dll_v1.2_recompiledBy_estriole Old Versions[all deprecated]Author's Note# *extra thanks to Tsukihime, poccil, & Glitchfinder# *this script requires the CollisionDetection.dll to be in the project root directory # *extra extra thanks to estriole for recompiling the .dll## *It's free for noncommercial useage. If it's for a commercial project, contact me.## I've nothing further to say, other than enjoy, and leave any questions, comments, concerns, or# suggestions by posting below. Edited March 3, 2016 by ???nOBodY??? 1 TBWCS reacted to this Share this post Link to post Share on other sites
Sixth 113 Posted April 29, 2015 (edited) Would this work with any parallax mapping script + pixel movement too? Is the process automated or will I need to use the provided script calls and code in my own collision system? A demo would be helpful, at least for me. Edit: So, I tried it, and it fails to load the dll, even if it is in the project's root folder, like the instructions says we need to put it. Using the ACE version on the ACE engine, btw. Edited April 29, 2015 by Sixth Share this post Link to post Share on other sites
???nOBodY??? 30 Posted April 29, 2015 That's odd... It works fine on mine. I'll take a look after work tonight. Share this post Link to post Share on other sites
RupamOntherocks 11 Posted April 29, 2015 @ SixthYeah, this happened with me too...It can't load the .dll file. I've copied the file in game directory..but helpless Share this post Link to post Share on other sites
???nOBodY??? 30 Posted April 30, 2015 Hm... it still works fine for me. Try this demo I prepared for you. Let me know if it still errors. If so, I might have some weird version of Ace, and need to reinstall it to have any hope of reproducing the error. Because it still works perfectly fine for me. Share this post Link to post Share on other sites
estriole 326 Posted April 30, 2015 i download the demo. when i start the game: Script 'Collisions' line 126: RuntimeError occurred. LoadLibrary: CollisionDetection.dll so basically it's cannot work even from demo... i guess it might because the way you compile your dll? try compile with Multi-threaded (/MT) checked at the Runtime Library settings... Share this post Link to post Share on other sites
???nOBodY??? 30 Posted April 30, 2015 (edited) I'm sure it has more to do with how the script loads it, though why my computer runs it without a hitch is a mystery to me. I'll try changing things up using dlopen instead, and see if that fixes the issue. Edit: Which version of windows are you guys using? I managed to find this: Windows 8.1 64bit => bugxp sp3 32bit => same bugvista sp2 64bit => same bugwindows 7 64bit => Functionalwindows 8 32/64bit => same bug along with: even when the DLL seems to be in the right place, it just can't load the DLL. By removing the scripted error message, I get a Runtime Error, LoadLibrary, regarding IsConnected = Win32API.new('System/ps3_controller.dll', 'ConnectedController', '', 'n'), or similar for the 360 controller line. I think it's applied to all the Win32API calls though, not just the "is this connected" check. . . . Edited May 1, 2015 by ???nOBodY??? Share this post Link to post Share on other sites
Rairun 2 Posted May 2, 2015 Windows 7 64bit here, and it doesn't work either. Share this post Link to post Share on other sites
RupamOntherocks 11 Posted May 2, 2015 I'am using XP SP3 32bit Share this post Link to post Share on other sites
estriole 326 Posted May 5, 2015 (edited) I use windows 7 64 bit may i ask what your windows which works? do you have the source code of the dll... maybe i can try compiling it like my EST CS2 - SCRIPT CONTROL dll. (which i know work fine so far in most computer...). Edited May 5, 2015 by estriole Share this post Link to post Share on other sites
Sixth 113 Posted May 5, 2015 Ohh, didn't notice the edit. I use Win7 Ultimate 64 bit too, with SP1. Share this post Link to post Share on other sites
seita 27 Posted May 5, 2015 (edited) windows 8.1 64bit~ Hopefully you can get this working on all versions of windows. It would be useless if only one segment of players could use it =[ Edited May 5, 2015 by seita Share this post Link to post Share on other sites
???nOBodY??? 30 Posted May 5, 2015 (edited) may i ask what your windows which works? It's also windows 7 64bit. I use visual studio 2008 professional for pretty much everything not java or android, so that's what I used to compile. Edit: Sounds like it's probably the .dll. I found this, which described pretty much the same problem. If anyone knows of any good compilers for C++ .dlls that will work with Ace, or specific settings for VisualStudio2008Professional, let me know. Edited May 6, 2015 by ???nOBodY??? Share this post Link to post Share on other sites
estriole 326 Posted May 6, 2015 (edited) here's the working dll i compile using my method . https://www.dropbox.com/s/aihncrzh1bm0l15/CollisionDetection.dll?dl=0 i compile your source code with microsoft visual C++ 2010 express... but i change a bit of it. (because it throw error when compiling) see spoiler on what i changed. 1) #include "stdafx.h" throw error. so i comment it. (i assume it's correct to comment it because i see // two line above it) 2) i add the header file (COLLISSIONDETECTION.h) to the solution... which contain: (because i also try to extern c inside the cpp before and encounter error). #define COLLISIONDETECTION_DLL __declspec(dllexport) extern "C" COLLISIONDETECTION_DLL int Bmp_checkIntersection(long object1, long object2, int x1, int y1, int x2, int y2, int minR, int minG, int minB, int minA, int minOverlaps); extern "C" COLLISIONDETECTION_DLL bool Rect_checkIntersection(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2, int minWidth, int minHeight); extern "C" COLLISIONDETECTION_DLL int Rect_getIntersectionY(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2); extern "C" COLLISIONDETECTION_DLL int Rect_getIntersectionX(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2); extern "C" COLLISIONDETECTION_DLL int Rect_getIntersectionW(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2); extern "C" COLLISIONDETECTION_DLL int Rect_getIntersectionH(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2); 3) for the configuration... i use default... the one that might differ maybe: general > configuration type = Dynamic library (.dll) c/c++ > code generation > runtime library = Multi threaded (/MT) then when compiling the solution it succeed without error. then i copy the dll to the demo folder. and it load the dll fine. the female npc will change the big stone event transparency when she touch it... but there's an error when i talk with the 'male' npc which show two picture and will transform to a girl when two picture collides. undefined method "pictures" for nil class. so i peek at your script and change this: def get_picture_spriteset(pic_id) @spriteset.picture_sprites.each do |pspr| #next unless pspr return pspr if pspr.picture.number == pic_id end nil end to def get_picture_spriteset(pic_id) @spriteset.picture_sprites.each do |pspr| next unless pspr return pspr if pspr.picture.number == pic_id end nil end and it works like a charm . credit tsukihime for the tutorial to use dll in RM . Edited May 6, 2015 by estriole 1 ???nOBodY??? reacted to this Share this post Link to post Share on other sites
???nOBodY??? 30 Posted May 7, 2015 (edited) Confirmed to be working in my system as well. Updated the Ace script and added the recompiled dll to the main post. Thanks, estriole! As a sidenote, my guess is that the difference between visual studio 2008 and 2010 might have been part of it, though the error when compiling you speak of, is a header file that's included with the template I used. I wonder if it could have been part of the problem, when I see the word "exclude"... stdafx.h // stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #pragma once #include "targetver.h" #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers // Windows Header Files: #include <windows.h> Edited May 7, 2015 by ???nOBodY??? Share this post Link to post Share on other sites
estriole 326 Posted May 7, 2015 glad it work out... maybe other people can also try the recompiled dll to make sure it's working in all machine. also... maybe this could also become a hint why error in 2008... in 2010... i use it's wizard to create the solutions. (i follow step by step from tsukihime tutorial ). below taken from tsukihime post If you are going to build your DLL through the IDE, you should set up your project so that the IDE automatically builds a DLL. 1. Create a new project (ctrl+shift+N) 2. Select win32 console application 3. Choose a name, hit OK Another wizard will come up. 4. Next 5. Select "DLL" and "Empty Project" 6. Finish and there's no header file in that empty project. so i need to create my own header which contain extern c for all the method in cpp. so maybe there's a problem in your template header like you suspected. Share this post Link to post Share on other sites
???nOBodY??? 30 Posted May 7, 2015 2008's setup is pretty much the same. I didn't choose the "empty project" option, and may have ended up with a bunch of random fluff. The header's comment, "// Exclude rarely-used stuff from Windows headers", kinda raises some flags too... Share this post Link to post Share on other sites
???nOBodY??? 30 Posted May 19, 2015 Using the old .dll actually crashes for me now in both VX & Ace, so I'm not sure what's up with it. Removed it from the first post. Share this post Link to post Share on other sites
Mireneye 1 Posted July 14, 2015 (edited) Oh boy! I really hope I can get this to work where Cidiomar's script failed me. Looking forward to experimenting ^-^EDIT:This is awesome! is there any way I can call this from script? I'm new to scripting so I'm a bit lost. What I'm trying to do is basically like. $game_player.collide_with(x) #I'd like X to be an array with most events on a map eventually.What I'm aiming for is to make this complement XAS to give XAS pixel perfect combat. precision. The way Xas works is by calling an sprite animation, they call the function make_pose. So I'm assuming all I have to do is check for collision with the event when the attack pose of the player is triggered.Any help appriciated ^^GREAT WORK on this script and the .DLL! Edited July 14, 2015 by Mireneye Share this post Link to post Share on other sites
Tdanger 2 Posted July 15, 2015 I'm having trouble setting this up. Is there much to do other than install the script and paste over the .dll? Share this post Link to post Share on other sites
Sixth 113 Posted July 15, 2015 @Tdanger This script is not an automated plug-and-play script, it is more like a developer tool. It gives you ways to check for pixel collision in different ways, but you have to set that up yourself using the provided new methods from the script. @Mireneye You can call the collision check from the 'update' method in Scene_Map. Iterate the events on the map, than inside the iteration, perform a check for the pixel collision between the player and the events. This way, it would check against all events on the map. It would look something like this: $game_map.events.each do |event| next if event.nil? evt_spr1 = SceneManager.scene.get_event_spriteset(0) # the player evt_spr2 = SceneManager.scene.get_event_spriteset(event.id) # the event next if evt_spr1.nil? || evt_spr2.nil? if evt_spr1.pixel_collide?(evt_spr2,10,10,10,10,3,3,1) # Do something here! This triggers if the player collides with any event. end endDepending on where you call this, you might need to enter some other safety checks too, like checking if the current scene is Scene_Map or not, etc.I haven't tested this yet, but I tested the player VS picture collision and that works perfectly fine for me. I tested that inside a custom script too, not by using the provided script calls. I might have messed up the arguments or their orders, just reading that description makes my head spin, so I just made them up, edit them yourself as you see fit. Well, try it out, see if it works or not. 1 Tdanger reacted to this Share this post Link to post Share on other sites
Tdanger 2 Posted July 15, 2015 @SixthThanks for clarifying, I came to a point where I realized the issue was probably my ignorance, so that makes sense. Share this post Link to post Share on other sites
???nOBodY??? 30 Posted July 23, 2015 @Mireneye The methods are written into the Game_Interpreter class, so if you added them to whatever class you're trying to call them from, they'd probably work just fine. Cidiomar's Ace-only .dll is the main reason I wrote this, to be honest, lol. @Sixth Sorry that the header made your head spin, xd. @Tdanger If you copy the script over, and copy the .dll over, you'll have access to script calls you can make from within events for pixel collisions. If you wanted this functionality built-in to custom scripts, now we're talking patches and modifications. Share this post Link to post Share on other sites
Sixth 113 Posted September 26, 2015 I tried to use this script to make a pixel based collision effect for tools in an ABS system, and it works well with simple event graphics. But the animation check won't work. The method 'getAnimationSpriteFrame' got some misnamed instance variables ('@animation_sprite' is actually '@ani_sprite' in VX Ace, same with every '@animation_xxxx' variables, so it's not '@animation' but '@ani'). Changing the names got rid of the NoMethod error, but whenever I try to get a collision check using an animation instead of event graphic, the game freezes, no errors, just a plain "Not responding" error forever. I wonder if I missed something or is that function is bugged or not working at all? I tried to look in the demo you made to see if there is an example for the animation collision check, but there isn't, unfortunately. Did you test that function? Did it work for you? Share this post Link to post Share on other sites
???nOBodY??? 30 Posted September 27, 2015 (edited) Oops... It's not just you. I never got the animation check to function correctly, though I might revisit it in the near future. I feel like I know why it wasn't working, but I need to do some more tests to figure out if I'm right. To be honest, I completely forgot that I left that in. Edited September 27, 2015 by ???nOBodY??? Share this post Link to post Share on other sites