Home   Help Search Login Register  

Author Topic: Need help on the locality of a specific script  (Read 1804 times)

0 Members and 1 Guest are viewing this topic.

Offline Sanctuary

  • Members
  • *
Need help on the locality of a specific script
« on: 24 May 2009, 01:57:58 »
Hello,

In my WW4 mod project , i have one script running that is responsible of generating an explosion and burning+smoke resulting, it happens for nearly all vehicles, and is launched by the following eventhandler "killed" so it only really run when it is happening (as i definitively want to avoid the alternative with an init eventhandler that would have to check regularly the health of the vehicles in the background)

class EventHandlers
{
killed="_this select 0 exec {\ww4_fx\burnn.sqs}";
};

Of course in single player there is strictly no problem, but from reports of Rellikki that is trying the mod in multiplayer , being the server himself and having a friend playing with him, there is a locality problem that begins to puzzle me a lot because i don't see how to get this right or what is really wrong.

In the start of the explosion script :

-if is used
?(local server):exit
Relliky is the server and see the explosion/burning effect as soon as a vehicle explode (i guess the mission did not featured a game logic named server ?)
His friend being client on Relliky server does not see it at all

-if is used
?!(local player):exit
The same Rellikki being the server see the explosion/burning effect (at least this time it is more logical in my mind)
His friend being client always does not see it at all (there i don't see why at all as his friend is supposedly local to himself and so the script should not exit for him)

And as i am definitively not good at all with multiplayer specific scripting, i really need help from some experts to get this simple script to have the correct enough locality check so when a vehicle explode, both whoever is the server and all the clients can actually see the explosion, smoke and the burning effect.

On the wiki, it is said that the eventhandler "killed" is local, that does not really clear things in my mind.

I checked a lot of other explosion script and noticed most of them do not have a locality check at all anywhere, while some does not seem different from mines.

Does that mean with the killed event being local, there is no need at all of a line of locality check script code for this explosion/burn script case ?

Offline zwobot

  • Members
  • *
Re: Need help on the locality of a specific script
« Reply #1 on: 24 May 2009, 22:51:22 »
Can you post the burnn.sqs script please? If you are using drop things in your burn script this thread I started a few days ago might be of interest to you.

In the meantime try to check whether the script is executed on all machines without any locality checks by inserting something like
Code: [Select]
hint format["%1 is executing burnn.sqs", name player]at the start of the script. That's how I would start to sort the problem out.
"Executing tactics in real combat is the hardest thing one can ever do...well I've never given birth but..well whatever."

Offline Sanctuary

  • Members
  • *
Re: Need help on the locality of a specific script
« Reply #2 on: 25 May 2009, 01:52:45 »
After lots of searches in various archives, i found some other people that were basically facing the same problem.
The culprit apparently is the nature of the "killed" eventhandler.

In the case in which i wanted to use it (an eventhandler built-in vehicles classes in a config) the killed eventhandler i said to apply only on vehicles that are local to the player, that's why a player was not able to see the result of the killed eventhandler on vehicles that were on either server group or other players group.

Unfortunately, it seems the only workaround was to use the "init" eventhandler as this one is global.

As an init eventhandler means that i have to run a check to see if a vehicle is alive, to not destroy performance i must use a high enough delay, and in some conditions, the explosion/burn/smoke generated may be delayed and would look then mor elike a secondary explosion.

So as a solution , i have to release 2 versions of the main config.cpp of my mod, the one with the "killed" eventhandler that works flawlessly in SP (as it create the explosion/burn/smoke exactly when it should), and for MP a config using an init eventhandler that may have a delayed explosion that will look more like a secondary one.

This way it works nicely for both SP and MP

The MP version is launched by
Code: [Select]
class EventHandlers
{
init = "_this exec {\ww4_fx\MPburnn.sqs}";
};

and apparently from reports of Rellikki and his friends , do not need the locality check to work correctly and does not multiply the occurences of the script by the amount of player

The MPBurnn.sqs :
Code: [Select]
_tgt = _this select 0

#alivecheck
~10
?(isNull _tgt): exit
?(alive _tgt): goto "alivecheck"
_tgt setfuel 0;removeallweapons _tgt
[_tgt] exec {\ww4_fx\expsfx.sqs}
_BOOOM = "WW4_Shell73" camcreate [(getpos _tgt select 0), (getpos _tgt select 1), (getpos _tgt select 2)]; _Fuze = "FxExploGround1" camcreate getpos _BOOOM;
_burnlight = "WW4_LIGHTDES" camcreate getpos _tgt; _burnlight inflame true
_ii = 0
#lop
~0.5
_cent = getpos _tgt
_dst = 0.5 - random (1)
_burnlight setpos _cent
drop ["cl_fire","","Billboard",100,6,[(_cent select 0)+_dst,(_cent select 1)+_dst, (_cent select 2)-0.5],[0,0,2.1],0,13.6,10.8,0.9,[3,2.8,5.6,8.8],[[1,1,1,0],[1,1,1,0.9],[0.07,0,0,0.8],[0,0,0,0.6],[0,0,0,0]],[0,1,0,0.33,0.66],0.2,(0.28),"","",_cent]
drop ["cl_basic","","Billboard",100,25,[(_cent select 0)+_dst,(_cent select 1)+_dst, (_cent select 2)+1],[1,0,2.1],0,13.6,11.7,0.9,[5,15,30],[[0,0,0,0.2],[0,0,0,0.4],[0,0,0,0.6],[0,0,0,0.2],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[0,1,0,0.33,0.66],0.09,(0.09),"","",_cent]
_ii = _ii + 1
? _ii <= 600 : goto "lop"
#end
_burnlight inflame false
~1
deletevehicle _burnlight
exit

The SP version , launched by
Code: [Select]
class EventHandlers
{
killed="_this select 0 exec {\ww4_fx\burnn.sqs}";
};

the burnn.sqs :
Code: [Select]
_this setfuel 0;removeallweapons _this
[_this] exec {\ww4_fx\expsfx.sqs}
BOOOM = "WW4_Shell73" camcreate [(getpos _this select 0), (getpos _this select 1), (getpos _this select 2)]; Fuze = "FxExploGround1" camcreate getpos BOOOM;
_burnlight = "WW4_LIGHTDES" camcreate getpos _this; _burnlight inflame true
_ii = 0
#lop
~0.5
_cent = getpos _this
_dst = 0.5 - random (1)
_burnlight setpos _cent
drop ["cl_fire","","Billboard",100,6,[(_cent select 0)+_dst,(_cent select 1)+_dst, (_cent select 2)-0.5],[0,0,2.1],0,13.6,10.8,0.9,[3,2.8,5.6,8.8],[[1,1,1,0],[1,1,1,0.9],[0.07,0,0,0.8],[0,0,0,0.6],[0,0,0,0]],[0,1,0,0.33,0.66],0.2,(0.28),"","",_cent]
drop ["cl_basic","","Billboard",100,25,[(_cent select 0)+_dst,(_cent select 1)+_dst, (_cent select 2)+1],[1,0,2.1],0,13.6,11.7,0.9,[5,15,30],[[0,0,0,0.2],[0,0,0,0.4],[0,0,0,0.6],[0,0,0,0.2],[0,0,0,0],[0,0,0,0],[0,0,0,0]],[0,1,0,0.33,0.66],0.09,(0.09),"","",_cent]
_ii = _ii + 1
? _ii <= 600 : goto "lop"
#end
_burnlight inflame false
~1
deletevehicle _burnlight
exit

(the expsfx.sqs is the smoke and flames that stay for some time after explosion)
Code: [Select]
_truck = _this select 0
_Gp = getpos _truck
_i = 0
_vel = 9
_vel2 = 5
_fir = [3,2]
_smk = [3,8]

#loop
drop ["cl_fire", "", "Billboard", 1, 1.5, [_Gp select 0, _Gp select 1, (_Gp select 2)+1], [random _vel2, random _vel2, random (_vel2*1.3)], 5, 50, 30, 1, _fir, [[1,1,0,1], [1,0.5,0,0.8], [1,1,0,0.7], [1,1,0,0.5], [1,1,0,0.1]], [0,1,0], 5, 0.05, "", "", ""]
drop ["cl_fire", "", "Billboard", 1, 1.5, [_Gp select 0, _Gp select 1, (_Gp select 2)+1], [random (-_vel2), random _vel2, random (_vel2*1.3)], 5, 50, 30, 1, _fir, [[1,1,0,1], [1,0.5,0,0.8], [1,1,0,0.7], [1,1,0,0.5], [1,1,0,0.1]], [0,1,0], 5, 0.05, "", "", ""]
drop ["cl_fire", "", "Billboard", 1, 1.5, [_Gp select 0, _Gp select 1, (_Gp select 2)+1], [random (-_vel2), random (-_vel2), random (_vel2*1.3)], 5, 50, 30, 1, _fir, [[1,1,0,1], [1,0.5,0,0.8], [1,1,0,0.7], [1,1,0,0.5], [1,1,0,0.1]], [0,1,0], 5, 0.05, "", "", ""]
drop ["cl_fire", "", "Billboard", 1, 1.5, [_Gp select 0, _Gp select 1, (_Gp select 2)+1], [random (-_vel2), random (-_vel2), random (-_vel2)], 5, 50, 30, 1,_fir, [[1,1,0,1], [1,0.5,0,0.8], [1,1,0,0.7], [1,1,0,0.5], [1,1,0,0.1]], [0,1,0], 5, 0.05, "", "", ""]
drop ["cl_fire", "", "Billboard", 1, 1.5, [_Gp select 0, _Gp select 1, (_Gp select 2)+1], [random _vel2, random (-_vel2), random (_vel2*1.3)], 5, 50, 30, 1, _fir, [[1,1,0,1], [1,0.5,0,0.8], [1,1,0,0.7], [1,1,0,0.5], [1,1,0,0.1]], [0,1,0], 5, 0.05, "", "", ""]
drop ["cl_fire", "", "Billboard", 1, 1.5, [_Gp select 0, _Gp select 1, (_Gp select 2)+1], [random _vel2, random (-_vel2), random (-_vel2)], 5, 50, 30, 1, _fir, [[1,1,0,1], [1,0.5,0,0.8], [1,1,0,0.7], [1,1,0,0.5], [1,1,0,0.1]], [0,1,0], 5, 0.05, "", "", ""]
drop ["cl_fire", "", "Billboard", 1, 1.5, [_Gp select 0, _Gp select 1, (_Gp select 2)+1], [random _vel2, random _vel2, random (-_vel2)], 5, 50, 30, 1, _fir, [[1,1,0,1], [1,0.5,0,0.8], [1,1,0,0.7], [1,1,0,0.5], [1,1,0,0.1]], [0,1,0], 5, 0.05, "", "", ""]

drop ["cl_basic", "", "Billboard", 1, 3.5, [_Gp select 0, _Gp select 1, _Gp select 2], [random _vel/2, random _vel/2, random (_vel*1.3)], 0.5, 50, 30, 1, _smk, [[0,0,0,0.8], [0.1,0.1,0.1,0.6], [0.4,0.4,0.4,0.4], [0.7,0.7,0.7,0.1], [1,1,1,0]], [0,1,0], 5, 0.05, "", "", ""]
drop ["cl_basic", "", "Billboard", 1, 3.5, [_Gp select 0, _Gp select 1, _Gp select 2], [random (-_vel)/2, random _vel/2, random (_vel*1.3)/2], 0.5, 50, 30, 1, _smk, [[0,0,0,0.8], [0.1,0.1,0.1,0.6], [0.4,0.4,0.4,0.4], [0.7,0.7,0.7,0.1], [1,1,1,0]], [0,1,0], 5, 0.05, "", "", ""]
drop ["cl_basic", "", "Billboard", 1, 3.5, [_Gp select 0, _Gp select 1, _Gp select 2], [random (-_vel)/2, random (-_vel)/2, random (_vel*1.3)], 0.5, 50, 30, 1, _smk, [[0,0,0,0.8], [0.1,0.1,0.1,0.6], [0.4,0.4,0.4,0.4], [0.7,0.7,0.7,0.1], [1,1,1,0]], [0,1,0], 5, 0.05, "", "", ""]
drop ["cl_basic", "", "Billboard", 1, 3.5, [_Gp select 0, _Gp select 1, _Gp select 2], [random (-_vel)/2, random (-_vel)/2, random (-_vel)/2], 0.5, 50, 30, 1, _smk, [[0,0,0,0.8], [0.1,0.1,0.1,0.6], [0.4,0.4,0.4,0.4], [0.7,0.7,0.7,0.1], [1,1,1,0]], [0,1,0], 5, 0.05, "", "", ""]
drop ["cl_basic", "", "Billboard", 1, 3.5, [_Gp select 0, _Gp select 1, _Gp select 2], [random _vel/2, random (-_vel)/2, random (_vel*1.3)], 0.5, 50, 30, 1, _smk, [[0,0,0,0.8], [0.1,0.1,0.1,0.6], [0.4,0.4,0.4,0.4], [0.7,0.7,0.7,0.1], [1,1,1,0]], [0,1,0], 5, 0.05, "", "", ""]
drop ["cl_basic", "", "Billboard", 1, 3.5, [_Gp select 0, _Gp select 1, _Gp select 2], [random _vel/2, random (-_vel)/2, random (-_vel)/2], 0.5, 50, 30, 1, _smk, [[0,0,0,0.8], [0.1,0.1,0.1,0.6], [0.4,0.4,0.4,0.4], [0.7,0.7,0.7,0.1], [1,1,1,0]], [0,1,0], 5, 0.05, "", "", ""]
drop ["cl_basic", "", "Billboard", 1, 3.5, [_Gp select 0, _Gp select 1, _Gp select 2], [random _vel/2, random _vel/2, random (-_vel)/2], 0.5, 50, 30, 1, _smk, [[0,0,0,0.8], [0.1,0.1,0.1,0.6], [0.4,0.4,0.4,0.4], [0.7,0.7,0.7,0.1], [1,1,1,0]], [0,1,0], 5, 0.05, "", "", ""]
_i=_i+1
~0.1
?(_i < 5):goto "loop"
exit

Offline zwobot

  • Members
  • *
Re: Need help on the locality of a specific script
« Reply #3 on: 25 May 2009, 08:00:46 »
Won't it work to add the killed eventHandler in the init eventHandler in the config?
Code: [Select]
class EventHandlers
{
       init = "_this addEventHandler [""killed"", {_this exec {\ww4_fx\MPburnn.sqs}}]";
};
In this way every unit (server/host, client) will get the killed eventHandler attached. Or is the problem that the killed eventHandler only is fired and executed on the unit which "owns" it?
"Executing tactics in real combat is the hardest thing one can ever do...well I've never given birth but..well whatever."

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Need help on the locality of a specific script
« Reply #4 on: 25 May 2009, 08:51:26 »
Weird idea: how about abusing the "Fuel" EH? According to the BIKI it's global.

Trigger it from the "Killed" EH. In the "Fuel" EH check if the vehicle is alive and do nothing if it is. If it's not start the fireworks.
try { return true; } finally { return false; }