PDF's Ridiculous Editing Questions

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
User avatar
Project Shadowcat
Posts: 9369
Joined: Thu Jul 14, 2005 8:33 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: Blacksburg, SC USA
Contact:

Post by Project Shadowcat »

So, the Player needs to be assigned a TID? I thought this never worked before, but it's worth trying. :?
User avatar
Apothem
Posts: 2070
Joined: Sat Nov 29, 2003 7:13 pm
Location: Performing open heart surgery on an ACS compiler.

Post by Apothem »

It's always worked, you just probably never knew about it :wink:

Pretty simple too, just use changetid command on enter and change it to whatever. For multiplayer support use playernumber() + offset number.
User avatar
Project Shadowcat
Posts: 9369
Joined: Thu Jul 14, 2005 8:33 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: Blacksburg, SC USA
Contact:

Post by Project Shadowcat »

Apothem wrote:It's always worked, you just probably never knew about it :wink:

Pretty simple too, just use changetid command on enter and change it to whatever. For multiplayer support use playernumber() + offset number.
Perhaps I'm just sleep-deprived or just plain out of it, but I don't quite get what you mean. Wouldn't setting Player 1 as TID 750 on the map and using HotWax's command Thing_Destroy(750,1); do the trick already?

Another question came up while working on a map and getting frustrated at the lame AI trying to bail me out:
8: Is there any way in a Single Player game to have no Friendly Fire? I.E., ally has a powerful Railgun, but not a whole lot of HPs to have him slug it out on his own. You want to get in and fight together, but there's a chance you can hurt him, or a railshot can go through you.
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Post by HotWax »

Project Dark Fox wrote:Perhaps I'm just sleep-deprived or just plain out of it, but I don't quite get what you mean. Wouldn't setting Player 1 as TID 750 on the map and using HotWax's command Thing_Destroy(750,1); do the trick already?
No it wouldn't. You can't set the player's TID on the map. In fact, you're actually setting the Player X Start's TID, and at map start, those starts are removed from the map (only their location is saved and used for the players' start positions), so you now have nothing on the map with TID 750 that you can interact with.

You can set the player's TID in an ENTER script, but if you just set it to a single number and then somebody decides to play your map multiplayer, the Thing_Destroy command would kill all the players!

Using PlayerNumber() + offset ensures that each player is assigned a unique TID and can be acted upon individually. It also works in single-player, so it's a win-win situation.

Code: Select all

script 1 ENTER {
     Thing_ChangeTID(0, PlayerNumber() + 1337);
}

script 900 (void) {
     // Kill the player foolish enough to cross the Line of Death!(TM)
     // Leave the other players alone
     Thing_Destroy(PlayerNumber() + 1337, 1);
}
Another question came up while working on a map and getting frustrated at the lame AI trying to bail me out:
8: Is there any way in a Single Player game to have no Friendly Fire? I.E., ally has a powerful Railgun, but not a whole lot of HPs to have him slug it out on his own. You want to get in and fight together, but there's a chance you can hurt him, or a railshot can go through you.
The only method I'm aware of is using +GHOST and +THRUGHOST hackery. If you use the SVN you can use custom pass-through flags to match up the weapons and actors so they don't impact one another, but I don't think it works for hitscan attacks.
User avatar
Project Shadowcat
Posts: 9369
Joined: Thu Jul 14, 2005 8:33 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: Blacksburg, SC USA
Contact:

Post by Project Shadowcat »

@ #7: So I can just copy that first script into the ENTER script to get a "floating TID"? Fortunately, I don't have Multi-Player in mind (yet), but I can also use the final line in script 900 of yours to kill off the player if he fails his defense mission.

@ #8: The best option then is to advise players to watch their ass.
User avatar
Project Shadowcat
Posts: 9369
Joined: Thu Jul 14, 2005 8:33 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: Blacksburg, SC USA
Contact:

Post by Project Shadowcat »

Hey, guys, here's a more interesting question or two.

9a: I have finally decided to change to an ACS-driven HUD, assuming DoomScript takes its time. While I've got no problems with the Health and Armor values, since they will be numeric; but I'm having a bitch of a time getting 11 (1 for empty) levels of fillbars up for ammo values instead of numbers. Mostly because I don't have a clue how to do arithmetic in ACS. I am calling for CheckInventory() and GetAmmoCapacity(), how do you set it up to do basically this: (Current Ammo x 10) / Max Ammo = Ammo Points ? (If Ammo Points = 5, the respective bar will be half-full)
9b: Which function calls up the numerical value on the weapon you're currently carrying -- if it exists?
User avatar
solarsnowfall
Posts: 1581
Joined: Thu Jun 30, 2005 1:44 am

Post by solarsnowfall »

CheckInventory (str inventory_item)
Project Dark Fox wrote:Current Ammo * 100 / Max Ammo = Ammo Points
That should work, though there may be a better way to approach the math. Just call CheckInventory in place of "current ammo".
User avatar
Zippy
Posts: 3302
Joined: Wed Mar 23, 2005 5:31 pm
Location: New Jersey

Post by Zippy »

Project Dark Fox wrote:9b: Which function calls up the numerical value on the weapon you're currently carrying -- if it exists?
[wiki]CheckWeapon[/wiki] takes a string (the class name of the weapon) and will return true if that is the player's active weapon (assuming the player is the script activator.) If you want to have a function which returns a number based on what weapon the player is using, you can just write one yourself, e.g.

Code: Select all

#define WEAPON_CHAINSAW 0
#define WEAPON_FIST 1
// etc...

function int playerWeapon()
{
   if( CheckWeapon("Chainsaw") )
   {
      return WEAPON_CHAINSAW;
   }
   else if( CheckWeapon("Fist") )
   {
      return WEAPON_FIST;
   }
   // etc...
}
User avatar
Project Shadowcat
Posts: 9369
Joined: Thu Jul 14, 2005 8:33 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: Blacksburg, SC USA
Contact:

Post by Project Shadowcat »

solarsnowfall wrote:CheckInventory (str inventory_item)
Project Dark Fox wrote:Current Ammo * 100 / Max Ammo = Ammo Points
That should work, though there may be a better way to approach the math. Just call CheckInventory in place of "current ammo".
I'm having bitchfits with how the arithmetic works in ACS. I am fully aware of CheckInventory, because it is ACC otherwise breaking on me once it encounters "*" in a script. I'm trying to figure out why it doesn't like that symbol in something like this:

Code: Select all

script 901 (void) //
{
[...]
10 * CheckInventory("Clip") / GetAmmoCapacity("Clip") = ammocount1;
   ^ BREAKAGE!
No, that is not a typo, because I am only using 11 levels of a bar. not 101. ammocount1 -4 would be called off to then display smallish bars according to relative ammo levels on a bottom corner of the screen, one for each of the four ammo types.

Zippy: GAH!! I left out a few words in that question. Fixing...
PDF (Fixed) wrote:9b: Which function calls up the numerical value on the weapon's ammo count you're currently carrying -- if it exists?
User avatar
Zippy
Posts: 3302
Joined: Wed Mar 23, 2005 5:31 pm
Location: New Jersey

Post by Zippy »

Project Dark Fox wrote:

Code: Select all

script 901 (void) //
{
[...]
10 * CheckInventory("Clip") / GetAmmoCapacity("Clip") = ammocount1;
   ^ BREAKAGE!
You're backwards.

Code: Select all

ammocount1 = 10 * CheckInventory("Clip") / GetAmmoCapacity("Clip");
Project Dark Fox wrote:Zippy: GAH!! I left out a few words in that question. Fixing...
PDF (Fixed) wrote:9b: Which function calls up the numerical value on the weapon's ammo count you're currently carrying -- if it exists?
You'll have to set up something similar to what I just posted above. Specifically, check which weapon the player is using, and then use that to CheckInventory the proper ammo type.
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Post by HotWax »

Heh. C format != Algebra. :)

The poor compiler can only read left to right and process as it goes, y'know.

So first it sees "10"... "10? 10 what? What's going on here? Well I'm sure the next token will make it all clear" Then of course it sees "*". "OMG, does not compute. ERROR ERROR DANGER WILL ROBINSON" puffs smoke out its ears for several seconds and then collapses on the floor. Nice going, you just killed the compiler.

On the other hand when it read's Zippy's it goes "ammocount1? Hey, I know what that is because it was defined above. Awesome! Let's see, then we have an equals sign, so we're doing assignment. Perfect. So now I just perform the calculation on the right side and assign the result back to ammocount1. I love my life!"

... Or something like that, anyway. :D
User avatar
Project Shadowcat
Posts: 9369
Joined: Thu Jul 14, 2005 8:33 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: Blacksburg, SC USA
Contact:

Post by Project Shadowcat »

HotWax: The explanation on how ACC works actually helps a lot for future coding; kick ass, HotWax.


Zippy: I'll look into that and see what I can learn from it.

Thanks guys for the help. :) If I have another question I will bring it up.
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Post by HotWax »

Project Dark Fox wrote:HotWax: The explanation on how ACC works actually helps a lot for future coding; kick ass, HotWax.
You can find out much more by reading any book on basic C programming syntax and structure.
User avatar
Project Shadowcat
Posts: 9369
Joined: Thu Jul 14, 2005 8:33 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: Blacksburg, SC USA
Contact:

Post by Project Shadowcat »

HotWax: If I find something like that around here in the middle of nowhere I'll let you know. :roll:

Zippy, 9b: I tried expanding on your bit of ACS, and... I got only errors.
Here's some of the code:

Code: Select all

#define AMMO_NULL 0
#define AMMO_BULL 1
#define AMMO_SHEL 2
#define AMMO_HEAP 3
#define AMMO_BATT 4
// etc...

function int playerWeapon()
{
   if( CheckWeapon("Fist") )
   {
      return AMMO_NULL;
   }
   else if( CheckWeapon("Pistol1") )
   {
      return AMMO_BULL;
   }
      else if( CheckWeapon("Pistol-S") )
   {
      return AMMO_BULL;
   }
      else if( CheckWeapon("Shotgun") )
   {
      return AMMO_SHEL;
   }
      else if( CheckWeapon("SuperShotgun") )
   {
      return AMMO_SHEL;
   }
And the errors:

Code: Select all

 Line 16 in file "script.acs" ...
 script.acs:16: Invalid variable type.
 > function int playerWeapon() 
 >                           ^
 script.acs:17: Invalid identifier.
 > { 
 > ^
User avatar
solarsnowfall
Posts: 1581
Joined: Thu Jun 30, 2005 1:44 am

Post by solarsnowfall »

function int PlayerWeapon (void)
How about this?

Code: Select all

#define NUM_WEAPONS	5
#define WEAPON_FAIL	65536 //value to return if a weapon from the string array can't be found.

str weapons[NUM_WEAPONS] = {"Fist", "Pistol1", "Pistol-S", "Shotgun", "SuperShotgun"};

function int playerWeapon (void) 
{
	for (int w=0; w<NUM_WEAPONS; w++)
		if (CheckWeapon (weapons[w]))
			return w;

	return WEAPON_FAIL;
}
Locked

Return to “Editing (Archive)”