Home   Help Search Login Register  

Author Topic: Armour Script  (Read 2489 times)

0 Members and 1 Guest are viewing this topic.

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Armour Script
« on: 17 Sep 2007, 22:09:30 »
This is one of my little creations.  I wanted to make a heavy armoured unit with a regeneration over time.

basically as you will see, the health value of the unit in constantly set to whatever theglobal is, and it regens all up to -400.  Each time you are shot 50 is taken away until it is reduced to 0 and the armour is depleted and your own standard tissue will take damage.

however your armour will regenerate over a long time.  it can depend on the number.  but over 5 seconds 50 of the damage is returned until the value is back to -400.  you get a hint each time your armour crosses to 75, 50, 25 and 0 (at which point the script no longer protects you until the regen takes effect, and you also have 100 which only appears on screen when your armour it 'returned' to 100, thusly you wont get a looping hint constantly.

this script doesnt not work against explossions.  i wish it did work, but i guess you gotta have a limit somewhere.  my explaination when i use this is that the armour is only effective against standard impact projectiles, unless your hit by about 3 sniper shots or the gun fire of a shilka, in which case you die instantly and a hint comes up explaining it was a 'major impact'

This is the Armour Script:

Code: [Select]
; *****************************************************
; ** Armour Script
; ** By Surdus Priest
; *****************************************************

[]exec "regen.sqs"
VSP_Armour = -400

#loop

_75 = 1
_50 = 1
_25 = 1
_0 = 1

#skip1
?(VSP_Armour == 0):goto "skip1"
?(damage player > 0):VSP_Armour = VSP_Armour +50

?!(VSP_Armour == -300):_75 = 1
?(_75 == 0):goto "pass75"
?(VSP_Armour == -300):Hint "Armour at 75 Percent"
_75 = 0
#pass75

?!(VSP_Armour == -200):_50 = 1
?(_50 == 0):goto "pass50"
?(VSP_Armour == -200):Hint "Armour at 50 Percent"
_50 = 0
#pass50

?!(VSP_Armour == -200):_25 = 1
?(_25 == 0):goto "pass25"
?(VSP_Armour == -100):Hint "Armour at 25 Percent"
_25 = 0
#pass25

?!(VSP_Armour == -200):_0 = 1
?(_0 == 0):goto "pass0"
?(VSP_Armour == 0):Hint "Armour at 0 Percent"
_0 = 0
#pass0

?(not alive player) and !(VSP_Armour == 0):Hint "Major Impact";exit

player setdamage VSP_Armour
~0.1

goto "loop"

you will find that the centre section is more focused on the hints.

this is the Regen Script:

Code: [Select]
; *****************************************************
; ** Regeneration Script for Armour.sqs
; ** By Surdus Priest
; *****************************************************

#loop

?(VSP_Armour == -400):goto "skip1"
?(VSP_Armour > -400):VSP_Armour = VSP_Armour - 50
?(VSP_Armour > -400):goto "skip2"
?((VSP_Armour == -400) and (alive player)):Hint "Armour at 100 Percent"
#skip1
#skip2

~5

goto "loop"

To test it, simply make a player unit, then another unit on other side, in the player init run []exec "armour.sqs"

and presto.

scripts are attached.
« Last Edit: 17 Sep 2007, 22:27:18 by Surdus Priest »
Campaigns are hard, I'll stick with scripting for now!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Armour Script
« Reply #1 on: 17 Sep 2007, 22:30:07 »
You are in a continuous loop without delay here:
Code: [Select]
#skip1
?(VSP_Armour == 0):goto "skip1"
while probably this situation will never happen. And why do you set the damage of the player to negative values (whatever you put there below 0 sets the damage to 0).

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: Armour Script
« Reply #2 on: 17 Sep 2007, 22:48:28 »
Quote
while probably this situation will never happen.

it can happen, and yes i'll put a delay in.  its there so that once the armour drops to 0, instead of the next shot killing the player, it simply returns the player to a vunarable state.

Code: [Select]
And why do you set the damage of the player to negative values (whatever you put there below 0 sets the damage to 0).
trust me, it works
Campaigns are hard, I'll stick with scripting for now!

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Armour Script
« Reply #3 on: 17 Sep 2007, 23:00:58 »
Then add also parameters so the caller may set the desired recovering ratio.
About negative values, they set the damage back to 0, so, which is the difference between setDamage -400 and setDamage 0 for the purpose of the script?

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: Armour Script
« Reply #4 on: 17 Sep 2007, 23:14:04 »
i dont know why, but by setting a large negative value on the setdamage, initally this makes the unit resistant to almost anything but explossions, however, once the unit is hit, the damage is set to 0 (again, i dont know why). however by looping the negative value, this effectively makes the unit godmode. 

about the paramaters, if you talking about making it customisable for the user, this is still only a beta test, i would very much like to be able to turn this into an addon, but my scripting skills still need improvements.  however, this suits the needs for my missions, but it can always be changed at any time.
Campaigns are hard, I'll stick with scripting for now!

Offline Cheetah

  • Former Staff
  • ****
Re: Armour Script
« Reply #5 on: 17 Sep 2007, 23:34:40 »
I'd like it if you wouldn't call it an armour script. Because that would be a body armour script for me and it isn't - not realistic to be one ;)

Other than that - SQF code couldn't shorten the code up a bit..  :whistle:
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: Armour Script
« Reply #6 on: 18 Sep 2007, 01:16:54 »
its like bio armour of sumthing!!! god!, hasnt anyone here played halflife??
Campaigns are hard, I'll stick with scripting for now!

Offline Cheetah

  • Former Staff
  • ****
Re: Armour Script
« Reply #7 on: 18 Sep 2007, 23:13:11 »
Haha frankly, no I haven't  :shhh:

But, can you explain how it works, because when I tested the negative damage thingy I noticed that it's not working all too well. It doesn't make a difference if the unit has -100 or -5 it won't die from a headshot. So those percentages are not real damage values, are they?
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: Armour Script
« Reply #8 on: 19 Sep 2007, 02:58:19 »
its complicated... until i find a way to measure the damage based on the impact rather that the damage done theres nothing i can do.

and no, their not damage values, their dependent on the number of impacts... this is not something i considered, if you know a way to help me with this, please do  :clap:
« Last Edit: 19 Sep 2007, 03:14:16 by Surdus Priest »
Campaigns are hard, I'll stick with scripting for now!