OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: OFPfreak on 09 Dec 2004, 06:25:19

Title: scripting.. how long to learn?
Post by: OFPfreak on 09 Dec 2004, 06:25:19
How long does it take to learn scripting? For me it looks like 2 years. Maybe its my age   :-\ (11 yrs old) I dont even know how to make a script. Luckily I know some HTML :) (only for briefings. I just copy the briefings and modify it. I cant even create it by hand  :'(). I wonder if anyone has a scripting tutorial for dummies. and not like snyper's one. Way too hard. Please  :-[
Title: Re:scripting.. how long to learn?
Post by: MachoMan on 09 Dec 2004, 09:27:26
Well if you know how to program a couple of days/weeks. If you do not know how to program (I mean some real language here; not HTML)  it will probably take a couple of months, depending on you brains. ;)
Title: Re:scripting.. how long to learn?
Post by: dmakatra on 09 Dec 2004, 12:22:50
I made my first script something like a day or two after I read Johan Gustavsson's Scripting Tutorial, and I was eleven too then. OMG was it crap. ;D It's in the ed depot if you wanna laugh at it. :P

If you've done C or any other similar programming language, getting into OFP scripting shouldn't be very hard. It's not hard if you don't know C (or similar) either, so don't be afraid. Actually, OFP scripting helped me learn C++ (I started reading it about a year ago) .

:beat: *Gets Shot* :beat:
Title: Re:scripting.. how long to learn?
Post by: macguba on 09 Dec 2004, 12:27:12
The relevant tutes are:-

Abuu's Basic Editing Tutorial
Johan Gustafsson's Editing Tututorial
Johan Gustafsson's Scripting Tutorial
snYpir's Friendly Intro to Code Snippets
Devilchaser's Mission/Scripting Guide
macguba's Tutorial Mission

Much of the stuff in these tutes you will know already.    I suggest you skim through all of these quite quickly in say, two sittings.    That will give you an idea of what's there.    Scripting is easy, but when you start you need to have an idea of where you're going, which is why trying to read one tute till you understand it is not the best way to start.   When you get stuck, move on an read something else, then come back to the tough bit later.    The pieces will eventually fall into place.

If you are having difficulties with anything in particular, post a question here.

To learn scripting to a highly advanced level takes a lifetime.   To learn really basic scripting takes as long as it takes to read "Write this inflame true in the init field of the fireplace.", which I reckon is under 10 seconds.
Title: Re:scripting.. how long to learn?
Post by: dmakatra on 09 Dec 2004, 12:31:59
To learn scripting to a highly advanced level takes a lifetime.   To learn really basic scripting takes as long as it takes to read "Write this inflame true in the init field of the fireplace.", which I reckon is under 10 seconds.

10 seconds?! :wow:

Took me 10 minutes. :'(

:beat: *Gets Shot* :beat:
Title: Re:scripting.. how long to learn?
Post by: nominesine on 09 Dec 2004, 14:57:10
IÂ'm 33 and hopelessly B.C (Before Computer). I learned scripting the slow and hard way, using the tutÂ's macguba mentioned. It will take you a few weeks or maybe months. But if youÂ're really interested in the game you will learn. Trust me. The trial-and-error method works.

I have a friend who works as a painter in Florence. He can barely switch on his computer and start ofp, but he can write working and quite advanced scripts, because he is genuinly interested in the game.

Start with adding code snippets in triggers and the activationfield of waypoints. This way you will learn how the basic principles of scripting works. Good luck.
Title: Re:scripting.. how long to learn?
Post by: penguinman on 09 Dec 2004, 16:58:48
well im now on a scale of 1 to10 a (4) with 6 being the average of scripters here.

the way i learned is first read tuts to get the basics, then more importantly just open up notepad and try what you learned.

also try taking other peoples already made scripts and copying them down(not using ctrl c,ctrl v) copy each part on your own(typing!) and take note of the writing behind the
(;)s those are notes to help the reader understand what each part does.

the most inportant part of scripting IMO is the
_man = this select 0
_tgt = this select 1

learn about these parts, they shold be the first thing u learn basicly, but thats just IMO
these are the one thing that is used in almost every script.
dont give up,
the benefits of scripting r more then just knowing how to script(obviosly)
they will also help you lots in your ability to make missions. ;)
Title: Re:scripting.. how long to learn?
Post by: XCess on 09 Dec 2004, 19:25:20
also, make sure u get hold of a command reference. The scripter's bible. I'd recommend LustyPooh's even though there hasnt been an update for the latest version... atleast, that I've heard of.
Title: Re:scripting.. how long to learn?
Post by: macguba on 09 Dec 2004, 21:23:55
There has been no direct update to Lustypooh's version.   However, the online version of the official comref (in the Ed Depot) has many helpful Comments which replicate many of the virtues of Lustypooh's verions.    

The only comrefs I use are the online one (always first port of call) and Lustypooh's Unofficial Comref.    
Title: Re:scripting.. how long to learn?
Post by: ThEoNeAnDoNlY on 09 Dec 2004, 21:32:43

i wouldnt worry too much about scripting though. yes if you want to make mission, well "good" mission you should know some scripts, but what happens to most people and me when i was starting out. is i read a tutorial, it got too complicated and i gave up. and then sometimes i just looked at a script and it seemed to put me off. but seriously m8, all u need is some motivation and you can do anything.

i started scripting/mission making ages ago, but it has been just this month that i have figured out how to do most things thanx to the unnoficial command reference, made by various artists. seriously m8, i was following inv44 for ages and then i cant remember why but i got one of the mission makers hotmail adresses (and imean im obsessed with inv44). i was tlking to him, and he told me that if i could make mission well there was a slight chanse i might be able to get in. this was my motivation. i put my heart and soul into learning the script stuff, and i can tell you how easy it is once you have got going, just keep refereing to your command reference and you cant go too far wrong. and now i can make (dont mean to boast) but i can make pretty amazing missions now, just because i have the basics at my fingertips, and it wasnt hard.

so if you want to make mission with the pros and script like a geek, all you need to do is get out there and concentrate on making a simple mission, fiddle with the init fields firsts and the conditions and onactivation fields. then move onto making your own little basic script

e.g

Quote
hint "i feel a andom burst of blabber coming"
~6
player globalchat "hey im on tv...or a game, hell im on a screen thats what counts"

exit

something so simple but it will make you feel very confident.

Guy
Title: Re:scripting.. how long to learn?
Post by: OFPfreak on 10 Dec 2004, 03:47:03
Nevermind guys.. It doesnt help anything.. I learn it sometime when the day comes to work at EA games or something  :-\
Title: Re:scripting.. how long to learn?
Post by: dalton on 10 Dec 2004, 23:57:14
10 seconds?! :wow:

Took me 10 minutes. :'(

:beat: *Gets Shot* :beat:
um... how could you read that in 10 minutes, but post it only 4 minutes after he posted?
Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 11 Dec 2004, 00:39:22
if you're gonna learn to script do it now, its easier to learn when you're young (thats why so many older people don't have a clue with computers  ;D)

heres what i did:
read 1 tut i think it was snyper's

found something to try scripting
didn't work

went to scripting boards on ofpec, tried to find easier things to attempt tp script
eventual made one that would work and BAM! i understood all (not really, but i got the hang of it)

so basically, get really familiar with commands by using them in triggers and stuff, then try it out for yourself, it won't take long before you get a "revelation" then you'll have the basic understanding and you can figure the rest out real easy. a few weeks i would say to learn basic scripting
Title: Re:scripting.. how long to learn?
Post by: Planck on 11 Dec 2004, 00:41:59
Quote
(thats why so many older people don't have a clue with computers  )


Pahhhh.........what do you youngsters know anyway?   ;)


Planck
Title: Re:scripting.. how long to learn?
Post by: dmakatra on 11 Dec 2004, 00:42:48
My father read it for me, only took him 3 minutes. ;D (EDIT: F00k me, this kind of writing is slow, never try this at home)

Bah! Bah I say to you my eleven year old padawan. Just read some of them tutes and feel the force. It will guide you. Someday you will be like me. Writing on your keyboard which is ATM behind the monitor to your computer, because your desk is filled with P&P RPG books. :P

Seriously (damn this hurst my wrists, but nothing can keep me away from ma baby OFPEC) , what is it you having problems with? It just doesn't rub in your skull?

:beat: *Gets AhMaenMyWristIsHurtingAndIDoAllKindsOfTypoesCrapNeedADoctored* :beat:
Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 11 Dec 2004, 00:51:23
Pahhhh.........what do you youngsters know anyway?   ;)


Planck

just generalizing on a stereotype

btw i live in florida, loaded with all sorts of clues old people who keep their turn signals on for 10 blocks and can't think to look around before backing out in a parking lot, but i'm rambling.
point is, i live around a lot of clueless old people  :P
lots of older people are cool, like the ones who are 40 and still play video games (brownie points!  ;D)
Title: Re:scripting.. how long to learn?
Post by: penguinman on 11 Dec 2004, 03:36:26
lol,      
yes Floridas senior citizens lack the common sense to take part in everyday things such as driving with out causing injury to pedestrians or property damage.

There is a tenis court near my house with a big tear in the fence where an old lady accidentaly hit the gas insted of the brake and plowed through the fence and onto the court.

but this is a little off topic.
anyways i think the person who started this post has long stopped listining.
Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 11 Dec 2004, 03:47:20
i can defend that we're proving to him that he should learn now.
judging by other threads he started he has given up though. thats no good, and its not hard to learn either. oh well, he's young, he has time (i say this even though i'm only 4 years older lol)
Title: Re:scripting.. how long to learn?
Post by: penguinman on 11 Dec 2004, 04:09:06
well i mean he dosent have to learn now, he is a little young
like some kind of genius. when i was 11 i was playing with my pokemon cards and didnt even known how to turn on a computer.

anyways i think were the only ones posting.

by the way, have u givven up on that plane crash script yet trig. and what about that ultimate halo.  its incredible how close u were to perfecting ultimate halo, :P
if were gona talk about learning scripting, how the hell do u script all those triginomitry and calculus stuff. is it because i havent learned it in school yet. wow :o I always thought all my life that all that complicated math and stuff was useless in real life and just bull that we would never use. and now im using the algebra i always thought was useless and pointless in scripts. if only my teacher could see me now. ;D
Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 11 Dec 2004, 04:33:47
i don't know what grade your in or anything, but i have taken geometry, 2 algebras, i'm in stats now, and i'm taking physics (thats the main one that helps), next year is calculus (joy joy).
basically for ofp you need to know the pythagorian theorem and how to use sin cos and tan.

if you want examples i can give them to you

EDIT: ahh.. a 9th grader, i'm 10th, so what math are you in?
Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 11 Dec 2004, 04:43:44
as for as those scripts, postponed for the moment. do you need them for something? i have a feeling i have completely lost the inspiration to finish them, and they are very difficult. just so you know, i was no where near close on the standing in the cargo thing ("ultimate halo" even though what i was doing had nothing to do with a HALO drop
Title: Re:scripting.. how long to learn?
Post by: penguinman on 11 Dec 2004, 04:48:30
Quote
i don't know what grade your in or anything, but i have taken geometry
understand what ur saying
Quote
2 algebras, i'm in stats now, and i'm taking physics (thats the main one that helps), next year is calculus (joy joy).
i can understand u still  :thumbsup:
Quote
basically for ofp you need to know the pythagorian theorem and how to use sin cos and tan.
WTF!!!, ur speaking english still, right ???
Quote
if you want examples i can give them to you
and... your back to english again  ;)

plz plz plz, dont even try this with me. i wont get it.

im in the same grade as u..
 
so the only reasonable explination is im stupider than u
 ;D

seriously: i just dont get it, sorry buddy :)
Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 11 Dec 2004, 05:01:08
examples it is!
pythagorian theorem: for right triangles - one 90 degree angle
c2 = a2 + b2
a = one side (makes up part of the right angle(90 degrees))
b = other side
c = hypotenuse (the longest side)    
 
       /|
  c   / | a
     /_|
      b
so for the 2d distance from 1 unit to another
getpos 1 select 0 - getpos 2 select 0 = b
getpos 1 select 1 - getpos 2 select 1 = a
c2 = a2 + b2
c = sqrt(a^2 + b^2)
gotta go, i'll tell more tomorrow
Title: Re:scripting.. how long to learn?
Post by: dmakatra on 11 Dec 2004, 12:30:02
Quote
well i mean he dosent have to learn now, he is a little young
like some kind of genius. when i was 11 i was playing with my pokemon cards and didnt even known how to turn on a computer.

LMAO. That must mean I'm some kind of Einstein. :P

I was playing Amiga games before I could walk. ;D

I'm only in 8th grade (should be 9th grade to you yankee-buggers) and doesn't understand this cos and sin shite either. And lemme tell you, this 'ere bugger Triggerhappy just made it even harder to understand.

Where is OFPFreak? I want to know his problemos so I can help him.

:beat: *Gets Shot* :beat:
Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 11 Dec 2004, 17:29:16
never even got to sine cosine and tangent, i only tried to show the pythagorian theorem

a dumbed down version

the lateral (no height like the distance command gives us) distance between 2 units is simply the square root of the difference of their east-west position squared + the difference of their north-south position squared

in ofp language
_ydiff = (getpos guy1 select 1) - (getpos guy2 select 1)
_xdiff = (getpos guy1 select 0) - (getpos guy2 select 0)
_latDist = sqrt (_ydiff^2 + _xdiff^2)


sin cos and tan are used with angles
Title: Re:scripting.. how long to learn?
Post by: penguinman on 11 Dec 2004, 19:37:16
okay i can not belive it i kinda got the first part a little about the pathegoina therom

explain it a little more
Title: Re:scripting.. how long to learn?
Post by: OFPfreak on 11 Dec 2004, 20:15:01
Triggerhappy cmon PLEAAAASE stop saying those freaky einstein things!!! Its 7 weeks vactation here alright!?  :o poor me got a honda civic crisis now.. whatever that is... Anyway lets make my post over 100 replies :P post the alphabet.. 1 post = 1 lette lolz
Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 11 Dec 2004, 20:33:58
ok, lets say we have 2 guys, for simplicity we will say they are a [10,20,0] for the first guy's pos, and [15,30,0] for the second, and we want to know what the actual distance is between them.
so first we do:
15 - 10 = 5 (one side or leg as it is called in geometry and stuff)
30 - 20 = 10 (other leg)
then 5 squared, or 52,or 5^2, is 25 (5*5)
and 10 squared is 100
add then together 100 + 25 = 125    ___
and do the square root (calculator) \/125 = 11.18m

so heres a problem for you to do if you want:
guy1's pos = [50,25,0]
guy2's pos = [73,42,0]
find the distance between them

EDIT: sorry ofpfreak, but penguinman is askin, and you don't seem to have any question that need answering ::)
Title: Re:scripting.. how long to learn?
Post by: OFPfreak on 11 Dec 2004, 20:45:12
oh oh oh!! I got a question!!! Im getting the scripting a lil bit but im having problems with a car bomb.. this is the original script:

Code: [Select]
_bomb= "timebomb" camcreate [getpos vehicle select 0, getpos vehicle select 1, (getpos vehicle select 2) + 2]

#Loop

_bomb SetPos  [getpos vehicle select 0, getpos vehicle select 1, (getpos vehicle select 2) + 2]

~0.1
goto "Loop"

And this my modified 1:

Code: [Select]
testcar=_this select 0
_bomb= "timebomb" camcreate [getpos testcar select 0, getpos testcar select 1, (getpos vehicle select 2) + 2]
#Loop

_bomb SetPos  [getpos testcar select 0, getpos testcar select 1, (getpos testcar select 2) + 2]

~0.1
goto "Loop"

If they are both wrong tell me becuase I want to know how to attach a bomb to a car and make it explode. I dont want a car just to turn weird like when they do when they are destroyed but I want them to have a large explosion. Or otherwise I want to make em explode with an addaction or radio command (e.g. bravo, alpha, charlie or addaction detonate!
Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 11 Dec 2004, 20:54:57
no need to ask the same question on 2 threads, i fixed it on the other one, but the radio command would only be a work around anyway, i can post that too if you want

if you blow up a vehicle it will turn wierd anyway, you can't kill it and keep it looking nice, the best you could do is delete it when it gets destroyed (no vehicle, no wierd wreckage)
Title: Re:scripting.. how long to learn?
Post by: penguinman on 12 Dec 2004, 01:36:36
ok hmm..

is it 28.6 meters  :)
Title: Re:scripting.. how long to learn?
Post by: penguinman on 12 Dec 2004, 01:54:00
ofp freak.

i understand that you have many problems with ofp because we all do( not that its a bad game, but more that its just a confusing game[for editing at least])  ;D

anyways if you go to the list of members there are somthing like 12,000. Now do u really think your problem is more important than any of the other 12,000 peoples problems. :)
if you dont understand what you did wrong as would be perfectly acceptable.  Basicly to put it simply(but it really is not as bad as it sounds but still somewhat of a problem) :) you have acted in the last few topics u  posted on like everybody and all the admins,moderators and even the website creator, made www.ofpec.com and all 12,000 members put everthing together to help you with YOUR problems in ofpec and nobody elses. You are acting just a tad bit ungratefull for peoples atempts to help you. :)


but that adds yet another problem to this whole ofp thing. because we need somthing like a tutor section in the forums, where great people like triggerhappy and macguba(not that there arent others but  I cant mention all of them) can help explain stuff(like the pathenon theorm) to people who dont get somthing(like me).

it wouldnt be for specific problems like the scripting boards, but more for just improving your knowlege in a general area of scripting(like the pathenon theorm).

EDIT: neat when i type www.ofpec.com it makes it a link

Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 12 Dec 2004, 01:55:13
exactly, its really easy

now to sin,cos, and tan
all of these are used on right triangles
so lets say you have a right triangle with sides a,b, and c (hypotenuse)
and angles x,y,and z(right angle)

*attempt at illustrating*
      x
      /|
c    / | a
    /_|
 y  b  z

side = other side *sin(opposite angle of what you're trying to find)
so
a = b*sin(y)
b = a*sin(x)

cos is the same except it uses the angle adjacent to the side

a = b*cos(x)
b = a*cos(y)

gotta go for now, be back later

EDIT: its pythagorian theorem
Title: Re:scripting.. how long to learn?
Post by: penguinman on 12 Dec 2004, 02:21:25
hmm, ok get a little of that

but how would i put any of that to use in scripting

Quote
15 - 10 = 5 (one side or leg as it is called in geometry and stuff)
30 - 20 = 10 (other leg)
then 5 squared, or 52,or 5^2, is 25 (5*5)
and 10 squared is 100
add then together 100 + 25 = 125    ___
and do the square root (calculator) \/125 = 11.18m

so heres a problem for you to do if you want:
guy1's pos = [50,25,0]
guy2's pos = [73,42,0]
find the distance between them

could you do somthing like that again , thanks trigg  ;D

hey im killing two birds w/ one stone, this is the same stuff im doing in 10th grade math. maby it will help me in school 2 as i havent got any of this stuff untill u explain it.(or maby its because i dont space off when its somthing interesting, like ofp) nice of you to explain it to me :)

thanks your the best trigg.
Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 12 Dec 2004, 04:18:02
actually, you don't really use that, but you can change it to find angles, like so:
sin-1
cos-1
tan-1
the commands in ofp are:
asin
acos
atan

with those you can find angles:
x = asin (b/c)
y = asin (a/c)
x = acos (a/c)
y = acos (b/c)
x = atan (b/a)
y = atan (a/b)

now to the PYTHAGORIAN THEOREM you really can't learn that name can you?

a few for you to do:
1) guy1: [30,50,0]
guy2: [15,60,0]

2)1: [0,12,0]
2: [37.3,52,0]

3)1: [2,79,0]
2: [53,28,0]

*remember that you always use the absolute value (positive of whatever you get) of their differences to find the distance

answers at bottom nice and tiny








1) 11.18
2) 54.69
3) 72.12
Title: Re:scripting.. how long to learn?
Post by: OFPfreak on 12 Dec 2004, 05:04:56
triggerhappy please shut up with those mathematics.. if you want to do them make your own post somewhere.. If you really want to bug me you'll see what i'll do next..  >:(
Title: Re:scripting.. how long to learn?
Post by: dmakatra on 12 Dec 2004, 14:07:36
That's great stuff with the distance and root and all, I figured that out. But cos, sin and tan is still messed up for me. Ah well, that's what .sqf files are for right? ;D

@ OFPFreak, Trigg was explaining OFP maths to us. Fine if you don't want us to take this here (even though it's extremley usefull stuff) but since you've multiple times ignored me when I was trying to help you, I don't really see another purpose of this thread. Fine if you solve the thread, that's your decision because it's not about the orginal purpose of the thread (aka OT) we are discussing here, but why would you as people as me are actually learning some pretty neat stuff here.

:beat: *Gets Shot* :beat:
Title: Re:scripting.. how long to learn?
Post by: Noon416 on 12 Dec 2004, 18:15:04
triggerhappy please shut up with those mathematics.. if you want to do them make your own post somewhere.. If you really want to bug me you'll see what i'll do next..  >:(
Behave, OFPfreak, or you'll see what I will do next.

Start appreciating the help people are giving to your answers, instead of getting angry at them. If you keep threatening people, you'll soon find that noone will be bothered helping you at all, and then where will you be?
Title: Re:scripting.. how long to learn?
Post by: Morglor9 on 12 Dec 2004, 19:32:35
Scripting length to learn really depends on how good you want the script (I still can't get CamCreate to work). But if you make something simple, all you really need are the kind of commands you'd put into a units init field or a trigger/waypoint's OnActivation field. For example, I made this Shell Shock script using simple commands like fadesound and setfog. I didn't release it because I couldn't make the sound work, but it looks about right and it isn't fancy, which is the point i'm trying to make in the boring paragraph you just read.
Title: Re:scripting.. how long to learn?
Post by: Mr.Pibb on 12 Dec 2004, 19:44:51
 Hello OfpFreak

 Ok, decided to just thorw a lil down here, from me that is not indeed 11 years old, but nonetheless quite relevant.

 I have been getting into (really getting into) scripting now for about 3 weeks. Although before this over the years I threw stuff in that was copied, never knew nothin, till just recently. Now already I can make some general scripts, with even some complexity for things I want done (with help sometimes of course, what makes this forum so great ;) )
 If yer anything like me (god forbid  ;D) I usually hate reading 'general tutorials', they are great and all, but personally I like to make stuff happen, kinda impatient.

 So I took the mission that I enjoy the most, un-pbo'd it, and decided what I wanted to see differently in it to my own likings, then started looking into the script and figuring out what did what, and pretty soon stuff started clicking. Next thing ya know a week later after reading some 'specific area tutorials' and poking thro the mission files I had a new working script that made use of the original mission scripts, cool! Was great to see it work out when I tested it. And ya, it took alot of screw ups, getting stuck here and there, but in the end it payed off and I walked away with more experience in ofp editing.
 So my point is I guess, theres more than one 'way' to learn the stuff, rather than diving into trying to learn all the basics at once from a lengthy general scripting tutorial, U might be like me and rather just learn the hard way, which to me is the funner way lol

 Anyhow, take what I said here with a grain of salt, Im just taking a break from working on my mission and thought Id type my thoughts on the subject.

Pibb
Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 12 Dec 2004, 20:17:40
If you'll notice, ofpfreak, your question has been answered more times than nessecary, and IMO, this is the best way of learning. Interactive, talking to people, asking questions, thats why school works the same way, and i prefer that to reading a tut, as do many other people.  Also, this is quite related to your question, because I'm helping people to LEARN SCRIPTING.  These maths can be very important in ofp, and lots of people don't know what they are or how to use them. Personally, i don't appreciate your attitude towards al the help people give you, and if you can't control yourself, then come back when you're older. You want to close down this topic then fine, i can show penguinman these maths on another thread, and hopefully i won't have to deal with your ungratefulness.

sorry admins, if i'm breaking rules here, not intending to  ::)
Title: Re:scripting.. how long to learn?
Post by: penguinman on 12 Dec 2004, 22:18:31

ok ofpfreak your really starting to get annoying and rude to people who are trying to help you, now im not going to drop down to leech's level(see post"my masterpiece not working")  but as you are already on a warning from earlier. I think you should know that if admins keep having to warn you, I think you could soon find yourself not able to log in to ofpec anymore. Now I am not an admin so I cant do anything like that but im trying to help keep you from having that happen.

as triggerhappy said same goes for me(im not trying to break the rules im just trying to help him) so sorry if thats not allowed

oh and triggerhappy:

pythagorian therom :P :P :P :P :P :P :P :P :P :P :P :P
pythagorian therom :P :P :P :P :P :P :P :P :P :P :P :P
pythagorian therom :P :P :P :P :P :P :P :P :P :P :P :P

but what would you use finding the distance between two objects for in scripting?
maby a very SIMPLE example of a part of a script using this
pythagorian therom :P

thanks man, your very helpfull

Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 12 Dec 2004, 22:42:28
its easier in scripting (no math involved!)
_xdiff = abs((getpos guy1 select 0) - (getpos guy2 select 0))
_ydiff = abs((getpos guy1 select 1) - (getpos guy2 select 1))
_distance = sqrt(_xdiff^2 + _ydiff^2)
or you could skip the variable thing and just replace it with what they are assigned:
_distance = sqrt((abs((getpos guy1 select 0) - (getpos guy2 select 0))^2) + ...

or something like that, i find it easier the first way (less parentheses)
Title: Re:scripting.. how long to learn?
Post by: OFPfreak on 13 Dec 2004, 03:48:46
in reply to everyone.. OK part of this is true.. but im abusing people who are trying to help me?? ok do you call annoying me with mathematics helping me?? dont blame everything on me! and by the way im getting part of the scripting right now.. ::)
Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 13 Dec 2004, 04:03:03
the math may not help you, but it helps penguinman, and apparently dmak a little too. if you don't want to bother with it just ignore the posts, i'm doing nothing to you, and don't even try to put any blame on anyone else. numerous times you've been warned by admins for breaking rules, and there was no math involved, or me, for that matter. in fact one of your threads had to be locked because of the way you were acting, all these people wouldn't blame just you unless you were the only one to blame.
Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 13 Dec 2004, 04:26:48
here's a link you may want to look at ofpfreak:
http://www.ofpec.com/yabbse/index.php?board=3;action=display;threadid=12 (http://www.ofpec.com/yabbse/index.php?board=3;action=display;threadid=12)
Title: Re:scripting.. how long to learn?
Post by: penguinman on 13 Dec 2004, 05:42:57
ok thats interesting how that works.
i understand it, but now i just have to remember how to use that stuff in scripting.  

so that would be used to get the distance between two objs ?which would then be harnesed for aditional purposes, like what

_unitdis =  _xdiff = abs((getpos guy1 select 0) - (getpos guy2 select 0))
_ydiff = abs((getpos guy1 select 1) - (getpos guy2 select 1))

so then it would be somthing like:

if unitdis = 10 exec"phase2.sqs"

thanks
Title: Re:scripting.. how long to learn?
Post by: dmakatra on 13 Dec 2004, 14:25:24
That's just silly. Use the command distance instead. ;)

_dis = (_loon1 distance _loon2)

:beat: *Gets Shot* :beat:
Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 13 Dec 2004, 21:43:40
but distance is in 3D so something could be in the air and fit the distance requirements
this limits it to being lateral distance, so you could use something like:
?_unitdis <= 20 && (getpos unit2 select 2) < 2
That assures you that it is on the ground (or really close)

penguin you're skipping a part
_unitdis = sqrt(_xdiff^2 + _ydiff^2)
Title: Re:scripting.. how long to learn?
Post by: penguinman on 19 Dec 2004, 04:11:32
oh ok i get it. :)

but u still havent awnsered my first question in my last post. what would that be used for ???
Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 19 Dec 2004, 04:18:37
...sorry but..i...dont..see a question.......
 ??? ??? ??? ??? ???
Title: Re:scripting.. how long to learn?
Post by: penguinman on 19 Dec 2004, 04:41:26
no its my fault, i should have been more clear

my quote
Quote
so that would be used to get the distance between two objs ?which would then be harnesed for aditional purposes, like what
Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 19 Dec 2004, 04:49:52
like for conditions in triggers, which you already stated, you could come up with some higher uses for it, but its a simple thing, for simple uses.
Title: Re:scripting.. how long to learn?
Post by: OFPfreak on 19 Dec 2004, 05:27:21
hey guys, thanks anyway for helping me made this post famous lolz
Title: Re:scripting.. how long to learn?
Post by: penguinman on 19 Dec 2004, 05:38:44
yes but like could u give me ex: of how to make it... say, exec another script if the distance between 2 soldiers is less then, 100 just for the sake of arguing(learning) ;D
Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 19 Dec 2004, 06:03:03
ok,
in the trigger, once you have found their lateral distance, for its condition:
dist <= 100
activation
[unit1,unit2] exec "unitdies.sqs"
which would like, kill the unit (cinematic) or something else
basically, this isn't used for much, whereas sine, cosine, and tangent are. and those are more complicated, and it's late over here. getting sleepy
Title: Re:scripting.. how long to learn?
Post by: penguinman on 20 Dec 2004, 02:04:48
hmm ok

ive got it cool  :)

although i hate to make u play teacher if you want to i would like to learn more of sin and cos,tang

but only if u want to ;D
Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 20 Dec 2004, 04:20:29
sure
Title: Re:scripting.. how long to learn?
Post by: OFPfreak on 20 Dec 2004, 08:00:41
um.... what is sin, cos and tan?? ???
Title: Re:scripting.. how long to learn?
Post by: macguba on 20 Dec 2004, 12:59:12
Sin, cos and tan come from a branch of mathmatics called trigonometry.    If you know certain things about a right angled triangle, for example the lengths of two of the sides, trigonometry enables you to calculate the length of the third side and also the two unknown angles.     It is an extremely powerful mathematical tool and is useful in many aspects of both OFP and RL.  

There are some basic guides to trig in the Editors Depot.    It is taught in schools, typically to children of about 14 although of course that varies widely.    
Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 20 Dec 2004, 21:51:17
hey, penguinman, i'll get back to you on this, its exam week fo me, so when i get the time i'll come back and show you how to use sin cos and tan.
alright?
unless someone else would like to explain it...
Title: Re:scripting.. how long to learn?
Post by: penguinman on 21 Dec 2004, 04:25:32
ok great,

 :)
Title: Re:scripting.. how long to learn?
Post by: RedHouse on 21 Dec 2004, 09:30:28
i dont understand it that well, but i know h^2 = b^2 + a^2,


this is some text i put in one of my scripts, it shows two ways to work out 2d rotations of a point on a grid but it took me ages to figure it out and i still dont know if its right but it works so im happy. I would explain it if i could but I really can't remember how the hell it works.

Code: [Select]
_m_TO_SQUARE = (_x_ORIGEN_U ^2) + (_y_ORIGEN_U ^2)
_m = sqrt _m_TO_SQUARE
_x_ORIGEN_ROTATED_U = _x_ORIGEN_U * cos angle + _y_ORIGEN_U * sin angle
_y_ORIGEN_ROTATED_U = _y_ORIGEN_U * cos angle - _x_ORIGEN_U * sin angle
_x_ROTATED_U = _x_ORIGEN_ROTATED_U + _xT
_y_ROTATED_U = _y_ORIGEN_ROTATED_U + _yT
_x_POSITION_U = ((_x_ROTATED_U - ((sin angle) * _m)))
_y_POSITION_U = ((_y_ROTATED_U - ((cos angle) * _m)))

maybe someone smarter will make sense of it.
Title: Re:scripting.. how long to learn?
Post by: THobson on 21 Dec 2004, 11:36:30
Apologies if I am missing something (this is a long thread).

Does this help:

A right angled triangle is one that has one angle = 90 degrees.  The side opposite this angle is called the hypotenuse.  Let us call it h and let us call the other sides x and y.
Also let us call the angle opposite side x theta.  The angle opposite side y will therefore be (90 - theta).

Then

h^2 = x^2 + y^2

sin (theta) = x/h
cos (theta) = y/h
tan (theta) = x/y

sin (90-theta) = y/h
cos (90-theta) = x/h
tan (90-theta) = y/x

From the above you can work out anything you need.


For example:
If an object is located at (x1,y1) with direction theta
and you want the coordinates of a point that is a distance d away  at an angle alpha to the direction the object is facing then the formulae are:

x = x1 + d*Sin(theta + alpha)
y = y1 + d*Cos(theta + alpha)



And:
To find the coordinates of a point in front of or to the side of an object

if:
x1,y1 are the coordinates of the object
theta is the direction of the object
d is the distance of the point from the object

then:
For a point in front of the object
X coordinate = x1 + d*sin(theta)
y coordinate = y1 + d*cos(theta)

(for a point behind use -d or theta+180)


For a point to the right of the object
X coordinate = x1 + d*cos(theta)
y coordinate = y1 - d*sin(theta)

(for a point to the left use -d or theta+180)  
 
 

Title: Re:scripting.. how long to learn?
Post by: RedHouse on 21 Dec 2004, 11:47:49
thats very helpfull thx
Title: Re:scripting.. how long to learn?
Post by: Triggerhappy on 21 Dec 2004, 15:40:27
well there you go penguinman
Title: Re:scripting.. how long to learn?
Post by: Lean Bear on 15 Feb 2005, 17:26:53
TriggerHappy's right everyone.

The Pythagoras Theorem, radii of circles, algebra in general is required to be able to script efficiently in computers. Not only OFP.

That's why you'll find that at college etc. to do a decent computing course involving prgramming, scripting etc. you'll need a high grade in Math.
Title: Re:scripting.. how long to learn?
Post by: dan ick on 15 Feb 2005, 19:05:18
 ;D Hey

             You will get there in the end i myself am just learning simple scripts and yes it is a bit confusing at first but like someone mentioned start with the init fields etc.....

I only started using PC's about a year and a half ago and i started with the inits,on activ etc.......
I could not understand scripts for months but i read Snypirs guide and a few others quite a few times till i could nearly remember it word for word,However i just seen the post with someone meantioning pythagoros,After seeing that very word and reading a bit of the example,There is now smoke pouring out of my ears and i can smell wood burning :P

Anyway Good luck ;)


YOU CAN DO IT,YOU DA MAN :-* ;D
Title: Re:scripting.. how long to learn?
Post by: OFPfreak on 18 Feb 2005, 22:45:19
yay locked it... that should do it for completely off-topic posts... go make ure own...