ID:1332086
 
(See the best response by D4RK3Z3R0.)
I already have a trigger for it to happen. the person steps in water and the variable wet goes up one triggering the action of the person clothes being ruined by a certain amount for a certain amount of time. Now I just need a way to make it happen. how do I make a variable go down a certain number at a specific time in a cetain amount of time. like his clothes are ruined by 3 every 3 seconds for 12 seconds.
Best response
mob
proc
Ruined_Cloth()
var/Wet_Cloth = 1
var/Wet_Time = 12
while(Wet_Cloth == 1 || Wet_Time >= 1)
sleep(100)
Wet_Time -= 1
//stuff here
if(Wet_Time <= 1)
Wet_Cloth = 0
//Stuff here
spawn()
var/TimeOfDamage = 12
while(TimeOfDamage)
if((TimeOfDamage/3) == round(TimeOfDamage/3)) //If TimeOfDamage results as a whole number when divided, then it is in the 3 second interval range. 12/3 = 4, 11/3 = 3.66, etc.
ClothesRuined -= 3 //If ruining them brings it to reach 0, or if you are increasing it so that at 10 or so they are completely ruined obviously change it to adding
TimeOfDamage--
sleep(10) //Sleep 1 second.
it would really help if you explained the code after you put it. it would benefit me more if I could understand it... im kinda a noob HAHA
In response to Hinotai
Hinotai wrote:
it would really help if you explained the code after you put it. it would benefit me more if I could understand it... im kinda a noob HAHA

Alright, thats why I put comments in mine.
spawn()//Makes the following launch without stalling whatever current proc this resides in. If you would rather, you can make this it's own proc.
var/TimeOfDamage = 12 //Setting how long you want the DPS effect to last.
while(TimeOfDamage)//While it has a value
if((TimeOfDamage/3)==round(TimeOfDamage/3))//If TimeOfDamage divided by 3, equals itself when rounded
Wet += 3 //...
TimeOfDamage-- //Reducing the amount of time left on the effect
sleep(10)//Pause for one second...
mob
proc
Ruined_Cloth()
var/Wet_Cloth = 1
var/Wet_Time = 12
while(Wet_Cloth == 1 || Wet_Time >= 1) //Makes the things under it reset until there wet_cloth and wet_time is null
Wet_Time -= 1 // - 1 wet time
//stuff here
sleep(100) // sleeps for a minute
if(Wet_Time <= 0) // if wet time is equal to less or 0 it will put wet cloth to 0
Wet_Cloth = 0
//Stuff here
In response to Koriami
Koriami wrote:
> spawn()
> var/TimeOfDamage = 12
> while(TimeOfDamage)
> if((TimeOfDamage/3) == round(TimeOfDamage/3)) //If TimeOfDamage results as a whole number when divided, then it is in the 3 second interval range. 12/3 = 4, 11/3 = 3.66, etc.
> ClothesRuined -= 3 //If ruining them brings it to reach 0, or if you are increasing it so that at 10 or so they are completely ruined obviously change it to adding
> TimeOfDamage--
> sleep(10) //Sleep 1 second.


The remainder operator would be perfect for that, see the % operator.