Home   Help Search Login Register  

Author Topic: Spawning things ontop of buildings  (Read 811 times)

0 Members and 1 Guest are viewing this topic.

Rappy

  • Guest
Spawning things ontop of buildings
« on: 10 Mar 2004, 23:04:02 »
Well this is probably a simple solution I've overlooked so I post it here.

Basically for a mp playground map I've made some actionmenu commands to spawn certain vehicles infront of you.

All works fine except for when you are on top of a building, then it spawns next to the building. I tried to give it height(in editor this would get the vehicle in the right place) but ingame it doesn't seem to work.

Should I use a gamelogic or something to somehow show it where to place the vehicle ?

Since it seems to count the ground plane (a bridge in water would spawn the vehicle on the bridge instead of in the water, yet for a bridge on ground the vehicle is spawned on the ground instead of on the bridge)

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:Spawning things ontop of buildings
« Reply #1 on: 11 Mar 2004, 07:57:38 »
This is a wierd bug. I remember MI_Fred encountering it when he was making a MP mission where you build defencive objects such as M2 machineguns using the action menu.
I wanted the script to be able to build the objects to a roof top if the player is there and not on the ground level.
I don't remember if he had it solved or not though. Maybe you can poke him with an IM?
Not all is lost.

Rappy

  • Guest
Re:Spawning things ontop of buildings
« Reply #2 on: 11 Mar 2004, 14:56:52 »
Ahh thanks, thought it might have to be a bug, I'll perhaps experiment with some things to see if there is a workaround.

It would be rather nice to spawn a bike on a rooftop on the fly and ride off the building, without having to preplace it.

Perhaps I should have a remote target(gamelogic, invisible H), need to test

Or perhaps find MI_Fred and ask him :)

Thanks

Offline MI_Fred

  • Members
  • *
  • AA
    • OFP Team Finlanders
Re:Spawning things ontop of buildings
« Reply #3 on: 11 Mar 2004, 15:08:37 »
I haven't tested this and I don't expect it to work, would be too good to be true. But it prolly will.  ;)

Code: [Select]
_dugl = "Logic" camCreate getPos dialogUser
_logic = "Logic" camCreate [0,0,0]
_x = getpos _dugl select 0
_y = getpos _dugl select 1
_dist = _logic distance _dugl
_ground = (_x ^ 2) + (_y ^ 2)
deleteVehicle _logic
deleteVehicle _dugl
_H = sqrt ((_dist ^ 2) - _ground)
_H should return the value relative to sea level. This is TakeOffTims function, but I find it easier when all is stuffed into 1 gigantic piece of code you can chew on. So I took it into one  ;D

EDIT: oh and setPos the mg infront of the dialogUser [somex,somey,_H].
« Last Edit: 11 Mar 2004, 15:09:56 by MI_Fred »
There's gooks over there, there's mines over there, and watch out those goddamn monkeys talk, I'll bite ya.

Rappy

  • Guest
Re:Spawning things ontop of buildings
« Reply #4 on: 11 Mar 2004, 18:25:31 »
Hey, thanks for the reply, I tested your code but it didn't work (I prolly misused it)

But there seems to be an easier way.

By spawning the game null on the player position, then just measuring the distance from the gamenull to player, since its on the same location the distance will be the height

So this way I could just add the height and get the object placed exactly to the right place.

Not a genious work but it worked nice with vehicles(another way was let em drop from some height, but this would most likely blow up some vehicles and might give complications in other areas)

I also tested and it works with MGs and I guess with any other object (ehehe pretty cool to see a MG placed on a roof actually)

Here's the code
_caller = _this select 0
_callx=getpos _caller select 0  
_cally=getpos _caller select 1  
_callz=getpos _caller select 2  
_calldir = getdir _caller  

#spawn
~0.2
_carxx = sin(_calldir)*_distance
_caryy = cos(_calldir)*_distance
_guide = "Logic" camCreate getPos _caller
_height = _guide distance _caller
_car = "sttklr250" createvehicle [(_callx+_carxx),(_cally+_caryy),50]
_car setpos [(getpos _caller select 0), (getpos _caller select 1), (getpos _guide select 2) +_height];
deletevehicle _guide



the object spawned in this example is the excellent dirt bike, but M2StaticMG is just as much fun :)


Either way, my problem is solved and I hope it might have helped somebody else too.


« Last Edit: 11 Mar 2004, 18:27:06 by Rappy »

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:Spawning things ontop of buildings
« Reply #5 on: 11 Mar 2004, 21:24:37 »
 :o
Good stuff Rappy  :thumbsup:
Not all is lost.

Rappy

  • Guest
Re:Spawning things ontop of buildings
« Reply #6 on: 11 Mar 2004, 22:04:53 »
You mean the map ? :D

It started out as a chopper training mp mission (it's hard to draw people into the game but I am doing quite well), but I ended up adding buildings and hte bridge on ground to test flying skills :D

ended up adding bikes and ramps too, turned out to be tons of fun :)

(bridge 50 meters off the ground + ramp = weee)

I hate the setpos stuff though, it's very hard to combine things and make em match up if every little change in terrain offsets the model (heck It seems even time of day affects it)