Home   Help Search Login Register  

Author Topic: replacing objects in-game  (Read 1783 times)

0 Members and 2 Guests are viewing this topic.

AnarCHy

  • Guest
replacing objects in-game
« on: 04 Jul 2004, 13:04:37 »
Well, how do you do it?

I am making a large SF mission which requires stealing a "strategic map", and I want to know how to replace the table with map with just Table when it says "Map Acquired".  Anyone know how?

P.S. Forgive me if this has come up in a different subject but I don't have time now to search.

Offline Roni

  • Members
  • *
  • Play the Game !
Re:replacing objects in-game
« Reply #1 on: 04 Jul 2004, 13:16:58 »
Sorry if this reply is very scanty but here goes -

Place your "table with map" object in your mission
Add an action to the table's Init field:

=> this addaction ["Take Map", "takeMap.sqs"]

Create a script called "takeMap.sqs"

Have the script do the following -
_tablePos = getPos this
deleteVehicle this
"table without map" camcreate _tablePos

I don't know the name of the table without map object - you'll have to look that up by putting one in the mission, saving the mission as a user mission, then jumping out and opening the mission file.

Good luck !

PS - anyone know how to determne the distance to the nearest enemy unit ?


Rags

AnarCHy

  • Guest
Re:replacing objects in-game
« Reply #2 on: 04 Jul 2004, 13:22:24 »
Thanks Roni i found it and it works well.



PS - anyone know how to determne the distance to the nearest enemy unit ?


Rags

If you see the unit, you press 2 for the targets and it will say the rough distance to the unit

AnarCHy

  • Guest
Re:replacing objects in-game
« Reply #3 on: 04 Jul 2004, 13:49:27 »
there is something else I need for the table to do...
Be all the way bove ground
When it creates the empty Table, half of it is underground.  Iknow I need to set pos it but dont know how.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:replacing objects in-game
« Reply #4 on: 04 Jul 2004, 18:59:44 »
There's an example in the online comref in the Ed Depot.  I won't try and and quote it because I'll get it slightly wrong.
Plenty of reviewed ArmA missions for you to play

Offline Roni

  • Members
  • *
  • Play the Game !
Re:replacing objects in-game
« Reply #5 on: 04 Jul 2004, 23:40:07 »
Hi AnarCHy

Delete the last line of the above suggested script and add the following -

_newtable = "table without map" camcreate _tablePos
_X = getpos _newtable select 0
_Y = getpos _newtable select 1
_Z = 1
_newtable setpos [_X, _Y, _Z]


I think that's it.  I used a variation of the above to make a "Jump" script - it's a player addaction and allows the player to jump onto roofs, rocks etc.

Good luck !



Roni



AnarCHy

  • Guest
Re:replacing objects in-game
« Reply #6 on: 05 Jul 2004, 01:02:45 »
Well, it worked once, then for some reason when I modified the script i little it did not change the table at all.

AND that last part you told me to add made the table be about 1m off the ground!

Heh, I don't know about you, but my tables never float ( :( )
« Last Edit: 05 Jul 2004, 01:16:31 by AnarCHy »

Offline Roni

  • Members
  • *
  • Play the Game !
Re:replacing objects in-game
« Reply #7 on: 05 Jul 2004, 01:24:10 »
Flaoting tables - what's your problem ?   ;D

Seriously, if you put items a bit above the ground they usually drop to floor height - I'm not sure why yours didn't.  Is your room on a slope or hill ?


In any event, I realised after I sent the last post that there is an easier way.  Try this -

In table with map's Init field - this addaction ["Take Map", "takeMap.sqs"]

Create a script called "takeMap.sqs"

Have the script do the following -

_tablePos = getPos this
deleteVehicle this
"table without map" camcreate [_tablePos select 0, _tablePos select 1, 0]

Much easier and should place the table at floor height.  If not, keep tweaking the last variable until it works.

Good Luck !


PS - I'm trying to find the distance between a given unit and the nearest enemy of that unit within a script.  Don't worry - I've posted it as a separate query.



Roni

AnarCHy

  • Guest
Re:replacing objects in-game
« Reply #8 on: 05 Jul 2004, 11:08:38 »
Thanks Roni - testing it now...  well, now the table is halfway underground again...
I am gonna keep messing with the last variable tho so... yeah.

Thanks

 - AnarCHy

AnarCHy

  • Guest
Re:replacing objects in-game
« Reply #9 on: 05 Jul 2004, 12:13:49 »
Yes... it works, but when I am outside of the Actions' radius and go inside and perform the action, the script does not take effect:
Let me try and tell you in more clarity what happens;

I am crawling through a base, and come into the action "Take Map"'s radius, and the action appears in my action menu, but when I choose it, the script does not replace the table with a blank one.  HOWEVER, I tried just placing myself next to the table.  And guess what happened when I chose "Take Map"?  It replaced the table!  the only time the table is not replaced is if I moved at all during the mission.

Help!!!

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:replacing objects in-game
« Reply #10 on: 16 Jul 2004, 23:27:05 »
I did something similar in one of my missions called Retreive our Maps.

I didn't use camcreate I simply had a table without the map and a table with the map and I swapped them over.  Specifically:

Table with Map called Map1 that had in its init field:  
map1index = this addaction["Get Map 1","GetMap1.sqs"]

I had a table called Table1 and a marker called MoveTo1

GetMap1.sqs was:

Code: [Select]
_pos = getPos Map1
Map1 setPos getPos MoveTo1
Table1 setPos _pos

GotMap1 = true

exit

I put both map1 and table1 facing the same direction so I did not need to re-align them in the script.

It worked every time whether I had moved or not.  You could play around with the setPos to give you your hight above/below ground. Specifically replace the line

Table1 setPos _pos

with:

Table1 setPos [_pos select 0, _pos select 1, (_pos select 2) - x]

where x is the amount below Map1 that you want to place Table1.

I have not tested this but it should work
« Last Edit: 17 Jul 2004, 21:25:11 by THobson »

DBR_ONIX

  • Guest
Re:replacing objects in-game
« Reply #11 on: 17 Jul 2004, 20:25:04 »
Just shortening the idea..
Have your table with map called maptable, and your empty one called maptable1

Then, the code, changetable.sqs (Anything, really)
Code: [Select]
maptable1 setpos getpos maptable
deletevehicle maptable

You could run that from a trigger, even,
Code: [Select]
maptable1 setpos getpos maptable;deletevehicle maptable
;)
- Ben

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:replacing objects in-game
« Reply #12 on: 17 Jul 2004, 21:20:20 »
Yeh.  I have not used delete vehicle before but I can see that would tighten up the code.

As one table has the map and one doesn't I suggest the code would be easier to read if it was clear which was which, so I would still stick with MapTable1 for the table with the map and Table1 with the table without the map.  (I am assuming there may be more than one map)

I think AnarCHy also wants to manage the height at which all this happens so his setPos will need to have the three coordinates shown separately.  That is still possible with what you have done.  It just makes it:

Code: [Select]
table1 setpos  [getpos maptable1 select 0, getpos maptable1 select 1, (getpos maptable1 select 2) - xx]
deletevehicle maptable1

Bye the way has anyone noticed that if you use the Map unit  (The map that is on a three legged easle)  and there is an explosion near it (even only a grenade) the map takes off and never comes down!  A pity.  I wanted to use it for my mission but couldn't for that reason.

« Last Edit: 17 Jul 2004, 21:21:33 by THobson »

Offline Roni

  • Members
  • *
  • Play the Game !
Re:replacing objects in-game
« Reply #13 on: 19 Jul 2004, 01:57:34 »
"Bye the way has anyone noticed that if you use the Map unit  (The map that is on a three legged easle)  and there is an explosion near it (even only a grenade) the map takes off and never comes down!"


I think that there is some sort of value for "Item Weight" or something in each items config file.  If you could hack this file for the Map item you could set the weight to something a lot higher.

Many lifetimes ago I learned how to play with the settings in DOOM.  I changed the standard Gunners to be invulnerable, be able to see through and walk through walls and have zero weight.  When you shot them they flew through the walls then started running back towards you.  Of course you couldn't see them until they walked back through the walls again . . .    :noo: :gunman:

If you try the Addons forum I'm sure you could find someone who might be able to help.



Roni

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:replacing objects in-game
« Reply #14 on: 19 Jul 2004, 08:23:54 »
I guess you are right.  Thanks.  In the end I just replaced it with a standard table with map.