"How do I ZScript?"

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.

Re: ZScript-only "How do I..." thread

Postby Major Cooke » Fri Jan 27, 2017 3:47 pm

Would it be better if all that just directly placed into Tick() then?
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ZScript-only "How do I..." thread

Postby Matt » Fri Jan 27, 2017 4:08 pm

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?
From Graf's last comment it seems we just need to figure out what all this means from the Wiki:
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);
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.


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.
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: ZScript-only "How do I..." thread

Postby Major Cooke » Fri Jan 27, 2017 4:17 pm

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.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ZScript-only "How do I..." thread

Postby ZZYZX » Fri Jan 27, 2017 4:41 pm

ZScript "How do I..." thread is not going to be simple. The language itself is full of complex and/or internal stuff.
User avatar
ZZYZX
le chat du rabbin
 
 
 
Joined: 14 Oct 2012
Location: Ukraine
Discord: ZZYZX#1394
Github ID: jewalky

Re: ZScript-only "How do I..." thread

Postby Matt » Fri Jan 27, 2017 5:41 pm

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?
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: ZScript-only "How do I..." thread

Postby Ed the Bat » Fri Jan 27, 2017 5:44 pm

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?

Now that one, I can answer! In this example, let's say I want to give every player one Clip:
Code: Select allExpand view
for(int i=0;i<MAXPLAYERS;i++)
{
   if(playeringame[i])
   {
      players[i].mo.A_GiveInventory("Clip");
   }
}
User avatar
Ed the Bat
I'm tired. I want to go home.
 
Joined: 03 May 2012
Location: Maryland, US

Re: ZScript-only "How do I..." thread

Postby ZZYZX » Fri Jan 27, 2017 7:03 pm

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.
User avatar
ZZYZX
le chat du rabbin
 
 
 
Joined: 14 Oct 2012
Location: Ukraine
Discord: ZZYZX#1394
Github ID: jewalky

Re: ZScript-only "How do I..." thread

Postby Ed the Bat » Fri Jan 27, 2017 7:04 pm

Yes, good catch. Always safer to have that net in place, just in case, right?
User avatar
Ed the Bat
I'm tired. I want to go home.
 
Joined: 03 May 2012
Location: Maryland, US

Re: ZScript-only "How do I..." thread

Postby Beed28 » Fri Jan 27, 2017 7:44 pm

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 allExpand view
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();
   }
}
User avatar
Beed28
Making entire worlds bounce up and down.
 
Joined: 24 Feb 2013
Location: United Kingdom

Re: ZScript-only "How do I..." thread

Postby TheCamaleonMaligno » Fri Jan 27, 2017 7:46 pm

small question: does SXF_TRANSFERPOINTERS transfer custom pointers?
User avatar
TheCamaleonMaligno
I eat little babies - Mathias Bossi
 
Joined: 28 Jun 2015
Location: Frozen igloo, IN MIDDLE OF THE DESERT!!

Re: ZScript-only "How do I..." thread

Postby ZZYZX » Fri Jan 27, 2017 8:02 pm

Should not. Remember classes have different field sets and checking for matching fields would be a bit of an overkill.
User avatar
ZZYZX
le chat du rabbin
 
 
 
Joined: 14 Oct 2012
Location: Ukraine
Discord: ZZYZX#1394
Github ID: jewalky

Re: ZScript-only "How do I..." thread

Postby Matt » Fri Jan 27, 2017 8:11 pm

Thanks!
(I assume "&&(players[i].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?
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: ZScript-only "How do I..." thread

Postby Major Cooke » Fri Jan 27, 2017 8:19 pm

@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.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: ZScript-only "How do I..." thread

Postby Beed28 » Fri Jan 27, 2017 8:33 pm

Ah ha, I figured it out. Cheers.
User avatar
Beed28
Making entire worlds bounce up and down.
 
Joined: 24 Feb 2013
Location: United Kingdom

Re: ZScript-only "How do I..." thread

Postby ZZYZX » Fri Jan 27, 2017 8:59 pm

Vaecrius wrote:Thanks!
(I assume "&&(players[i].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.
User avatar
ZZYZX
le chat du rabbin
 
 
 
Joined: 14 Oct 2012
Location: Ukraine
Discord: ZZYZX#1394
Github ID: jewalky

PreviousNext

Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests