Home   Help Search Login Register  

Author Topic: starting on scripting- please help  (Read 650 times)

0 Members and 1 Guest are viewing this topic.

Offline ryankaplan

  • Members
  • *
  • yeah...
starting on scripting- please help
« on: 25 Jul 2004, 19:27:24 »
ok, firstly all the scripting tutorials are quite hard and hardly explain jack shit to people who don't know ms basic. so that's why i came here.

i want to create a very simple anti-personel mine made with grenades. When a ground unit enters the trigger area which is set to activate when  anyone is  present in the area. i don't want air units to activate it though.

i plan to do this by getting the position of the unit who enters the minefield  by the getpos command, which will make the trigger check the height of the unit and if it is more than 3 then a grenade will be created with the camcreate command right on the soldiers foot. now i know how to do almost all of these things by themselves, but i do not know how to connect them together in a script. can somebody right the script down for me as a whole down here? i will greatly appreciate it. and i know there are other scripts like this but the point of it is to learn the damn scripts. anyway, i am not a stupid guy so i should understand how you made the cript. thanks alot to anyone who helps me.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:starting on scripting- please help
« Reply #1 on: 25 Jul 2004, 19:42:55 »
Working trigger, copied and pasted

Area:   4x4
Activation Box:   anybody present
Name:  trig14
Condition:   this and onMine && "land" counttype thislist > 0
On Activation:  grenade14 = "grenade" camCreate [getpos trig14 select 0, getpos trig14 select 1, 0]

onMine is a variable which switches the minefield on and off.    It is true when East units are in the general area, and false when they are not.   This is to prevent West units from setting off the mines when East (the player) is far away and thus "wasting" the mines.

There are much fancier mine scripts out there, but this does the job for me.     I have some variations:  sometimes the grenade is created underground to simulate a sort of "toe-popper".

On Activation:  grenade14 = "grenade" camCreate [getpos trig14 select 0, getpos trig14 select 1, -12]

Sometimes two grenades are created, which is a bit nastier.   ;D    Sometimes the grenade is created in the air, falls to the ground and then explodes.   This gives you a split second to duck if you see it, although there is no warning.   (The minefield is in a forest, so its simulated the grenade falling out of a tree.  It's a bit crap but variety is the spice of life, or at least the Un-Testable Mission.)

You could of course create the grenade at the position of the loon who set off the mine.   Syntax not guaranteed but try something like

grenade14 = "grenade" camCreate getpos thislist select 0

This would guarantee a very severe case of death, whereas putting it at the centre of the trigger gives chance of wounding.


To learn scripting generally, read both snYpir's Friendly Intro to Code Snippets and also Johan Gustafsson's Scripting Guide.    You can find very simple working examples of scripts in the Tutorial Mission.  All in the Ed Depot - tutes - getting started.
« Last Edit: 25 Jul 2004, 19:53:00 by macguba »
Plenty of reviewed ArmA missions for you to play

Offline ryankaplan

  • Members
  • *
  • yeah...
Re:starting on scripting- please help
« Reply #2 on: 25 Jul 2004, 19:51:21 »
not exactly what i wanted but thanks for your time anyway.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:starting on scripting- please help
« Reply #3 on: 25 Jul 2004, 19:57:21 »

Quote
not exactly what i wanted but thanks for your time anyway.

WTF?    That is exactly what you asked for!  

Quote
i want to create a very simple anti-personel mine made with grenades. When a ground unit enters the trigger area which is set to activate when  anyone is  present in the area. i don't want air units to activate it though.

I went to the trouble of firing up OFP and digging through my triggers because for once it was possible to answer a question absolutely comprehensively.    I have never written a post that answered a question better than that.

Oh well, at least I don't have to answer more of your problems.  I would be amused to hear in what respects my post does not answer your question.
« Last Edit: 25 Jul 2004, 20:00:45 by macguba »
Plenty of reviewed ArmA missions for you to play

Offline ryankaplan

  • Members
  • *
  • yeah...
Re:starting on scripting- please help
« Reply #4 on: 25 Jul 2004, 20:17:00 »
i said thanks for your time so i wasn't being rude, sorry if i offended you but no need to get stropy.

firstly, i wanted a script, so i can look at it and learn it because i am knew to scripting. i couldn't find any very simple scripts, they are all good and flashy.

and secondly; this didn't work.

grenade14 = "grenade" camCreate getpos thislist select 0
nor did this when i tried it.
grenade14 = "grenade" camCreate [getpos thislist select 0, getpos thislist select 1, 0]

i am supposing the problem is with the "thislist". or am i not meant to put thislist?

again, i am sorry if i offended you.


Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:starting on scripting- please help
« Reply #5 on: 25 Jul 2004, 20:32:34 »
You did say thanks (not everybody does) and to that extent you were entirely polite, but you did not read my answer properly and that's what made me cross.    Anyway, now you have and you've apologised so no harm done and we're all friends again.   ;)

If you want to put the code in a script file, you can but in this case there is no real need.    As far as script code is concerned, triggers and script files are just boxes:  use whichever kind of box best suits the circumstances.   you need a trigger to detect if the victim is present, and the code is just one line, so it will fit fine in the trigger.

thislist is an array of all the units that would activate the trigger.     select 0 means grabbing the first element in the array.    It is fine to use thislist in the On Activation line of a trigger, though sometimes you have to try a variey of syntaxes (or at least I do) before it works.

What happened when it didn't work?   Give us more details.

Try this:-

grenade14 = "grenade" camCreate getpos [thislist select 0]

On the other hand this
Quote
grenade14 = "grenade" camCreate [getpos thislist select 0, getpos thislist select 1, 0]

is nowhere close, I have no idea what it would be but more like:

grenade14 = "grenade" camCreate [getpos (thislist select 0) select 0, getpos (thislist select 0) select 1, 0]
« Last Edit: 25 Jul 2004, 20:33:19 by macguba »
Plenty of reviewed ArmA missions for you to play

Offline ryankaplan

  • Members
  • *
  • yeah...
Re:starting on scripting- please help
« Reply #6 on: 25 Jul 2004, 21:09:30 »
this workewd but partially
grenade14 = "grenade" camCreate [getpos (thislist select 0) select 0, getpos (thislist select 0) select 1, 0]

the grenade explodes right the guys feet but it also explodes when aircraft fly above it. when i put
this and onMine && "land" counttype thislist > 0
on the condition field the grenades did not explode even when a couple of east players where there.

so i removed the condition and i gave 6 seperate (not in squads) guys waypoints to go through the minefield and only the first 2 of them exploded. the trigger is set to repeatedly. the rest went through safely. i joined the six soldiers in a squad but the same thing happened.

i could just have alot of small triggers all next to eachother but this would take a year if i decided to mine a large area.


Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:starting on scripting- please help
« Reply #7 on: 25 Jul 2004, 22:24:49 »
"and" means the same as "&&".   Why I have both I couldn't tell you.

Do you want to switch the minefield on and off?   If not, remove all mention of onMine.

Try Anybody present and

On Activation:   this && "land" counttype thislist > 0

A big minefield by this method would indeed be very trigger intensive and in that case it might be wise to investigate othe avenues.  

PS - Good missions do take a long time.   If you want something really worthwhile don't budget on fewer than 200 hours.   My Un-Impossible Mission has taken maybe 400.    Sounds a lot?   Think about a film ... lasts about 90 minutes right?   How many man-hours of work in that?    You can of course through something vaguely acceptable together in a few weekends, and when you're learning that's probably the best thing to do.  
« Last Edit: 25 Jul 2004, 22:31:49 by macguba »
Plenty of reviewed ArmA missions for you to play

Dubieman

  • Guest
Re:starting on scripting- please help
« Reply #8 on: 25 Jul 2004, 22:26:33 »
Well hey there.


Well I got this tut from OFPEC I think, I go back to it every once and a while for little stuff. It should help you out.


And get Chris's OFP script editor, from OFPEC. That's a great tool.

But here is script of sorts from CHOFPSE, I don't think it has an air units check....
Code: [Select]
; **********************************************************************
; **** Causes an explosion at a trigger.
; ****
; **** 1 parameter needed:
; ****    1. Trigger where explosion will be. (Object)
; ****
; **** Example how to use:
; ****    TRIGGER:
; ****    Radius: 3
; ****    Name: Mine_1
; ****    Activation: EAST + PRESENT
; ****    On Activation: [Mine_1] Exec "Mine.sqs"
; ****
; **** By CHenderMan@cableone.net
; **********************************************************************

; Get the parameter given
_trigger = _this Select 0

; Get the position for the explosion
_pos = GetPos _trigger

; Set the type (change type here if needed)
_type = "Heat125"

; Create the explosion
_mine = _type CamCreate _pos
CamDestroy _mine

Exit

Hope it helps.

PS: About 99% of the time, listen to what Macguba says, he's very smart OFPwise. I dunno about real life... :D ;D


Offline ryankaplan

  • Members
  • *
  • yeah...
Re:starting on scripting- please help
« Reply #9 on: 25 Jul 2004, 23:48:38 »
awsome stuff macguba. the trigger now works superbly. after a bit of trial i found out the best way to deploy a minefild is create alot of triggers next to eachother (prefarebly 7x7 to 10x10) and set them on repeatedly. i changed the grenade to heat105 because it leaves a bit of smoke where it explodes and if i want the units to be injured i lower the z axis to -4.
if i want the armoured units to be completly invulnarable to heat105 i set it's z axis to 0. (or atleast invulnarable enough for a bmp to be able to take 10 blows of it and still live.  onec again thanks alot.

btw: is there a way to somehow know if player is in a tank (not jeep) because if there is we can make a smokescreen for tanks with the same trigger, only the heat105 changed to smokeshell and activated by radio alpha.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:starting on scripting- please help
« Reply #10 on: 25 Jul 2004, 23:52:47 »
Lol, see, I told you it was the answer.    ;D

If you know which tanks it might be

Condition:  (player in tank1) or (player in tank2)

Remember that AI can see through smoke, human players can't.     (I have a feeling the JAM2 smoke is opaque to AI units.)
Plenty of reviewed ArmA missions for you to play