louis 0 Posted February 14, 2002 A question for you script gurus out there. I haven't been doing this long so I am fighting with some concepts. Here's what I wanted to do: A unit (tank) has a bunch of waypoints set until it gets called to a trouble spot. It leaves to give chase. When it has done it will return to it's patrol. I don't intend a player to be involved in this unit / group The script I have been playing with (not refined or generic yet so excuse the messy coding) works ok for one unit. grp LockWP true #update m1 move GetPos enemy seenhim=vehicle m1 knowsabout enemy ? seenhim>0 : vehicle m1 dotarget enemy ? seenhim>0 : vehicle m1 dofire objnull @unitready m1 ~.001 ? (alive enemy) and (alive vehicle m1) : goto "update" hint "It's all over! Tank returning to patrol or it's dead!" grp LockWP false exit m1 is the tank name enemy is in my test case a single T80 so this works but I am having problems when testing this with another tank in the west group. The problem is that if the leader's tank is disabled the whole group stops dead or amusingly if the occupants are alive and jump out they'll continu on foot or prone with the second tank following very slowly. I decided to have a play with groups and leaders etc but without success. I can't seem to kill the leader so one of the other tanks can take command. Here is a much messed about script in it's last incarnation (some stuff is redundant): #update _lead=leader grp _lead move GetPos enemy _veh = vehicle leader grp ? not(leader grp in vehicle leader grp): leader grp setdammage 1 ; tried these alternative but doesn't work either ; ? not(alive m1):"_x setdammage 1" foreach crew m1 ; ? not(alive m1):"_x setdammage 1" foreach crew m1 seenhim=vehicle leader grp knowsabout enemy ? seenhim>0 : _veh dotarget enemy ? seenhim>0 : _veh dofire objnull @unitready _veh ~.001 ? (alive enemy) and ((alive vehicle leader grp) and ("not alive vehicle _x" count units grp==0)) : goto "update" hint "It's all over! Tank group returning to patrol or it's dead!" grp LockWP false exit One problem I discovered was not what it seems is that the line "Vehicle leader grp" does not return "m1" as I thought it returns "Bravo something" and "leader grp" returns much the same so the test just fails. So the problem is really to determine if the leader's tank is dead or can't move, kill the crew and let the other commander take over. I can't seem to get at the crew either "crew m1" fails too. Question is am I barking up the wrong tree? I didn't want to manipulate waypoints as the tank could be anywhere in it's waypoint structure and the idea seemed neat. Should I be looking at using the script on several single tanks not grouped? The above scripts actually works most of the time as long as the group commander isn't disabled. Any ideas? Cheers Louis Share this post Link to post Share on other sites
ConanOfOz 0 Posted February 15, 2002 Hey Louis... Your code is way over my head -- I don't understand what it does or how. BUT I do understand your problem. Can you identify the Leader of the group? If so, then test to see if he's in a vehicle. If he's not, knock him off, or remove him from the group. This should cause the next most senior officer to become leader (yes?). And that would solve this problem (yes?) If you cannot identify the Leader, why not? Something to do with how the whole tank command was created perhaps? For example, if you make the tanks "empty", and create the crew(s) externally as a group, then put them in the tanks... Well, this way you could name the crew individually if you wanted to. Surely, then you could check each one if you have to to determine who is and is not riding in a functional tank. Hope my thoughts help. Share this post Link to post Share on other sites
louis 0 Posted February 15, 2002 Yes, I get the leader with : _lead=leader grp and the vehicle he's in by :_veh = vehicle leader grp and this is teh line that sees if he is in the vehicle : ? not(leader grp in vehicle leader grp): leader grp setdammage 1 .. although I have not put the variables in the example it's the same thing. The problem is strange, it leader still lives after he jumps although on one occasion at least I saw him jump out and then die so figured it was working, but then if run several times the results are unpredictable - most of the time he doesn't die and tries to lead from foot. I take your point and suggestion about creating an empty tank which is a good one but the idea I wanted was a generic script which would work for any group of units so I didn't even want to have to name the tank or people in it. In theory this should kill everyone in the tank "_x setdammage 1" foreach crew m1 and actually it does work when tested on it's own but running in this loop where I tried to use it like this : ? not(alive m1):"_x setdammage 1" foreach crew m1 didn't seem to get at them. This must be something to do with timing, I don't know but the not(alive m1) doesn't return true for some reason, probably because of the @unitready which stops the script until the unit has reached it's waypoint. Trying to remove this though didn't seem to resolve it. I have to admit I am perplexed as to why. Oh well it's a learning curve I suppose. :-) Louis Share this post Link to post Share on other sites