SlappyThePirate
October 15th, 2011, 01:46 PM
I've got a big problem with my map's scripts, and I'm not sure how to explain it. There are quite a lot of scripts in this map at this point. I don't think I'm going to add any more because it seems like the more I add, the worse the map functions as a whole.<br><br>Here's some pictures of Valhalla so far. They're pretty recent, but the visual elements change a lot in this WIP. For example, the lightmaps on the first one, below, were just a test, and the wraith particles (old ones below) are changed at this point...<br><img src="http://www.modacity.net/forums/attachment.php?attachmentid=2421&stc=1" attachmentid="2421" alt="" id="vbattach_2421" class="previewthumb"><br><img src="http://www.modacity.net/forums/attachment.php?attachmentid=2422&stc=1" attachmentid="2422" alt="" id="vbattach_2422" class="previewthumb"><br><br>Anyway, I've got 5 hsc files of script, one running player model permutations by team, another backpacking weapons with a seperate permutation system, an automatic vehicle loading and unloading function for the 4 man cannons, one that does those 4 mancannons for warthogs and mongeese, one syncing the fusion coil destructions, and one doing weapon respawns/propping up against walls. Along with some maintenance/sync stuff. I removed any others. I have the vehicle mancannon script temporarily removed for the sake of debugging the player mancannon one.<br>Problem is, the mancannon scripts will randomly-- and I mean reandomly as in I can start the same map file and get different results-- crap out and not load the player into cannons. I can start the game and be able to ride mancannons A and D, but B/C don't work. Then I can quit, new game, and have only B work.<br>People told me it's because I'm overloading Halo with player checks in the script. I did in fact have a ton of checks-- every tick it would check if the current player (from a player increment) was in a trigger volume AND not in any of the vehicles on the map AND that no players are in the cannon... before loading. The unload check isn't as bad.
(script static boolean areyouNOTinavehicle
(not
(or
(vehicle_test_seat h1 "W-Driver" (unit (list_get (players) plyrnum)))
(vehicle_test_seat h1 "W-Gunner" (unit (list_get (players) plyrnum)))
(vehicle_test_seat h1 "W-Passenger" (unit (list_get (players) plyrnum)))
(vehicle_test_seat h2 "W-Driver" (unit (list_get (players) plyrnum)))
(vehicle_test_seat h2 "W-Gunnerr" (unit (list_get (players) plyrnum)))
(vehicle_test_seat h2 "W-Passenger" (unit (list_get (players) plyrnum)))
(vehicle_test_seat m1 "M-Driver" (unit (list_get (players) plyrnum)))
(vehicle_test_seat m1 "M-Passenger" (unit (list_get (players) plyrnum)))
(vehicle_test_seat m2 "M-Driver" (unit (list_get (players) plyrnum)))
(vehicle_test_seat m2 "M-Passenger" (unit (list_get (players) plyrnum)))
(vehicle_test_seat m3 "M-Driver" (unit (list_get (players) plyrnum)))
(vehicle_test_seat m3 "M-Passenger" (unit (list_get (players) plyrnum)))
(vehicle_test_seat m4 "M-Driver" (unit (list_get (players) plyrnum)))
(vehicle_test_seat m4 "M-Passenger" (unit (list_get (players) plyrnum)))
(vehicle_test_seat m5 "M-Driver" (unit (list_get (players) plyrnum)))
(vehicle_test_seat m5 "M-Passenger" (unit (list_get (players) plyrnum)))
(vehicle_test_seat b1 "B-Driver" (unit (list_get (players) plyrnum)))
(vehicle_test_seat b2 "B-Driver" (unit (list_get (players) plyrnum)))
(vehicle_test_seat s1 "S-Driver" (unit (list_get (players) plyrnum)))
(vehicle_test_seat s2 "S-Driver" (unit (list_get (players) plyrnum)))
)
)
)
(if
(and
(volume_test_object cannona (unit (list_get (players) plyrnum)))
(not (vehicle_test_seat_list cannona seatname (players)) )
(areyouNOTinavehicle)
)
(begin
(object_create_anew cannona)
(vehicle_load_magic cannona seatname (unit (list_get (players) plyrnum)))
)
)
(if
(and
(objects_can_see_object lookera (unit (list_get (players) plyrnum)) 90)
(vehicle_test_seat cannona seatname (unit (list_get (players) plyrnum)))
)
(begin
(vehicle_unload cannona seatname)
(object_teleport (unit (list_get (players) plyrnum)) landA)
)
)
That's a lot of checks that halo has to do on (unit (list_get (players) plyrnum)). So the optimized version is:
(if (volume_test_object cannond (unit (list_get (players) plyrnum))) (if
(and
(not (vehicle_test_seat_list cannond seatname (players)) )
(areyouNOTinavehicle)
)
(begin
(object_create_anew cannond)
(vehicle_load_magic cannond seatname (unit (list_get (players) plyrnum)))
)
)
)
(if (vehicle_test_seat cannond seatname (unit (list_get (players) plyrnum)))
(if
(objects_can_see_object lookerd (unit (list_get (players) plyrnum)) 90)
(begin
(vehicle_unload cannond seatname)
(object_teleport (unit (list_get (players) plyrnum)) landD)
)
)
)
That way the script only checks the trigger condition at first. If it's not true then it won't bother doing the work of checking all the vehicles.
That optimization made the map run fine-- keeping halo from overloading it self with (unit (list_get (players) plyrnum)) checks.
But that was without all the backpacks and without all the vehicles launching scripts included in the compile. With those included, stuff craps out. And I'm lost and stumped.
(script static boolean areyouNOTinavehicle
(not
(or
(vehicle_test_seat h1 "W-Driver" (unit (list_get (players) plyrnum)))
(vehicle_test_seat h1 "W-Gunner" (unit (list_get (players) plyrnum)))
(vehicle_test_seat h1 "W-Passenger" (unit (list_get (players) plyrnum)))
(vehicle_test_seat h2 "W-Driver" (unit (list_get (players) plyrnum)))
(vehicle_test_seat h2 "W-Gunnerr" (unit (list_get (players) plyrnum)))
(vehicle_test_seat h2 "W-Passenger" (unit (list_get (players) plyrnum)))
(vehicle_test_seat m1 "M-Driver" (unit (list_get (players) plyrnum)))
(vehicle_test_seat m1 "M-Passenger" (unit (list_get (players) plyrnum)))
(vehicle_test_seat m2 "M-Driver" (unit (list_get (players) plyrnum)))
(vehicle_test_seat m2 "M-Passenger" (unit (list_get (players) plyrnum)))
(vehicle_test_seat m3 "M-Driver" (unit (list_get (players) plyrnum)))
(vehicle_test_seat m3 "M-Passenger" (unit (list_get (players) plyrnum)))
(vehicle_test_seat m4 "M-Driver" (unit (list_get (players) plyrnum)))
(vehicle_test_seat m4 "M-Passenger" (unit (list_get (players) plyrnum)))
(vehicle_test_seat m5 "M-Driver" (unit (list_get (players) plyrnum)))
(vehicle_test_seat m5 "M-Passenger" (unit (list_get (players) plyrnum)))
(vehicle_test_seat b1 "B-Driver" (unit (list_get (players) plyrnum)))
(vehicle_test_seat b2 "B-Driver" (unit (list_get (players) plyrnum)))
(vehicle_test_seat s1 "S-Driver" (unit (list_get (players) plyrnum)))
(vehicle_test_seat s2 "S-Driver" (unit (list_get (players) plyrnum)))
)
)
)
(if
(and
(volume_test_object cannona (unit (list_get (players) plyrnum)))
(not (vehicle_test_seat_list cannona seatname (players)) )
(areyouNOTinavehicle)
)
(begin
(object_create_anew cannona)
(vehicle_load_magic cannona seatname (unit (list_get (players) plyrnum)))
)
)
(if
(and
(objects_can_see_object lookera (unit (list_get (players) plyrnum)) 90)
(vehicle_test_seat cannona seatname (unit (list_get (players) plyrnum)))
)
(begin
(vehicle_unload cannona seatname)
(object_teleport (unit (list_get (players) plyrnum)) landA)
)
)
That's a lot of checks that halo has to do on (unit (list_get (players) plyrnum)). So the optimized version is:
(if (volume_test_object cannond (unit (list_get (players) plyrnum))) (if
(and
(not (vehicle_test_seat_list cannond seatname (players)) )
(areyouNOTinavehicle)
)
(begin
(object_create_anew cannond)
(vehicle_load_magic cannond seatname (unit (list_get (players) plyrnum)))
)
)
)
(if (vehicle_test_seat cannond seatname (unit (list_get (players) plyrnum)))
(if
(objects_can_see_object lookerd (unit (list_get (players) plyrnum)) 90)
(begin
(vehicle_unload cannond seatname)
(object_teleport (unit (list_get (players) plyrnum)) landD)
)
)
)
That way the script only checks the trigger condition at first. If it's not true then it won't bother doing the work of checking all the vehicles.
That optimization made the map run fine-- keeping halo from overloading it self with (unit (list_get (players) plyrnum)) checks.
But that was without all the backpacks and without all the vehicles launching scripts included in the compile. With those included, stuff craps out. And I'm lost and stumped.