Home   Help Search Login Register  

Author Topic: Advice on a Soldier-Loadout script  (Read 2481 times)

0 Members and 2 Guests are viewing this topic.

Offline desertjedi

  • Members
  • *
Advice on a Soldier-Loadout script
« on: 23 Sep 2009, 17:29:42 »
I have a working soldier loadout script that assigns a loadout to all West soldiers based on the "type" of soldier (AA, AT, TL, G, Medic, etc.). It's a bit restrictive in that I have to pass the soldier type to the script so it knows what loadout to choose. It would be great if I could make it more flexible by having the script figure out what is the "type" of soldier. This would make it much easier to use in other missions where I have not pre-defined all the soldiers.

I've looked at all the "attributes" of soldiers in the mission.sqm file and the only one I found that infers the "soldier type" is vehicle. Example is 'SoldierWAT'. Unfortunately, I looked at some missions and I found a large variety of these 'soldier types' depending on what soldier models the mission author uses. Some began with 'Soldier' while others began with 'USMC'.

Can anyone advise me if there's a smart way to make the script assign a loadout (AA, AT, Medic, G, etc.) without me having to tell the script the type of soldier?


Offline i0n0s

  • Former Staff
  • ****
Re: Advice on a Soldier-Loadout script
« Reply #1 on: 24 Sep 2009, 01:57:35 »
Try typeOf and isKindOf.

Offline desertjedi

  • Members
  • *
Re: Advice on a Soldier-Loadout script
« Reply #2 on: 12 Oct 2009, 17:57:44 »
Can someone give me a "debug" line of code that will help me display in-game some actual values of "typeOf" and "isKindOf" for soldiers I'm using?

The only values I could find in some editing manuals were pretty generic and wouldn't give me enough info.

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: Advice on a Soldier-Loadout script
« Reply #3 on: 12 Oct 2009, 18:07:52 »
hint str(typeOf _unit);

or

player sidechat str(typeOf _unit);

Booleans:
_unit isKindOf "USMC_Soldier"
same as
typeOf _units == "USMC_Soldier"

Also check my script that saves preconfigured loadouts after respawn: http://www.ofpec.com/forum/index.php?topic=34253.msg235655#msg235655

You might be able to adapt it to your needs.

Also, check the COMREF: http://www.ofpec.com/COMREF/index.php?action=read&id=209#Man

Offline desertjedi

  • Members
  • *
Re: Advice on a Soldier-Loadout script
« Reply #4 on: 13 Oct 2009, 00:30:03 »
Thanks for the loadout script. It looks great but I wouldn't know where to invoke it from...or when. My editing knowledge is very limited.

What I can probably do is simply cut out your case statement and put it into the loadout script that I currently use. It simply runs at the very start of the mission and that's it. I would just have to keep in mind that if the mission uses other types of soldiers, it would need to be modified. Thanks.

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: Advice on a Soldier-Loadout script
« Reply #5 on: 13 Oct 2009, 01:22:16 »
There's an example mission posted with my script.

If you go the simpler route, at the end of your init.sqf, make sure you put:
sleep 1;
waitUntil{alive player};

Followed by the case statement (otherwise it will try to assign gear while still on the briefing screen and it won't take effect)

Offline desertjedi

  • Members
  • *
Re: Advice on a Soldier-Loadout script
« Reply #6 on: 16 Oct 2009, 21:57:47 »
Quote
If you go the simpler route, at the end of your init.sqf, make sure you put:
sleep 1;
waitUntil{alive player};

Can you give me some context/explanation for that? Is the init.sqf file a script that is executed once when each player joins and that's it? Is it executed again upon player death?

And does putting that statement at the end cause the script to go into some event-wait-state where it's dormant until the player is initially spawned or respawned?

BTW, TCP, I replied to your PM but there's no record of me sending it. Hope you got it.
« Last Edit: 16 Oct 2009, 22:13:37 by desertjedi »

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: Advice on a Soldier-Loadout script
« Reply #7 on: 16 Oct 2009, 23:24:32 »
Right, you need to put it at the end of init.sqf, because it will suspend the script.

(Description.ext is the only thing that gets executed on Mission Selection)

Init.sqf gets executed on Briefing Map.

It is only executed once for the server and each client including JIP players.

sleep 1; is not executed until briefing is done and intro or mission starts.

waitUntil{alive player}; is not required but I use it anyways. You have to use it if you want to wait for a particular player i.e. < leader player > (squadleader) since not everyone is synchronised and spawn at slightly different times.

Nothing is saved on respawn. All gear will go back to BIS defaults. You would had to use something like < player addEventHandler ["killed", {player execVM loadout.sqf}]; > to redo all the loadout. In this case, sleep 1; waitUntil{alive player}; is required to wait until respawn delay is over.