Object movement question for the experts.

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Balr14
Colonel
Posts: 450
Joined: Sat Aug 03, 2002 4:01 am
Location: Germantown, WI, USA

Object movement question for the experts.

Post by Balr14 »

I've looked closely at JV_map's airplane and vehicle scripts and Scorpio_midget's tank scripts. It looks like vehicle control with respect to direction of movement is basically replacing the player model with a vehicle (or airplane) model. The player movement controls then function to control the vehicle. If this is correct, then it would seem there isn't any way to control a vehicle independent of the player controls, particularly something that is brush based and not a model.

I'm trying to control the directional movement of a scripted object that is brush based and I don't see how it's possible. Is this true, or am I missing something?
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

what you want would probably be impossible since you're talking about setting direct velocities, which i dont think are possible through mods. in MOHAA the only way to set velocities is by using move commands, which handle all calculations for you.

but i could be wrong.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

And wrong you are. :P If you use physics_on on a script_object, you can mess with its velocity and it will behave more or less correctly. :) You can't change the mass of the object, though, which is a pity. The collision detection can be sometimes a bit off, and the object's rotation is never affected.

Balr14, it doesn't matter if an object is a model or a brush, it can be done, but I'm warning you - it's not an easy thing. What complicates matters is the fact that you want the rafts to be floating on water. You'll either have to:
  • make the water solid (not an option IMHO),
  • use a script to force the raft's Z axis position every frame.
There's also the question of the raft's propulsion - does it have an engine? Does it go with the current? It'd be quite weird if the player could make it go back and forth. ;) Also, how do you choose which player controls it?
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

It's perfectly possible to use a script_object instead of a model. A model, however, is often preferable for 2 reasons:
  • You can attach other entities to a model. You can only bind or glue entities to a brushobject. The difference is that attach is handled on the client whereas bind and glue are handled on the server. As a result, glue and bind induce significant network traffic whereas attach induces zero continuous network traffic.
  • Texturing is often easier on a model. If you're using brushes, you'd have to use only custom textures with the lightmap stage replaced by a rgbGen lightingSpherical. This will allow dynamic lighting (to some extent) on the brushobject. Otherwise you'll get a static lightmapped object which doesn't look half as good. Additionally, it's not possible to instantiate a brushobject with static lightmaps. i.e.

    Code: Select all

    local.instance = spawn ScriptObject model $template.brushmodel
    will spam the console complaining the lightmap shouldn't be rendered twice.
My first attempts @ the modern warfare heli were flying script_objects, so it's certainly possible, but if you have the possibility I recommend using a model for better performance and flexibility.

Concerning the actual script definately the major headache would be the collisions.. Mohaa's physics_on 'physics' is extremely buggy so I wouldn't want to rely on it for a mission critical object.. I haven't looked at your map but if it's possible to parametrize the boundaries of the river that would be the way to go.. however that's most likely not possible. :( In that case the shape of your raft is of major importance.. if it's more or less circular in a plan view, you're lucky. Good collision can be relatively easily achieved with traces. If you have a 'box'-boat, however, things will be much more complicated. I haven't been able to rigidly implement such a case in mohaa, yet :(

The closest I have come:
  • The modern wafare heli: it uses 12 script_objects with physics_on hidden and bound to the heli, at the vertices of its bounding box (8) and at the midpoints of the major edges (4). This method is unelegant and buggy so not recommended (it basically sucks).
  • Bouncing box: this one is already much better, utilizing a grid of sighttraces on the faces of the cube. It's definately an unrefined method but still relatively easy to implement without prior knowledge of map geometry. A major problem is that it'll be rather slow if you have many rafts. Also the accuracy depends on the size of the object compared to the size of a world feature: rocks etc that are much smaller than the raft will easily penetrate. This method suffers particularly from convex world geometry but does rather 'ok' in a concave world.
See also:
Bouncing box
Ropebridge
jv_boat
jv_heli - Improved version of MW's heli. Never released except I gave it to Gen Cobra.. not sure if he ever used it.
Image
Balr14
Colonel
Posts: 450
Joined: Sat Aug 03, 2002 4:01 am
Location: Germantown, WI, USA

Post by Balr14 »

Thanks. I guess I'll try and create a model then. After further consideration, I've decided the rafts should be large inverted mushroom tops, with a wooden (or mushroom stem) tripod to attach the rudder/oar. I already have large mushrooms in the map, so it seems only logical they would serve as rafts.

Hopefully, it is controlled by the player who grabs the rudder/oar. Propusion would be in the same manner as rotating a fixed machine gun, only when you swing the oar forward you drop it into the water and lift it out when you swing it back. Of course you would need to repeat the motions on both left and right sides. Once you have adequate movement, you use the oar to steer. Up/down keys would raise lower the oar/rudder, use key would attach the oar to the player.

Anyway, that's the way I'd like it to be, if I was a better scripter.

By the way jv_map, I studied your scripting work in your Flight mod. It's really some very impressive work.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Balr14 wrote:By the way jv_map, I studied your scripting work in your Flight mod. It's really some very impressive work.
Cool :D I didn't know those scripts are actually studyable.

Random quote:

Code: Select all

if(local.__STK0VAR0 > local.__STK0VAR6)
{
local.__STK0VAR0 = local.__STK0VAR6
}

if (self.speed - self.ground_velocity * self.groundfwdvec != 0.0)
{
local.__STK0VAR7 = local.__STK0VAR1 - local.__STK0VAR1 * self.groundnormal * self.groundnormal

local.__STK0VAR8 = self.groundsteer_sin
local.__STK0VAR9 = self.groundsteer_cos

local.__STK0VAR10 = local.__STK0VAR9 * self.groundfwdvec + local.__STK0VAR8 * self.groundlfvec
local.__STK0VAR11 = -local.__STK0VAR8 * self.groundfwdvec + local.__STK0VAR9 * self.groundlfvec

local.__STK0VAR12 = waitthread getgroundfrictioncoefficient_model2 (local.__STK0VAR7 * local.__STK0VAR10 / self.GROUNDFRICTIONYIELDSPEED_FORWARD)
local.__STK0VAR12 = local.__STK0VAR12 * self.ROLLINGRESISTANCE
local.__STK0VAR13 = -local.__STK0VAR12 * local.__STK0VAR10 * local.__STK0VAR0

local.__STK0VAR14 = abs (local.__STK0VAR7 * local.__STK0VAR10)
local.__STK0VAR15 = local.__STK0VAR7 * local.__STK0VAR11

if(local.__STK0VAR14 == 0.0)
{
local.__STK0VAR16 = 0.5 * level.PI
}
else
{
local.__STK0VAR16 = waitthread global/skylimit/math.scr::arctan (local.__STK0VAR15 / local.__STK0VAR14)
}

local.__STK0VAR17 = abs (local.__STK0VAR7 * local.__STK0VAR11)

local.__STK0VAR12 = waitthread getgroundfrictioncoefficient_model2 (local.__STK0VAR16 / self.GROUNDFRICTIONYIELDSLIPANGLE * 2.0 / level.PI)
local.__STK0VAR12 = self.GROUNDFRICTIONLATERAL * local.__STK0VAR12
local.__STK0VAR18 = waitthread getgroundfrictioncoefficient_model2 (local.__STK0VAR17 / self.GROUNDFRICTIONYIELDSPEED_LATERAL)
local.__STK0VAR12 = local.__STK0VAR12 * local.__STK0VAR18

local.__STK0VAR19 = -local.__STK0VAR12 * local.__STK0VAR11 * local.__STK0VAR0

// may be used to 'artificially' improve steering
// but shifting back center of gravity is preferred
if(self.TAILGEARFORCEBIAS)
{
local.__STK0VAR19 = local.__STK0VAR19 * self.TAILGEARFORCEBIAS
}
Wouldn't have made sense to me :P .. so let me know if you'd like to have a look at the source scripts (without method inlining) since they are far more readable :) Thanks, anyway ;)

Although I don't fully understand the rudder/oar story (maybe I have to read it again :P), a mushroom raft sounds doable. That doesn't mean it'll be easy, though. I don't know if you already have a scripter on this, or want to try it yourself, or are looking for someone to do it for you. Either way, people here will be able to assist you :) . You might also want to get in touch with Elgan, mostly found at http://mods-r-us.net . Without doubt he's one of the best active scripters for mohaa and has plenty of experience with vehicles.
Image
Post Reply