Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: Ai Shoots Flares [script] version 1.3

  1. #1
    Warrant Officer Demonized's Avatar
    Join Date
    Nov 16 2010
    Location
    Back from afk 2013
    Posts
    2,614

    Ai Shoots Flares [script] version 1.3

    AIsoldierFlare v1.3


    updated to v1.3 - 25.mar.2011
    changelog v1.3Spoiler:


    I wanted AI to shoot FLARES when they got engaged or spotted enemy in the dark.
    So they could put pressure on players using NVG´s against opponents that do not have that technological perk.
    Now there are all colors flares available through options.

    Script works with Arma2, OA, or CO, BAF and PMC, as well as compatible with any addon if using curtom weapons option.
    Script works in MP and on dedicated server as well.
    Note: v.1.3 is not confirmed on dedi server yet but should be ok.

    Script will give AI actual light over a area relative to he flare so they can see in the night when flare is up, a certain distance.
    Default game flares is eyecandy for players only when not using this script, AI is blind as a bat if not using this script or similar.

    Script can be used by AI from any side, West, East, Guer and Civilian.
    Script only works when AI is on foot, it pauses when AI in vehicle and resumes when AI is on foot again.
    Script does not care if its day or night so dont add this to your day missions, unless you want to see flares used in daylight.
    in v1.3 there is a sun angle option by CarlGustaffa to check day or night, so you can possibly have multiple days missions going without no problem.
    Script will equip AI with a weapon based on its faction, russians get russian weapons etc.
    Launcher weapons is preserved if not specified otherwise.

    Basic Usage:Copy the content from init.sqf to your init.sqf, there is optional EH for players for both MP and SP missions as well.
    but this is the only line that is important for the script.
    add this line to your init.sqf or in a trigger or something, as long as its activated before any Ai flare script its ok.
    PHP Code:
    AIsoldierFlare_units = []; 
    add minimum this line with your selection in any soldier/civilian units initline, there are several options you can use if you choose so, but this works.
    PHP Code:
    wep = [thisexecVM "scripts\lightsoldflare.sqf"
    If any enemy is detected by AI unit or AI´s group in its patrol or current movement:
    AI will shoot a flare from its grenade launcher weapon up in the air near or towards enemy detected.
    This will not magically create a flare in the air, AI will: if he is still alive, manually shoot the flare into the air.
    Also script works on its own, so you can have 100 AI´s using this same script at the same time in same or different groups, script will not interfeer with it self, or make trouble for any other scripts or waypoints.

    I tested scripts version 1.2 with upsmon script active as well, and it worked nicely in MP on dedicated server, version 1.3 works nicely with the latest upsmon 5.0.8 R2.
    With 1 unit and with 100 units no problems, also in full mission with 50 AI groups using upsmon and no impacts, script works in the background.
    It will not conflict with other movement, only make AI unit pause current move for a second to fire flare and then move on as scripted in upsmon(or other scripts) or waypoints.

    Readme: Spoiler:


    Credits:
    Carl Gustaffa for initial help on v.1 and the crucial light part of script.
    Das Attorny for help in understanding cfg files, crucial to new weapon selection.
    BI community, and others for everything posted, and everything answered.


    Demo mission should work for Arma2, OA, CO since i used baf and pmc units on pmc map:
    http://www.4shared.com/file/kgdK6ySg..._3Proving.html


    Feel free to modify, skin, strip, bash and trample script at will, if you use it in your own releases it would be nice with a credit line.
    Also any feedback is welcome, bugs, requests, optimization tips etc.

    Enjoy
    Last edited by Demonized; Mar 25 2011 at 18:47. Reason: Updated to version 1.3

  2. #2
    A preliminary question - is it absolutely necessary for the AI to fire the flares, or can the flares appear, with the assumption being that they were fired by an enemy?

    In a quick look of the script, as long as you know the direction of the enemy, just have the unit shoot the flare in that direction? It might reduce the overall code.

    It also seems like you could nest a single waituntil nearestenemy loop within a while loop that checks for the flares in the unit's magazine array.

    Oops, instead of having that while check 2 parameters, I'd nest an if/then for just the ammo, and if there is ammo, then the _keeplooping would be true. Dunno if you really need to check for alive? If you do, you could just make it if alive and has ammo, then _keeplooping is true.

    Just a couple ideas.
    Last edited by TRexian; Dec 3 2010 at 19:53.

  3. #3
    Warrant Officer Demonized's Avatar
    Join Date
    Nov 16 2010
    Location
    Back from afk 2013
    Posts
    2,614
    Author of the Thread
    1:yes you can magically just create flares in the air, with a nearestenemy or list of detected side in trigger, however afaik you cannot make a flare being shot in the air without having someone to actually fire it.
    but for just creating a flare would make the script a just few lines, but not seem so realistic, as my aim was to have the AI himself shoot the flare, maybe you dont even need a script, everything may possibly be done from a trigger.

    2:im not familiar with how to get direction to an enemy, thoug i suspect its something like getdir setdir x,y axis sumthing sumthing.

    3:
    Oops, instead of having that while check 2 parameters, I'd nest an if/then for just the ammo, and if there is ammo, then the _keeplooping would be true. Dunno if you really need to check for alive? If you do, you could just make it if alive and has ammo, then _keeplooping is true.
    i thought that was what i did, unfortunately im not very familiar with while do..

    Edit: added second test of while do in first post bottom.
    Last edited by Demonized; Dec 6 2010 at 00:03. Reason: added info of new test

  4. #4
    I have a scripted solution where AI will use flares actively based on suspicion. However, as it's based on one running script per running AI unit with flares, it's not the best possible solution. But note the following:
    1) If AI suspects something, then he will fire flares in order to see better so he can make that call better.
    2) It's based on distance and some randomness, so they won't fire flares all over the place.
    3) Last I checked, the actual flare object doesn't seem to have a valid #lightpoint associated with it. It's bright for the player, but it won't help the AI at all Earlier I solved this problem by doing some magical revealing, but now I attach a #lightpoint object to the actual flare while it's alive. And voila, the AI can now also spot you when they fire a flare
    4) Although they will continue to shoot flares, they don't actually have to in order to see you once you've been made (they can see new enemies though that they didn't know of before). It's like grass and smoke - once you've been made there really is no hiding anymore.
    5) Units are given equipment based on their class, grenadiers will have half of their HEs replaced with flares. Furthermore, they are magically restocked to keep the battlefield lit. Keep in mind I did it for an MP mission, so sometimes you have to cheat a little to ease the load.
    6) AI doesn't know and/or couldn't care less what they are shooting. They may well try to hit you with a flare.
    7) It's actually flare shooting (not magically created), so you can often hear the shot being fired, because they tend to be close.

    So yes, I'm doing the same mistake as OP, by having one script running for each unit, instead of looping over units with the same script. But it works pretty good, and they start using them before they have a valid ID on the guy. I've posted this stuff before, but I consider it a bit outdated. Let me know if a refreshed version is useful. To test it in action, try Domino (not Domination, but based on it, the flare stuff is not in Domination) during night mission.
    Regards
    Carl Gustaffa - left this game due becoming Steam Exclusive

  5. #5
    Let me know if a refreshed version is useful.
    Always is! Yes, please.

  6. #6
    Crap. Me and my big mouth Ehm, ok. Note that this is for east enemy AI only. I thought I had a more generalized version available, but I'm not sure how up to date that one is compared to how I use it in Domino, so I show this way.

    When units are created, call this:
    Code:
    [_unit] call x_equipunit;
    Where x_equipunit is:
    Code:
    x_equipunit = {
    	private ["_unit"];
    	_unit = _this select 0;
    	_muzzles = getArray(configFile>> "cfgWeapons" >> primaryWeapon _unit >> "muzzles");
    	if (count _muzzles == 2) then {
    		_flaremagsw = ["FlareWhite_M203","FlareGreen_M203","FlareRed_M203","FlareYellow_M203"];
    		_flaremagse = ["FlareWhite_GP25","FlareGreen_GP25","FlareRed_GP25","FlareYellow_GP25"];
    		if ("M203Muzzle" in _muzzles) then {
    			if (typeOf _unit in ["TK_Soldier_GL_EP1"]) then {
    				{_unit removeMagazine "1Rnd_HE_M203"} forEach [1,2,3,4];
    			};
    			for "_i" from 0 to 3 do {
    				_unit addMagazine (_flaremagsw select (_flaremagsw call XfRandomFloorArray));
    			};
    		};
    		if ("GP25Muzzle" in _muzzles) then {
    			_unit addMagazine (_flaremagse select (_flaremagse call XfRandomFloorArray));
    		};
    		_unit addEventHandler ["fired",{_this spawn DOM_EH_Fired}];
    		[_unit] execVM "bat\EnemyFlares.sqf";
    	};
    };
    XfRandomFloorArray is a basic randomizer:
    Code:
    XfRandomFloorArray = {floor (random (count _this))};
    The DOM_EH_Fired is precompiled via:
    Code:
    DOM_EH_Fired = compile preprocessFileLineNumbers "bat\EH-Fired.sqf";
    which looks like this (tried to remove all additional stuff it does):
    Code:
    _unit = _this select 0;
    _weapon = _this select 1;
    _muzzle = _this select 2;
    _mode = _this select 3;
    _ammo = _this select 4;
    _magazine = _this select 5; //Not in use yet.
    _projectile = _this select 6; //_this expanded removed, now uses internal projectile support.
    _flareammo = ["F_40mm_White","F_40mm_Green","F_40mm_Red","F_40mm_Yellow"];
    _flaremagsw = ["FlareWhite_M203","FlareGreen_M203","FlareRed_M203","FlareYellow_M203"];
    _flaremagse = ["FlareWhite_GP25","FlareGreen_GP25","FlareRed_GP25","FlareYellow_GP25"];
    
    //For AI, add back ammo if shooting flares
    if (_unit != player) then {
    	_restore = "";
    	if (_muzzle == "GP25Muzzle") then {
    		switch (_ammo) do {
    			case "F_40mm_White" : {_restore = "FlareWhite_GP25"};
    			case "F_40mm_Green" : {_restore = "FlareGreen_GP25"};
    			case "F_40mm_Red" : {_restore = "FlareRed_GP25"};
    			case "F_40mm_Yellow" : {_restore = "FlareYellow_GP25"};
    		};
    	} else {
    		switch (_ammo) do {
    			case "F_40mm_White" : {_restore = "FlareWhite_M203"};
    			case "F_40mm_Green" : {_restore = "FlareGreen_M203"};
    			case "F_40mm_Red" : {_restore = "FlareRed_M203"};
    			case "F_40mm_Yellow" : {_restore = "FlareYellow_M203"};
    		};
    	};
    	if (_restore != "") then {_unit addMagazine _restore};
    };
    if (_ammo in _flareammo) then { //Forget these for now, I'll try to explain in detail later.
    //	["glflareclient", [_projectile]] call XNetCallEvent;
    //	["glflareserver", [_projectile]] call XNetCallEvent;
    };
    And finally, the actual script that does the shooting of the flares:
    Code:
    private ["_unit","_check","_leader","_flarechance","_mags","_one_flare","_one_flare_muzzle","_muzzles","_enemies"];
    _unit = _this select 0;
    _flarechance = 0.6;
    _enemylist = [];
    _flareammo = ["F_40mm_White","F_40mm_Green","F_40mm_Red","F_40mm_Yellow"];
    _flaremagsw = ["FlareWhite_M203","FlareGreen_M203","FlareRed_M203","FlareYellow_M203"];
    _flaremagse = ["FlareWhite_GP25","FlareGreen_GP25","FlareRed_GP25","FlareYellow_GP25"];
    _flarefired = false;
    _unit setVariable ["flarefired", false];
    sleep 0.123;
    while {alive _unit} do {
    	_flarefired = _unit getVariable "flarefired";
    	if (_flarefired) then {sleep 10.123 + (random 10)};
    	_leader = leader _unit;
    	_check = false;
    	_enemies = [];
    	_enemies = nearestObjects [_unit,["SoldierWB"],400];
    	{
    		scopeName "xxxx1";
    		if((_leader knowsAbout _x >= 0.05) && (_unit distance _x < 300) && ((side _unit) getFriend (side _x)) < 0.6) then {
    			_check = true;
    			breakout "xxxx1";
    			sleep 1.123;
    		};
    	} forEach _enemies;
    	
    	if (_check && !_flarefired && (random 1 < _flarechance) && !(call X_fnc_isDay)) then {
    		_one_flare = "";
    		_mags = magazines _unit;
    		{
    			scopeName "xxxx2";
    			if (_x in _flaremagsw || _x in _flaremagse) then {
    				_one_flare = _x;
    				breakOut "xxxx2";
    			};
    		} forEach _mags;
    		sleep 3.345;
    		if (!_flarefired && alive _unit) then {
    			if (_one_flare != "") then {
    				sleep 1.234;
    				_muzzles = getArray(configFile>> "cfgWeapons" >> primaryWeapon _unit >> "muzzles");
    				_one_flare_muzzle = "";
    				if ("GP25Muzzle" in _muzzles) then {_one_flare_muzzle = "GP25Muzzle"};
    				if ("M203Muzzle" in _muzzles) then {_one_flare_muzzle = "M203Muzzle"};
    				sleep (3 + random 6);
    				_unit selectWeapon _one_flare_muzzle;
    				if (count _enemies == 0) then {
    					_unit doWatch [getPos _unit select 0, getPos _unit select 1, 200];
    				} else {
    					_unit doWatch [getPos (_enemies select 0) select 0, getPos (_enemies select 0) select 1, 150 + (300 - (_unit distance (_enemies select 0))/2)];
    				};
    				sleep 1.234;
    				_unit fire [_one_flare_muzzle, _one_flare_muzzle, _one_flare];
    				sleep 1.234;
    				_flarefired = true;
    				_unit setVariable ["flarefired", true];
    				_unit doWatch objNull;
    				sleep 31.234;
    				if (random 1 < 0.7) then {
    					if (_one_flare_muzzle == "GP25Muzzle") then {
    						_unit addMagazine (_flaremagse select (_flaremagse call XfRandomFloorArray));
    					} else {
    						_unit addMagazine (_flaremagsw select (_flaremagsw call XfRandomFloorArray));
    					};
    				};
    			};
    		}
    		else {
    			_flarefired = false;
    		};
    		sleep 30;
    	};
    	sleep 10 + (random 10);
    	_flarefired = false;
    	_unit setVariable ["flarefired", false];
    };
    Note the low knowsAbout value in red. That's what trigger the unit to use flares in the first place. Adjust to suit. Also I'm using "SoldierWB", which isn't very generalized. Adjust to suit. The blue command nearestObjects would probably work even better with nearestEntities.

    The script checks for night using a generalized function that looks like:
    Code:
    X_fnc_IsDay = {
    	private ["_ret"];
    	_ret = if (call X_fnc_SunElev > 0) then {true} else {false};
    	_ret
    };
    and (phew...)
    Code:
    X_fnc_SunElev = {
    	/*
    		Author: CarlGustaffa
    
    		Description:
    		Returns the suns altitude for current day and hour of the year on any island (whos latitude may differ).
    
    		Parameters:
    		None needed.
    
    		Returns:
    		Suns altitude in degrees, positive values after sunrise, negative values before sunrise.
    	*/
    	private ["_lat", "_day", "_hour", "_angle", "_isday"];
    	_lat = -1 * getNumber(configFile >> "CfgWorlds" >> worldName >> "latitude");
    	_day = 360 * (dateToNumber date);
    	_hour = (daytime / 24) * 360;
    	_angle = ((12 * cos(_day) - 78) * cos(_lat) * cos(_hour)) - (24 * sin(_lat) * cos(_day));
    	_angle
    };
    but for a static mission on a static island you could pull it off with a normal time check instead.

    Now, about those effect files, they are called in this weird looking way because that's the semantics that Domination uses. How you end up calling them are up to you, but they are split up into client and server scripts so you can easily see what's going on. In Domination there is a middle wrapper handling system that sits between everything, but I'm not going to add more confusion by using that here, so I'll just show the scripts that end up on clients and server:

    client:
    Code:
    GL_Effects_Flare_Client = {
    	_projectile = _this select 0;
    	_delay = time + 3;
    	waitUntil {count getArray (configFile >> "CfgAmmo" >> typeOf _projectile >> "lightColor") > 1 || time > _delay};
    	if (time > _delay) exitWith {}; //Not a flare.
    	sleep 2;
    	if (!alive _projectile) exitWith {}; //Color will not have enough elements if dead.
    	_timetolive = getNumber (configFile >> "CfgAmmo" >> (typeOf _projectile) >> "timeToLive");
    	_color = getArray (configFile >> "CfgAmmo" >> typeOf _projectile >> "lightColor");
    	_r = _color select 0;
    	_g = _color select 1;
    	_b = _color select 2;
    	_a = _color select 3;
    	sleep 0.05;
    	_sm = "#particlesource" createVehicleLocal getPos _projectile;
    	_sm setParticleRandom [0.5, [0, 0, 0], [0, 0, 0], 0, 0.3, [0, 0, 0, 0], 0, 0, 360];
    	_sm setParticleParams [["\ca\Data\ParticleEffects\Universal\Universal", 16, 12, 8,0],
    		"", "Billboard", 1, 3, [0, 0, 0],
    		[0,0,0], 1, 1, 0.80, 0.5, [0.6,1.4],
    		[[0.9,0.9,0.9,0.6], [1,1,1,0.3], [1,1,1,0]],[1],0.1,0.1,"","",_projectile];	
    	_sm setdropinterval 0.02;
    	_sp = "#particlesource" createVehicleLocal getPos _projectile;
    	_sp setParticleRandom [0.03, [0, 0, 0], [0, 0, 0], 0, 0.2, [0, 0, 0, 0], 0, 0, 360];
    	_sp setParticleParams [["\ca\Data\ParticleEffects\Universal\Universal", 16, 13, 2,0],
    		"", "Billboard", 1, 0.1, [0, 0, 0],
    		[0,0,0], 1, 1, 0.80, 0.5, [1.5,0],
    		[[_r,_g,_b,-4], [_r,_g,_b,-4], [_r,_g,_b,-2],[_r,_g,_b,0]],[1000],0.1,0.1,"","",_projectile,360];	
    	_sp setdropinterval 0.001;
    //	_projectile say3D "FlareBurnGL"; //Activate if you have a 30 second sound sample available.
    	_to_delete = [_sm, _sp];
    	sleep 0.1;
    	[_to_delete, _projectile] spawn {
    		_to_delete = _this select 0;
    		_projectile = _this select 1;
    		waitUntil {!alive _projectile};
    		{deleteVehicle _x} forEach (_to_delete);
    	};
    };
    server:
    Code:
    GL_Effects_Flare_Server = {
    	_projectile = _this select 0;
    	_delay = time + 3;
    	waitUntil {count getArray (configFile >> "CfgAmmo" >> typeOf _projectile >> "lightColor") > 1 || time > _delay};
    	if (time > _delay) exitWith {}; //Not a flare.
    	sleep 2;
    	if (!alive _projectile) exitWith {}; //Color will not have enough elements if dead.
    	_color = getArray (configFile >> "CfgAmmo" >> typeOf _projectile >> "lightColor");
    	_r = _color select 0;
    	_g = _color select 1;
    	_b = _color select 2;
    	_a = _color select 3;
    	_li = "#lightpoint" createVehicleLocal [0,0,0]; //getPos _projectile;
    	_li setLightBrightness 0.24; //2.44;
    	_li setLightAmbient[_r*0.8, _g*0.8, _b*0.8];
    	_li setLightColor[_r, _g, _b];
    	_li lightAttachObject [_projectile, [0,0,0]];
    	[_projectile] spawn {
    		_projectile = _this select 0;
    		while {alive _projectile} do {
    			_projectile setPosASL [(getPosASL _projectile select 0) + 0.05 * (wind select 0), (getPosASL _projectile select 1) + 0.05 * (wind select 1), (getPosASL _projectile select 2) + 0.2];
    			sleep 0.075;
    		};
    	};
    	waitUntil {!alive _projectile};
    	deleteVehicle _li;
    };
    Client script adds a lightsource (really only needed if you have AIs on your team, since AI will see what you see, and the flare alone as I said will not actually give additional spotting capabilities to the AI) to the flare. It also adds a glowing orb, also visible in daylight, and some smoke effects. Burnt residue effect was removed (didn't like how it looked in the end).

    Server script also adds a lightsource (highly needed in COOP games, or they won't be aided by the flare). It doesn't add glowing orb or smoke as AI could care less. But it does add wind drift, but you may have to adjust its effect and delay to suit. Due to how AI sometimes shoots flares by aiming at you, I decided not to include any simulation stopping just above ground (like in ACE), and I rather just call it "destroyed on impact" instead.

    Feel free to enhance and fix, no permissions needed, and no credits required. It may look a bit complex, but it's actually quite straightforward - no rocket science going on here Remember, running scripts on a per unit basis is BAD stuff, so optimizing this to loop over all units instead might be a first optimization step. GL flares are a bit more straightforward to handle than arty flares, as there are no incoming sounds, delay, expel sound, delay, ignite sequence that needs to be maintained.

    Hope this is useful, and not adding too much confusion to the mix. Alternatively, you can try to create it for yourself from scratch, and come back and check how I solved some of the error messages you might come across. Hope I managed to put it all in this time, instead of just fragments

  7. #7
    Warrant Officer Demonized's Avatar
    Join Date
    Nov 16 2010
    Location
    Back from afk 2013
    Posts
    2,614
    Author of the Thread
    wow that was alot of info CarlGustaffa

    Any chance i dont have to pick your scripts apart to find the create light on flare shot part??
    Maybe an example script of how to attach light to my AI launched flare?

    I understand the script, im just not seeing what you _this select 0; from to get projectile in the server script....??
    I think that server script is only thing i need to compliment my own script with actual light for ai... right?

    In testing of my own script i didnt actually notice AI being blind even with flare, tho my test subject was this setDammage false; and once bluefor ai with NVG spotted him they shot, him and he launched flare, and started to kill them all, then launched next flare if anyone still left, and so on..

    If i understand correctly:
    My players in COOP using NVG´s approaching enemy, enemy doesnt see them, and is on aware mode, players shoot at enemy, enemy switches to combat mode and launches flare, and starts shooting at any player that is shooting, wich probably is all of them by this point, enemy sees players because of their shooting and not flare itself?? flare is only eyecandy for players??
    That seems like a silly thing for BIS to still have ingame..

    Edit: i am trying to look at a while loop and integrate all flare AIs into an array in same script, but im getting nowhere with that, my problem is the while loop stops or never starts.. so its kindof on the shelf for now, still learning.

    Edit2: Man i feel stupid, my while loops didnt work because of while () do { instead of the correct while {} do {
    I have finished my script with while do, but with all the help lines in it its now 0.10kb bigger than my original script lol.
    Script has countermeasure to prevent multiple ais spamming nightsky with flares.
    Also have incorporated an ambush or attack on sight option.
    I have updated my first post at beginning of thread with script.

    ---------- Post added at 05:26 PM ---------- Previous post was at 03:29 PM ----------

    Script fully working and updated with combat, ambush option as well as AI spam sky with flares prevention, and check if ai in vehicle then dont shoot.
    Last edited by Demonized; Dec 5 2010 at 11:47.

  8. #8
    Indeed flares are only eyecandy for players (can also work against players though, by washing out their NVGs, and I'm using this as a valid arty flare tactics for AI), and indeed it is silly. Disappointing even. A flare doesn't aid AI vision or ability to spot things. A #lightpoint object does (didn't always).

    The point of this mess is that they start shooting flares based on suspicion of enemy around them, instead of waiting until they have confirmation, in which the flares doesn't really do anything. At the same time the script prevents them from using flare at all unknowns, only unknowns that actually are enemies. Or they would keep shooting flares all the time which looked silly.

    Even with reveal, you'll only obtain a value of 1, which is not enough to start shooting, but enough to send units out to observe. So when the #lightpoint illuminates their enemy, knowsAbout goes high enough so they actually open fire.

    Not sure what you mean about _this = _projectile. It's the lines that are commented here that sends [_projectile] as a parameter to the wrapper function, which in turn (but now shown) sends _projectile as parameter to the server and client scripts. You could possibly use publicVariable and addPublicVariableEventHandler to cope with it instead. If you really want to know about how it works in Domination, check out this, but I guess it's kinda hard to wrap your head around unless you're able to follow the code.

  9. #9
    Warrant Officer Demonized's Avatar
    Join Date
    Nov 16 2010
    Location
    Back from afk 2013
    Posts
    2,614
    Author of the Thread
    checking out your link now.
    What i meant in previous post was:
    From where or how do you call the "server" script that creates a light for the ai on the projectile"the flare"?

    This from above scripts confuses me...
    PHP Code:
    _projectile _this select 6//_this expanded removed, now uses internal projectile support. 
    when its not being used or is it??

    basically i wanted to know how to get the unit or name of: (flare shot aka the projectile)
    for then to create a light source on for the AI to spot enemy players due to more light, from the flare.

    I am far from a good scripter, i usually learn by copying and modifying or looking at others scripts.
    Your scripts posted above may be just to much for me to understand atm.

    Edit: i see you use a firedeventhandler to launch the create light on projectile script, is that correct?
    Never messed with evenhandlers before, time to research again.

  10. #10
    Ehm, never mind the //comment on that line. If you see the notes on fired EH, you'll see that after b1.54.73642, magazine and projectile is passed automatically to the script. Before we had to use some tricks to obtain the projectile.

    It works like this: When an AI that qualifies for a grenadier (determined in the x_equip function) shoots his weapon, the fired EH is started, and all those parameters are obtained automatically. As it is here only for server AI, the server script can be started normally. But you have to make sure somehow that the client script is started as well, for clients, if you want the added visual effects and sound (if activated). I'm using the wrapper in Domination to do it, but you could use publicVariables for an easier approach.

    Yeah that's how I learn myself, watching other peoples stuff. Domination is now not as easy to read as it once was, but that's pretty much how I started. Trying to read and learn the updated ways made me understand scripting better in general.

    Eventhandlers is a very important aspect of scripting, get down to business

Page 1 of 3 123 LastLast

Posting Permissions

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