Forum Jump :

Author Message

scoe  



Posts: 15
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2015-12-06 20:11        
     
Hi everybody,

I am trying to allow AI units with a custom loadout to patrol a marker location (could be done with UPS - not really worried about this part), then die, respawn at another marker with their custom loadout, and assault the original marker. Rinse and repeat.

I've tried several various respawn scripts combined with a respawn event handler to restore the equipment but have been unsuccessful so far. I do not fully understand scripting, but usually well enough to piece what I need together after looking at it.


My latest attempt uses an Arma 2 code from Norrin (http://www.armaholic.com/page.php?id=6197) that seems close, but also gives some errors each time it runs. The unit respawns and the weapon is removed, but none of the other equipment changes as far as I can tell, and then moves to the designated waypoint. All I need to figure out is how to clear the errors and get the equipment back on respawn.

Unit Init:


AI_respawn_Init.sqf:


AI_Respawn.sqf:



Waypoint.sqf:


Any help would be appreciated. This has take most of my free time the past few days.


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#2 Posted at 2015-12-07 00:13        
     
You could do this with just a single script. You whould put something like this in the AI's init box:
this execVM "ai_init.sqf"; this addEventHandler ["Respawn", {[_this select 0] execVM "ai_init.sqf"}];

ai_init.sqf whould give the ai it's loadout, then send it to the waypoint. So you should put _unit = _this select 0; to the top of it, then export the loadout in script form (or just change the variable name from this to _unit). Then finally you'd add the end of the waypoint.sqf.

EDIT: Actually the waypoint thing is kinda complicated if this group has more than 1 unit, I'll look in to it and update this. Right now it'll weirdly create multiple waypoints.

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Advertisement


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#3 Posted at 2015-12-07 01:36        
     
for loadout you can use bis_fnc: saving & loading inventory

[_unit, [missionNamespace, format ["current_inv_%1", typeof (_unit)]]] call BIS_fnc_saveInventory; in an init file,

then in respawn file or through EH "Respawn" as Wak wrote:
[_unit, [missionNamespace, format ["current_inv_%1", typeof (_unit)]]] call BIS_fnc_loadInventory;

Very useful also for respawning players with the inventory they had when dying but you need to discriminate each player with the variable in format expression (name instead of typeof for example).

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message

scoe  



Posts: 15
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name:

 
#4 Posted at 2015-12-07 22:17        
     
Thank you both. I'll be trying some things out over the next few days and we'll see what happens.