Page 4 of 97
Re: ZScript-only "How do I..." thread
Posted: Fri Jan 27, 2017 3:47 pm
by Major Cooke
Would it be better if all that just directly placed into Tick() then?
Re: ZScript-only "How do I..." thread
Posted: Fri Jan 27, 2017 4:08 pm
by Matt
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.
Re: ZScript-only "How do I..." thread
Posted: Fri Jan 27, 2017 4:17 pm
by Major Cooke
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.
Re: ZScript-only "How do I..." thread
Posted: Fri Jan 27, 2017 4:41 pm
by ZZYZX
ZScript "How do I..." thread is not going to be simple. The language itself is full of complex and/or internal stuff.
Re: ZScript-only "How do I..." thread
Posted: Fri Jan 27, 2017 5:41 pm
by Matt
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?
Re: ZScript-only "How do I..." thread
Posted: Fri Jan 27, 2017 5:44 pm
by Ed the Bat
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 all
for(int i=0;i<MAXPLAYERS;i++)
{
if(playeringame[i])
{
players[i].mo.A_GiveInventory("Clip");
}
}
Re: ZScript-only "How do I..." thread
Posted: Fri Jan 27, 2017 7:03 pm
by ZZYZX
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.
Re: ZScript-only "How do I..." thread
Posted: Fri Jan 27, 2017 7:04 pm
by Ed the Bat
Yes, good catch. Always safer to have that net in place, just in case, right?
Re: ZScript-only "How do I..." thread
Posted: Fri Jan 27, 2017 7:44 pm
by Beed28
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();
}
}
Re: ZScript-only "How do I..." thread
Posted: Fri Jan 27, 2017 7:46 pm
by TheCamaleonMaligno
small question: does SXF_TRANSFERPOINTERS transfer custom pointers?
Re: ZScript-only "How do I..." thread
Posted: Fri Jan 27, 2017 8:02 pm
by ZZYZX
Should not. Remember classes have different field sets and checking for matching fields would be a bit of an overkill.
Re: ZScript-only "How do I..." thread
Posted: Fri Jan 27, 2017 8:11 pm
by Matt
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?
Re: ZScript-only "How do I..." thread
Posted: Fri Jan 27, 2017 8:19 pm
by Major Cooke
@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.
Re: ZScript-only "How do I..." thread
Posted: Fri Jan 27, 2017 8:33 pm
by Beed28
Ah ha, I figured it out. Cheers.
Re: ZScript-only "How do I..." thread
Posted: Fri Jan 27, 2017 8:59 pm
by ZZYZX
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.