A little problem with spawning position
Moderator: InsideQC Admins
15 posts
• Page 1 of 1
A little problem with spawning position
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:
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.
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: Select all
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.
-

ajay - Posts: 559
- Joined: Fri Oct 29, 2004 6:44 am
- Location: Swindon, UK
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.
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.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
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.
-

ceriux - Posts: 2223
- Joined: Sat Sep 06, 2008 3:30 pm
- Location: Indiana, USA
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...
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...
-

ajay - Posts: 559
- Joined: Fri Oct 29, 2004 6:44 am
- Location: Swindon, UK
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.
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.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Also, if you don't want it to look like it's at a different offset when you look up and down, change this:
to this:
Actually, I discourage this method entirely and recommend you make it a v_ weapon
- Code: Select all
oil.origin = oil_spot.origin + v_forward*70;
to this:
- Code: Select all
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
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.
- Sajt
- Posts: 1215
- Joined: Sat Oct 16, 2004 3:39 am
Why don't you use MOVETYPE_TOSS instead of MOVETYPE_NONE?
QuakeWiki
getButterfly - WordPress Support Services
Roo Holidays
Fear not the dark, but what the dark hides.
getButterfly - WordPress Support Services
Roo Holidays
Fear not the dark, but what the dark hides.
-

Chip - Posts: 575
- Joined: Wed Jan 21, 2009 9:12 am
- Location: Dublin, Ireland
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.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
-

ajay - Posts: 559
- Joined: Fri Oct 29, 2004 6:44 am
- Location: Swindon, UK
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:
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.
... I'm really keen to work out why it doesn't work!
Anyway, I've changed it to this:
- Code: Select all
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.
-

ajay - Posts: 559
- Joined: Fri Oct 29, 2004 6:44 am
- Location: Swindon, UK
As Spike already pointed out, your problem is here:
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).
- Code: Select all
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).
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
15 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
