Home   Help Search Login Register  

Author Topic: Respawn with startweapon for AI  (Read 2994 times)

0 Members and 2 Guests are viewing this topic.

Mueck

  • Guest
Respawn with startweapon for AI
« on: 28 May 2006, 16:08:20 »
Hello everyone!

First off all sorry for my bad english. I hope u can understand me anyway.

I got this script. It helps me to respawn with my weapon of the beginning.

Code: [Select]
;; reload.sqs
;; based on Universal Weapons Respawn by toadlife and Hamdinger

;; this will prevent the script from starting until
;; the mission has started.
;; this way, it will store the loadout the soldiers started with
;; (allowing for group leader to customize).
;;
@time > 1

;; these arrays store the player's weapons and mags.
;;
_weapArray = weapons player
_magArray = magazines player

;; checks for rifle/GL, fixes
;;
_primary = primaryweapon player
?(_primary == "M16GrenadeLauncher"): _primary = "M16Muzzle"
?(_primary == "Ak74GrenadeLauncher"): _primary = "AK74Muzzle"
?(_primary == "Ak47GrenadeLauncher"): _primary = "AK47Muzzle"

;; waits for first player death to start the loop.
;;
@!alive player

;; this looped section adds the weapons and mags to
;; the player upon respawning.
;;
#start
@alive player
removeAllWeapons player
{player addMagazine _x} forEach _magArray
{player addWeapon _x} forEach _weapArray
player selectWeapon _primary
player selectweapon (primaryweapon unit)
@!alive player
goto "start"

;; end reload.sqs
;; --tactician

The script works good but only for me as player. My AI teammates respawn everytime with M16.  :-[
It would be nice if someone could help me.

Michael.
« Last Edit: 28 May 2006, 16:48:36 by Michael »

Offline Igor Drukov

  • Contributing Member
  • **
  • Conscientious Subjector
Re: Respawn with startweapon for AI
« Reply #1 on: 28 May 2006, 18:30:24 »
Just edit the script more or less like this :


Code: [Select]
_sol=_this select 0
? !(local _sol) : exit
@time > 1


_weapArray = weapons _sol
_magArray = magazines _sol

_primary = primaryweapon _sol

@!alive _sol


#start
@alive _sol
removeAllWeapons _sol
{_sol addMagazine _x} forEach _magArray
{_sol addWeapon _x} forEach _weapArray
_sol selectWeapon _primary
_sol selectweapon (primaryweapon unit)
@!alive _sol
goto "start"

Now what you need to do is call it for every unit in your squad, for instance from the init.sqs :

Code: [Select]
{[_x] call {reload.sqs}} ForEach units NameOfMyGroup
This should do the trick.


Beware though, this means that the server will run the script for every AI unit in the group, which may cause some lag.



[edit]
2nd line of the script
[/edit]
« Last Edit: 28 May 2006, 18:36:08 by Igor Drukov »

Mueck

  • Guest
Re: Respawn with startweapon for AI
« Reply #2 on: 28 May 2006, 19:39:01 »
Thank you for ur help!

Sorry  but i am a big noob. The second code should i put in a new script or in the init from the leader ?
And how ist the command to give a group a name ? :-[
 
Michael

Offline Igor Drukov

  • Contributing Member
  • **
  • Conscientious Subjector
Re: Respawn with startweapon for AI
« Reply #3 on: 28 May 2006, 19:42:59 »
Ok, it is often useful to have a script called init.sqs in your mission folder (just like your reload.sqs) : in there, you can put whatever you want that needs to be activated at the beginning of the mission. No need to call it from anywhere, the game automatically runs it when the mission starts.

Weather commands for instance are often in an init.sqs. There are also defined the specific variables a mission needs (e.g. obj1, GunDead, what have you...).
It is also convenient to call other scripts (like your reload.sqs) from there.


To give a group a name, type the following in the init line of the squad leader :

Code: [Select]
TheNameOfMyGroup=group this


[edit]
incomplete early posting
[/edit]
« Last Edit: 28 May 2006, 19:49:04 by Igor Drukov »

Mueck

  • Guest
Re: Respawn with startweapon for AI
« Reply #4 on: 28 May 2006, 20:35:06 »
Thank you Igor by trying to help me.
I doesnt works. But i think ur script is good but i believe i make a mistake. I dont have any idea about script and stuff like that so i am writing now everything exactly what i am doing in hope u finde the mistake.

1. I create a group wiht me as leader. I write in the init.         people = group this
2. Then i create the scripts in my missionfolder

Quote
_sol=_this select 0
? !(local _sol) : exit
@time > 1


_weapArray = weapons _sol
_magArray = magazines _sol

_primary = primaryweapon _sol

@!alive _sol


#start
@alive _sol
removeAllWeapons _sol
{_sol addMagazine _x} forEach _magArray
{_sol addWeapon _x} forEach _weapArray
_sol selectWeapon _primary
_sol selectweapon (primaryweapon unit)
@!alive _sol
goto "start

and

Quote
{[_x] call {reload.sqs}} ForEach units People

whats wrong ?!?!  Of course i got a spawnpoint.

Offline Igor Drukov

  • Contributing Member
  • **
  • Conscientious Subjector
Re: Respawn with startweapon for AI
« Reply #5 on: 28 May 2006, 21:24:52 »
Ok, I've made at least one big mistake, and a stupid assumption about MP scripting.


The big mistake :


it should be
Code: [Select]
{[_x] exec {reload.sqs}} ForEach units People
instead of

Code: [Select]
{[_x] call {reload.sqs}} ForEach units People

The wrong assumption :

the soldier will be recognized as the same by the script after respawning. Working on this. I'll get back to you asap unless someone comes up with a working solution. Stand by !

Mueck

  • Guest
Re: Respawn with startweapon for AI
« Reply #6 on: 28 May 2006, 21:44:27 »
Yeah doesnÂ't work.  :'( But thanks for trying to help me Igor!   ;)

Maybe someone got a solution ?!?

Offline Igor Drukov

  • Contributing Member
  • **
  • Conscientious Subjector
Re: Respawn with startweapon for AI
« Reply #7 on: 28 May 2006, 21:53:43 »
Ok I've got it. The solution I found to this interesting problem is somewhat complicated.

I use General Barron's functions SquadNumber.sqf and SquadOrder.sqf.


To cut a long story short, see the attachment below.

[edit]
Put the unzipped folder into your OFP/users/MyName/Mpmissions directory.
Open your MP editor, look for the mission called "AI_respawn" written in yellow in Desert Island, chose a slot, and kill your mates. After five seconds, they'll have retrieved their original loadouts.
[/edit]

[attachment deleted by admin]
« Last Edit: 28 May 2006, 21:57:21 by Igor Drukov »

Mueck

  • Guest
Re: Respawn with startweapon for AI
« Reply #8 on: 28 May 2006, 22:24:17 »
It Works.  Thank you Igor!   8)

If i got some other question i will ask u again   ;)

Morning i try it to use it in my mission.
« Last Edit: 28 May 2006, 22:31:48 by Michael »

Offline Igor Drukov

  • Contributing Member
  • **
  • Conscientious Subjector
Re: Respawn with startweapon for AI
« Reply #9 on: 28 May 2006, 22:45:30 »
Np mate.

I see that you've registered today, so welcome to these forums.
If there's still a "solve" button, don't forget to click it after a few days.
It's always a good thing to leave the thread open a bit, because someone could come up with a different, simpler solution.


Anyway, welcome again, and enjoy OFPEC !

Mueck

  • Guest
Re: Respawn with startweapon for AI
« Reply #10 on: 28 May 2006, 22:53:54 »
Yeah ok. Thanks again ;-)

Monday i will try to use it in my mission. If i still got a problem i ask again.



Mueck

  • Guest
Re: Respawn with startweapon for AI
« Reply #11 on: 29 May 2006, 00:32:56 »
IÂ'm back. The script works very good but i have one more question. :-*

What have i to do to let the other team (east) respawn with there beginnig weapon at the same time  too ? :-X

Offline Igor Drukov

  • Contributing Member
  • **
  • Conscientious Subjector
Re: Respawn with startweapon for AI
« Reply #12 on: 29 May 2006, 21:45:07 »
The exact same procedure as with the west squad. Make sure they are all playable, have an east respawn marker, and that's it !

Mueck

  • Guest
Re: Respawn with startweapon for AI
« Reply #13 on: 30 May 2006, 16:17:45 »
YES IT WORKS ! I forgot to change the init.sqs. :-X
Thank you again Igor  ;D

basti

  • Guest
Re: Respawn with startweapon for AI
« Reply #14 on: 10 Jun 2006, 16:53:34 »
i got another question !!

where can i find or download barrons squadnumber and squadorder ????

thanx