Jump to content
Sign in to follow this  
Carpaazi

Trigger that adds action and gives a pipebomb ?

Recommended Posts

Heyall!

Im making a cooperative spetznatz mission, and there is a part in the mission where players need to collect hidden exlosives (pipebombs) from a trashcan.

I know its something like this

this addAction ["Take explosives","scripts\explosives.sqs"]

but this doesnt seem to work because the action "take explosives" doesn't show up at all?

I have a trigger 2x2 in size above the trashcan and it is as follows: activation = OPFOR -> repeatedly, condition = ({_x in thislist} count [p1,p2,p3,p4,p5,p6]) == 1 (im quite sure this is not the right code to be used when i want the trigger to activate for the specific p-unit only, so help here too =) ?), activation = this addAction ["Take explosives","scripts\explosives.sqs"].

I need a know what to write inside the "explosives.sqs" so that the p-unit that arrives at the triggers area, can use the action, and a pipebomb is added to his gear

Any suggestions are welcome

Share this post


Link to post
Share on other sites

Get rid of the trigger and just use condition parameter for addAction:

trashcan addAction ["Take Explosives","scripts\explosives.sqs",[],1,true,true,"","isPlayer _this && _this distance _target <= 3"

This will make the action only show when a player is within 3m of the trashcan. Much easier than using triggers.

Then for the explosives.sqs:

(_this select 1) addMagazine "PipeBomb"
(_this select 0) removeAction (_this select 2)

Edited by Big Dawg KS

Share this post


Link to post
Share on other sites

Thank you!

Btw you had a little typo at the "explosives.sqs"

(_this select 1) addMazine "PipeBomb"

, hehe xD (addmazine)

Thanks again!

Share this post


Link to post
Share on other sites

Lies... :j:

A suggestion though:

(_this select 1) playMove "AinvPknlMstpSlayWrflDnon"

Animation name may be slightly wrong, written out of memory (part I'm unsure about is Slay), but adds a nice effect.

Edit: Fuck this shitty dell keyboard. :mad:

Edited by Big Dawg KS

Share this post


Link to post
Share on other sites

I would suggest actually adding the action to the trashcan instead of putting it in a trigger.

init of the trashcan

this addAction ["Take explosives","scripts\explosives.sqf"]

scripts/explosives.sqf

_obj = _this select 0;
trashguy = _this select 1;
_id = _this select 2;
publicVariable "trashguy";
_obj setVehicleInit format ["this removeAction %1;trashguy playMove 'AinvPknlMstpSlayWrflDnon'",_id];
processInitCommands;
trashguy addMagazine "PipeBomb";

should work, i guess.

Edit:

good idea with the animation, I've changed the code accordingly.

ps.: The very difference with this code, is that it works in multiplayer.

Edited by Tajin

Share this post


Link to post
Share on other sites

It's possible they'd started replying before you did Big, but finished later. :) For one I thank you for your pointing out that addaction has a condition parameter to it, didn't know that. :)

Share this post


Link to post
Share on other sites

And imagine how happy I was when I found it, that is why I must spread the word (already posted 3 examples of it).

Share this post


Link to post
Share on other sites
Did you just like ignore all of the posts below the first or something? :j:

Well, my post simply took a bit longer.

Anyway, take a closer look. I don't think its necessary to check the distance as long as the action is attached directly to the trashcan (nice to have it though). The important point is.: I assume that your example will only work in singleplayer, because in multiplayer if player 1 picks the explosives, player 2 could still see the action.

I don't quite see your problem with my post, if we put all this together we'll get the perfect solution. How can that be wrong ?

Edited by Tajin

Share this post


Link to post
Share on other sites

Not having a comref I can't check behaviour of addAction in MP, but yes I'm assuming the script executes on all clients (please correct me if I'm wrong). Even if it doesn't there are plenty of quick and easy ways to fix it.

Ex:

trashcan addAction ["Take Explosives","scripts\explosives.sqs",[],1,true,true,"","isPlayer _this && _this distance _target <= 3 && !explosivesTaken"

(_this select 1) addMagazine "PipeBomb"
(_this select 1) playMove "AinvPknlMstpSlayWrflDnon"
explosivesTaken = true; publicVariable "explosivesTaken"

This way you also have a global variable to know that the explosives were taken (needs to be updated for JIP players though, like any global variable), if you need to at any point (for example if it was an objective and you want to know if it's been completed).

As for your solution, it looks a bit messy. I think mine is a cleaner, which is always nice. Also, I wanted to emphasize the ability to give actions conditions.

I'm checking the distance because the default radius for actions is quite large (like somewhere around 10m), and since these explosives are supposed to be "hidden", plus the fact that Carpaazi initially used a 2x2 trigger (which is quite small), I figured the player should have to get fairly close before being able to see it.

Btw, it would have taken you a long time to write that post if you didn't see my first post (my post: 10:44 your post: 11:17 that's a whole half hour).

Edit: I want to break this piece of shit keyboard so badly... :mad:

Edited by Big Dawg KS

Share this post


Link to post
Share on other sites

I try these new varitation also. Argue more so i can try out your scripts,hahaha! ;D

Thank you for the both of you!

Share this post


Link to post
Share on other sites

Nothing messy about it. Using setVehicleInit is a default procedure for making things MP-compatible. Ofcourse you can use an publicVar in the action-condition, but:

1. I still wouldn't play the animation on all clients, so you would need setVehicleInit anyway.

2. If the explosives are gone, they are gone... no need to keep the action. Why not free up that tiny bit of memory and remove it ? Conditions are cool if you want the action to show up again whenever the condition is met, but in this case it is only fired once. ;)

3. My solution should work with JIP too. Because the script overwrites the vehicle init, effectively removing the addaction command aswell.

It's good to have such discussions, since there is alot to learn from them. Just please trust me that I do put some thought in every line of code I post here. ;)

ps:

Btw, it would have taken you a long time to write that post if you didn't see my first post (my post: 10:44 your post: 11:17 that's a whole half hour).

I dont hit F5 all the time and I've got work to do here so it can sometimes take quite a while to finish a post. ;)

Edited by Tajin

Share this post


Link to post
Share on other sites
1. I still wouldn't play the animation on all clients, so you would need setVehicleInit anyway.

I wasn't aware of playMove having only local effects (doesn't make any sense why it should)? Then again I don't have a comref to check... :(

2. If the explosives are gone, they are gone... no need to keep the action. Why not free up that tiny bit of memory and remove it ? Conditions are cool if you want the action to show up again whenever the condition is met, but in this case it is only fired once.

Because it's new, and we should use it for everything... :j:

3. My solution should work with JIP too. Because the script overwrites the vehicle init, effectively removing the addaction command aswell.

Well, I'm not a fan of JIP anyways. Besides, anything you do has to be made JIP proof now (partly why I don't like it).

Share this post


Link to post
Share on other sites
Because it's new, and we should use it for everything...

hahaha :D

If you say so.

No access to a comref ?

http://www.arma2.com/comref/comref.html <-- there you go

Pretty much anything that is not a solid object ingame is only local. Lovely isn't it ?

JIP is not so hard if you keep it in mind from the beginning. Adding it afterwards is a pain. :(

Edited by Tajin

Share this post


Link to post
Share on other sites
No access to a comref ?

http://www.arma2.com/comref/comref.html <-- there you go

I will never understand the content filter at my workplace and why it decides to block this only sometimes... thank you (saved to desktop, now I have it and they can't take it away from me). :yay:

Edit: Lol, the links don't work (they still try to take me to arma2.com, and then it's blocked) but at least I can still read everything (thank god for ctrl-F).

Edit 2: This comref says nothing about MP behaviour. I'd usually use the Wiki but that's also blocked (fucking workplace).

hahaha

If you say so.

Btw, I was being sarcastic (I'm not sure if people ever realize when I am).

Edited by Big Dawg KS

Share this post


Link to post
Share on other sites

Guess i can test these varitation of yours once my friend get the damn game first xD.

Its always good to have more thatn one example/suggestion to test and see what works best =)

Share this post


Link to post
Share on other sites

TAJIN

Your solution doesn't give the pipebomb for some reason?

It reads "Take explosives", player makes the move, but grabs air =/

---------- Post added at 11:52 AM ---------- Previous post was at 11:52 AM ----------

BIG DAWG KS

trashcan addAction ["Take Explosives","scripts\explosives.sqs",[],1,true,true,"","isPlayer _this && _this distance _target <= 3 && !explosivesTaken"

This doesn't show up at all xD. I added ] at the end of the code since it was missing there but it doesnt show any "take explosives" text on screen nor in action menu.

Share this post


Link to post
Share on other sites

One question regarding the explosives number in the trashcan.

it seems that i can take unlimited amount of pipebombs from there xD. That can be bad and makes players quickly to play around with the explosives and do all kinds of stupid things (hmm,think i blow up whole elektrozavodsk)

Can you limit the number of explosives IN the trashcan, or PER player FROM the trashcan?

Also i noticed this script has problem with the switchmove, it doesn't "play" it

Share this post


Link to post
Share on other sites

Explosives.sqf

(_this select 1) addMagazine "PipeBomb"
(_this select 1) playMove "AinvPknlMstpSlayWrflDnon"
explosivesTaken = true; publicVariable "explosivesTaken"

trashcan object:

trashcan addAction ["Take Explosives","scripts\explosives.sqf",[],1,true,true,"","isPlayer _this && _this distance _target <= 2 && !explosivesTaken"]

Share this post


Link to post
Share on other sites

woops, had an wrong variable in there

fixed:

init of the trashcan

this addAction ["Take explosives","scripts\explosives.sqf"]

scripts/explosives.sqf

_obj = _this select 0;
trashguy = _this select 1;
_id = _this select 2;
publicVariable "trashguy";
_obj setVehicleInit format ["this removeAction %1;trashguy playMove 'AinvPknlMstpSlayWrflDnon'",_id];
processInitCommands;
trashguy addMagazine "PipeBomb";

Share this post


Link to post
Share on other sites
(_this select 1) addMagazine "PipeBomb"

(_this select 1) playMove "AinvPknlMstpSlayWrflDnon"

explosivesTaken = true; publicVariable "explosivesTaken"

You are missing semicolons after each line in the script. Add them first and see how it behaves.

Edit: Ok here's how you could allow them to take up to a certain number of charges.

Init

trashcan addAction ["Take Explosives","scripts\explosives.sqf",[],1,true,true,"","isPlayer _this && _this distance _target <= 2 && explosivesRemaining > 0"]; explosivesRemaining = 3

explosives.sqf

(_this select 1) addMagazine "PipeBomb";
(_this select 1) playMove "AinvPknlMstpSlayWrflDnon";
explosivesRemaining = explosivesRemaining - 1; publicVariable "explosivesRemaining"

@Tajin, what's the nature of addAction (in terms of script locality) in MP? I haven't tested recently but my guess is scripts are local to the player who "used" the action (or the server if AI used it). Is this correct?

Edited by Big Dawg KS

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×