Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
4 registered members (NewbieZorro, Grant, TipmyPip, AndrewAMD), 13,040 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: What should i learn :S [Re: Helghast] #246036
01/13/09 10:50
01/13/09 10:50
Joined: Jan 2008
Posts: 1,580
Blade280891 Offline OP
Serious User
Blade280891  Offline OP
Serious User

Joined: Jan 2008
Posts: 1,580
:S arh, i can't work out how to use c_scan to detect entities.

Can anyone show me an example.


My Avatar Randomness V2

"Someone get me to the doctor, and someone call the nurse
And someone buy me roses, and someone burned the church"
Re: What should i learn :S [Re: croman] #246105
01/13/09 16:54
01/13/09 16:54
Joined: Oct 2008
Posts: 218
Nashua NH
heinekenbottle Offline
Member
heinekenbottle  Offline
Member

Joined: Oct 2008
Posts: 218
Nashua NH
Quote:

damn. 1145 posts and still almost a noob to lite-c smile that's not seen often.


I started with A5 and it took me a while to get use to the C-Script Syntax, might have been around 1145 post for me as well.

And now switching to Lite C adds pointers (C-Script only had entity pointers, I don't think it had any real programing pointers) and structs and somewhat different syntax for me to get use to, so I am in a way still a noob.


I was once Anonymous_Alcoholic.

Code Breakpoint;
Re: What should i learn :S [Re: heinekenbottle] #246108
01/13/09 17:02
01/13/09 17:02
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline
Serious User
croman  Offline
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
i apologize to all of you smile but i ment a noob in game programming. after all he said that...btw it was just a joke, it's not worth of dicussing :P



Ubi bene, ibi Patria.
Re: What should i learn :S [Re: Blade280891] #246112
01/13/09 17:15
01/13/09 17:15
Joined: Oct 2008
Posts: 218
Nashua NH
heinekenbottle Offline
Member
heinekenbottle  Offline
Member

Joined: Oct 2008
Posts: 218
Nashua NH
Originally Posted By: Blade28081991
:S arh, i can't work out how to use c_scan to detect entities.

Can anyone show me an example.


Sure.

c_scan scans an area in a sphere or a part of a sphere (an arc, circle, cone, etc).

It will trigger any entity with "enable_scan."

c_scan has four parameters, c_scan(position,angle,areaOfEffect,mode).

Position is where it starts.

Angle gives its direction

Area of effect is a vector. X is the horizontal arc range in degrees (360 for a circle or sphere). Y is the vertical arc range in degrees (360 for a circle or sphere. Z is the radius.

Mode is the flag which you wish to use:

IGNORE_ME Ignores the me entity; to be combined with SCAN_ENTS.
IGNORE_YOU Ignores the you entity; to be combined with SCAN_ENTS.
IGNORE_PASSABLE A7.2 LC Ignores entities with the PASSABLE flag; to be combined with SCAN_ENTS.
IGNORE_FLAG2 A7.2 LC Ignores entities with FLAG2; to be combined with SCAN_ENTS.
SCAN_ENTS Scans for entities within the cone, and triggers their EVENT_SCAN event.
SCAN_POS Scans for camera positions placed in the level.
SCAN_PATHS Scans for path start positions.
SCAN_NODES Scans for path node positions.
SCAN_LIGHTS Scans for static lights.
SCAN_LIMIT Finds only entities with ENABLE_SCAN set, or only static lights whose range can reach the scan origin. Can be combined with SCAN_ENTS and SCAN_LIGHTS.
SCAN_FLAG2 A7.2 LC Opposite of IGNORE_FLAG2: Finds only entities with FLAG2.

Combined with an OR, |, symbol, just like in the other c_ instructions.

Here's an example: This is a function called in my tank game that causes a barrel to explode, doing damage to anything nearby:

Code:
function scanExpl(ENTITY* ent)
{
	ANGLE scanAng;				//the angle the scan range fires at
	scanAng.pan = 360;		//360 degrees
	wait(1);						//wait to avoid dangerous instructions (this is called after an event)
	c_scan(my.x,scanAng.pan,vector(360,360,300),IGNORE_PASSABLE | IGNORE_ME | SCAN_ENTS | SCAN_LIMIT);
								//scan from the gas tank, ignoring the gas tank, doing a full sphere with a 300 unit radius
	vec_scale(normal,10); // produce an explosion into the normal direction
	wait(1);
	effect(effect_explo,500,ent.x,normal);
	ent_create("sphere.mdl",ent.x,explo);		//create the explosion sphere
	random_seed(0);
	int iNum = integer(random(100));
	if(iNum < 10)
		ent_create("wrench2.mdl",my.x,wrench);
	wait(1);
	ent_remove(me);									//remove the gas tank
}


When this function is called, it defines an angle, the pan is assigned the value 360 for a circular scan. Then there is wait(1) because I'm using event triggers and c_scan is a dangerous instruction and this keeps that error from occuring.

Then I call c_scan at the object's position, a 360 direction, a full sphere with a radius of 300 units, and with the mode set to ignore passable, ignore itself. SCAN_ENTS triggers the entities with ENABLE_SCAN set and SCAN_LIMIT detects only entitys with ENABLE_SCAN.

After the c_scan, the barrel explodes, with a particle and a model effect, then with a random number, it decides whether or not it will drop a wrench (power up that fixes a tank) and then removes itself.

And this is the other half of c_scan, enabling an entity to react. This code makes the player tank take damage, either itself or its shield, if it is in range of the scan.
Code:
function pEvents()
{
	if(event_type == EVENT_SCAN)
	{
		if(!player.shielded)
		{
			my.health -= 20 * player.armor * god;
			player.armor += 0.1;					//take away a fifth of the armor
		}
		else
		{
			shield.health -= 20;
		}
	}
}

action pTank()
{
	//...set parameters and such

	player = my;														//set the pointer
	set(my,FLAG2 | SHADOW | METAL | CAST);								//set some flags
	my.emask |= (ENABLE_SCAN);										//allows the tank to recieve c_scans
	my.event = pEvents;												//called if the tank is hit by a c_scan
        //...code continues on


my.emask is set to ENABLE_SCAN, allowing the tank to be detected by c_scan and calling "pEvents()" when it is hit by a scan.

pEvents() then checks if the event_type is EVENT_SCAN and if so, it then applies damage to either the player or the shield.


This code is tested and does work.

Last edited by heinekenbottle; 01/13/09 17:16.

I was once Anonymous_Alcoholic.

Code Breakpoint;
Re: What should i learn :S [Re: heinekenbottle] #248263
01/25/09 17:21
01/25/09 17:21
Joined: Jan 2008
Posts: 1,580
Blade280891 Offline OP
Serious User
Blade280891  Offline OP
Serious User

Joined: Jan 2008
Posts: 1,580
Ok, so now if i want to have an entity scan for other entities near it would all the entities need to have scan enabled and a function for it?


My Avatar Randomness V2

"Someone get me to the doctor, and someone call the nurse
And someone buy me roses, and someone burned the church"
Re: What should i learn :S [Re: Blade280891] #251713
02/14/09 17:06
02/14/09 17:06
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Sorry that I dig out this old thread again, but to me it seems that you never got an answer for your last question.

So its a Yes and a No.
c_scan only "finds" (reports) entities that have enable_scan set. Now you can also attach an event function to these entities if they should react on the c_scan event.
Imagine this:
You stand in a room and have a blindfold on. Now you ask: "Is there anyone here in a circle of 2 meters around me?" (c_scan) and then the person standing next to you answers "yes" (you is set to that person).
Now you know there is someone and you can adress him (the you pointer).
From here on your can use that information (someone answered and who answered) to do something.
That would be what the scanning-entity would do.
Now if you tell all thoses people in the room that they should do something when you ask, that would be the event function.

Hope this makes it a more clear.

Re: What should i learn :S [Re: Xarthor] #251715
02/14/09 17:08
02/14/09 17:08
Joined: Jan 2008
Posts: 1,580
Blade280891 Offline OP
Serious User
Blade280891  Offline OP
Serious User

Joined: Jan 2008
Posts: 1,580
Yes it does help quite a bit smile thanks.


My Avatar Randomness V2

"Someone get me to the doctor, and someone call the nurse
And someone buy me roses, and someone burned the church"
Page 2 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | 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