Results 1 to 4 of 4

Thread: In Perimeter Script/Death Script. Errors & 2 Quest

  1. #1
    My First Script: A unit walks within 100 meters of an object. Once he is in the perimeter (100m) of that object, a simple text warning would appear, and continue to appear until the unit is gone from the area. However, if that unit were to die, his brand new toy (his chopper) would explode

    The script:
    Quote Originally Posted by [b
    Quote[/b] ]_Object = _this select 0
    _CenterObject = _this select 1
    _radius = _this select 2
    _freq = _this select 3
    _script = _this select 4
    _vektor = _this select 5
    _life = _this select 6
    _Killchopper = this select 7

    setdammage 1.0 = _die

    #Update
    ~_freq
    ? (_Object Distance _CenterObject) <= _radius : goto "InZone"
    goto "Update"

    #InZone
    _vektor exec _script
    ? (_life == "LOOP") : goto "Update"
    &#33; (alive _Object) : goto "KillChopper"
    ; _script is only a text propt (print.sqs) that says "In Zone&#33;"

    #KillChopper
    _Killchopper _die

    exit

    ; Init field:
    ; [Player, CenterObject, 100, 1, "print.sqs", ["In Zone&#33;"], "LOOP", DeadChopper] exec "inzone.sqs"
    Questions:
    1. Once the unit is within 100m of the center object, the warning will go off, however it will continue to go off even if the unit is dead inside the parimeter. How do I fix this?
    2. The chopper doesn&#39;t explode when "_Object" is dead, why?
    My ARMA2 Movie Film: http://www.youtube.com/watch?v=dTw38KXsiyk (Base Attack 5!)

  2. #2
    Quote Originally Posted by [b
    Quote[/b] ]1. Once the unit is within 100m of the center object, the warning will go off, however it will continue to go off even if the unit is dead inside the parimeter. How do I fix this?
    Because :

    Quote Originally Posted by [b
    Quote[/b] ]? (_life == "LOOP") : goto "Update"
    is tested before :

    Quote Originally Posted by [b
    Quote[/b] ]&#33; (alive _Object) : goto "KillChopper"
    If _life == "loop", the alive condition is never reached by the script. Moreover, &#33;(alive _object) isn&#39;t a condition if you don&#39;t write the question mark at the beginning of the line.

    You should write :

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#InZone
    _vektor exec _script
    ? &#33;&#40;alive _Object&#41; &#58; goto &#34;KillChopper&#34;
    ? &#40;_life == &#34;LOOP&#34;&#41; &#58; goto &#34;Update&#34;

    [/QUOTE]

    Quote Originally Posted by [b
    Quote[/b] ]2. The chopper doesn&#39;t explode when "_Object" is dead, why?
    Same reasons, plus

    Quote Originally Posted by [b
    Quote[/b] ]setdammage 1.0 = _die
    doesn&#39;t work.

    Write :

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#KillChopper
    _Killchopper setdammage 1[/QUOTE]

    instead.

    WW1 ArmA:CWA Mod || Romans and Barbarians ArmA:CWA Mod
    Goodbye W0lle, we'll miss you

  3. #3
    You can have macro-like commands in scripts with call. Like this:

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_kill = {_this setdammage 1.0;}

    chop call _kill[/QUOTE]
    or
    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_hypotenuse = {sqrt&#40;&#40;_this select 0&#41;^2 + &#40;_this select 1&#41;^2&#41;}

    _a = 3
    _b = 4
    _c = &#91;_a, _b&#93; call _hypotenuse

    hint format &#91;&#34;c=%1&#34;, _c&#93;[/QUOTE]

  4. #4
    Master Gunnery Sergeant
    Join Date
    Nov 12 2003
    Posts
    1,393
    Author of the Thread
    Wow thanks guys. I&#39;ll do a test on this tonight. (New mission scripter, thanks for your patience too).

    But what metal said was quite interesting. I haven&#39;t made it to that advanced type scripting yet; but what is:

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_hypotenuse = {sqrt&#40;&#40;_this select 0&#41;^2 + &#40;_this select 1&#41;^2&#41;}

    _a = 3
    _b = 4
    _c = &#91;_a, _b&#93; call _hypotenuse

    hint format &#91;&#34;c=%1&#34;, _c&#93;[/QUOTE]
    That looks interesting.

    Anyways, I&#39;ll give this script I&#39;m working on - a little test later today.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •