Home   Help Search Login Register  

Author Topic: Some basic mathematics  (Read 1196 times)

0 Members and 1 Guest are viewing this topic.

Offline Kendo J

  • Members
  • *
  • Britain Has more varieties of cheese than France
Some basic mathematics
« on: 24 Sep 2008, 12:13:24 »
On my way to work today I thought this one up... but I need a more logical brain to look at it

I have a mission
It has a script that when you are at base you can use an action bar click to find out the over all casualties of the three armies in the mission. It is diplayed in a hint that says..

Quote
NATO casualties: 0
Air: 0
Armour: 0
Support Vehicles: 0

Russian Fed Cas: 0
Air: 0
Armour: 0
Support Vehicles: 0

Resistance FIA Cas: 0
Armour: 0
Support Vehicles: 0

The numbers of casualties are simply added up as each unit has an event-handler KILLED which adds 1 to the casualty total.

NOW the question is I need some way of starting a count during an event such as a battle or beach landing that once it reaches a certain amount of casualties will end that event.

for example: I want the event to end when a casualty count gets to 40 or above, the amount at the start of the event.

Here is what I thought it might be like...

Quote

east_casualties = E_casu_event_start

;Lets say E_casu_event_start value starts at 12

#loop
~5
east_casualties = E_casu_event_end

;when E_casu_event_end value reaches 53 in theory the script should go to event end as the value of E_casu_event_end - E_casu_event_start should equal 41.

E_casu_event_end - E_casu_event_start > 40 : goto "eventend"

goto "loop"

#eventend
"1" objstatus "DONE"
exit

What I want to know is will it work?

More specifically is the syntax correct? or will I just get errors all over the place?

Kendo
« Last Edit: 24 Sep 2008, 12:16:03 by Kendo J »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Some basic mathematics
« Reply #1 on: 24 Sep 2008, 15:04:31 »
Should work. The lines:
Code: [Select]
east_casualties = E_casu_event_startand
Code: [Select]
east_casualties = E_casu_event_endare not needed because you never use the variable east_casualties.
urp!

Walter_E_Kurtz

  • Guest
Re: Some basic mathematics
« Reply #2 on: 24 Sep 2008, 21:11:53 »
Quote
The lines:
are not needed because you never use the variable east_casualties.
Incorrect. I believe Kendo is using the east_casualties variable to keep track of the total number of dead, adding to it through the event handler.

The script ought to work, apart from that your definitions are the wrong way round - the variable on the left takes its value from the definition on the right.

Perhaps something like the following:
Code: [Select]
;define E_casu_event_start as the number of casualties that have been inflicted so far
E_casu_event_start = east_casualties

#loop
~5

;when the difference between starting casualties (E_casu_event_start) and current casualties (east_casualties) is greater than 40, goto event end

? (east_casualties - E_casu_event_start) > 40 : goto "eventend"

goto "loop"

#eventend
"1" objstatus "DONE"
exit

Offline Kendo J

  • Members
  • *
  • Britain Has more varieties of cheese than France
Re: Some basic mathematics
« Reply #3 on: 26 Sep 2008, 11:48:11 »
thanks guys... Walter is right, my definitions were the wrong way round and East_casualties is the total amount of dead throughout the game.... and it works a treat....

Now I am putting this a stage further.... to count how many units are used and determine the total amount of realistic reinforcements each side gets.


For now topic is resolved
Cheers
Kendo