OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Wadmann on 16 Jun 2003, 18:15:35
-
I would like to know how to activate a trigger when any unit picks up a weapon created by the "createweaponvehicle" command. I have read about the "hasweapon" command but it asks for the weapon name (ie "M16") but I would like to trigger it if a specific weapon named (and displayed) by "createweaponvehicle" is picked up for a booby trap effect. I have searched but perhaps I am not phrasing my question correctly any I get few or no results from my prompts. Thanks in advance for any replies! Wadmann
-
I think you mean "createvehicle", not "createweaponvehicle".
You could probably use a trigger or a script to monitor the position of the weapon in question. When the position changes, then camcreate a grenade at that point. That would represent a booby trapped weapon.
-
Use this (http://www.ofpec.com/includes/download2.php?id=194) script and in it you can name the 2 weapons you created.
so in your script you can now write player hasweapon "_Pistol1"
-
Ace, your sig make my eyes hurt ... :P
-
Thanks for the quick replies! Please let me make a couple of points clear:
1) I usually post from work (Hope my boss isn't looking) so most information is from memory (deaddog-you are correct about "createvehicle").
2) I cannot script! I understand enough and even modify them a little but I cannot create a script from scratch.
3) I was looking for something that I could put in the condition field of the trigger (something like "foreach this list hasweapon rpd1") in order to activate my boobytrap script.
I hope this clarifies what I am looking for. Thanks again!
Wadmann
-
Type this in you're condision field
unit hasweapon "m16" (for example)
Then the trigger starts.
But this does not work with endings
I hope this is what you mean
-
I am using the script that Ace linked to and have a weapon named "rpd1". If I understand correctly, I can use "rpd1" as a weapon name for the "hasweapon" command. I thought that "hasweapon" command was asking for "sebak47" for a Nam Pak weapon (or as in the script example "tokarev") .
Assuming I can use "rpd1" to specify that exact weapon, what would I type in the condition field of a trigger that would activate if any unit picks up the weapon named "rpd1". I am guessing something like
(_this inlist) hasweapon "rpd1"
Am I even close to getting my desired results?
@FleX- I think you mean that you cannot use this to end a mission. If true then no worries, this is just for a little fun in the middle of a mission.
Wadmann
-
Yes that should work. I would test but I am on a computer without OFP
And Flex, u can end missions with that condition.
-
Ace, your sig make my eyes hurt ... :P
Huh? Why?
-
Thanks Ace! I did not get a chance to try that line of code last night but I will try to make some time tonight and confirm if it works so that we can close this thread. Do I need to create a trigger that covers the entire map that would create a list of all players or will (_this inlist) create it's own list?
Wadmann
-
Huh? Why?
the avatar, not the sig ::)
-
Ace, your sig (avatar) make my eyes hurt ...
hehehe, mission accomplished. Next avatar - one of those swirly red and black circles used for hypnosis
-
After typing in (_this inlist) hasweapon "rpd1" in the condition field of a trigger, I received this error message:
Error:Local variable in global space
I then replaced the () with {} and received this error message:
Error:hasweapon type string expected object
I have tried several variations including "_rpd1" , _rpd1 (that gave "local variable in global space") with different bracket combinations and still no success.
If none of the gifted scripters out there can help me with this angle, then I may have to ask deaddog to elaborate on the method of determine a change in movement to activate my trigger.
Thanks in advance for any and all replies!
Wadmann
-
DOes it have to be anyone within a trigger?
Or can it just be the player picking up the weapon
Player hasweapon "rpd1"
-
Here is what I found after some experimenting.
Store the position of the weapon after it is created:
rpd1="weaponholder" createvehicle blahblahposition
rpd1 addmagazinecargo ["m16",4] (or whatever)
rpd1 addweaponcargo ["m16",1]
rpd1_pos=getpos rpd1
All of that can be created in a trigger or script.
Now, in another trigger, put this in the condition field:
(getpos rpd1 select 0) != (rpd1_pos select 0) && (getpos rpd1 select 1) != (rpd1_pos select 1)
Basically, if the weapon moves (gets picked up) then the trigger will activate. It doesn't matter who picks it up. The size of the trigger doesn't matter nor does the position of the trigger. This worked for me.
:)
-
Thanks for the recent replies!
@ Ace - I want it to be able to be used in MP so I did not want to limit it to Player. ;)
@deaddog - Thanks for the detailed response! When I get home this evening I will try it out and (hopefully) close this thread. One question though. Do I put the line rpd1_pos=getpos rpd1 in the activation line of the trigger that created rpd1?
Thanks for all of the help! ;D
Wadmann
-
Do I put the line rpd1_pos=getpos rpd1 in the activation line of the trigger that created rpd1?
Yes. You can put all four of those lines in the activation line of one trigger, just separate them with a ;
-
how do you create a weapon?
-
I was hoping to close this thread but tis not the case! :(
@KyleSarnik - See the second reply in this thread and click on "this".
@deaddog - I copied and pasted right from your reply and nothing happened. ??? I even put some text in the trigger just to see if the trigger was activated but my scripts were not being triggered but still nothing happened! Did you actually create a demo mission to test your code and if so (and more to the point) do you still have it and can I get it? Did you change any of the trigger settings like "Activation" or "Type"? I am not trying to make this any harder than it should be but a demo or even a script would sure help my sorry a*s out! Thanks in advance for any effort put forth to help me out of this nightmare. ;D
Wadmann
-
I didn't save my mission but I did make a new one. Just a couple of triggers. I attached it below. Just make a folder called takegun.intro (or whatever) and put the mission.sqs file in it.
I did this with an ak47. I did notice one interesting thing. If you are carrying a gun (like the m16) and then take the one on the ground, the trigger will not activate. If you drop the m16 and then take the ak, it works. If you substitute a secondary type weapon (rpg or law), then the script will trigger.
My theory on this is this. We are not actually creating a weapon. We are creating a "weapon holder". If we take the ak47 then the m16 is placed in the "weaponholder" and it doesn't "go anywhere" so its position does not change.
If we put a rpg in it, or we are empty handed, then no weapon is put back in the weapon holder. It then is deleted or disappears, thus it moves.
Basically, if we trade weapons the trigger won't fire but if we take the weapon without replacing one, it works.
Also, you will have to wait about 20 seconds after the weapon holder is created before you can take the weapon. An OFP issue.
Let me know if this helps. :)
-
Thanks for taking the time to make a demo deaddog. After posting my reply last night, I attempted to resolve this on my own (mistake) and several hours later determined that your code should have worked! I guess great minds think alike as I came to the conclusion that "rpd1" never moved, nor was it picked up,merely replaced so that the trigger conditions that we were trying would not work. I finally used a small any unit present trigger to get it to work.
One thing I must now work out ( if possible) is when using a secondary weapon like a rpg as a created weapon, it stands up vertically, not lying down like an ak would. I did download a script from the editors depot the tweaks the pitch/bank of an object and will atempt to get an rpg to lay on the ammo box when time permits.
I would like to resolve this so that I can start another thread with an issue that I now have with imported sounds not working. :P If it's not one OFP issue, it's another!
Hopefully my next post will be "Case closed!". ;D
Wadmann