quakergamer 0 Posted December 24, 2003 Hello, I have made a script that creates a new explosion when the missile hits the ground, here is how it works: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _sa2 = _this select 0 _Weapon = _this select 1 _Missile = nearestObject [_sa2, "OPGWC_SA2"] #MainLoop ? (not alive _Missile): goto "Effect" When at effect, it will execute this script: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> #Effect [_sa2, _Missile] exec "\DS_obj\SA2\SA2_Explosion.sqs" exit The SA2_Explosion.sqs script is made as follow : <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _sa2 = _this select 0 _missile = _this select 1 _pos = getPos _missile Ok so the problem is that it cannot get Position of the missile because it got deleted. Result ? It doesn't create an explosion. If i change the _pos = getPos _missile with _pos = getPos _sa2 everything works fine! Any ideas ? Thank you! Merry Christmas everyone! Share this post Link to post Share on other sites
Footmunch 0 Posted December 27, 2003 Quake, When the Missile isn't alive anymore, the game engine deletes the object, so you can't getpos on it anymore. The thing to do is to keep a 'running' update of the missile pos while waiting for the not alive condition, and then pass the last position. So: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#MainLoop ~0.05 _lastmisspos = getpos _Missile ?(not alive _Missile): goto "Effect" goto "MainLoop" #Effect [_sa2, _lastmisspos] exec "\DS_obj\SA2\SA2_Explosion.sqs" exit and in the explosion sqs: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_sa2 = this select 0 _missX = (this select 1) select 0 _missY = (this select 1) select 1 _missZ = (this select 1) select 2 If you need the speed/velocity of the missile, you can do the same thing. BTW - this is all launched from the fired EH on the SA-2, yep? Share this post Link to post Share on other sites
quakergamer 0 Posted December 28, 2003 Quake,When the Missile isn't alive anymore, the game engine deletes the object, so you can't getpos on it anymore. The thing to do is to keep a 'running' update of the missile pos while waiting for the not alive condition, and then pass the last position. So: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#MainLoop ~0.05 _lastmisspos = getpos _Missile ?(not alive _Missile): goto "Effect" goto "MainLoop" #Effect [_sa2, _lastmisspos] exec "\DS_obj\SA2\SA2_Explosion.sqs" exit and in the explosion sqs: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_sa2 = this select 0 _missX = (this select 1) select 0 _missY = (this select 1) select 1 _missZ = (this select 1) select 2 If you need the speed/velocity of the missile, you can do the same thing. BTW - this is all launched from the fired EH on the SA-2, yep? OK I will try it, thanks Footmunch. And yes everything is launched from the fired EventHandler found in the SA2 Class! *EDIT* Too bad no more errors but nothing happens. I've written exactly the same thing as up there... <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_sa2 = _this select 0 _Weapon = _this select 1 _Missile = nearestObject [_sa2, "OPGWC_SA2"] #MainLoop _lastmisspos = getpos _Missile ? (not alive _Missile): goto "Effect" goto "Wait" #Effect [_sa2, _lastmisspos] exec "\DS_obj\SA2\SA2_Explosion.sqs" exit #Wait ~0.05 goto "MainLoop <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_sa2 = _this select 0 _pos = _this select 1 _x = _pos select 0 _y = _pos select 1 .... Share this post Link to post Share on other sites
Footmunch 0 Posted December 28, 2003 Quake Try adding some trace statements of the form: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> player globalchat "In Explosion.sqs" player globalchat format["%1", _Missile] And try to see whether the explosion script is getting called, and whether you've got hold of the missile correctly. The only thing I can think of: is the name of the _missile_ OPGWC_SA2? Or something like OPGWC_SA2_Miss? IIRC, the fourth element of the fired EH array is the name of the missile class (ie ammoname). Share this post Link to post Share on other sites
quakergamer 0 Posted December 28, 2003 QuakeTry adding some trace statements of the form: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> player globalchat "In Explosion.sqs" player globalchat format["%1", _Missile] And try to see whether the explosion script is getting called, and whether you've got hold of the missile correctly. The only thing I can think of: is the name of the _missile_ OPGWC_SA2? Or something like OPGWC_SA2_Miss? IIRC, the fourth element of the fired EH array is the name of the missile class (ie ammoname). The name of the missile AND the name of the ammo are OPGWC_SA2 . I am going to try what you said and see when the script is called! Thanks for the help footmunch! *EDIT* OK! I got it , it finally works: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _sa2 = _this select 0 _Weapon = _this select 1 _Missile = nearestObject [_sa2, "OPGWC_SA2"] #MainLoop _lastmisspos = getpos _Missile ~0.05 player globalchat format["%1", _lastmisspos] ? (not alive _Missile): goto "Effect" goto "MainLoop" #Effect [_sa2, _lastmisspos] exec "\DS_obj\SA2\SA2_Explosion.sqs" exit I have switched the 0,05 second wait with the _lastmisspos = getpos _Missile and it seems to work. My computer needs a small time to get the position of the object and if it has 0,05 seconds more BEFORE deleting the missile, it gets the correct position! Thanks for your help footmunch! Share this post Link to post Share on other sites
bazooka_boy 0 Posted January 31, 2004 Could your script be modified to do the following? When hitting a specific object (my bunker addon) you see the explosion but no damage is done to the object or those inside at the time of impact. I need something to do this as although my bunker is bullet proof, a bazooka or tank shell often kills those in side (which should really happen for a bunker) Bazooka_Boy Share this post Link to post Share on other sites
Scud 0 Posted April 28, 2004 Quote[/b] ]I need something to do this as although my bunker is bullet proof, a bazooka or tank shell often kills those in side (which should really happen for a bunker) Have you tried adding a roadway lod and create planes like invisible shields on the outer walls, just dont cover doorways or any other openings. Share this post Link to post Share on other sites