0 registered members (),
1,397
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
c_scan ( different explo damage solutions )
#444998
08/25/14 11:30
08/25/14 11:30
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
OP
Serious User
|
OP
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
Hey, And no the title is not from a new book or such , it is a problem that I have with the c_scan function in one of my current projects (fps game). I create a missile in the form of a disk. I want to give this disk explosion damage but only a circular zone (not in a sphere), so I do the following c_scan:
if (c_scan(my.x, my.pan, vector(360, 0, 150), SCAN_ENTS | IGNORE_ME | IGNORE_FLAG2 | IGNORE_PASSABLE | IGNORE_WORLD) > 0)
{
....
}
The missile's roll is 0. The thing is that this checks in a sphere and not in a circular zone relative to the missile's angle for some reason. I tested it several times with large groups of enemies. Maybe important the mention is that it is a big world in x,y,z coordinates (every is scaled a lot). Could something like that be it? That the large world coordinates messes with a maximum amount of a variable or something like that? Or, perhaps more likely, I am just making a stupid mistake here? Or something else? Thanks.
Last edited by rayp; 09/02/14 17:23. Reason: changed title, wished by starter
|
|
|
Re: [ many explosion damage solutions ] c_scan and a big world
[Re: Reconnoiter]
#445002
08/25/14 20:03
08/25/14 20:03
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
OP
Serious User
|
OP
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
I found this quote from Superku: -400000...400000 level size is way too big. var ranges from approx. -1024567 to 1024567 (or 999999, that's easier to remember). When you calculate with these huge values, there will probably be many "math" problems: For instance when using vec_dist, the function squares 400000 which is of course above 999999. As a result vec_dist will return nothing useful, so other instructions will do the same. Scale your whole level down e.g. by 90%.
(I feel like I'm talking rubbish, but this should be correct.) Maybe I should rescale everything. I am hesitating, there are alot of models to rescale than . The map size is: x -> 500 to 27500 y -> 4500 to 30500 z -> -7000 to 0 (the weird coordinates are cause of the sun positions limitations) -edit, @pararealist, ty going to try that -edit 2, @pararealist, setting it 1 (like vector(360, 1, 500)) hits nothing. Setting to e.g. 30 or higher (like vector(360, 30, 500)) hits everything like it does a sphere check.
Last edited by Reconnoiter; 09/01/14 17:18.
|
|
|
Re: c_scan and a big world
[Re: Reconnoiter]
#445004
08/25/14 23:28
08/25/14 23:28
|
Joined: Jul 2008
Posts: 2,107 Germany
rayp
X
|
X
Joined: Jul 2008
Posts: 2,107
Germany
|
Another, maybe more fast, way would be using a "FOR" to cycle through all ents, using vec_dist and c_trace ( c_trace to avoid applying "explo - damage" behind / through walls ). Note: c_scan will only return the nearest entity ( YOU ) found. Use a FOR instead ( +vec_dist ), or entities EVENT_SCAN to react to more than one at once. If your scanmode contains SCAN_ENTS, then only ents with ENABLE_SCAN flag set, will be found / event - triggered. Guess u know already, just wanted to remind.
my.emask |= (ENABLE_SCAN | WHATEVER...); // now c_scan + SCAN_ENTS detects / triggers me
C_SCAN probs, another thread: Replace c_scan with FOR and vec_distHeres a simple example of a "selfmade c_scan / explosion without c_scan" ( not tested but iam pretty sure it'll compile n run ):
ENTITY* myplayer;
#define health skill100
#define can_explode skill99
#define do_explode skill98
#define removeable skill97
void rayps_exploscan (ENTITY* _ent){
if (!_ent) return; // entity doesnt exist? stop!
if (me) my.removeable = 0; // when 1, explosion done, "FOR" cycled through all ents
var _explorange = 300; // range of explosion ( _ent.x + 300 )
var _stored_you = 0; // guess this is optional. avoids(?) that this code changes YOU
if (you) _stored_you = handle (you);
for (you = ent_next (NULL); you; you = ent_next (you)){
//if (!_ent) break; // wtf!?! lost _ent - entity? stop!
var _dist2ent = _explorange + 1; // distance _ent.x -> you[n].x: starts false(>range)
_dist2ent = vec_dist (_ent.x, you.x); // _dist2ent = distance between _ent and you[n]
if (you.can_explode){ // only damage some ents, with "can_explode = 1" 4ex
trace_mode = IGNORE_ME | IGNORE_PASSABLE | USE_POLYGON;
if (_dist2ent < _explorange) if (c_trace (_ent.x, your.x, trace_mode)){ // hit something?
you.health = 0; // you.can_explode=1 + in range + hit by c_trace? DIE!
you.can_explode = 0; // only a "oneshot" event
you.do_explode = 1; // when ent dies, it'll produce an explosion too
}
}
}
if (_stored_you) you = ptr_for_handle (_stored_you); // restores you - pointer (optional?)
if (me) my.removeable = 1; // me aka my, still exists? then mark as removeable now!
}
action WED_Barrel_Explo{ // very basic n simple example of an explodeable object
my.do_explode = 0; // if set to 1, we'll explode when health <= 0
my.can_explode = 1; // now the "FOR" takes care about us ( = we're explodeable now )
my.health = 100;
while (my.health){ // iam alive...
draw_text ("Barrel: Waiting 4 rayps_exploscan's in range (health>0)...", 10, 10, vector (0, 0, 255));
wait (1);
}
set (my, PASSABLE | INVISIBLE); // switch in2 ghostmode :D
if (my.do_explode) rayps_exploscan (me); // produce another explosion, this time at "my" pos
while (!my.removeable) wait (1); // while zero, my explosion (FOR) is still running
wait (1);
ptr_remove (me); // finally remove this exploded, damaged barrel
}
action myHero(){
myplayer = me;
...
while (my.health > 0){
...
if (key_space && !myplayer.removeable) rayps_exploscan (myplayer); // debug: spawn explo's around player (waits until explo done)
...
wait (1);
}
...
}
About the c_scan command values, this works normally for a simple "explosion - scan":
c_scan (my.x, my.pan, vector (360, 0, 1000),...
Should scan in a "circle" ( 360° ) cone, into the direction "my" looks to, in a range of 1000. Great 4 debugging traces or scans ( some may not know yet ):
c_trace (...tracestuff...);
if (HIT_TARGET) draw_point3d (target.x, vector (50, 50, 255), 100, 3);
// ---------------------------------------------------------------------------------
// mhm, not sure c_scan sets HIT_TARGET, thats why i would use "result" 2 compare instead
if (c_scan (...scanstuff...)) draw_point3d (target.x, vector (50, 50, 255), 100, 3);
Displays a red point, one frame long, at "target"s - vector - position. Greets N peace
Last edited by rayp; 08/26/14 22:08. Reason: added draw_point3d - c_scan example
Acknex umgibt uns...zwischen Dir, mir, dem Stein dort... "Hey Griswold ... where u gonna put a tree that big ?" 1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected rayp.flags |= UNTOUCHABLE;
|
|
|
Re: c_scan and a big world
[Re: alibaba]
#445023
08/26/14 10:45
08/26/14 10:45
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
OP
Serious User
|
OP
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
Great 4 debugging traces or scans ( some may not know yet ): Code:
c_trace ()... / c_scan ()... if (HIT_TARGET) draw_point3d (target.x, vector (50, 50, 255), 100, 3);
Displays a red point, one frame long, at "target"s - vector - position.
, how to make this in a while for a group? I have it now for one ent permanently but can't seem to do it for a whole group:
c_scan...
if (HIT_TARGET)
{
VECTOR target_vec;
vec_set(target_vec, target.x);
while (1) { draw_point3d (target_vec, vector (50, 50, 255), 100, 3); wait(1); }
}
@alibaba, thats a smart idea. My only question with this is if particle creation is allowed in event functions? I remember reading in the manual that I can't do things like ent_create etc. in events, so I thought that included things like effect (...).
|
|
|
Re: c_scan and a big world
[Re: alibaba]
#445040
08/26/14 20:11
08/26/14 20:11
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
OP
Serious User
|
OP
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
Earlier I had particle functions in my events, the game was less stable than. The manual (v8.45) says under the event section: it shouldn't perform instructions that can trigger events itself, displace entities, start particles or change anything else in the level.
Last edited by Reconnoiter; 08/26/14 20:12.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|