Home   Help Search Login Register  

Author Topic: weird0 script exits too soon  (Read 477 times)

0 Members and 1 Guest are viewing this topic.

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
weird0 script exits too soon
« on: 07 Jan 2004, 18:40:17 »
Code: [Select]
_count = (count units maingroup) - 12


#createstart
?_count == 0: goto "vehiclecheck"
_count = _count +1
_rand = random 100
_skill = random 1

?_rand > 95: _bmp = true; _t55 = false; _t72 = false; _t80 = false
?_rand > 96: _t55 = true; _bmp = false; _t72 = false; _t80 = false
?_rand > 97: _t72 = true; _bmp = false; _t55 = false; _t80 = false
?_rand > 98: _t80 = true; _bmp = false; _t55 = false; _t72 = false

?_rand < 20: goto "hunter"
?(_rand >= 20) && (_rand < 35): goto "SoldierGB"
?(_rand >= 35) && (_rand < 50): goto "SoldierGG"
?(_rand >= 50) && (_rand < 60): goto "SoldireGMedic"
?(_rand >= 60) && (_rand < 70): goto "SoldireGMG"
?(_rand >= 70) && (_rand < 80): goto "SoldireGSniper"
?(_rand >= 80) && (_rand < 90): goto "SoldireGLAW"
?(_rand >= 90): goto "SoldireGAT"

#Hunter
?(local server): "Hunter" createunit [[(getpos (leader maingroup) select 0)+20,(getpos (leader maingroup) select 1)+20,0], maingroup, "",_skill]
goto "createstart"

#SoldierGB
?(local server): "SoldierGB" createunit [[(getpos (leader maingroup) select 0)+20,(getpos (leader maingroup) select 1)+20,0], maingroup, "",_skill]
goto "createstart"

#SoldierGG
?(local server): "SoldierGG" createunit [[(getpos (leader maingroup) select 0)+20,(getpos (leader maingroup) select 1)+20,0], maingroup, "",_skill]
goto "createstart"

#SoldierGMedic
?(local server): "SoldierGMedic" createunit [[(getpos (leader maingroup) select 0)+20,(getpos (leader maingroup) select 1)+20,0], maingroup, "",_skill]
goto "createstart"

#SoldierGMG
?(local server): "SoldierGMG" createunit [[(getpos (leader maingroup) select 0)+20,(getpos (leader maingroup) select 1)+20,0], maingroup, "",_skill]
goto "createstart"

#SoldierGSniper
?(local server): "SoldierGSniper" createunit [[(getpos (leader maingroup) select 0)+20,(getpos (leader maingroup) select 1)+20,0], maingroup, "",_skill]
goto "createstart"

#SoldierGLAW
?(local server): "SoldierGLAW" createunit [[(getpos (leader maingroup) select 0)+20,(getpos (leader maingroup) select 1)+20,0], maingroup, "",_skill]
goto "createstart"

#SoldierGAT
?(local server): "SoldierGAT" createunit [[(getpos (leader maingroup) select 0)+20,(getpos (leader maingroup) select 1)+20,0], maingroup, "",_skill]
goto "createstart"



#vehiclecheck


#BMPRes
?_bmp && (local server): _tank = "BMPRes" createVehicle [(getpos (leader maingroup) select 0)-20,(getpos (leader maingroup) select 1)-20,0]
exit

#T55G
?_t55 && (local server): _tank = "T55G" createVehicle [(getpos (leader maingroup) select 0)-20,(getpos (leader maingroup) select 1)-20,0]
exit

#T72Res
?_t72 && (local server): _tank = "T72Res" createVehicle [(getpos (leader maingroup) select 0)-20,(getpos (leader maingroup) select 1)-20,0]
exit

#T80Res
?_t80 && (local server): _tank = "T80Res" createVehicle [(getpos (leader maingroup) select 0)-20,(getpos (leader maingroup) select 1)-20,0]
exit

The script is supposed to count the units in 'maingroup' and create so many as is missing from 12. Last time I got 1 MG soldier and before that 2 hunters. I know the script works, but it's just that it seems to stop looping too soon or something.

Anyone spot an error my eye can't see (besides the bad editing.. save it)?  ;D
Not all is lost.

Offline .pablo.

  • Former Staff
  • ****
  • When in doubt, empty the magazine.
Re:weird0 script exits too soon
« Reply #1 on: 07 Jan 2004, 18:56:53 »
idk if i understand your script, it looks like if the group is full it goes to add a vehicle
Quote
"?_count == 0 : goto "vehiclecheck"
instead of looping back to itself (with a time delay).  but i might be misunderstanding what the script is doin.

the following is all one special case:
Quote
_count = (count units maingroup) - 12
if the group has 12 units, this will be 0
then...
Quote
#createstart
?_count == 0: goto "vehiclecheck"
the first check done will send the script to "vehiclecheck"
then...
Quote
#vehiclecheck
#BMPRes
?_bmp && (local server): _tank = "BMPRes" createVehicle [(getpos (leader maingroup) select 0)-20,(getpos (leader maingroup) select 1)-20,0]
_bmp isnt defined yet, idk what that would do to the script
then...
Quote
exit
the next line tells the script to exit
so it looks like that specific problem would only emerge if the player started with a full group


on another point, it looks like if the group had 11 people, the script might try to add an armored vehicle with a crew of 3 people, which might screw things up (cuz of the 12 person max on groups)

and instead of repeating the same code for all the different units, you can just create an array of the different types of units
Quote
soldierarray = [Hunter, SoldierGG, etc]
tankarray = [bmp, t72, etc]
« Last Edit: 07 Jan 2004, 19:23:06 by .pablo. »

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:weird0 script exits too soon
« Reply #2 on: 07 Jan 2004, 19:11:29 »
Hey .pablo. and thanks for the effort  :D
All you said is true and it's exactly as I want it to be.

The group will have 6 units to start with and some of them will die along the way. The plan is to give the group reinforcements if it has less than 12 men, if it has already got 12 men, the script should exit and nothing should happen.
The _count check will see to it that it does.

A good point with the vehicles. I need to define the vehicle variables to false just in case the group should have 12 units for some reason without going through the main part of the script. Done.

Your last worry is something not to worry about because the createvehicle command always creates empty vehicles and not manned.



I just tried the script and it's still the same problem. This time at best I managed to get 6 new units created into the group. All of them were Granadiers and I had only 3 units in the group to start with.. the problem remains.

[edit]
BTW the script is activated by a trigger I placed in each city of Nogova. When a city has been cleared of enemy the players get reinforcements equal in amount to their casualties, and even sometimes if they're lucky they get a free armored vehicle :P
« Last Edit: 07 Jan 2004, 19:14:23 by Artak »
Not all is lost.

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:weird0 script exits too soon
« Reply #3 on: 07 Jan 2004, 19:38:30 »
Oh ffs how blind am I!  :o

* Artak goes to buy a second pair of classes.. extra thick


I added some lines to see where the script stops/exits and noticed that if the value of _rand is over 50 the script simply stops and doesn't exit from where it should.

Who spots it?


.
.
.


Can you see it already?




 ;D




That's right!

?_rand < 20: goto "hunter"
?(_rand >= 20) && (_rand < 35): goto "SoldierGB"
?(_rand >= 35) && (_rand < 50): goto "SoldierGG"
?(_rand >= 50) && (_rand < 60): goto "SoldireGMedic"
?(_rand >= 60) && (_rand < 70): goto "SoldireGMG"
?(_rand >= 70) && (_rand < 80): goto "SoldireGSniper"
?(_rand >= 80) && (_rand < 90): goto "SoldireGLAW"
?(_rand >= 90): goto "SoldireGAT"

Bad bookmark names. Typ0 visited my keyboard and made the script bad.

Thanks sorry for anyone who had a look and became an alcoholic because couldn't find the error.  ;)  Maybe we've learned something.
Not all is lost.

Offline .pablo.

  • Former Staff
  • ****
  • When in doubt, empty the magazine.
Re:weird0 script exits too soon
« Reply #4 on: 07 Jan 2004, 23:40:12 »
lol, i know to check spelling more now :P

that makes me think, does ofpec have a debugging guide for scripting (like a list of things to check for)?
« Last Edit: 07 Jan 2004, 23:41:19 by .pablo. »

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:weird0 script exits too soon
« Reply #5 on: 08 Jan 2004, 07:12:25 »
Hmm.. not that I know of. What a good subject to write a tutorial on. Great idea pablo  :o
Not all is lost.