Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,209 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
updating camera code #286176
08/23/09 17:46
08/23/09 17:46
Joined: Jul 2009
Posts: 80
Area 51
F
fangedscorpion Offline OP
Junior Member
fangedscorpion  Offline OP
Junior Member
F

Joined: Jul 2009
Posts: 80
Area 51
How do I get his line of code to work now, with the newer lite-c version:

view = camera;

Whenever I define an entity with this, I cannot see the entity in the 3d world. Any help?


"Pow! You are dead! Not big suprise!" -Heavy
Re: updating camera code [Re: fangedscorpion] #286229
08/24/09 00:23
08/24/09 00:23
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
Do you mean to make an entity visible only in that view? AFAIK entities do not have a "view" parameter, but you can set up which entities are visible in which views using material events.

Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: updating camera code [Re: JibbSmart] #286231
08/24/09 02:18
08/24/09 02:18
Joined: Jul 2009
Posts: 80
Area 51
F
fangedscorpion Offline OP
Junior Member
fangedscorpion  Offline OP
Junior Member
F

Joined: Jul 2009
Posts: 80
Area 51
Yes I want to make a gun for a FPS or a pickup for a player in my game. How can I accomplish this?


"Pow! You are dead! Not big suprise!" -Heavy
Re: updating camera code [Re: fangedscorpion] #286237
08/24/09 06:24
08/24/09 06:24
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
Ah, I get it. Are you using a view entity?
eg:
Code:
ENTITY* shotgun_onscreen =
{
  type = "shotgun.mdl";
  layer = 2; // display above view entities with layer 1
//flags = SHOW;  // C-Script only!
  flags2 = SHOW; // lite-C only: visible on screen from the start
  x = 100; // place 100 quants ahead of the view
  y = -50; // 50 to the right
  z = 0; // and center vertically
  view = camera; // attached to the camera
}



Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: updating camera code [Re: JibbSmart] #286326
08/24/09 17:11
08/24/09 17:11
Joined: Jul 2009
Posts: 80
Area 51
F
fangedscorpion Offline OP
Junior Member
fangedscorpion  Offline OP
Junior Member
F

Joined: Jul 2009
Posts: 80
Area 51
Can I shoot bullets from this entity, by using this code?:

action playerweapon()
{
minig = my;
VECTOR wpnht;
VECTOR wpnoffset;
set(my,PASSABLE);
while(1)
{
vec_set(wpnoffset.x, vector(50,-18,-20));
vec_rotate(wpnoffset.x, vector(camera.pan, camera.tilt,0));
vec_add(wpnoffset.x, camera.x);
vec_set(my.x, wpnoffset.x);
my.pan = camera.pan;
my.tilt = camera.tilt;
wait(1);
}
}

function rmvblts()
{
ent_create("bullethole.pcx", vector(my.x,my.y,my.z), NULL);
set(my,PASSABLE);
set(my,INVISIBLE);
ent_remove(my);
}

function mvbllt()
{
VECTOR bspeed, trceblt;
set(my,ENABLE_IMPACT);
my.event = rmvblts;
my.pan = camera.pan;
my.tilt = camera.tilt;
bspeed.x = 200 * time_step;
bspeed.y = 0;
bspeed.z = 0;
vec_set(trceblt, vector(75,0,0));
vec_rotate(trceblt,camera.pan);
vec_add(trceblt, camera.x);
while(my!=NULL)
{
c_move(my,bspeed,nullvector,IGNORE_PASSABLE);
if(c_trace(my.x, trceblt, IGNORE_PASSABLE| USE_POLYGON| SCAN_TEXTURE)>0)
{
rmvblts();
}
wait(1);
}

}

function firegun()
{
proc_kill(4);
vec_for_vertex(temp.x, minig, 53);
ent_create("bullet.mdl", temp.x, mvbllt);
wait(0.14);
}

Also do you know why whenever I hit a rigid body (a barrel with a box bounds) the bullet will not destroy itself?

Last edited by fangedscorpion; 08/24/09 17:12.

"Pow! You are dead! Not big suprise!" -Heavy
Re: updating camera code [Re: fangedscorpion] #286363
08/24/09 23:16
08/24/09 23:16
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
Okay, with that kind of code you don't want to use an "ENTITY* =" definition like I showed (that creates a view entity that only functions in view space). The way you're doing it has advantages of easier lighting (dynamic lights interacting with view entities can be problematic), and the disadvantage of slightly more difficult to code.

Some things I noticed:
-- What's with the "wait(0.14);" in the firegun() function? Use negative numbers for seconds (or fractions of seconds), eg "wait(-0.14);".
-- You also want the bullet to have the event-flag "ENABLE_ENTITY" -- ENABLE_IMPACT only triggers when another entity moves into the bullet. ENABLE_ENTITY will trigger when the bullet hits another entity. If you have level blocks, also use ENABLE_BLOCK. You don't really need ENABLE_IMPACT at all.
-- I have no idea why you're tracing to 75 quants in front of the camera in the bullet action.

I hope those points are useful! laugh

Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: updating camera code [Re: JibbSmart] #286369
08/25/09 00:48
08/25/09 00:48
Joined: Jul 2009
Posts: 80
Area 51
F
fangedscorpion Offline OP
Junior Member
fangedscorpion  Offline OP
Junior Member
F

Joined: Jul 2009
Posts: 80
Area 51
I could never get the ent_decal command to work correctly. Whenever I tried to make a decal, I always got an error.
Here is the code:

function spawn_sprite()
{

proc_kill(4); // stops the function from running more than 1 time
// spawn a sprite at mouse click position, 200 quants behind the screen

while (key_space) {wait (1);}

vec_set(temp.x,camera.x);
vec_set(temp2,vector(20000,0,0));
vec_rotate(temp2,camera.pan);
vec_add(temp2,camera.x);
trace(temp,temp2);
ent_create("bullethole.pcx",target,NULL);
//ent_decal(you,"bullethole.tga",you.x, you.y);
}



function makedecals()
{
// calculate the target vector
VECTOR trace_target;
vec_set(trace_target,vector(5000,0,0)); // the weapon has a firing range of 5000 quants
vec_rotate(trace_target, camera.pan);
vec_add(trace_target, camera.x);

// display a red spot at the target position
if (c_trace(camera.x,trace_target, IGNORE_PASSABLE | USE_POLYGON| SCAN_TEXTURE) > 0) // hit something?
{
draw_point3d(hit.x,vector(50,50,255),100,3);
}//ent_create("hairs.bmp", hit.x, NULL);


// fire and then place a decal at the hit position
if (key_space) // fire
{
if (HIT_TARGET) // target hit?
{
//spawn_sprite();
//p = ent_decal(you,"bullethole.tga",7+random(3),random(360)); // place a random sized decal at the hit entity
//p.lifespan = 1600; // remove decal after 100 seconds
}
//PARTICLE* p = ent_decal(you,bmMark,you, 5); // place a random sized decal at the hit entity
// p->lifespan = 80;
//hit.x);
//ent_create("bullethole.tga",vector(hit.x,hit.y,hit.z),NULL);
//ent_decal(you,bmMark,you, 5);
}
wait(1);
}

Any advice?

Here is another link to the code as well:

http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Main=35040&Number=286107#Post286107

Last edited by fangedscorpion; 08/25/09 00:52.

"Pow! You are dead! Not big suprise!" -Heavy
Re: updating camera code [Re: fangedscorpion] #286385
08/25/09 05:20
08/25/09 05:20
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
I haven't used ent_decal before. Sorry; hopefully someone else can help there.

Could you please use code tags to make your code easier to read? Just put your code between tags like this: [code ] blah..blah blah... [/ code] (without the spaces in the tags). It allows the forum to preserve whitespace (indents and what-not) and makes it easier to read.

Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: updating camera code [Re: JibbSmart] #286448
08/25/09 11:14
08/25/09 11:14
Joined: Aug 2008
Posts: 482
B
bart_the_13th Offline
Senior Member
bart_the_13th  Offline
Senior Member
B

Joined: Aug 2008
Posts: 482
I think it wont work if you use you as 3rd and 4th parameter since you can be NULL at anytime...
Click to reveal..

Code:
function mvbllt()
{
VECTOR bspeed, trceblt;
set(my,ENABLE_IMPACT);
my.event = rmvblts;
my.pan = camera.pan;
my.tilt = camera.tilt;
bspeed.x = 200 * time_step;
bspeed.y = 0;
bspeed.z = 0;
vec_set(trceblt, vector(75,0,0));
vec_rotate(trceblt,camera.pan);
vec_add(trceblt, camera.x);
while(my!=NULL)
{
c_move(my,bspeed,nullvector,IGNORE_PASSABLE);
if(c_trace(my.x, trceblt, IGNORE_PASSABLE| USE_POLYGON| SCAN_TEXTURE)>0)
{
rmvblts();
}
wait(1);
}



Sorry if I dont use indentation.
The rmvblts function only remove itself, you could add ent_remove(you) somewhere in the function but it will be simpler if you add ent_remove(me) in the end of mvblts function like this:
Click to reveal..

Code:
function mvbllt()
{
...
  my.skill71=0;
  while(my.skill71!=NULL) //<---Changed my to my.skill71(or any flag or var  you like)
  {
     c_move(my,bspeed,nullvector,IGNORE_PASSABLE);
     c_trace(my.x, trceblt, IGNORE_PASSABLE| USE_POLYGON| SCAN_TEXTURE)//this line can be removed if you like
     if(result>0){my.skill71=1;}
     wait(1);
   }
   ent_remove(me);
}





Last edited by bart_the_13th; 08/25/09 11:15.
Re: updating camera code [Re: bart_the_13th] #286528
08/25/09 17:06
08/25/09 17:06
Joined: Jul 2009
Posts: 80
Area 51
F
fangedscorpion Offline OP
Junior Member
fangedscorpion  Offline OP
Junior Member
F

Joined: Jul 2009
Posts: 80
Area 51
Do you know how to create a decal that actually works?
Whenever I try to make one, I always receive an error.


"Pow! You are dead! Not big suprise!" -Heavy

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

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