itchboy Posted July 19, 2014 Report Share Posted July 19, 2014 After doing all those cars and trucks, I decided I should finally let this see the light of day.Its a script that makes people not wearing oxygen tanks cough when an object is burning.int DummyGroup = 29;object DummyFireCheck : CommandScript{ DummyFireCheck() { } bool CheckTarget(GameObject *Caller, Actor *Target, int ChildID) { } void PushActions(GameObject *Caller, Actor *Target, int childID) { GameObjectList gol1 = Game::GetGameObjects(TYPE_OBJECT); for(int a = 0; a < gol1.GetNumObjects(); a++) { GameObject obj = gol1.GetObject(a); obj.PushActionExecuteCommand(ACTION_APPEND, "DummyBurningCheck", &obj, 0, false); } }};object DummyBurningCheck : CommandScript{ DummyBurningCheck() { SetGroupID(DummyGroup); } bool CheckTarget(GameObject *Caller, Actor *Target, int ChildID) { } void PushActions(GameObject *Caller, Actor *Target, int childID) { GameObject b(Caller); if(b.IsBurning()) { GameObjectList PersonInRange = b.GetObjectsInRange(200.f, ACTOR_PERSON); for(int k = 0; k < PersonInRange.GetNumObjects(); k++) { bool IsSpecialFireFighter = false; Person p(PersonInRange.GetObject(k)); if(p.GetPersonType() == PT_FIREFIGHTER_MASK) { IsSpecialFireFighter = true; } if(!IsSpecialFireFighter && !p.IsInjured()) { p.Hurt(INJUREREASON_ENERGY, 10.f); int random = Math::rand(); if (random % 4 == 0) { if (!p.IsPulling() && (p.IsIdle() || p.IsWaiting())) { p.PushActionInterruptAnim(ACTION_INSERT, "cough"); if (p.GetGender() == GENDER_MALE) Audio::PlaySample3D("mod:Audio/FX/voices/man/0/contamination01.wav", p.GetPosition()); else if (p.GetGender() == GENDER_FEMALE) Audio::PlaySample3D("mod:Audio/FX/voices/woman/0/contamination01.wav", p.GetPosition()); else if (p.GetGender() == GENDER_CHILD) Audio::PlaySample3D("mod:Audio/FX/voices/child/0/contamination01.wav", p.GetPosition()); } } } if (p.IsInjured()) p.SetBloodPuddle(false); } } b.PushActionWait(ACTION_NEWLIST, 4.f); b.PushActionExecuteCommand(ACTION_APPEND, "DummyBurningCheck", &b, 0, false); }};Now, my issue with this is that everytime the script is executed (it is intended to function as a loop), it causes massive lag. This is because EVERY object in the map has to be checked if it burns, and then the people need to react accordingly. I have tried adding a condition that only checks objects with FireObjects, but it makes little difference. The second major issue is that it only works on objects, not on houses, openhouses or vehicles.Can any of the scripting masters help? Thanks. Quote Link to comment Share on other sites More sharing options...
mariuswww Posted July 19, 2014 Report Share Posted July 19, 2014 ERS Berlin has this (although its mission based) maybe check that out? I can't help you sorry.. Quote Link to comment Share on other sites More sharing options...
itchboy Posted July 19, 2014 Author Report Share Posted July 19, 2014 ERS Berlin has this (although its mission based) maybe check that out? I can't help you sorry..They achieve that using a mission script. I made one for use in freeplay, which is based on a looped command script. Both of our scripts though are based from the smoke element of Mission 2.Thanks for trying to help. Quote Link to comment Share on other sites More sharing options...
Wkboy714 Posted July 19, 2014 Report Share Posted July 19, 2014 I'm no expert on scripting at all, but perhaps instead of checking every object it can check if there are any particle effects active (eg smoke and/or flames)? Quote Link to comment Share on other sites More sharing options...
The Loot Posted July 20, 2014 Report Share Posted July 20, 2014 Interesting. I think one thing that would be nice to have added is that NPC people would need to be made to try to move away from the fire or smoke. They don't always flee, and might not flee far enough, though that provides opportunities to remove them yourself. Quote Link to comment Share on other sites More sharing options...
itchboy Posted July 20, 2014 Author Report Share Posted July 20, 2014 I'm no expert on scripting at all, but perhaps instead of checking every object it can check if there are any particle effects active (eg smoke and/or flames)?I tried this at first, but the game does not have a function to look for active particles. It only allows me to select any of the following in the for loop: TYPE_UNKNOWN, TYPE_OBJECT, TYPE_PERSON, TYPE_HOUSE, TYPE_VEHICLE, TYPE_OPEN_HOUSEI also tried this fucntion as an if condition: GetNumActiveFireChilds()But it causes a script error because the function is intended to be uses in conjunction with an integer value. Quote Link to comment Share on other sites More sharing options...
novius Posted July 20, 2014 Report Share Posted July 20, 2014 I have virtually no scripting experience in em4 outside of minor edits. That in mind, what about this?(I'm assuming GetNumActiveFireChilds returns an integer as how many objects are burning)If GetNumActiveFireChilds >0, then activate your script that finds them. That way you're only reading a number every loop unless there's an active burn. Quote Link to comment Share on other sites More sharing options...
itchboy Posted July 20, 2014 Author Report Share Posted July 20, 2014 I have virtually no scripting experience in em4 outside of minor edits. That in mind, what about this?If GetNumActiveFireChilds (I'm assuming returns an integer as how many objects are burning) >0, then activate your script that finds them. That way you're only reading a number every loop unless there's an active burn.Good idea. That would definitely reduce the CPU strain, but I still have to figure out how to link GetNumActiveFireChilds() to each burning object and then link them to the people within range of the burning object so that the people will cough and take damage.Still waiting on Hoppah or bma to give light to the situation. Quote Link to comment Share on other sites More sharing options...
novius Posted July 20, 2014 Report Share Posted July 20, 2014 Fair point. I guess I assumed that was a base game variable.Would it be good enough to just add the animation to the part of the script where people are injured by the fire? Or are you specifically looking to have uninjured people cough that aren't in the danger zone as well? Quote Link to comment Share on other sites More sharing options...