by ibm5155 » Sat Feb 01, 2014 3:53 pm
While I was trying to find a way to get a way to get a ceiling position from random places (I still not found) ;---;
So I saw the problem, So I did a rainfall script for zandronum, I wanted it to be as generic as pocible (Like you only call it and the scripts do the rest of the work

)
It actually worked quite well, I can see the rainfall even if I'm inside a building, the rainfall doesn't summon inside 3D floors where the higher ceiling has a f_sky,...
But it's still not perfect '-'
I hope this code'll help with something
Code: Select all
int weather_quality=0;
script 47 (void) clientside{//Rainfall script
int X_SPOT=0, Y_SPOT=0, X_MIN=0, X_MAX=0, Y_MIN=0, Y_MAX=0, VAR_SPOT=250.0;
int z_heigh,y_heigh, x_heigh;
int a=0,b=0,c=0;
int MAX2;
int tid=122;
int x, y, z ;
int tid2=unusedTID(1000,2000);
int player_tid2;
if(rain_sound==1)thing_activate(144);
while(true){
player_tid2=consoleplayernumber()+PLAYER_TID;
a=getactorx(player_tid2);//getactorx(ConsolePlayerNumber());
b=getactory(player_tid2);//getactory(ConsolePlayerNumber());
c=getactorz(player_tid2);//getactorz(ConsolePlayerNumber());
if(weather_quality==-1) {X_MIN=-250.0; X_MAX=250.0; Y_MIN=-500.0; Y_MAX=250.0; VAR_SPOT=250.0;}
else if(weather_quality==0) {X_MIN=-1000.0; X_MAX=1000.0; Y_MIN=-1000.0; Y_MAX=1000.0; VAR_SPOT=500.0;}
else if(weather_quality==1) {X_MIN=-2000.0; X_MAX=2000.0; Y_MIN=-2000.0; Y_MAX=2000.0; VAR_SPOT=500.0;}
else if(weather_quality==2) {X_MIN=-2500.0; X_MAX=2500.0; Y_MIN=-2500.0; Y_MAX=2500.0; VAR_SPOT=500.0;}
else if(weather_quality==3) {X_MIN=-3000.0; X_MAX=3000.0; Y_MIN=-3000.0; Y_MAX=3000.0; VAR_SPOT=500.0;}
else if(weather_quality==4) {X_MIN=-3500.0; X_MAX=3500.0; Y_MIN=-3500.0; Y_MAX=3500.0; VAR_SPOT=300.0;}
X_SPOT=X_MIN; Y_SPOT=Y_MIN;
while(Y_SPOT<=Y_MAX){
while(X_SPOT<=X_MAX){
x_heigh=random(a+X_SPOT,a+X_SPOT+VAR_SPOT); y_heigh=random(b+Y_SPOT,b+Y_SPOT+VAR_SPOT);
z_heigh=GetActorCeilingZ(PLAYER_TID + PlayerNumber())-16.0;
spawn("mapspot",x_heigh,y_heigh,z_heigh ,tid,0);
if (thingcount(t_none,tid)==0){
spawn("mapspot",x_heigh,y_heigh,c+10.0 ,tid,0);
if(thingcount(t_none,tid)==0){
spawn("mapspot",x_heigh,y_heigh,GetSectorCeilingZ(0,x_heigh /1.0,y_heigh /1.0)-20.0,tid,0);
if(thingcount(t_none,tid)==0){
spawn("mapspot",x_heigh,y_heigh,c+74.0 ,tid,0);
if(thingcount(t_none,tid)==0) spawn("mapspot",x_heigh,y_heigh,c+274.0 ,tid,0);
} } }
if (CheckActorCeilingTexture(tid, "F_SKY1")){
z_heigh=GetHigherCeiling(tid)-16.0;
thing_remove(tid);
spawn("mapspot",x_heigh,y_heigh,z_heigh,tid,0);
if(rain_detail==0)spawnspot("raindrop",tid,0,0);
else if(rain_detail==1)spawnspot("raindrop2",tid,0,0);
else spawnspot("raindrop3",tid,0,0);
}
X_SPOT+=VAR_SPOT;
thing_remove(tid);
if(weather_quality==-1) delay(1);
}
X_SPOT=X_MIN;
Y_SPOT+=VAR_SPOT;
}
delay(1);
}
}
function int GetHigherCeiling(int tid2) {//THIS PART WAS CREATED BY Ijon Tichy and edited by IBM5155
int posx=getactorx(tid2);
int posy=getactory(tid2);
int posz=GetActorCeilingZ(tid2);//504
int z=posz+25.0;
int test=0;
int tid=unusedTID(1000, 2000);
spawn("mapspot",posx,posy,z,tid,0);
while(GetActorCeilingZ(tid)!=0){
z=z+25.0;//850.0
thing_remove(tid);
spawn("mapspot",posx,posy,z,tid,0);
test++;
}if(test==0){
thing_remove(tid);
z=posz;
}else{
thing_remove(tid);
spawn("mapspot",posx,posy,z-27.0,tid,0);
z=GetActorCeilingZ(tid);
thing_remove(tid);
}return z;
}
function int secret_in(int position){
return secret[position];
}
function int unusedTID(int start, int end)//THIS PART WAS CREATED BY Ijon Tichy
{
int ret = start - 1;
int tidNum;
if (start > end) { start ^= end; end ^= start; start ^= end; }
while(ThingCount(0,ret++)!=0);
return ret-1;
}
Decorate part
Code: Select all
actor TOP_SKY{
//$Category Ibm Stuff
+NOINTERACTION
+CEILINGHUGGER
Radius 0
Height 0
States
{
Spawn:
IBWA A 12 A_SpawnItemEx("Raindrop3", random(-128, 128), random(-128, 128), random(-128, 128), 0, 0, 0, 0, 0, 0)
Stop
}
}
actor HeightIndicator
{
//$Category Ibm Stuff
+NOINTERACTION
Radius 0
Height 0
}
Actor ExplosionParticle2
{
//$Category Ibm Stuff
Height 0
Radius 0
Mass 0
+Missile
+NoBlockMap
//+NoGravity
+DontSplash
+FORCEXYBILLBOARD
+CLIENTSIDEONLY
+THRUACTORS
RenderStyle Add
Scale 0.04
Speed 6
States
{
Spawn:
SPAK AAAAAAAAAAAAAAAAAAAAAAAA 1 A_FadeOut(0.02)
Stop
}
}
Actor Raindrop3HQ
{
//$Category Ibm Stuff
+MISSILE
+CLIENTSIDEONLY
+SPAWNCEILING
+ALLOWPARTICLES
+DONTSPLASH
DeathSound"IBRN"
scale 0.1
Height 0
Alpha 0.6
States
{
Spawn:
IBWA A 9 A_JumpIf(waterlevel > 0, "Death")
Loop
Death:
RAIN B 1
TNT1 A 0 A_CustomMissile ("ExplosionParticle2", 0, 0, random (0, 20), 2, random(0,120))
TNT1 A 0 A_CustomMissile ("ExplosionParticle2", 0, 0, random (0, 20), 2, random(0,120))
TNT1 A 0 A_CustomMissile ("ExplosionParticle2", 0, 0, random (0, 20), 2, random(0,120))
TNT1 A 0 A_CustomMissile ("ExplosionParticle2", 0, 0, random (0, 20), 2, random(0,120))
RAIN B 1
Stop
}
}
Actor Raindrop3
{
//$Category Ibm Stuff
+MISSILE
+CLIENTSIDEONLY
+SPAWNCEILING
+ALLOWPARTICLES
+DONTSPLASH
scale 0.1
//Scale 0.9
Height 0
Alpha 0.6
States
{
Spawn:
IBWA A 9 A_JumpIf(waterlevel > 0, "Death")
Loop
Death:
RAIN B 1
TNT1 A 0 A_CustomMissile ("ExplosionParticle2", 0, 0, random (0, 20), 2, random(0,120))
TNT1 A 0 A_CustomMissile ("ExplosionParticle2", 0, 0, random (0, 20), 2, random(0,120))
TNT1 A 0 A_CustomMissile ("ExplosionParticle2", 0, 0, random (0, 20), 2, random(0,120))
TNT1 A 0 A_CustomMissile ("ExplosionParticle2", 0, 0, random (0, 20), 2, random(0,120))
RAIN B 1
Stop
}
}
Actor Raindrop2HQ
{
//$Category Ibm Stuff
+MISSILE
+CLIENTSIDEONLY
+SPAWNCEILING
+ALLOWPARTICLES
+DONTSPLASH
DeathSound"IBRN"
scale 0.08
Height 0
States
{
Spawn:
IBWA A 9 A_JumpIf(waterlevel > 0, "Death")
Loop
Death:
RAIN B 1
TNT1 A 0 A_CustomMissile ("ExplosionParticle2", 0, 0, random (0, 20), 2, random(0,120))
RAIN B 1
Stop
}
}
Actor Raindrop2
{
//$Category Ibm Stuff
+MISSILE
+CLIENTSIDEONLY
+SPAWNCEILING
+ALLOWPARTICLES
+DONTSPLASH
scale 0.08
//Scale 0.9
Height 0
States
{
Spawn:
IBWA A 9 A_JumpIf(waterlevel > 0, "Death")
Loop
Death:
RAIN B 1
TNT1 A 0 A_CustomMissile ("ExplosionParticle2", 0, 0, random (0, 20), 2, random(0,120))
RAIN B 1
Stop
}
}
Actor RaindropHQ
{
//$Category Ibm Stuff
+MISSILE
+CLIENTSIDEONLY
+SPAWNCEILING
+DONTSPLASH
DeathSound"IBRN"
Scale 0.9
Height 0
Alpha 0.3
States
{
Spawn:
RAIN A 9 A_JumpIf(waterlevel > 0, "Death")
Loop
Death:
RAIN B 10
Stop
}
}
and with that you win this
For making this guy perfect, I really need that this
http://zdoom.org/wiki/GetSectorCeilingZ return a functional value, like there are 3 sectors with tag 0, each one with different ceiling heigh and both with sky, idk why it will only return the value of the higher ceiling and not the sector that I set ex: GetSectorCeilingZ(0,30,30);
EDIT:Actually this code is working really well O_o idk what I touched that it made not rain on sectors with transfer height but...
While I was trying to find a way to get a way to get a ceiling position from random places (I still not found) ;---;
So I saw the problem, So I did a rainfall script for zandronum, I wanted it to be as generic as pocible (Like you only call it and the scripts do the rest of the work :D)
It actually worked quite well, I can see the rainfall even if I'm inside a building, the rainfall doesn't summon inside 3D floors where the higher ceiling has a f_sky,...
But it's still not perfect '-'
I hope this code'll help with something :)
[code]
int weather_quality=0;
script 47 (void) clientside{//Rainfall script
int X_SPOT=0, Y_SPOT=0, X_MIN=0, X_MAX=0, Y_MIN=0, Y_MAX=0, VAR_SPOT=250.0;
int z_heigh,y_heigh, x_heigh;
int a=0,b=0,c=0;
int MAX2;
int tid=122;
int x, y, z ;
int tid2=unusedTID(1000,2000);
int player_tid2;
if(rain_sound==1)thing_activate(144);
while(true){
player_tid2=consoleplayernumber()+PLAYER_TID;
a=getactorx(player_tid2);//getactorx(ConsolePlayerNumber());
b=getactory(player_tid2);//getactory(ConsolePlayerNumber());
c=getactorz(player_tid2);//getactorz(ConsolePlayerNumber());
if(weather_quality==-1) {X_MIN=-250.0; X_MAX=250.0; Y_MIN=-500.0; Y_MAX=250.0; VAR_SPOT=250.0;}
else if(weather_quality==0) {X_MIN=-1000.0; X_MAX=1000.0; Y_MIN=-1000.0; Y_MAX=1000.0; VAR_SPOT=500.0;}
else if(weather_quality==1) {X_MIN=-2000.0; X_MAX=2000.0; Y_MIN=-2000.0; Y_MAX=2000.0; VAR_SPOT=500.0;}
else if(weather_quality==2) {X_MIN=-2500.0; X_MAX=2500.0; Y_MIN=-2500.0; Y_MAX=2500.0; VAR_SPOT=500.0;}
else if(weather_quality==3) {X_MIN=-3000.0; X_MAX=3000.0; Y_MIN=-3000.0; Y_MAX=3000.0; VAR_SPOT=500.0;}
else if(weather_quality==4) {X_MIN=-3500.0; X_MAX=3500.0; Y_MIN=-3500.0; Y_MAX=3500.0; VAR_SPOT=300.0;}
X_SPOT=X_MIN; Y_SPOT=Y_MIN;
while(Y_SPOT<=Y_MAX){
while(X_SPOT<=X_MAX){
x_heigh=random(a+X_SPOT,a+X_SPOT+VAR_SPOT); y_heigh=random(b+Y_SPOT,b+Y_SPOT+VAR_SPOT);
z_heigh=GetActorCeilingZ(PLAYER_TID + PlayerNumber())-16.0;
spawn("mapspot",x_heigh,y_heigh,z_heigh ,tid,0);
if (thingcount(t_none,tid)==0){
spawn("mapspot",x_heigh,y_heigh,c+10.0 ,tid,0);
if(thingcount(t_none,tid)==0){
spawn("mapspot",x_heigh,y_heigh,GetSectorCeilingZ(0,x_heigh /1.0,y_heigh /1.0)-20.0,tid,0);
if(thingcount(t_none,tid)==0){
spawn("mapspot",x_heigh,y_heigh,c+74.0 ,tid,0);
if(thingcount(t_none,tid)==0) spawn("mapspot",x_heigh,y_heigh,c+274.0 ,tid,0);
} } }
if (CheckActorCeilingTexture(tid, "F_SKY1")){
z_heigh=GetHigherCeiling(tid)-16.0;
thing_remove(tid);
spawn("mapspot",x_heigh,y_heigh,z_heigh,tid,0);
if(rain_detail==0)spawnspot("raindrop",tid,0,0);
else if(rain_detail==1)spawnspot("raindrop2",tid,0,0);
else spawnspot("raindrop3",tid,0,0);
}
X_SPOT+=VAR_SPOT;
thing_remove(tid);
if(weather_quality==-1) delay(1);
}
X_SPOT=X_MIN;
Y_SPOT+=VAR_SPOT;
}
delay(1);
}
}
function int GetHigherCeiling(int tid2) {//THIS PART WAS CREATED BY Ijon Tichy and edited by IBM5155
int posx=getactorx(tid2);
int posy=getactory(tid2);
int posz=GetActorCeilingZ(tid2);//504
int z=posz+25.0;
int test=0;
int tid=unusedTID(1000, 2000);
spawn("mapspot",posx,posy,z,tid,0);
while(GetActorCeilingZ(tid)!=0){
z=z+25.0;//850.0
thing_remove(tid);
spawn("mapspot",posx,posy,z,tid,0);
test++;
}if(test==0){
thing_remove(tid);
z=posz;
}else{
thing_remove(tid);
spawn("mapspot",posx,posy,z-27.0,tid,0);
z=GetActorCeilingZ(tid);
thing_remove(tid);
}return z;
}
function int secret_in(int position){
return secret[position];
}
function int unusedTID(int start, int end)//THIS PART WAS CREATED BY Ijon Tichy
{
int ret = start - 1;
int tidNum;
if (start > end) { start ^= end; end ^= start; start ^= end; }
while(ThingCount(0,ret++)!=0);
return ret-1;
}
[/code]
Decorate part
[code]
actor TOP_SKY{
//$Category Ibm Stuff
+NOINTERACTION
+CEILINGHUGGER
Radius 0
Height 0
States
{
Spawn:
IBWA A 12 A_SpawnItemEx("Raindrop3", random(-128, 128), random(-128, 128), random(-128, 128), 0, 0, 0, 0, 0, 0)
Stop
}
}
actor HeightIndicator
{
//$Category Ibm Stuff
+NOINTERACTION
Radius 0
Height 0
}
Actor ExplosionParticle2
{
//$Category Ibm Stuff
Height 0
Radius 0
Mass 0
+Missile
+NoBlockMap
//+NoGravity
+DontSplash
+FORCEXYBILLBOARD
+CLIENTSIDEONLY
+THRUACTORS
RenderStyle Add
Scale 0.04
Speed 6
States
{
Spawn:
SPAK AAAAAAAAAAAAAAAAAAAAAAAA 1 A_FadeOut(0.02)
Stop
}
}
Actor Raindrop3HQ
{
//$Category Ibm Stuff
+MISSILE
+CLIENTSIDEONLY
+SPAWNCEILING
+ALLOWPARTICLES
+DONTSPLASH
DeathSound"IBRN"
scale 0.1
Height 0
Alpha 0.6
States
{
Spawn:
IBWA A 9 A_JumpIf(waterlevel > 0, "Death")
Loop
Death:
RAIN B 1
TNT1 A 0 A_CustomMissile ("ExplosionParticle2", 0, 0, random (0, 20), 2, random(0,120))
TNT1 A 0 A_CustomMissile ("ExplosionParticle2", 0, 0, random (0, 20), 2, random(0,120))
TNT1 A 0 A_CustomMissile ("ExplosionParticle2", 0, 0, random (0, 20), 2, random(0,120))
TNT1 A 0 A_CustomMissile ("ExplosionParticle2", 0, 0, random (0, 20), 2, random(0,120))
RAIN B 1
Stop
}
}
Actor Raindrop3
{
//$Category Ibm Stuff
+MISSILE
+CLIENTSIDEONLY
+SPAWNCEILING
+ALLOWPARTICLES
+DONTSPLASH
scale 0.1
//Scale 0.9
Height 0
Alpha 0.6
States
{
Spawn:
IBWA A 9 A_JumpIf(waterlevel > 0, "Death")
Loop
Death:
RAIN B 1
TNT1 A 0 A_CustomMissile ("ExplosionParticle2", 0, 0, random (0, 20), 2, random(0,120))
TNT1 A 0 A_CustomMissile ("ExplosionParticle2", 0, 0, random (0, 20), 2, random(0,120))
TNT1 A 0 A_CustomMissile ("ExplosionParticle2", 0, 0, random (0, 20), 2, random(0,120))
TNT1 A 0 A_CustomMissile ("ExplosionParticle2", 0, 0, random (0, 20), 2, random(0,120))
RAIN B 1
Stop
}
}
Actor Raindrop2HQ
{
//$Category Ibm Stuff
+MISSILE
+CLIENTSIDEONLY
+SPAWNCEILING
+ALLOWPARTICLES
+DONTSPLASH
DeathSound"IBRN"
scale 0.08
Height 0
States
{
Spawn:
IBWA A 9 A_JumpIf(waterlevel > 0, "Death")
Loop
Death:
RAIN B 1
TNT1 A 0 A_CustomMissile ("ExplosionParticle2", 0, 0, random (0, 20), 2, random(0,120))
RAIN B 1
Stop
}
}
Actor Raindrop2
{
//$Category Ibm Stuff
+MISSILE
+CLIENTSIDEONLY
+SPAWNCEILING
+ALLOWPARTICLES
+DONTSPLASH
scale 0.08
//Scale 0.9
Height 0
States
{
Spawn:
IBWA A 9 A_JumpIf(waterlevel > 0, "Death")
Loop
Death:
RAIN B 1
TNT1 A 0 A_CustomMissile ("ExplosionParticle2", 0, 0, random (0, 20), 2, random(0,120))
RAIN B 1
Stop
}
}
Actor RaindropHQ
{
//$Category Ibm Stuff
+MISSILE
+CLIENTSIDEONLY
+SPAWNCEILING
+DONTSPLASH
DeathSound"IBRN"
Scale 0.9
Height 0
Alpha 0.3
States
{
Spawn:
RAIN A 9 A_JumpIf(waterlevel > 0, "Death")
Loop
Death:
RAIN B 10
Stop
}
}
[/code]
and with that you win this :D [youtube]u7ChFtjfX-s[/youtube]
For making this guy perfect, I really need that this http://zdoom.org/wiki/GetSectorCeilingZ return a functional value, like there are 3 sectors with tag 0, each one with different ceiling heigh and both with sky, idk why it will only return the value of the higher ceiling and not the sector that I set ex: GetSectorCeilingZ(0,30,30);
EDIT:Actually this code is working really well O_o idk what I touched that it made not rain on sectors with transfer height but...