[solved 97%] how to randomize door keys?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

[solved 97%] how to randomize door keys?

Postby Lagi » Tue May 12, 2020 1:41 am

I would like to extend the set of 3 keys to 6 (using new Neoworm keys), and randomize them.
Spoiler:

f.ex. replace default yellow key with one of the: yellow, green,blue, silver, obsidian, red.

for that (in heretic) I would have 6x set of:
  • key,
  • gizmo orb color,
  • map color,
  • UI gem color,
Spoiler:


that would have to be randomly pick for each key, at the start of each map.


Please advice, I dont know how to do that, nor what would be good aproach.
Randomspawner will not do :), I believe I need some ACS at start of each map, than generate random number, and then each number will replace the default key,gizmo,gem with another set.

But maybe im wrong and its something super simple like randomspawnerEX that can replace all 4 thing at once?

https://zdoom.org/wiki/LOCKDEFS - lump with lock def. I would need that for message.
https://zdoom.org/wiki/Key_types - list of locks numbers
https://zdoom.org/wiki/Classes:KeyYellow - actor of the yellow key
https://zdoom.org/wiki/Default_status_bars - ui code


GRP in heretic WAD:
Ykeyicon, Gkeyicon, Bkeyicon - name of the UI gems
BkyyA0, AkyyA0, CkyyA0 - name of animated keys (1st frame)

KGZy - orb held by gizmo https://zdoom.org/wiki/Classes:KeyGizmoFloatYellow
gizmos are the same, just spawn different orb above https://zdoom.org/wiki/Classes:KeyGizmoYellow
Last edited by Lagi on Fri May 15, 2020 10:39 am, edited 2 times in total.
User avatar
Lagi
 
Joined: 23 Jun 2018
Location: Thou shalt alter thy beliefs with new evidence

Re: how to randomize door keys?

Postby Lagi » Wed May 13, 2020 2:44 am

haha progress



Code: Select allExpand view
script 8226 ENTER // key shuffle at start of each map
{   

INT k1 = random(1,6);; // old yellow key, first that appear usually
INT k2 = random(1,6);; // old green key
INT k3 = random(1,6);; // old blue key


//k1 = random(1,6);

while ((k1 == k2))
{
k2 = random(1,6);
}

while ((k3 == k1) || (k3 == k2) )
{
k3 = random(1,6);
}

Print(d:k1, s:" : ",d:k2, s:" : ",d:k3); 
}


I have also all graphical resources done


User avatar
Lagi
 
Joined: 23 Jun 2018
Location: Thou shalt alter thy beliefs with new evidence

Re: how to randomize door keys?

Postby Lagi » Wed May 13, 2020 9:53 am

so far, its not working
[spoiler]
this two functions even separate do "nothing" in my case :? Im slowly getting there
SetActorProperty (87,APROP_Species ,"KeyYellow");
SpawnSpot("keyyellow", 87);


Code: Select allExpand view
script 8226 ENTER // key shuffle at start of each map
{   

INT k1 = random(1,6);; // old yellow key, first that appear usually
INT k2 = random(1,6);; // old green key
INT k3 = random(1,6);; // old blue key


//1 - yellow (old) tid 87 , gizmo 96
//2 - green (old) 86, 95
//3 - blue (old) 85, 94
//4 - silver 884
//5 - obsidian 883
//6 - red 882


while ((k1 == k2))
{
k2 = random(1,6);
}

while ((k3 == k1) || (k3 == k2) )
{
k3 = random(1,6);
}

Print(d:k1, s:" : ",d:k2, s:" :B ",d:k3); 

 

switch (k1) {
         case 1:
            //SetActorProperty (87,APROP_Species ,"KeyYellow");
            //SpawnSpot("keyyellow", 87);
            //SpawnSpot("KeyGizmoyellow", 96);            
         break;

         case 2:
            SetActorProperty (86,APROP_Species ,"KeyYellow");
            SpawnSpot("keygreen", 87);
            SpawnSpot("KeyGizmogreen", 96);            
         break;   
         
         case 3:
            SetActorProperty (85,APROP_Species ,"KeyYellow");
            SpawnSpot("keyblue", 87);
            SpawnSpot("KeyGizmoblue", 96);            
         break;   
         
         case 4:
            SetActorProperty (884,APROP_Species ,"KeyYellow");
            SpawnSpot("keysilver2", 87);
            SpawnSpot("KeyGizmoSilver", 96);            
         break;   
         
         case 5:
            SetActorProperty (883,APROP_Species ,"KeyYellow");
            SpawnSpot("keyobsidian", 87);
            SpawnSpot("KeyGizmoobsidian", 96);            
         break;   
         
         case 6:
            SetActorProperty (882,APROP_Species ,"KeyYellow");
            SpawnSpot("keyred", 87);
            SpawnSpot("KeyGizmoRed", 96);            
         break;   

   }


switch (k2) {
         case 1:
            SetActorProperty (87,APROP_Species ,"KeyGreen");
            SpawnSpot("keyyellow", 86);
            SpawnSpot("KeyGizmoyellow", 95);            
         break;

         case 2:
            //SetActorProperty (86,APROP_Species ,"KeyGreen");
            //SpawnSpot("keygreen", 86);
            //SpawnSpot("KeyGizmogreen", 95);            
         break;   
         
         case 3:
            SetActorProperty (85,APROP_Species ,"KeyGreen");
            SpawnSpot("keyblue", 86);
            SpawnSpot("KeyGizmoblue", 95);            
         break;   
         
         case 4:
            SetActorProperty (884,APROP_Species ,"KeyGreen");
            SpawnSpot("keysilver2", 86);
            SpawnSpot("KeyGizmoSilver", 95);            
         break;   
         
         case 5:
            SetActorProperty (883,APROP_Species ,"KeyGreen");
            SpawnSpot("keyobsidian", 86);
            SpawnSpot("KeyGizmoobsidian", 95);            
         break;   
         
         case 6:
            SetActorProperty (882,APROP_Species ,"KeyGreen");
            SpawnSpot("keyred", 86);
            SpawnSpot("KeyGizmoRed", 95);            
         break;   

   }

switch (k3) {
         case 1:
            SetActorProperty (87,APROP_Species ,"KeyBlue");
            SpawnSpot("keyyellow", 84);
            SpawnSpot("KeyGizmoyellow", 94);            
         break;

         case 2:
            SetActorProperty (86,APROP_Species ,"KeyBlue");
            SpawnSpot("keygreen", 84);
            SpawnSpot("KeyGizmogreen", 94);            
         break;   
         
         case 3:
            //SetActorProperty (85,APROP_Species ,"KeyBlue");
            //SpawnSpot("keyblue", 84);
            //SpawnSpot("KeyGizmoblue", 94);            
         break;   
         
         case 4:
            SetActorProperty (884,APROP_Species ,"KeyBlue");
            SpawnSpot("keysilver2", 84);
            SpawnSpot("KeyGizmoSilver", 94);            
         break;   
         
         case 5:
            SetActorProperty (883,APROP_Species ,"KeyBlue");
            SpawnSpot("keyobsidian", 84);
            SpawnSpot("KeyGizmoobsidian", 94);            
         break;   
         
         case 6:
            SetActorProperty (882,APROP_Species ,"KeyBlue");
            SpawnSpot("keyred", 84);
            SpawnSpot("KeyGizmoRed", 94);            
         break;   

   }

}



well I spawn something in this coordinates.

those number W...T...F...

builder has more rationale coords :?: (that dont work withACS :P )
Spoiler: bottom left corner


---

edit because my printf use d: instead of f:

ok

===============

I also give each key and gizmo ACS_execute(nr) in spawn to give TID (because by default everyone is zero), 887...882 or 996...991.
The keys are working (random generatered) but gizmos not. WHY OH WHy

This half success mean i could just use randomspawner for 100% same or better result :x

Screw it, I give player fake inventory equal to keycolor number.
then check amount of inventory on key spawn and gizmo spawn.


Code: Select allExpand view
script 8226 ENTER // key shuffle at start of each map
{   
DELAY(100);

INT k1 = 2;/*random(1,6);; // old yellow key, first that appear usually
INT k2 = random(1,6);; // old green key
INT k3 = random(1,6);; // old blue key


//1 - yellow (old)
//2 - green (old)
//3 - blue (old)
//4 - silver
//5 - obsidian
//6 - red


while ((k1 == k2))
{
k2 = random(1,6);
}

while ((k3 == k1) || (k3 == k2) )
{
k3 = random(1,6);
}
*/
 

switch (k1) {
         case 1:
            
            SpawnSpot("keyyellow", 887, 887);
            SetActorProperty (887,APROP_Species ,"KeyYellow");
            SpawnSpot("KeyGizmoyellow", 996, 996);
            
         break;

         case 2:
            Thing_Remove(996);
            SpawnSpot("keygreen", 887, 886);
            SetActorProperty (886,APROP_Species ,"KeyYellow");
            SpawnSpotForced("KeyGizmogreen", 996, 995,0);   
            Thing_Remove(887);
            
         break;   
         
         case 3:
            
            SpawnSpot("keyblue", 887, 885);
            SetActorProperty (885,APROP_Species ,"KeyYellow");
            SpawnSpot("KeyGizmoblue", 996, 994);   
            //Thing_Remove(887);
            //Thing_Remove(996);
         break;   
         
         case 4:
            
            SpawnSpot("keysilver2", 887, 884);
            SetActorProperty (884,APROP_Species ,"KeyYellow");
            SpawnSpot("KeyGizmoSilver", 996, 993);   
            //Thing_Remove(887);
            //Thing_Remove(996);
         break;   
         
         case 5:
            
            SpawnSpot("keyobsidian", 887, 883);
            
            SetActorProperty (883,APROP_Species ,"KeyYellow");
            SpawnSpot("KeyGizmoobsidian", 996, 992);   
            //Thing_Remove(887);
            //Thing_Remove(996);
         break;   
         
         case 6:
            
            SpawnSpot("keyred", 887, 882);
            SetActorProperty (882,APROP_Species ,"KeyYellow");
            SpawnSpot("KeyGizmoRed", 996, 991);
            //Thing_Remove(887);
            //Thing_Remove(996);
         break;   

   }

/*
switch (k2) {
         case 1:
            SetActorProperty (887,APROP_Species ,"KeyGreen");
            SpawnSpot("keyyellow", 886, 887);
            SpawnSpot("KeyGizmoyellow", 995, 996);
            Thing_Remove(886);
            Thing_Remove(995);
         break;

         case 2:
            SetActorProperty (886,APROP_Species ,"KeyGreen");
            SpawnSpot("keygreen", 886, 886);
            SpawnSpot("KeyGizmogreen", 995, 995);            
         break;   
         
         case 3:
            SetActorProperty (885,APROP_Species ,"KeyGreen");
            SpawnSpot("keyblue", 886, 885);
            SpawnSpot("KeyGizmoblue", 995, 994);   
            Thing_Remove(886);
            Thing_Remove(995);
         break;   
         
         case 4:
            SetActorProperty (884,APROP_Species ,"KeyGreen");
            SpawnSpot("keysilver2", 886, 884);
            SpawnSpot("KeyGizmoSilver", 995, 993);
            Thing_Remove(886);
            Thing_Remove(995);
         break;   
         
         case 5:
            SetActorProperty (883,APROP_Species ,"KeyGreen");
            SpawnSpot("keyobsidian", 886, 883);
            SpawnSpot("KeyGizmoobsidian", 995, 992);      
            Thing_Remove(886);
            Thing_Remove(995);
         break;   
         
         case 6:
            SetActorProperty (882,APROP_Species ,"KeyGreen");
            SpawnSpot("keyred", 886, 882);
            SpawnSpot("KeyGizmoRed", 995, 991);   
            Thing_Remove(886);
            Thing_Remove(995);
         break;   

   }

switch (k3) {
         case 1:
            SetActorProperty (887,APROP_Species ,"KeyBlue");
            SpawnSpot("keyyellow", 885, 887);
            SpawnSpot("KeyGizmoyellow", 994, 996);
            Thing_Remove(885);
            Thing_Remove(994);
         break;

         case 2:
            SetActorProperty (886,APROP_Species ,"KeyBlue");
            SpawnSpot("keygreen", 885, 886);
            SpawnSpot("KeyGizmogreen", 994, 995);
            Thing_Remove(885);
            Thing_Remove(994);
         break;   
         
         case 3:
            SetActorProperty (885,APROP_Species ,"KeyBlue");
            SpawnSpot("keyblue", 885, 885);
            SpawnSpot("KeyGizmoblue", 994, 994);            
         break;   
         
         case 4:
            SetActorProperty (884,APROP_Species ,"KeyBlue");
            SpawnSpot("keysilver2", 885, 884);
            SpawnSpot("KeyGizmoSilver", 994, 993);
            Thing_Remove(885);
            Thing_Remove(994);
         break;   
         
         case 5:
            SetActorProperty (883,APROP_Species ,"KeyBlue");
            SpawnSpot("keyobsidian", 885, 883);
            SpawnSpot("KeyGizmoobsidian", 994, 992);   
            Thing_Remove(885);
            Thing_Remove(994);
         break;   
         
         case 6:
            SetActorProperty (882,APROP_Species ,"KeyBlue");
            SpawnSpot("keyred", 885, 882);
            SpawnSpot("KeyGizmoRed", 994, 991);   
            Thing_Remove(885);
            Thing_Remove(994);
         break;   

   }
*/
}
[/spoiler]

backup
Code: Select allExpand view
script 8226 ENTER // key shuffle at start of each map
{   
DELAY(100);

INT k1 = 2;/*random(1,6);; // old yellow key, first that appear usually
INT k2 = random(1,6);; // old green key
INT k3 = random(1,6);; // old blue key


//1 - yellow (old)
//2 - green (old)
//3 - blue (old)
//4 - silver
//5 - obsidian
//6 - red


while ((k1 == k2))
{
k2 = random(1,6);
}

while ((k3 == k1) || (k3 == k2) )
{
k3 = random(1,6);
}
*/
 

switch (k1) {
         case 1:
            
            SpawnSpot("keyyellow", 887, 887);
            SetActorProperty (887,APROP_Species ,"KeyYellow");
            SpawnSpot("KeyGizmoyellow", 996, 996);
            
         break;

         case 2:
            Thing_Remove(996);
            SpawnSpot("keygreen", 887, 886);
            SetActorProperty (886,APROP_Species ,"KeyYellow");
            SpawnSpotForced("KeyGizmogreen", 996, 995,0);   
            Thing_Remove(887);
            
         break;   
         
         case 3:
            
            SpawnSpot("keyblue", 887, 885);
            SetActorProperty (885,APROP_Species ,"KeyYellow");
            SpawnSpot("KeyGizmoblue", 996, 994);   
            //Thing_Remove(887);
            //Thing_Remove(996);
         break;   
         
         case 4:
            
            SpawnSpot("keysilver2", 887, 884);
            SetActorProperty (884,APROP_Species ,"KeyYellow");
            SpawnSpot("KeyGizmoSilver", 996, 993);   
            //Thing_Remove(887);
            //Thing_Remove(996);
         break;   
         
         case 5:
            
            SpawnSpot("keyobsidian", 887, 883);
            
            SetActorProperty (883,APROP_Species ,"KeyYellow");
            SpawnSpot("KeyGizmoobsidian", 996, 992);   
            //Thing_Remove(887);
            //Thing_Remove(996);
         break;   
         
         case 6:
            
            SpawnSpot("keyred", 887, 882);
            SetActorProperty (882,APROP_Species ,"KeyYellow");
            SpawnSpot("KeyGizmoRed", 996, 991);
            //Thing_Remove(887);
            //Thing_Remove(996);
         break;   

   }

/*
switch (k2) {
         case 1:
            SetActorProperty (887,APROP_Species ,"KeyGreen");
            SpawnSpot("keyyellow", 886, 887);
            SpawnSpot("KeyGizmoyellow", 995, 996);
            Thing_Remove(886);
            Thing_Remove(995);
         break;

         case 2:
            SetActorProperty (886,APROP_Species ,"KeyGreen");
            SpawnSpot("keygreen", 886, 886);
            SpawnSpot("KeyGizmogreen", 995, 995);            
         break;   
         
         case 3:
            SetActorProperty (885,APROP_Species ,"KeyGreen");
            SpawnSpot("keyblue", 886, 885);
            SpawnSpot("KeyGizmoblue", 995, 994);   
            Thing_Remove(886);
            Thing_Remove(995);
         break;   
         
         case 4:
            SetActorProperty (884,APROP_Species ,"KeyGreen");
            SpawnSpot("keysilver2", 886, 884);
            SpawnSpot("KeyGizmoSilver", 995, 993);
            Thing_Remove(886);
            Thing_Remove(995);
         break;   
         
         case 5:
            SetActorProperty (883,APROP_Species ,"KeyGreen");
            SpawnSpot("keyobsidian", 886, 883);
            SpawnSpot("KeyGizmoobsidian", 995, 992);      
            Thing_Remove(886);
            Thing_Remove(995);
         break;   
         
         case 6:
            SetActorProperty (882,APROP_Species ,"KeyGreen");
            SpawnSpot("keyred", 886, 882);
            SpawnSpot("KeyGizmoRed", 995, 991);   
            Thing_Remove(886);
            Thing_Remove(995);
         break;   

   }

switch (k3) {
         case 1:
            SetActorProperty (887,APROP_Species ,"KeyBlue");
            SpawnSpot("keyyellow", 885, 887);
            SpawnSpot("KeyGizmoyellow", 994, 996);
            Thing_Remove(885);
            Thing_Remove(994);
         break;

         case 2:
            SetActorProperty (886,APROP_Species ,"KeyBlue");
            SpawnSpot("keygreen", 885, 886);
            SpawnSpot("KeyGizmogreen", 994, 995);
            Thing_Remove(885);
            Thing_Remove(994);
         break;   
         
         case 3:
            SetActorProperty (885,APROP_Species ,"KeyBlue");
            SpawnSpot("keyblue", 885, 885);
            SpawnSpot("KeyGizmoblue", 994, 994);            
         break;   
         
         case 4:
            SetActorProperty (884,APROP_Species ,"KeyBlue");
            SpawnSpot("keysilver2", 885, 884);
            SpawnSpot("KeyGizmoSilver", 994, 993);
            Thing_Remove(885);
            Thing_Remove(994);
         break;   
         
         case 5:
            SetActorProperty (883,APROP_Species ,"KeyBlue");
            SpawnSpot("keyobsidian", 885, 883);
            SpawnSpot("KeyGizmoobsidian", 994, 992);   
            Thing_Remove(885);
            Thing_Remove(994);
         break;   
         
         case 6:
            SetActorProperty (882,APROP_Species ,"KeyBlue");
            SpawnSpot("keyred", 885, 882);
            SpawnSpot("KeyGizmoRed", 994, 991);   
            Thing_Remove(885);
            Thing_Remove(994);
         break;   

   }
*/
}

script 8927 (void)
{

   //SpawnForced("keyred", 128<<16,-50016043,1572964);
  // SpawnSpot("keyred", 240);
   
  int x = ActivatorTID ();
  Print(d:x);
}



Script 9451 ENTER
{
   Thing_ChangeTID(0, 1001 + PlayerNumber()); // This assigns the TID, player is 1001
}

Script 8928 (void)
{
    GiveActorInventory(1001, "keyred", 1);
}




Script 6887 (void)
{
    Thing_ChangeTID(0, 887);
                int x = ActivatorTID ();
  Print(d:x);
}

Script 6886 (void)
{
    Thing_ChangeTID(0, 886);
            int x = ActivatorTID ();
  Print(d:x);

}

Script 6885 (void)
{
    Thing_ChangeTID(0, 885);
}

Script 6884 (void)
{
    Thing_ChangeTID(0, 884);
}

Script 6883 (void)
{
    Thing_ChangeTID(0, 883);
}

Script 6882 (void)
{
    Thing_ChangeTID(0, 882);
}


Script 6996 (void)
{
    Thing_ChangeTID(0, 996);
        int x = ActivatorTID ();
  Print(d:x);
}

Script 6995 (void)
{
    Thing_ChangeTID(0, 995);
}

Script 6994 (void)
{
    Thing_ChangeTID(0, 994);
}

Script 6993 (void)
{
    Thing_ChangeTID(0, 993);
}

Script 6992 (void)
{
    Thing_ChangeTID(0, 992);
}

Script 6991 (void)
{
    Thing_ChangeTID(0, 991);
}
User avatar
Lagi
 
Joined: 23 Jun 2018
Location: Thou shalt alter thy beliefs with new evidence

Re: how to randomize door keys?

Postby Lagi » Thu May 14, 2020 6:23 am

works!!!

random keys and gizmos. its like brand new heretic now :D
I only need more keys!!! like tons of them. So each level can have a chance to have unique set.

aa.. and UI gem is not working, but eee... i need to finish my shift in quarry first :roll: .

Code: Select allExpand view
Script 9451 ENTER
{
   Thing_ChangeTID(0, 1001 + PlayerNumber()); // This assigns the TID, player is 1001
}

script 8226 ENTER // key shuffle at start of each map
{   

INT k1 = random(1,6); // old yellow key, first that appear usually
INT k2 = random(1,6); // old green key
INT k3 = random(1,6); // old blue key

// the value would be new key color
//1 - blue (old)
//2 - green (old)
//3 - yellow (old)
//4 - silver
//5 - obsidian
//6 - red

while ((k1 == k2))
{
k2 = random(1,6);
}

while ((k3 == k1) || (k3 == k2) )
{
k3 = random(1,6);
}
TakeActorInventory(1001,"k1",6);
TakeActorInventory(1001,"k2",6);
TakeActorInventory(1001,"k3",6);
GiveActorInventory(1001, "k1", k1);
GiveActorInventory(1001, "k2", k2);
GiveActorInventory(1001, "k3", k3);

// Print(d:k1, s:" .. ", d:k2, s:" ..", d:k3);

INT hk1 = random(0,2); // old yellow key UI high position
INT hk2 = random(0,2); // old green key
INT hk3 = random(0,2); // old blue key



while ((hk1 == hk2))
{
hk2 = random(0,2);
}

while ((hk3 == hk1) || (hk3 == hk2) )
{
hk3 = random(0,2);
}
TakeActorInventory(1001,"hk1",6);
TakeActorInventory(1001,"hk2",6);
TakeActorInventory(1001,"hk3",6);
GiveActorInventory(1001, "hk1", hk1);
GiveActorInventory(1001, "hk2", hk2);
GiveActorInventory(1001, "hk3", hk3);




}




script 8927 (int KeyOrGizmo, int vanillaKeyColor)
{
delay(2); //this is need to give computer time to do previous scripts - I think, otherwise nothing happen. 1 is enough, but 2 just in case.
//the Spawn number is define in MapInfo, need to add any new keys&gizmos over there.
//As well as increase K1,K2,K3 amounts in ACS and in decorate ammo def

int k1 = 84+(CheckActorInventory(1001, "k1"));
int k2 = 84+(CheckActorInventory(1001, "k2"));
int k3 = 84+(CheckActorInventory(1001, "k3"));

int g1 = 984+(CheckActorInventory(1001, "k1"));
int g2 = 984+(CheckActorInventory(1001, "k2"));
int g3 = 984+(CheckActorInventory(1001, "k3"));

//Print(d:g1, s:" ./. ", d:g2, s:" ./.", d:g3);


str doorkey[6] = { "KeyBlue2" ,"KeyGreen2", "KeyYellow2", "KeySilver2", "KeyObsidian", "KeyRed" };


switch(KeyOrGizmo)
{



case 1: // door keys itself

         switch(vanillaKeyColor) {
                        case 1: //yellow
                        SpawnSpotForced(doorkey[CheckActorInventory(1001,"k1")-1],0,878,0);
                        //Thing_SpawnNoFog(0,k1,0,878);
                        SetActorProperty (878,APROP_Species ,"KeyYellow");   //this tell game to consider the new key as old Yellow
                        break;

                        case 2: //green
                        SpawnSpotForced(doorkey[CheckActorInventory(1001,"k2")-1],0,868,0);
                        SetActorProperty (868,APROP_Species ,"Keygreen");      
                        break;
                        
                        case 3: //blue
                        SpawnSpotForced(doorkey[CheckActorInventory(1001,"k3")-1],0,858,0);
                        SetActorProperty (858,APROP_Species ,"Keyblue");      
                        break;
                     }
break;

case 2: //gizmos      
         switch(vanillaKeyColor) {
                        case 1: //yellow
                        Thing_SpawnNoFog(0,g1,0,0);
                        break;

                        case 2: //green
                        Thing_SpawnNoFog(0,g2,0,0);
                        break;
                        
                        case 3: //blue
                        Thing_SpawnNoFog(0,g3,0,0);
                        break;
                     }

break;
}

}


part of decorate
Code: Select allExpand view
//================================================
// spawners at old keys

ACTOR KeyYellowSpawner replaces KeyYellow
{
states{
Spawn:
   tnt1 a 1 NoDelay ACS_execute(8927,0,1,1) // arg1 is Key=1 or Gizmo=2;   arg2 is vanillaKeyColor Yellow=1, Green=2, Blue=3
   tnt1 a 100
   stop

}
}


mapinfo with new spawnIDs:
Code: Select allExpand view
SpawnNums
{
   85 = KeyBlue2
   86 = KeyGreen2
   87 = KeyYellow2
   88 = KeySilver2
   89 = KeyObsidian
   90 = KeyRed
   //can go till 110
   985 = KeyGizmoblue2
   986 = KeyGizmogreen2
   987 = KeyGizmoYellow2
   988 = KeyGizmoSilver
   989 = KeyGizmoObsidian
   990 = KeyGizmoRed
}
Last edited by Lagi on Sat May 16, 2020 2:17 am, edited 2 times in total.
User avatar
Lagi
 
Joined: 23 Jun 2018
Location: Thou shalt alter thy beliefs with new evidence

Re: [solved 74%] how to randomize door keys?

Postby Lagi » Thu May 14, 2020 9:58 am

here is the part of UI zscript code that I would hope to modify,to display different gem in different position

1. I need to check how many invenotry of K1 player has, and base on that draw apropriate picture "*keyIcon". Need to make list of icons and assign number to everyone.
2.position would be X - stay same; Y- would be 20 + HK1(random 0-2)*8

Code: Select allExpand view
// Draw Keys
         if (CPlayer.mo.CheckKeys(131, false, true)) DrawImage("YKEYICON", (-4.5+offset, -36), DI_ITEM_OFFSETS|DI_SCREEN_CENTER_BOTTOM, alpha:alphaFloatGraph);
         if (CPlayer.mo.CheckKeys(129, false, true)) DrawImage("GKEYICON", (-4.5+offset, -28), DI_ITEM_OFFSETS|DI_SCREEN_CENTER_BOTTOM, alpha:alphaFloatGraph);
         if (CPlayer.mo.CheckKeys(130, false, true)) DrawImage("BKEYICON", (-4.5+offset, -20), DI_ITEM_OFFSETS|DI_SCREEN_CENTER_BOTTOM, alpha:alphaFloatGraph);
         


here is my enum [shouldnt the icon names be with " ? like strings? I have no idea what im doing :) ]
Code: Select allExpand view
   enum KeyGems
   {
   BkeyIcon = 1,
   GkeyIcon = 2,
   YkeyIcon = 3,
   SkeyIcon = 4,
   okeyIcon = 5,
   rkeyIcon = 6   
   }


=======================
edit:

so i have random key position on UI. Now "only" to change the gem colors :)
Code: Select allExpand view
if (CPlayer.mo.CheckKeys(131, false, true)) DrawImage("KeyGem(GetAmount("hK1"))" ,...
something like this would be sweet

i give player amount of items (hk1) equal to UI key position. Hey, do I look like a coder?

Code: Select allExpand view
if (CPlayer.mo.CheckKeys(131, false, true)) DrawImage("YKEYICON", (-4.5+offset, -20 - (GetAmount("hK1"))*8), DI_ITEM_OFFSETS|DI_SCREEN_CENTER_BOTTOM, alpha:alphaFloatGraph);   
         if (CPlayer.mo.CheckKeys(129, false, true)) DrawImage("GKEYICON", (-4.5+offset, -20 - (GetAmount("hK2"))*8), DI_ITEM_OFFSETS|DI_SCREEN_CENTER_BOTTOM, alpha:alphaFloatGraph);
         if (CPlayer.mo.CheckKeys(130, false, true)) DrawImage("BKEYICON", (-4.5+offset, -20 - (GetAmount("hK3"))*8), DI_ITEM_OFFSETS|DI_SCREEN_CENTER_BOTTOM, alpha:alphaFloatGraph);
      
User avatar
Lagi
 
Joined: 23 Jun 2018
Location: Thou shalt alter thy beliefs with new evidence

Re: [solved 74%] how to randomize door keys?

Postby Lagi » Fri May 15, 2020 10:39 am

DONE :D

random key,
with the same color gizmos,
with appropriate UI gem color,
with random UI position


yes yes gem is misaligned, and red gem color suck - will fix it soon (and steal neoworm resources)

zscript
Code: Select allExpand view
   
         // Draw Keys
         
         string uikeygem[6] = { "BkeyIcon" ,"GkeyIcon", "ykeyIcon", "SkeyIcon", "OkeyIcon", "FkeyIcon" };
         
                        
         if (CPlayer.mo.CheckKeys(131, false, true))
         {
            DrawImage(uikeygem[GetAmount("k1")-1], (-4.5+offset, -20 - (GetAmount("hK1"))*8), DI_ITEM_OFFSETS|DI_SCREEN_CENTER_BOTTOM, alpha:alphaFloatGraph);   
         
         
         
         }


BTW why in array declaration i skip index 0, but in return value I still have to take it into consideration is beyond me [do i sound smart now? :) ].
User avatar
Lagi
 
Joined: 23 Jun 2018
Location: Thou shalt alter thy beliefs with new evidence

Re: [solved 97%] how to randomize door keys?

Postby 3saster » Wed May 20, 2020 12:02 am

Good job! Looks like got most of it working, and just need to finish it off.
Lagi wrote:BTW why in array declaration i skip index 0, but in return value I still have to take it into consideration is beyond me [do i sound smart now? :) ].

You phrased that really weird, but I think I know what you mean. When you declare an array, the "index" is not an index, but the number of elements (so string uikeygem[6] has 6 elements total). When you call a particular element, the first element is element 0, so if you have n elements, the valid index values range from 0 to n-1. Thus, you aren't "skipping index 0" in the declaration, the number in that place just represents size instead of index this time. As an additional useful thing to note, if you are doing the declaration (string uikeygem[6]) and the instantiation (= whatever) at the same time, then you can not put the size specification, and it will figure it out from the instantiation. For example,
Code: Select allExpand view
string uikeygem[] = { "BkeyIcon" ,"GkeyIcon", "ykeyIcon", "SkeyIcon", "OkeyIcon", "FkeyIcon" };

will automatically make uikeygem have size 6. Not always something you want, but good to know.
User avatar
3saster
 
Joined: 11 May 2018
Location: Canada


Return to Scripting

Who is online

Users browsing this forum: No registered users and 2 guests