Jump to content
Sign in to follow this  
A-SUICIDAL

Strange trigger problem - need help

Recommended Posts

For testing purposes I created a small 10 meter radius repeating trigger and set it to be activated by civilian.

In the "On Act" field I have a simple hint that says "trigger activated".

I then place a civilian inside the trigger radius.

When I test the sample mission, the civilian activates the trigger right away and I see the hint message appear on my screen saying "trigger activated".

So far everything works as it should.

Now, here's my problem...

I place a marker inside the trigger where I want a 2nd civilian to spawn.

When the mission starts I see the "trigger activated" hint appear as it should.

I then execute a script by radio that spawns a 2nd civilian on the marker that is inside the trigger and the trigger does not activate a 2nd time even though the trigger is set to "repeatedly".

The "trigger activated" hint should've appeared a second time, but it did not.

Why?

So I slide the 1st civilian just outside the trigger radius and then test the sample mission again.

The mission starts and no hint appears, which is expected.

I then use the radio to spawn the 2nd civilian on the marker inside the trigger - and the trigger activates and the hint appears.

This makes no sense at all.

If the trigger is set to "repeatedly", then I should be able to place the 1st civilian inside the trigger radius and see the hint appear for him at mission start - and then spawn a 2nd civilian inside the trigger radius and see the hint appear for him too.

So rather than ask why this is happening, I just need help in finding out away to make it so the trigger will activate a second time when I spawn the 2nd civilian inside the trigger radius.

Is it possible to make this work?

Share this post


Link to post
Share on other sites

The trigger will only repeat when the condition changes to true. As an example do this. place the trigger.As a player civ, run in and out of the trigger. Also don't forget you can use the deact to do stuff too.

Share this post


Link to post
Share on other sites

The trigger won't repeat if one of the civilians is standing in it. I can start 2 ungrouped civilians outside the trigger and give them both separate waypoints inside the trigger and the trigger fires when the first civilian enters the trigger, but does not fire a second time when the 2nd civilian enters the trigger, because the first civilian is still standing in it - and I need it to fire twice for both civilians.

Lets say I have a 15000 meter trigger covering the entire map and as civilians are randomly generated by a module I need to add an event handler to each civilian by use of a trigger. This doesn't seem to work. How would I go about doing this?

Share this post


Link to post
Share on other sites

if (side _x == civ) then {
{_x addEventHandler ["Killed",
{
//code
}]} foreach units in thisList;
};
};

Would be my first guess.

Share this post


Link to post
Share on other sites

This is what I had in my trigger, but it only worked for civilians that were already present, not civilians that were generated later.

trigger covers entire map, repeatedly

On Act:

nul = [thisList, civilian] execVM "civilian_init.sqf";

civilian_init.sqf:


private
[
"_civilian"
];

_civilian = _this select 0;

{
if (_x isKindOf "civilian") then 
{
	_x AddEventHandler ["killed", {nul= _this execVM "wrongful_kill.sqf";}];
};

} forEach _civilian;

wrongful_kill.sqf:

deduct points from the killer, 
maybe send killer to jail, 
whatever punishment you want to script.

---------- Post added at 05:06 AM ---------- Previous post was at 04:53 AM ----------

Thanks tryteyker. I should have thought of that sooner. I forgot that I am already using that method in my mission for adding enemy skills. I place it in the init of an invisible H-pad.

{
if (side _x == EAST) then {  
	_x setskill ["aimingAccuracy",0.60];
	_x setskill ["aimingShake",0.95];
	_x setskill ["aimingSpeed",0.95];
	_x setskill ["endurance",0.95];
	_x setskill ["spotDistance",0.95];
	_x setskill ["spotTime",0.95];
	_x setskill ["courage",0.95];
	_x setskill ["reloadSpeed",0.95];
	_x setskill ["commanding",0.95];
};
} foreach allunits;

I still think it's funny how triggers work in this game. It's like the electronic door mat to a store - when you stand on it the door opens and stays open until you step off of it. I wish the game had an alternate trigger that would open and shut the door instantly even if you're still standing on it.

Share this post


Link to post
Share on other sites

I stuck this in the init of an H-pad:

{
if (side _x == civilian) then {
	_x addEventHandler ["Killed",{nul= _this execVM "wrongful_kill.sqf";}];
};
} foreach allunits;

It seems to work just fine.

Share this post


Link to post
Share on other sites

edited...

Actually, it doesn't seem to work for spawned units.

I thought it worked when I tested it a little while ago.

It only seems to work for the civilians that are present at mission start.

Invisible H-pad init:

{if (side _x == civilian) then {_x addEventHandler ["Killed",{nul= _this execVM "wrongful_kill.sqf"}]}} foreach allunits

so how can I make this work for units that are spawned later in the mission?

and I can now assume that my setSkill H-pads do not work on spawned enemy, so now I guess I have to set their skills in their spawn scripts or something. grr

Edited by A-SUICIDAL

Share this post


Link to post
Share on other sites

I don't think it can be done.

I just finished reading this other thread... Best-way-to-detect-spawned-unit

In my case I am not using a spawn script to spawn the civilians, otherwise I would add the EH to a spawn script. I am instead using the civilian module which automatically generates civilians.

I am also using the custom map Faysh Khabur, which does not have defined city locations, so the civilian module will not work - unless I place a game logic "city center" in each city and name it according to each city location, then I run a script that tells the civilian module named "CIV_SPAWNER" to spawn civilians when needed. I do this by starting the mission with the civilian module init blank, then when a random task is assigned at one of the cities, I do this...

CIV_SPAWNER setVariable ["townlist",[Rabiah]]; processInitCommands; clearVehicleInit CIV_SPAWNER;

... which then spawns the civilians in that specific task/city location. Upon completion of that task/city, when all players have left that task location - I delete all remaining civilians and enemy and everything in that area. When a new task/city is randomly assigned, I then add a new city to the civilian module, which tells the module to spawn civilians at the new task/city location. This seems to work fine, but I still cannot seem to find a way to add an event handler to the civilians that are spawned by the civilian module. Again, I don't think it can be done, but then again somebody always figures out a way to do it.

Edited by A-SUICIDAL

Share this post


Link to post
Share on other sites

It should be very possible to detect a given side and add an eventhandler to them. But since you're using the module, I'm just not sure how. But it can be done. It's really easy if you're spawning the units via script or pre-placed. You could use upsmon, which is far better than the module anyhow, and add these EH very easily. UPSMON > all... just saying.

Share this post


Link to post
Share on other sites

I'm reading this now...

Adding eventhandler to civilians spawned by script-created ALICE module

Seems very interesting. If I can't get it to work I will write my own civilian spawn scripts. The only problem I have with civilians when I place them or spawn them is... they always run away and disappear - even if they are given waypoints etc.

I'll take another look at upsmon. I used once it a long time ago, but for enemy.

Share this post


Link to post
Share on other sites

UPSMON is the tits dude. You can have civs patrol, or man random buildings within a marker etc. Another thing is how easy it is to use, but yet it does so much for the AI.

Share this post


Link to post
Share on other sites

I wasn't a huge fan of upsmon back when I used it because the enemy were always hiding in buildings and on roof tops. It seemed fun at first, but then when it came to entering a building and trying to clear each room, well, you can't even enter a doorway sideways because your gun barrel hit's the doorway and won't let enter through the door unless you walk in straight - and when there is an enemy to your immediate left inside the doorway and you can't walk in aiming to the left, you get killed because you have to walk in straight and you can't turn quick enough to the left to shoot him. So I normally use my own spawn scripts and and try to keep the enemy outside of the buildings. With my scripts I know exactly what the enemy will be doing and they do it well. I really don't need the enemy to be dicking around in a bunch of buildings when I need them patrolling my thought out defensive waypoints. The best part about not using upsmon is... I get the satisfaction of knowing that I didn't take the easy way out when it comes to the enemy in my mission. They are my children and they do what I want them to do, heh :)

Anyway, I tried using this in the civilian module and it works great:

CIV_SPAWNER setVariable ["townlist",[Rabiah]];
CIV_SPAWNER setvariable ["ALICE_civilianinit", [{_this addeventhandler ["killed",{null = _this execVM "wrongful_kill.sqf";}]}]] call bis_fnc_variablespaceadd; 
processInitCommands; 
clearVehicleInit CIV_SPAWNER;

I'm not sure if I need "processInitCommands;" part, but it doesn't seem to be hurting anything. In any case, my civilian module is now spawning civilians that have an "EH Killed". With the Civilian module, it only spawns a few civilian in the current task/city. Just enough of them to get in the way at times. It doesn't get laggy since they are removed when the task is completed and then new civilians are added to the next task/city. I've put so much work into this mission that I definitely don't mind getting lazy when it comes to adding the civilians by means of a module. They server very little purpose other than to have a laugh when players get punished for accidentally killing them.

Edited by A-SUICIDAL

Share this post


Link to post
Share on other sites

Well, atleast they were manning the buildings instead of standing around acting like idiots LOL :p

Share this post


Link to post
Share on other sites

My enemy don't stand around. If they did, then I would use upsmon. Most of the task areas in my mission take place in areas where there are only small huts and lots of clay walls. Anyway, I can simply place a waypoint on top of a building and the enemy group will patrol the building well. Again, I've used upsmon in the past and it worked pretty well, but it's not what I need in this particular mission. 10 random tasks, some in very large cities and the "spawned" enemy patrol just fine so far. It took a lot of careful planning and work to get it working just the way I want it. It would take much more work to reverse engineer my entire mission and remove all of my markers and spawn scripts just to add upsmon and have the mission turn into a room clearing mission where I constantly get killed in a building because this game is not meant for room clearing with it's omg horrible glitchy doorways and rooms. I'm not into that. I wont ever enter a building unless I need the cover to heal myself or reload in cover. Yeah it looks cool when they patrol through buildings, but I need them patrolling the streets, alleyways, bunkers and c4 targets.

Share this post


Link to post
Share on other sites

If you're experiencing problems with doorways n' stuff I can only recommend STMovement, fixes that issue perfectly.

Share this post


Link to post
Share on other sites

Just going back to the original problem of repeating triggers a couple of methods are

cond this and round (time %1) ==1

The trigger will re evaluate once every second but you won't be able to use the timer boxes.

The other method is to set a variable in an init looptrig = true

cond this and looptrig

on act looptrig false

on dea looptrig true

this will re evaluate about once every 0.5 secs and you can use timer boxes.

Share this post


Link to post
Share on other sites

That's useful stuff F2k Sel, thank you.

tryteyker, I would love to use STMovement, but unfortunately I don't want my mission to require any addons other than the addon island Faysh Khabur.

I googled STMovement and found this very cool video:

What really bugs me is that I've been dealing with the quirky player movement and terrible collision system in this game for like FOREVER and omg I hate it, but that's not what bugs me. What really bugs me is that Bohemia Interactive never fixes the things that really need to be fixed. They should contact Rg at Shack Tack and ask permission to implement the STMovement into the next Arma 2 patch. And they really need to fix that damn bug that happens when a crouched player holding a launcher goes to stand and it first holsters the launcher and then stands and then switches back to holding the launcher again. It's like a 10 second animation that always gets you killed. Or how bout when you are holding the launcher and you get hit and lose the use of your legs and suddenly you get stuck switching back and forth from a lying flat position to crouching holding your launcher and then lying flat again and then crouching again holding your launcher, then you die, lol. So ridiculous.

I'm going to install STMovement right now. I'll use the addon privately for my own benefit. When I watch the movie above, what I really wish is that the enemy could move around easier like that too.

Share this post


Link to post
Share on other sites

STMovement doesn't place any requirement on your mission, it's a client based addon. I'd be wary of using huge mods like JSRS (especially JSRS, this places a requirement on your mission) and other sound mods / visual mods. These tend to place additional requirements which kinda ruins missions immensely (I have a huge mission laying around waiting to be released, but it needs like 10 mods :().

So be wary of huge mods, but ShackTactical's mods don't place mission requirements.

Share this post


Link to post
Share on other sites

Don't run any mods, even client side mods when editing. Unless ofcourse you're making a map with addons. I remember, back in A1, using only FDF & having strange shit happen. The mission would become dependant on this client side addon (fdf)

Share this post


Link to post
Share on other sites

If the mission is dependent on any mods, it is because some mods will write directly into the mission.sqf and even if you later remove the addon vehicle or addon rifle etc, sometimes it stays written into the mission.sqm file. To remedy this, first back up your mission file/folder, now simply open your mission.sqf, remove all of the lines at the top for both "addons" and "addonsAuto", then save your mission.sqf file.

Now launch your game without any addons enabled, then open your mission in the editor and save it again and it will only write stuff into the mission.sqf file that come with the stock game.

If for some reason you cannot open the mission because you left some sort of addon vehicle placed in the mission, the game will tell you what the name is of the missing object. So what you do then is... open the mission.sqf again using a text editor and use the *find* option in notepad or whatever text editor you normally use and search for the name of the missing object. Then replace the classname of the object with a vehicle classname that comes with the game, for instance - replace the addon tank classname with a standard HMMWV classname. Now save the mission in the text editor and try opening it in the game editor and it should open just fine. If it doesn't open, then you must've left more addon vehicles in the mission. All you need to do is replace the addon vehicle classname in the mission.sqm with a vehicle classname that is not an addon.

In the past I have downloaded sample missions made by other scripters for the sole purpose of wanting to open the mission in the editor and examine how their script worked. There have been times when the mission creator noted that several addons would need to be installed in order to view his sample mission. Instead of going through the process of downloading and installing an addon island and addons tanks - that were not really needed in order to test the script that I was interested in examining, I would instead download and install the mission only and then replace the addon island and addon tanks by replacing the classnames as I described above. I've done this for maybe 20 missions so far. I've openned missions that were not even designed for Arma 2 and I've fixed my friends broken missions that were loaded with addons even after they removed the placed addon vehicles. If you have an old broken mission, I can fix it.

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  

×