Inside3D!
     

A little problem with spawning position

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming
View previous topic :: View next topic  
Author Message
ajay



Joined: 29 Oct 2004
Posts: 295
Location: Swindon, UK

PostPosted: Tue Jun 08, 2010 6:50 pm    Post subject: A little problem with spawning position Reply with quote

Ok background:
As you may have seen in my "wonderful" earthQUAKE trailer, I have barrels in the mod that obviously explode and can be used as a weapon...
Anyway, to make it more useful I want it to not only explode when shot or bombed, but also to be pick-up-able and put-down-able so the player can place them where they can be of most 'use'.
So far I've got it mostly working. It can be picked up, it can be carried (sort of, see 'errors' below) and then placed (sort of, see 'errors' below). It will also blow up when shot etc.

Ok, now: 'errors'
- The model doesn't show when you're carrying it. I'm pretty sure this is not a code error, as if I change it to the rocket launcher model then it shows up. I think I need to adjust the model, but that's for another thread (in Modelling section, in fact)
- The positioning works, but not perfectly, depending on the angle the player is pointing at (up and down) it'll either be floating in mid air or half stuck in the ground.

See video: http://www.youtube.com/watch?v=ORnmNvrnR2w

Anyway the code that places the barrel is:
Code:
void() new_oildrum =
{
   local entity   oil, oil_spot;

   oil = spawn();
   oil_spot = find (world, classname, "player");
   oil.origin = oil_spot.origin + v_forward*70;//'50 0 0';
   oil.solid = SOLID_BBOX;
   oil.movetype = MOVETYPE_NONE;
   setmodel (oil, "progs/barrel.mdl");
   droptofloor();
   oil.health = 5;//20, may change
   oil.th_die = oildrum_explode;
   oil.takedamage = DAMAGE_AIM;
   oil.touch = oildrum_pickup;
};


This is kinda vital to the mod, in that a major part of it is about the player setting traps from objects within the environment. To be honest I'm still fairly happy that I've got this far with it, but would appreciate some help getting it perfect.
_________________
my site
Back to top
View user's profile Send private message MSN Messenger
Arkage



Joined: 19 Nov 2009
Posts: 27

PostPosted: Tue Jun 08, 2010 7:20 pm    Post subject: Reply with quote

For one id say that the model isnt postioned correctly, i think it been addressed in your other topic.

As for the floating, id do a trace line down and placethe barrel at the hit location but moved up by half its height.
Back to top
View user's profile Send private message
ajay



Joined: 29 Oct 2004
Posts: 295
Location: Swindon, UK

PostPosted: Tue Jun 08, 2010 7:23 pm    Post subject: Reply with quote

Cheers Arkage, but I don't know how to do that? Smile
_________________
my site
Back to top
View user's profile Send private message MSN Messenger
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Tue Jun 08, 2010 7:30 pm    Post subject: Reply with quote

v_forward*70 will put the barrel in the ground if the player is facing downwards at the time.
droptofloor will fail if its in a solid, or indeed if its in the player at the time.
Try moving the barrel up by 70*2, calling droptofloor, then checking to make sure its not dropped too far.

warning1: droptofloor may be spammy...
warning2: by moving it up 70*2 it may now be in the ceiling, causing walkmove to fail.

to avoid spam (w1), call walkmove(0,0) and check its return value to test to see if its stuck somewhere. also not sure if it'll fail if floating too high up... fl_fly should allow it to succeed when mid-air.
to resolve warning2, try a few different heights. :s

warning3: walkmove triggers triggers. but this shouldn't be an issue.

be prepared for walkmove to fail.
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
ceriux



Joined: 06 Sep 2008
Posts: 968
Location: Florida, USA

PostPosted: Tue Jun 08, 2010 7:56 pm    Post subject: Reply with quote

i was thinking of something like this once, the easiest way i could see it is make it a weapon that has a max ammo capacity of 1 and when its in the "world" make it the ammunition. when the ammunition is picked up the player can only choose to have the "barrel" as a weapon thats out so you cant switch out. after you fire the weapon it throws it out sorta like a grenade. at least my line of thinking.
_________________
QuakeDB - Quake ModDB Group
Back to top
View user's profile Send private message Yahoo Messenger
ajay



Joined: 29 Oct 2004
Posts: 295
Location: Swindon, UK

PostPosted: Tue Jun 08, 2010 8:02 pm    Post subject: Reply with quote

ceriux, thats exactly it mate! Just needs a little tweaking
_________________
my site
Back to top
View user's profile Send private message MSN Messenger
ajay



Joined: 29 Oct 2004
Posts: 295
Location: Swindon, UK

PostPosted: Tue Jun 08, 2010 8:14 pm    Post subject: Reply with quote

Just been discussing on facebook how coding may be a metaphor for life. In reality I think it's more like learning a foreign language; this is a good example: when in France a few years ago, I got by as they tend to know more English than I know French. After a while I got brave and tried out my appalling French, the listener obviously then replied rapidly in their own language and I was totally lost.
Now is similar. Spike's given me a great answer, but my knowledge was all tied up in my initial code, and although I've everything I need to make it work I have no idea how to do it!

NB This is in no way a criticism of the help I've been given, just an explanation of why I need a little more...
_________________
my site
Back to top
View user's profile Send private message MSN Messenger
Spike



Joined: 05 Nov 2004
Posts: 944
Location: UK

PostPosted: Tue Jun 08, 2010 9:17 pm    Post subject: Reply with quote

traceline is nice, but it doesn't cope with spikes/weird-shaped walls. tracebox does, but that's an extension.
walkmove(0,0) tests an entity's position reliably, but may move the ent down steps or fail if floating. setting self.flags|=FL_FLY; should fix that.
so put your barrel where you want it, and then keep moving it around until walkmove(0,0) returns true. when it does, call droptofloor() to ensure that its truely on the ground and not floating - but it might plummet far below you which would be unrealistic, in which case, detect that and abort (or use movetype_toss and undo the droptofloor).

that help any?

and yes, french is a horrible horrible language.
_________________
What's a signature?
Back to top
View user's profile Send private message Visit poster's website
Sajt



Joined: 16 Oct 2004
Posts: 1026

PostPosted: Wed Jun 09, 2010 12:53 am    Post subject: Reply with quote

Also, if you don't want it to look like it's at a different offset when you look up and down, change this:

Code:
oil.origin = oil_spot.origin + v_forward*70;


to this:

Code:
oil.origin = oil_spot.origin + oil_spot.view_ofs + v_forward*70;


Actually, I discourage this method entirely and recommend you make it a v_ weapon Razz
_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Back to top
View user's profile Send private message
Chip



Joined: 21 Jan 2009
Posts: 314
Location: Romania

PostPosted: Wed Jun 09, 2010 10:37 am    Post subject: Reply with quote

Why don't you use MOVETYPE_TOSS instead of MOVETYPE_NONE?
_________________
My Projects: Quake 1 Mods | OpenQuartz 2 | ChipQuake
Back to top
View user's profile Send private message Visit poster's website
ajay



Joined: 29 Oct 2004
Posts: 295
Location: Swindon, UK

PostPosted: Wed Jun 09, 2010 11:59 am    Post subject: Reply with quote

with TOSS it just drops right through the floor...
_________________
my site
Back to top
View user's profile Send private message MSN Messenger
frag.machine



Joined: 25 Nov 2006
Posts: 728

PostPosted: Wed Jun 09, 2010 12:13 pm    Post subject: Reply with quote

I think Sajt and avirox' suggestions are the best, so far: treat the oil drum like a 1-shot grenade launcher. Make a v_oil.mdl, and when you "fire" it, you toss the missile(using another model, oil.mdl) like a grenade (only using less velocity) and swap back to other weapon.
_________________
frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/
Back to top
View user's profile Send private message Visit poster's website
ajay



Joined: 29 Oct 2004
Posts: 295
Location: Swindon, UK

PostPosted: Wed Jun 09, 2010 8:34 pm    Post subject: Reply with quote

Yeah, I think you're right, I may have to redo it all, its not a lot of work really.
_________________
my site
Back to top
View user's profile Send private message MSN Messenger
ajay



Joined: 29 Oct 2004
Posts: 295
Location: Swindon, UK

PostPosted: Thu Jun 10, 2010 6:05 pm    Post subject: Reply with quote

But, before I change it all....

... I'm really keen to work out why it doesn't work!

Anyway, I've changed it to this:
Code:
void() new_oildrum =
{
   local entity   oil, oil_spot;

   oil = spawn();
   oil_spot = find (world, classname, "player");
   oil.origin = oil_spot.origin + v_forward*90;

   oil.flags = FL_ITEM;
   oil.solid = SOLID_TRIGGER;
   oil.movetype = MOVETYPE_BOUNCE;

   setmodel (oil, "progs/barrel.mdl");
   setsize (oil, '-18 -18 -25', '35 36 45');
   oil.health = 5;
   oil.th_die = oildrum_explode;
   oil.takedamage = DAMAGE_AIM;
   oil.touch = oildrum_pickup;
}


It works fine... unless.... the player isn't facing down, in which case the barrel just disappear's thru' the ground.

Now, I am planning that when the player is carrying the barrel, their speed is reduced ('cos it's heavy, obv) so whilst I'm playing with that I could stop the player looking down too (possible??) which wouldn't be too unrealistic as it it would be pretty hard too look down much when you're carrying a bloomin' oli drum!

Thoughts appreciated muchly, ta.
_________________
my site
Back to top
View user's profile Send private message MSN Messenger
frag.machine



Joined: 25 Nov 2006
Posts: 728

PostPosted: Thu Jun 10, 2010 7:03 pm    Post subject: Reply with quote

As Spike already pointed out, your problem is here:

Code:

oil.origin = oil_spot.origin + v_forward*90;


One way would be to save the player angles in a temp vector, force them to a fixed roll and tilt value (0), recalc v_forward, use these values to the drum origin and finally restore the player angles from the temp vector. This way the player can freely look around (and up and down) without affect the Z coordinates (but the drum origin stills being affected by player yaw angle value).
_________________
frag.machine - Q2K4 Project
http://fragmachine.quakedev.com/
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> QuakeC Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group