Gamestudio Links
Zorro Links
Newest Posts
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
folder management functions
by 7th_zorro. 04/15/24 10:10
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
LPDIRECT3DCUBETEXTUR
E9

by Ayumi. 04/12/24 11:00
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 04/11/24 14:56
SGT_FW
by Aku_Aku. 04/10/24 16:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (7th_zorro, Quad), 373 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
11honza11, ccorrea, sakolin, rajesh7827, juergen_wue
19045 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
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 Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Hey,

And no the title is not from a new book or such grin , 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:

Code:
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: c_scan and a big world [Re: Reconnoiter] #445001
08/25/14 20:00
08/25/14 20:00
Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
pararealist Offline
Senior Member
pararealist  Offline
Senior Member

Joined: Dec 2006
Posts: 434
UK,Terra, SolarSystem, Milky W...
sector.y vertical scan sector in degrees, or 0 for a circular scan cone.

try using 1.


A8.3x Commercial, AcknexWrapper and VS 2010 Express
○pararealist now.
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 Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
I found this quote from Superku:

Quote:
-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 eek . 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 Offline

X
rayp  Offline

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.
Code:
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_dist


Heres a simple example of a "selfmade c_scan / explosion without c_scan" ( not tested but iam pretty sure it'll compile n run ):
Code:
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":
Code:
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 ):
Code:
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: rayp] #445020
08/26/14 09:46
08/26/14 09:46
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Awesome rayp! Its like christmas came early this year laugh . First going to try that draw_point3d function.

Re: c_scan and a big world [Re: Reconnoiter] #445022
08/26/14 10:11
08/26/14 10:11
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
Or a combination of EVENT_DETECT and vec_to_ent may also work.
In the event function you do something like this:

VECTOR temp;
vec_set(temp.x,you.x);
vec_to_ent(temp.x,my.x);
if(temp.z==0)
{
... some code
}

i guess this would also check in a circular plane.


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
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 Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Quote:

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:

Code:
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: Reconnoiter] #445029
08/26/14 12:11
08/26/14 12:11
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
I see no reason for not being allowed to create particles in an event.
Best way is trying and seeing if it throws out an error.


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
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 Offline OP
Serious User
Reconnoiter  Offline 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:

Quote:

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.
Re: c_scan and a big world [Re: Reconnoiter] #445042
08/26/14 20:16
08/26/14 20:16
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
I always understood it that way that you shouldn´t use functions in events that can trigger events itself, for example a second scan in the detect event. Because if you do that you would have an endless loop of detect events.
But particles should have no side effects.


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Page 1 of 3 1 2 3

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1