OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Evan Scown on 18 Jun 2006, 22:13:30
-
Ok my idea is I have made alittle building (thanks to editor upgrade) and in it i have a desk and an officer. What I'm wanting to do is when a player approches the desk, he/she gets a nice happening set preset weapons. Is this doable? If so how?
Note the players are in a group called WGroup and are at the preasent not armed.
-
are you talking about entering an armoury and selecting a weapon from the selection.
If so, for best results, this would require a dialog system
yes its doable
it would take a skilled scripter/dialog maker some effort to create a pleasant system
Its certainly not for the novice
-
hoping you have a single floor building, this way should work
set one trigger, size and shape as you need
anybody present (may be changed for your needs)
on activation: dude = thislist select 0; [dude] exec "addweapon.sqs"
script "addweapon.sqs"
_unit = _this select 0
_unit addmagazine "M16"
_unit addweapon "M16"
exit
-
I've attached a screen shot with an idea cause I figured while a trigger would be handy for the for a talking part, I could do something like that in the script. But as you can see 8 guys, individually required to go in and kit up.
[attachment deleted by admin]
-
ok, wrote the following script for your purpose...hope it is what you need.
this script has to be started for every unit you like to get a weapon at table.
; ***********************************************************
; ** [this, table, 5, "G36A", "G36Amag", 3] exec "addweapon.sqs" **
; ***********************************************************
; ** Object might be a named object placed yourself, or a map object by using "object 12345" which might be pretty inaccurate
; ** A table or an invisible help object like a gamelogic might do the job
; getting variables
_unit = _this select 0
_object = _this select 1
_mindist = _this select 2
_weapon = _this select 3
_magazine = _this select 4
_magcount = _this select 5
_a = 0
; _unit = Unit which has to get weapon
; _object = Editor object which will "give" the weapon
; _mindist = distance unit to object ro receive Weapon
; _weapon = Weapon to give (duh)
; _magazine = no comment...guess it yourself ;-)
; _magcount = numbers of magazines to give
#loop
? (_unit distance _object) <= _mindist: goto "addweapon"
~1
goto "loop"
#addweapon
; removeallweapons _unit //uncomment this line if necessarly
#weaponloop
_a = _a + 1
_unit addmagazine _magazine
? _a != _magcount : goto "weaponloop"
_unit addweapon _weapon
#end
exit
greetings
[sT]-Myke[aO]
-
Sweet, thanks mate. If I wanted to do multiple weapons and else, cause I'll prolly play around with howmany weapons I want, so like not define _weapon & _magazine till later in the script?
-
well, if you like to have multiple weapons (like a M16 with 4 mags, a LAW launcher with 3 missiles and a binoc and a NV google) you can just extend the script (you might fix insert a "addweapon "binocs" if you like to give everyone a binoc) for your needs.
Or you can call the script multiple times for each weapon. This way you could do something like "well soldier, you have now your rifle, go now to that table to get your LAW".
Myself, i like to keep things open in script and insert parameters while executing script. This way i can easily experiment around with different things without the need to alt+tab out of OFP and edit the script itself. Surplus you can use the same script for different needs without editing and saving it.
If i would have fix inserted the M16 in this script, and now you would like to have a sniper rifle for another unit, you would have a second script just for this guy.
And now imagine you would like to give every unit a different weapon....stupid idea i knw, but just think about...this would make 8 scripts.
With a "one-size-fits-all" script the mission file will be smaller. I know, .sqs files will not take a lot of space, but once you use a lot of scripting, it might be a difference between 100 scripts or 25 scripts. You get the idea.
But the most important thing: read my script carefully, i left a lot of comments in there for you. Check how the script works, what it does. Once you get the flow of a script you might be able to change it to your needs.