"How do I ZScript?"
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.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
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.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
-
- Posts: 8193
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: ZScript-only "How do I..." thread
Would it be better if all that just directly placed into Tick() then?
-
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Re: ZScript-only "How do I..." thread
From Graf's last comment it seems we just need to figure out what all this means from the Wiki:Ed the Bat wrote:Going back to this topic...
Would anyone be able to teach me how to make a variant of A_RailAttack that honors autoaim?
I can't access a copy of gzdoom.pk3 right now but I'm assuming this function is scriptified enough that the flags should be in there somewhere.double AimLineAttack(double angle, double distance, out FTranslatedLineTarget pLineTarget = null, double vrange = 0., int flags = 0, Actor target = null, Actor friender = null);
Actor, int LineAttack(double angle, double distance, double pitch, int damage, Name damageType, class<Actor> pufftype, int flags = 0, out FTranslatedLineTarget victim = null);
Also, can a mod maybe move the Darwinia sprite sloping stuff to a separate thread? It can get a little hard to follow a thread like this with something this complex going on at the same time.
-
- Posts: 8193
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: ZScript-only "How do I..." thread
First off, it's already solved.
Second, it's a "How do I..." thread where it belongs. We really don't need to be making more as it would've been solved in good time anyway.
Third, it's a great place to look for things that may have been asked already. I say keep it.
Second, it's a "How do I..." thread where it belongs. We really don't need to be making more as it would've been solved in good time anyway.
Third, it's a great place to look for things that may have been asked already. I say keep it.
-
-
- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: ZScript-only "How do I..." thread
ZScript "How do I..." thread is not going to be simple. The language itself is full of complex and/or internal stuff.
-
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Re: ZScript-only "How do I..." thread
Guess I'll start the next question then! (notwithstanding I too want to know the answer to Ed's)
I want to do a for loop that goes through all the players on the map to do something to each of them. How would I set up this loop?
I want to do a for loop that goes through all the players on the map to do something to each of them. How would I set up this loop?
-
- Posts: 3060
- Joined: Thu May 03, 2012 1:18 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Maryland, US
Re: ZScript-only "How do I..." thread
Now that one, I can answer! In this example, let's say I want to give every player one Clip:Vaecrius wrote:I want to do a for loop that goes through all the players on the map to do something to each of them. How would I set up this loop?
Code: Select all
for(int i=0;i<MAXPLAYERS;i++)
{
if(playeringame[i])
{
players[i].mo.A_GiveInventory("Clip");
}
}
-
-
- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: ZScript-only "How do I..." thread
Remember to check for .mo not being null. This can happen for spectators for example if ZScript ever gets to Zandronum.
Also under certain circumstances this probably could happen in GZDoom as well.
Also under certain circumstances this probably could happen in GZDoom as well.
-
- Posts: 3060
- Joined: Thu May 03, 2012 1:18 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Maryland, US
Re: ZScript-only "How do I..." thread
Yes, good catch. Always safer to have that net in place, just in case, right?
-
- Posts: 598
- Joined: Sun Feb 24, 2013 4:07 pm
- Location: United Kingdom
Re: ZScript-only "How do I..." thread
How would I be able to remove all ammo and weapons currently present on the map? Using this doesn't seem to work, for example;
Code: Select all
Class ActorController : Actor
{
int Monster_MaxHP;
Default
{
+NOINTERACTION
+NOTRIGGER
}
Override void Tick()
{
Actor ac;
let it = ThinkerIterator.Create();
while (ac = Actor(it.Next()))
{
if(ac.GetClass() == "Ammo" || ac.GetClass() == "Weapon")
{
ac.A_FadeOut(1.0);
}
}
Super.Tick();
}
}
-
- Posts: 85
- Joined: Sun Jun 28, 2015 3:25 pm
- Location: Frozen igloo, IN MIDDLE OF THE DESERT!!
Re: ZScript-only "How do I..." thread
small question: does SXF_TRANSFERPOINTERS transfer custom pointers?
-
-
- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: ZScript-only "How do I..." thread
Should not. Remember classes have different field sets and checking for matching fields would be a bit of an overkill.
-
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Re: ZScript-only "How do I..." thread
Thanks!
(I assume "&&(players.mo)" would do the trick? Or do I need to add a !=null after the mo?)
Beed: GetClass or CheckClass? Surely there's something in that function that lets you specify whether to check for an inheritance ancestor or not?
Questions:
How does using "GetGravity()" differ from using the word "gravity" (which seems to work)?
What's the difference between the AddInventory and GiveInventory (and GiveAmmo) functions? Does Add bypass pickup states? Do the first two ignore skill-based ammo doubling?
(I assume "&&(players.mo)" would do the trick? Or do I need to add a !=null after the mo?)
Beed: GetClass or CheckClass? Surely there's something in that function that lets you specify whether to check for an inheritance ancestor or not?
Questions:
How does using "GetGravity()" differ from using the word "gravity" (which seems to work)?
What's the difference between the AddInventory and GiveInventory (and GiveAmmo) functions? Does Add bypass pickup states? Do the first two ignore skill-based ammo doubling?
-
- Posts: 8193
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: ZScript-only "How do I..." thread
@Beed28, I have just the thing you need.
Only it's a bit ridiculous since that's actually a setup template and what not, but it works. Summon AmmoRemover.
Only it's a bit ridiculous since that's actually a setup template and what not, but it works. Summon AmmoRemover.
-
- Posts: 598
- Joined: Sun Feb 24, 2013 4:07 pm
- Location: United Kingdom
Re: ZScript-only "How do I..." thread
Ah ha, I figured it out. Cheers.
-
-
- Posts: 1384
- Joined: Sun Oct 14, 2012 1:43 am
- Location: Ukraine
Re: ZScript-only "How do I..." thread
Vaecrius wrote:Thanks!
(I assume "&&(players.mo)" would do the trick? Or do I need to add a !=null after the mo?)
Objects implicitly cast to bool like in C, yes.
Vaecrius wrote:What's the difference between the AddInventory and GiveInventory (and GiveAmmo) functions? Does Add bypass pickup states? Do the first two ignore skill-based ammo doubling?
AddInventory takes an Inventory object (possibly created using Spawn()).
GiveInventory takes a class name.