Jump to content
  • 0

Script Help


Zemini

Question

There are six runes a player can collect.  The more runes they have the higher chance a Demon (lets call it Joe) will spawn.

 

This script will run at certain points, but once a joe spawns, it terminates for the remainder of the map.

 

At most the player will have 5 keys since once they collect 6, they can access the final level.  Also, the more keys you have the higher chance to spawn a second and perhaps even a third Joe.

 

#Keys  --  chance for one -- chance for two -- chance for three

1 Key:  10%, 2%, 0% (if zero is a problem, then 1% is fine)

2 Keys:  20%, 5%, 1%

3 keys: 20%, 10%, 2%

4 keys: 30%, 15%, 3%

5 Keys: 40% , 20%, 4%

6 Keys:  Irrelevant since access to the levels will be locked.  But i suppose 100% for all three for the sake of testing.

 

I would also want to mess around with these numbers for testing purposes.

 

Appreciat any help

 

Edited by Zemini

Share this post


Link to post

9 answers to this question

Recommended Posts

  • 0

So each key needs to be custom inventory item, or tie them to door keys could work as well. I think i write a basic actor example  needed, but no guarantee of it actually working

 

Spoiler

Actor JoeSpawnerChecker : CustomINventory 1342// Actor to be placed in the maps to run the event
{  
  Radius 64
  Height 56
  +INVENTORY.ALWAYSPICKUP
  STATES
   {
     SPAWN:
        TNT1 A 1// Just a big fat invisible nonsolid actor
        Loop
     Pickup: // Where the magic happens
        TNT1 A 0 A_JumpIfINventory("JoeStopper", 1, "DoNotta")
        TNT1 A 0 A_JumpifInventory( "JoeKey", 5, "BigSpawn")
        TNT1 A 0 A_JumpifInventory( "JoeKey", 4, "BigSpawn1")
        TNT1 A 0 A_JumpifInventory( "JoeKey", 3, "BigSpawn2")
        TNT1 A 0 A_JumpifInventory( "JoeKey", 2, "BigSpawn3")
        TNT1 A 0 A_JumpifInventory( "JoeKey", 1, "BigSpawn4")
		Stop
	 DoNotta:
        TNT1 A 0
		Stop
	 JoeSpawning1:
        TNT1 A 0 A_GIveINventory("JoeStopper", 1)
	    TNT1 A 0 A_SpawnItemEx("Joe")
		TNT1 A 0 A_Jump(50, "ReRoll")
		Stop
     ReRoll:
		TNT1 A 0 A_SpawnItemEx("Joe")
		TNT1 A 0 A_Jump(25,"ReRoll2")
		Stop
	ReRoll2:
		TNT1 A 0 A_SpawnItemEx("Joe")
		Stop
	 BigSpawn:
		TNT1 A 0 A_Jump(100, "JoeSpawning1")
		Stop    
	 BigSpawn1:
		TNT1 A 0 A_Jump(80, "JoeSpawning1")
		Stop
	 BigSpawn2:
		TNT1 A 0 A_Jump(70, "JoeSpawning1")
		Stop
	 BigSpawn3:
		TNT1 A 0 A_Jump(60, "JoeSpawning1")
		Stop
	 BigSpawn4:
		TNT1 A 0 A_Jump(50, "JoeSpawning1")
		Stop
}
}

Actor JoeStopper: CustomInventory
{
INventory.InterHubAmount 1// Use this if you need the stopper to persist between maps, otherwise dont use it.
}

Actor Joe : Demon
{
  States
  {
     Spawn:
      TNT1 A 35 A_UNsetSolid
     Visible:
	  TFOG ABCD 4
  	  Sarg A 0 A_SetSolid
 	 Spawn2:
       SARG AABBCCDD 4 A_Wander
	 	Loop
     See:
        SARG AABBCCDD 2 A_Chase
		Loop
}
}
        
Actor JoeKey : CustomInventory  // This is just the basic place holder item that makes the check. Not sure how you are implementing the actual 								   //pickup
{
  INventory.Amount 1
  Inventory.MaxAmount 6
  +Inventory.AlwaysPickUp
}
  

 

 

Share this post


Link to post
  • 0

Well not really doing what i need it to.  I was hoping to get this done in a script.  Script runs at specific parts and spawns Joe at carefully selected map spots around each map.  Is that possible?

Share this post


Link to post
  • 0

I've read this a few times now and I think I might be getting my head around it.

 

You're saying that you have a WAD with a series of maps in it - the first six are your "normal" level progression, and the seventh is the final map. It's possible for a player to pick up more than one rune in a map, so they may not play all seven maps; they could jump to the final map from an earlier one than the sixth.

 

In each map, there are various scripted points that can spawn runes - every time the player collects a rune, however, there's a chance for Joe to spawn, and then no more runes will spawn on that map. (This got a bit confusing as you refer to them as "keys" in that part of your post.)

 

Kalensar's post is correct that you'll need to have some custom inventory items for your runes as regular keys won't travel between maps - you'll need something that is retained in inventory. However, the scripting for managing the Joe spawning would be ACS script.

 

I'd set up a simple while(!JoeSpawned) loop in an ENTER script (where JoeSpawned is a boolean value that is set to TRUE when the obvious happens). Then your rune code would run in the middle, and the script would terminate after Joe pops up. However, you'd need the same script added to every map.

 

Your Joe-spawning odds are just a matter of calling some random numbers and seeing what happens. You can make your life easier by setting up some INT constants at the top of your scripts and using those in the main code - then you can tweak just by changing the values of your constants rather than updating everything - but you'll still need to tweak them for every map, unless you do something clever with an #include statement.

 

Ultimately, though, I wonder whether it's all worth it. There's something to be said for keeping things fairly linear. If your players reach the final map too quickly, they may feel a little cheated - playing through all of them, getting one rune per map, means they get maximum play.

Share this post


Link to post
  • 0
7 hours ago, Zemini said:

Well not really doing what i need it to.  I was hoping to get this done in a script.  Script runs at specific parts and spawns Joe at carefully selected map spots around each map.  Is that possible?

 

 

Let me iterate that what I wrote out was not meant to be an actual solution, but more as a guideline example That could be adapted to hopefully show the necessary steps to accomplish the task as I was able to understand it. As I don't have access to the actual project the best I could do was fulfill the criteria as roughly outlined.

 

The Actor I built to run the process described was meant to be placed in the map at the locations you wanted the checks to run on the summoning chances. It is big, fat and invisble acting as similar to a PickUp item, and does not show in the Item Inventory.bar. I never tested it in game. When I make ideas like this I do it generally on the assumption that the modder I gift these to has some understanding of how DECORATE looks and works. The more complex the idea presented, the more wild my attempt at solution will look. In this case, especially where I did not test it, the best I can do is cover the parameters needed and hope its a good skeleton code that can be adapted easily. To be fair to myself, I have not built anything like this before, but I can write down the Order of Operations that I'm positive can make the special effect happen roughly as desired.

 

So don't feel to bad about it having trouble working because I did not design it to work out of the box at all because its purpose was to show a build that might be similar to the end result that would most likely work.

 

Another thing to know: I am a very unorthodox codemonkey when it comes to tackling various ideas, and even moreso when the ideas have a unique idea like this Summon Checker OP presented. I am not good with ACS or Zscript that involves activities that are used in  ACS style. Almost every solution I will ever offer is DECORATE and with a specific bend toward normally ACS styled effects with a DECORATE mockup designed to replicate ACS style activites. AKA my attempts at replicating some effects can be Highly experimental in nature.

 

The reason I use DECORATE over ZSCRIPT is mainly due to source port versatility in ZDoom family because ZSCRIPT has parameters and functions that don't work on LZDoom, ZDoom or Zandronum. I usually aim for LZDoom compatibility and sometimes Zandronum for projects that seem fun for it. Decorate also doesnt need the necessary use of semicolons, so Decorate allows me to build ideas faster. My main problem with ZSC is that I am just not fluent with the syntax meaning for many of the necessary characters that are integral for forming the necessary instructions that ZSC uses. By contrast my fluency in DECORATE has a decently high success rate for ideas that are not generally built using DECORATE. My favorite example is a G-Button Grenade complete with throwing animations. Its not perfect mechanically due to weapon switching limitations, but not a single use of ZSD or ACS in the entire grenade mechanic; whereas the weapon switch on grenades back to previous weapon is usually done by ACS or ZSC in the same vein as Brutal Doom.

 

Sorry for the long diatrab there, but it seemed slightly necessary to explain my techniques in Doom Modding just because they have the habit of not being a normal approach when compared to other mods that replicate similar looking effects.

Share this post


Link to post
  • 0
5 hours ago, Artinum said:

I've read this a few times now and I think I might be getting my head around it.

 

You're saying that you have a WAD with a series of maps in it - the first six are your "normal" level progression, and the seventh is the final map. It's possible for a player to pick up more than one rune in a map, so they may not play all seven maps; they could jump to the final map from an earlier one than the sixth.

 

In each map, there are various scripted points that can spawn runes - every time the player collects a rune, however, there's a chance for Joe to spawn, and then no more runes will spawn on that map. (This got a bit confusing as you refer to them as "keys" in that part of your post.)

 

Kalensar's post is correct that you'll need to have some custom inventory items for your runes as regular keys won't travel between maps - you'll need something that is retained in inventory. However, the scripting for managing the Joe spawning would be ACS script.

 

I'd set up a simple while(!JoeSpawned) loop in an ENTER script (where JoeSpawned is a boolean value that is set to TRUE when the obvious happens). Then your rune code would run in the middle, and the script would terminate after Joe pops up. However, you'd need the same script added to every map.

 

Your Joe-spawning odds are just a matter of calling some random numbers and seeing what happens. You can make your life easier by setting up some INT constants at the top of your scripts and using those in the main code - then you can tweak just by changing the values of your constants rather than updating everything - but you'll still need to tweak them for every map, unless you do something clever with an #include statement.

 

Ultimately, though, I wonder whether it's all worth it. There's something to be said for keeping things fairly linear. If your players reach the final map too quickly, they may feel a little cheated - playing through all of them, getting one rune per map, means they get maximum play.

 

Yes these are NOT keycards.  They persist from level to level.  IDKFA will give you all of them but you can't collect more than 1.

 

Think of it like Quake 1.  Central Hub style campaign. You collect the runes and when you have all 4 (one from each episode) the final level opens up.  You also loose access to the episode you completed (unless you noclip). 

 

I wanted to added another layer of difficulty which increases with each you rune key you find.  That way Episode 1 can actually become more difficult if you choose to complete that one last (since you will have 5 runes and that creates more demonic invasions).

 

In my campaign there is 6 rune keys which means a maximum of 5 layers of difficulty.

Edited by Zemini

Share this post


Link to post
  • 0

Here is my current working script i stole that i am trying to edit.

 

//spawn joe, higher chance with more runes
bool HasExecutedOnce = false;
str KeyTypes[6] = { "1RUNE", "2RUNE", "3RUNE", "4RUNE", "5RUNE", "6RUNE" };
Script "joe" (void)
{

  int chancePerKey = 100/6;
  int totalChance = 0;
  for(int i = 0; i < 6; i++)
  {
      if(HasExecutedOnce == false)
      if(CheckInventory(KeyTypes))
      {
        totalChance += chancePerKey;
      }
  }
  if(random(0,100) < totalChance)
  {
      SpawnSpot("TeleportRed", 401,0,0); //i changed the teleport fog to let the player know that this is a Rune invasion
      SpawnSpot("joe", 401, 661); //or any other special monster to several other map spots in the world.
      thing_hate(661,0,0);
      HasExecutedOnce = true;
  }

}

Edited by Zemini

Share this post


Link to post
  • 0
On 6/6/2024 at 4:14 PM, Zemini said:

      if(CheckInventory(KeyTypes))

 

Shouldn't that be:

if(CheckInventory(KeyTypes[i]))

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...