Jump to content
Sign in to follow this  
MarcosPasamani

Need help with some scritps

Recommended Posts

Hello guys! I'm new here and on the Mission Editior of OFP Resistance. I have some questions:

- How to make random weapons spawn ON THE GROUND of the map. (Like in DayZ)

- How to make smoke effect (simulate a helicopter crash really far)

- How to make when you die, you start playing with another man of your SIDE. So when everyone die it's a Game Over.

- How to set which weapon your character will spawn with.

That's all for now :rolleyes:

Uhh, and sorry for four questions at the same time, but it's 'cause I started editing two weeks ago.

Share this post


Link to post
Share on other sites

Hi. Maybe this will help you to start with. Look up the used commands in wiki for more detailed info and examples.

To place a visible weapon on ground you need an invisible object called weapon holder:

holder = "WeaponHolder" createvehicle getpos player; holder addweaponcargo ["M21", 1]; holder addmagazinecargo ["M21", 3];

To select random item from array use select and random:

["M16", "AK47", "M21", "Binocular", "NVGoggles"] select ((random 5)-0.5)

To create smoke, repeatedly call the drop command:

drop ["cl_basic", "", "Billboard", 1, 60, [0,50,0], [0,0,0.5], 0, 1.272, 1, 0, [5,10,60],[[0.1,0.1,0.1,1],[0.1,0.1,0.1,0]],[0,1,0,1,0,1,0,1,0,1,0,1],1,0.2,"","", player]

Side respawn is only possible with scripting workaround. Group respawn is possible in multiplayer by placing a description.ext text file in the mission dir with line:

respawn="GROUP";

To give player a specific loadout:

removeAllWeapons player; player addMagazine "AK47"; player addWeapon "AK47";

Share this post


Link to post
Share on other sites

hi,

Hi. Maybe this will help you to start with. Look up the used commands in wiki for more detailed info and examples.

To place a visible weapon on ground you need an invisible object called weapon holder:

holder = "WeaponHolder" createvehicle getpos player; holder addweaponcargo ["M21", 1]; holder addmagazinecargo ["M21", 3];

In MP, when you createVehicle ammocrates and weaponholders the addWeaponCargo and addMagazineCargo commands aren't broadcasted to every computers in ArmA2 OA there's addWeaponCargoGlobal and addMagazineCargoGlobal which is pretty usefull but not in ofp. You must use publicVariable to send the weaponholder name. Also you must use the reveal command to make the "take weapon" action appears much faster.

Something like this should work in multiplayer:

;*********************************************************
;Spawn weaponholder MP compatible Script by Nikiller v0.9b
;Spawn weaponholder at defined position
;Note: put a game logic named server on the map
;contact: nikillerofp@hotmail.fr
;positionName exec "spawn_weaponholder.sqs"
;*********************************************************

_obj=_this
_s=local Server

nik_holder=objNull
? _s: nik_holder="Weaponholder" createVehicle [0,0,0]
~0.1
? _s: _p=getPos _obj; nik_holder setPos _p; nik_holder setDir random 360; publicVariable "nik_holder"
~0.1
@ !(isNull nik_holder)
~0.1
nik_holder addWeaponCargo ["M16",1]
nik_holder addmagazinecargo ["M16",3]

#reveal
~0.1
? player knowsAbout nik_holder<1: player reveal nik_holder; goto "reveal"

exit

@OP: If you are creating a loot system like in dayZ those commands may help to spawn/despawn weaponholders in buildings: nearestBuilding and buildingPos

PM me if you need help.

cya.

Nikiller.

Share this post


Link to post
Share on other sites

I got the idea he might be using createUnit to create enemies dynamically at some point, so he could just use their init lines to also create MP synced loot at the same time.

Share this post


Link to post
Share on other sites

hi,

I got the idea he might be using createUnit to create enemies dynamically at some point, so he could just use their init lines to also create MP synced loot at the same time.

Agree that's the easiest way.

Maybe there's another trick: Spawn an invisible dummy unit like assistants in WW4 mod, randomly add weapon/magazines, force it to drop with DROP WEAPON/MAGAZINE action and delete the dummy unit. Not sure but I think it would even work with createVehicle command.

cya.

Nikiller.

Share this post


Link to post
Share on other sites

Here are a couple of ways to do full "side" respawning:

First method is to use a regular "BASE" respawn mode to respawn the player outside of the mission area (while playing a camera script so they don't see this), the killed eventhandler (or a client side monitor script) then starts finding a suitable AI unit for them to replace (searching an array of possible units etc). Once the candidate unit has been selected, record all the necessary information about it (position, heading, position in vehicle) delete the AI unit then move the player into the matching position with the equipment the AI unit had.

A second way is to fudge the "GROUP" respawn mode where each player has a second disabled AI in their group, outside of the mission area that they can spawn into when they die (catching the player to stop them becoming a seagull while the script finds a candidate to spawn into). A killed eventhandler then joins the selected AI unit into the player's group, then kills the player again, causing the player to be spawned into the new unit. If there are still candidate units available then another "catch" AI is spawned outside the mission area in the player's group.

The second method requires less scripting and gives a 100% accurate loadout. The first method is far more reliable since I've found the second method places a lot of strain on the game and can easily cause loss of synchronisation. Either way, "side" respawning can only be achieved with complex scripting. The second method quickly becomes impractical if the player is in a group with other players/in-mission AI, you'd have to start shuffling them in and out of groups using join, which will put a lot of stress on the game.

Edited by *Zeewolf*

Share this post


Link to post
Share on other sites

Hello, so I have a question:

How to place a weapon inside a building? I learned how to spawn weapons on the ground, and I'd like to know how to put them inside a building. (I tried just moving the icon on Mission Editor but when it's on a building, the weapon simply disappear.) Another thing, if it's just zoom in on ME and move, I can't because I use a notebook and after reconfiguring the controls the zoom in / out isn't working.

Thanks!

Share this post


Link to post
Share on other sites

If you know how to spawn a weapon on the ground, then you should be able to spawn it inside a building using the buildingpos command : https://community.bistudio.com/wiki/buildingPos

Enterable buildings do have some predefined positions set up in their path lod, which you can retrieve with the buildingpos command.

Share this post


Link to post
Share on other sites

Ok, all I asked now I know how to do. Thanks to JdB, ProfTournesol, Pulverizer, Nikiller and *ZeeWolf*.

But now I have another one ;). I'm using the Farmland Horror Pack, but the zombies follow me at any distance. If I spawn on the north, and the zombies on the south, they still follow me! so after some hours they will meet me. I want to know how to make the zombies "see" and follow me from a certain distance. As zombies are AI, I think some code could make it.

Thanks again, and I think this is the last question. Sorry for taking your time.

Edited by MarcosPasamani

Share this post


Link to post
Share on other sites

hi,

Ok, all I asked now I know how to do. Thanks to JdB, ProfTournesol, Pulverizer, Nikkiler and *ZeeWolf*.

But now I have another one ;). I'm using the Farmland Horror Pack, but the zombies follow me at any distance. If I spawn on the north, and the zombies on the south, they still follow me! so after some hours they will meet me. I want to know how to make the zombies "see" and follow me from a certain distance. As zombies are AI, I think some code could make it.

Thanks again, and I think this is the last question. Sorry for taking your time.

Farmland zombies doesn't work well in MP causing server desync and poor performances. There's also scripting errors like ? !alive_z instead of ? !alive _z everywhere making each zombie script running forever even if the zombie is dead. Unfortunetly it is not easily fixable by only mission editing scripting.

For the zombies attacking at any distance problem , I guess you want something like dayZ where zombies attack you only when they see you or hear you. You will have to code a script from scratch to fix it since FML script is not made in this way.

cya.

Nikiller.

Share this post


Link to post
Share on other sites
hi,

Farmland zombies doesn't work well in MP causing server desync and poor performances. There's also scripting errors like ? !alive_z instead of ? !alive _z everywhere making each zombie script running forever even if the zombie is dead. Unfortunetly it is not easily fixable by only mission editing scripting.

For the zombies attacking at any distance problem , I guess you want something like dayZ where zombies attack you only when they see you or hear you. You will have to code a script from scratch to fix it since FML script is not made in this way.

cya.

Nikiller.

:( I can't do it :(. I'm really a noob. I don't know what's scratch man! I'm noob. :(

Share this post


Link to post
Share on other sites
Maybe there's another trick: Spawn an invisible dummy unit like assistants in WW4 mod, randomly add weapon/magazines, force it to drop with DROP WEAPON/MAGAZINE action and delete the dummy unit. Not sure but I think it would even work with createVehicle command.

MWS uses this:

_civ = "MWS_MAN" createVehicle getpos player
_civ addMagazine _w3
_civ action ["DROP MAGAZINE","",1,1,_w3]
~1.5
MWS_tag_HOLDER = nearestObject [_civ, "weaponholder"]
publicVariable "MWS_tag_HOLDER"
deleteVehicle _civ

It creates little, invisible man (model by STGN) which drops the magazine. publicVariable is there to broadcast existence of the object to other players so it can be revealed to them and they can take it immediately.

#WaitForDrop
MWS_tag_HOLDER = objnull
@MWS_tag_HOLDER != objnull
#Reveal
? player knowsAbout MWS_tag_HOLDER < 1 : player reveal MWS_tag_HOLDER; goto "Reveal"

Unit is a hardened civilian. Model is in the MWS package.

class MWS_MAN : Civilian
{
model = "\NAME_OF_YOUR_ADDON\p3d\noMan.p3d";
armor = 10000
scope = 1
};

The process could be speeded up by making animation faster (couldn't get a working code to show here).

The non-addon way would be to create a standard civilian elsewhere (corner of the island), have him drop the item, find it with nearestObject and then move it to desired location.

Share this post


Link to post
Share on other sites

hi,

:( I can't do it :(. I'm really a noob. I don't know what's scratch man! I'm noob. :(

From scratch means from zero. It means you must write your own script.

@Faguss: Thanks for confirmation.

cya.

Nikiller.

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
Sign in to follow this  

×