Jump to content
rellikki

Rellikki's script releases

Recommended Posts

This thread is dedicated to my script releases for mission editing uses. These are a bunch of scripts I've created for my missions for various purposes, which I'm hoping that others would find some use for too. All the scripts are free to use and modify for your missions, but I'm only asking you to credit me for my work. Feel free to post comments, criticism or even ideas.

Released:

Forest detection script

Dynamic skill increasing script

Rearming script

Dynamic view distance script

More to come.

Edited by Rellikki

Share this post


Link to post
Share on other sites

Forest detection script

To start off, here's a little something I recently made. This script detects if a specific position is inside forest. It can be useful, for example, if you want to be able to designate a landing zone for a chopper with a map click, but want to prevent the player from choosing a position inside forest; or if you want to prevent objects from spawning there.

What the script does is check for the nearest object's Z coordinate (height) and compare it to predefined values measured by me. It is not fully guaranteed to work. It's possible that the script might mistake other objects for forest or otherwise interfere with other nearby objects. But after a lot of testing, I can say that it should do its job and work 90% of the time.

forestDetection.sqs

; Forest detection script
; by Rellikki
;
; Used to detect if a position is inside forest.
; Marker named "forestDetection" needed to work. The script looks for the nearest object around the marker.
; Execute the script simply with: [] exec "forestDetection.sqs"

_height = getPos (nearestObject [getMarkerPos "forestDetection" select 0, getMarkerPos "forestDetection" select 1, getMarkerPos "forestDetection" select 2]) select 2

? (_height >= 18.0418 && _height <= 23.1900) || (_height >= 25.8946 && _height <= 28.5844) || (_height >= 23.4063 && _height <= 24.344) || (_height >= 11.6016 && _height <= 12.7339) : goto "forest"
goto "notForest"

#forest
; This line of code will execute if forest was detected. Put all your foresty things here.
exit

#notForest
; This line of code will execute if forest was not detected. Put all your non-foresty things here.
exit

In the demo mission below you can put the script to test and check different spots around Nogova for forests with a map click:

Download demo mission

Edited by Rellikki

Share this post


Link to post
Share on other sites

Dynamic skill increasing script

Updated 8.3.2011!

This script dynamically increases A.I. skill depending on their rank and/or class.

skill.sqs

; Dynamic skill increasing script
; by Rellikki
;
; Dynamically increases A.I. skill depending on their rank and/or class.
; Execute the script with: unit_name exec "skill.sqs"

? "Man" countType [_this] == 0 : {_x exec "skill.sqs"} forEach crew _this

; List all the special classes in the array below, like officers or specops, which will always get the "elite" skill setting, no matter what their rank.
_eliteArray = []
? typeOf _this in _eliteArray: goto "elite"

? rating _this >= 2500: goto "elite"
? rating _this >= 500: goto "veteran"
goto "grunt"

; Ranks from lieutenant to above will get the "elite" skill setting below.
#elite
_this setSkill 0.85 + random 0.15
exit

; Ranks from corporal to above will get the "veteran" skill setting below.
#veteran
_this setSkill 0.65 + random 0.2
exit

; Privates will get the "grunt" skill setting below.
#grunt
_this setSkill 0.45 + random 0.2
exit

In the demo mission below two groups of oppositing sides have been given dynamically increased skill, with a simple trigger, which executes the script for everyone:

Download demo mission

Edited by Rellikki

Share this post


Link to post
Share on other sites

Rearming script

Updated 8.3.2011!

Tired of giving units different loadout one by one? This script rearms units with class specific predefined loadouts. You can easily use it to mass rearm a whole map of units with different weapons of your choice.

I find this script very useful in conjunction with the skill increasing script above. With them, you can increase the A.I. skill for more intelligent behaviour and faster aiming and, using this script, give them HD ammo (JAM3 or WW4 for example), so they're not too accurate with their guns. Just a little tip.

rearm.sqs

; Rearm script
; by Rellikki
;
; Used to rearm units with class specific predefined loadouts.
; Execute the script with: unit_name exec "rearm.sqs"

? "Man" countType [_this] == 0 : {_x exec "rearm.sqs"} forEach crew _this

goto typeOf _this
exit

; List all the classes you want to rearm like in the example below.
#SoldierWB
removeAllWeapons _this
{_this addMagazine "AK47"} forEach [1, 2, 3, 4]
_this addWeapon "AK47"
_this selectWeapon "AK47"
{_this addMagazine "HandGrenade"} forEach [1, 2, 3]
exit

#class2
; ...and here...
exit

#class3
; ...and so forth.
exit

In the demo mission below a group of resistance soldiers have been given different loadouts instead of their default weapons, with a simple trigger, which executes the script for everyone:

Download demo mission

Edited by Rellikki

Share this post


Link to post
Share on other sites

Dynamic view distance script

This script dynamically changes player's view distance according to the height from the sea level. One will get a better view on top of a mountain, but in lowlands it'll be a little more foggy, depending on your set values, of course - Mission maker can easily set the max. & min. view distance and height for his needs. This script is especially useful in multiplayer where the view distance is fixed and can't be changed from the options.

viewdistance.sqs

; Dynamic view distance script
; by Rellikki
;
; Changes view distance according to player's height from the sea level
; Uses TakeOffTim's ASL height function. Credits to him.
;
; Execute the script with: [<min. view distance>, <max. view distance>, <min. height>, <max. height>] exec "viewdistance.sqs"
; The variables should be self-explanatory. View distance will be set to the minimum value if the player is at the minimum height or below and vice versa.

_minDist = _this select 0
_maxDist = _this select 1
_minHeight = _this select 2
_maxHeight = _this select 3

#loop
_height = [player] call Relli_ASLheight

_dist = _minDist - (_height - _minHeight) * (_minDist - _maxDist) / (_maxHeight - _minHeight)
? _dist < _minDist : _dist = _minDist
? _dist > _maxDist : _dist = _maxDist

setViewDistance _dist
; The number below defines how often the view distance gets updated. Change it according to your needs. Smaller time equals for smoother change, longer time for better performance.
~2
goto "loop"

Required:

ASLheight.sqf

/*----------------------------------------------------------------------------------------------------------------------
Computes the height above sea level
© by TakeOffTim
Wenn ihr diese Funktion in eurer Mission benutzen wollt, vermerkt bitte, dass sie von mir ist.
If you want to use this function in your mission, please make a note that I´ve made it.
----------------------------------------------------------------------------------------------------------------------*/

private ["_unit","_logic","_x","_y","_xLog","_yLog","_dist","_ground"];

_unit = _this select 0;
_logic = "logic" camCreate [0,0,0];

_x = getpos _unit select 0;
_y = getpos _unit select 1;
_dist = _logic distance _unit;
_ground = (_x ^ 2) + (_y ^ 2);

deleteVehicle _logic;

sqrt ((_dist ^ 2) - _ground)

In the demo mission below you can see the script in use as you walk up the mountains in southern Everon:

Download demo mission

Edited by Rellikki

Share this post


Link to post
Share on other sites

These are scripts I will use a lot. Thanks Rellikki.

Share this post


Link to post
Share on other sites

Hey Rellikki, some useful scripts you got there, thank you! These will be a great help in mission making.

It's good to see new releases for OFP, especially when they are good quality :)!

Keep them coming!

Share this post


Link to post
Share on other sites

Thanks for the comments.

I updated my rearming script and skill increasing script, as I found out that the scripts wouldn't execute for vehicle crew properly. Now they should be fixed.

I also added a new script which dynamically changes player's view distance according to his height from the sea level. :)

Edited by Rellikki

Share this post


Link to post
Share on other sites

Very good scripts !

Maybe a script support pack, a bit like the SP/MP one from years ago, with ready to use scripts and ressources for mission makers could be interesting.

Share this post


Link to post
Share on other sites

Thanks for the comment. I'm not really familiar with the script support pack, to be honest, but I think it's an idea worthy of consideration. :)

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

×