Use DamageFunction instead of Damage as the property.ramon.dexter wrote:How do I use random number in Damage property of projectile? When i put in 'random(1,10);', it returns error, that even numbers has to be used
"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: 5023
- Joined: Sun Nov 14, 2010 12:59 am
Re: "How do I ZScript?"
-
- Posts: 8193
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: "How do I ZScript?"
Just be warned, changing the damage from then on out will remove the damagefunction and it'll be based on damage*1d8! At least that's what it looks like from the source code.
-
- Posts: 344
- Joined: Thu May 07, 2015 4:24 pm
- Graphics Processor: nVidia with Vulkan support
- Location: New England Area, USA
Re: "How do I ZScript?"
If I'm trying to make an inventory item that should only be picked up if, say, the player doesn't have item X in his inventory, which virtual function should I override - HandlePickup, TryPickup, TryPickupRestricted, CanPickup, or ShouldStay?
I've been trying HandlePickup already, but even when it returns false it seems to get added to the inventory...
I've been trying HandlePickup already, but even when it returns false it seems to get added to the inventory...
-
- Posts: 111
- Joined: Wed Jun 15, 2016 2:49 pm
Re: "How do I ZScript?"
Is it possible to detect multiple simultaneous key-presses inside of InputProcess? Set booleans when buttons are pressed and remove when released—Thanks Gutawer
Also is it possible to register an EventHandler while the game is running? I recall seeing ZZYZX mention this, but I can't seem to figure it out.
Any help would be appreciated
EDIT: Also, is it not possible to put a constant array in a struct?
EDIT 5: Can I access a variable in an EventHandler from my StatusBar?
EDIT 2: Is there no way to do exponents? exp(x) is only e^x ** Operator—Thanks Gutawer again
EDIT 3: I guess I know nothing. Does cos(x) have a relatively significant performance cost like sqrt(x)? Don't bother micro-optimizing—Thanks Gutawer again
EDIT 4: And is there a way to get pi? Set it as a constant because it's close enough—Thanks Apeirogon
Also is it possible to register an EventHandler while the game is running? I recall seeing ZZYZX mention this, but I can't seem to figure it out.
Any help would be appreciated
EDIT: Also, is it not possible to put a constant array in a struct?
EDIT 5: Can I access a variable in an EventHandler from my StatusBar?
EDIT 2: Is there no way to do exponents? exp(x) is only e^x ** Operator—Thanks Gutawer again
EDIT 3: I guess I know nothing. Does cos(x) have a relatively significant performance cost like sqrt(x)? Don't bother micro-optimizing—Thanks Gutawer again
EDIT 4: And is there a way to get pi? Set it as a constant because it's close enough—Thanks Apeirogon
Last edited by ZippeyKeys12 on Sun Nov 05, 2017 7:45 pm, edited 2 times in total.
-
- Posts: 1606
- Joined: Mon Jun 12, 2017 12:57 am
Re: "How do I ZScript?"
TL:DR Just define its as constant.ZippeyKeys12 wrote: EDIT 4: And is there a way to get pi?
Pi is irrational transcendent number and cant be evaluate like 2+2, just approximately defined to some decimal number. Even if you planing use eulers identity to find n roots of number (why?),pi=3.141596 and e=2.718281828 would be more than satisfaing aproximation, because other number in gzdoom may, and would, be defined with musch less precision.
How make a_chase function more "intelligent", because, as example, monster hard to find entrance into small corridor where stand player?
-
- Posts: 111
- Joined: Wed Jun 15, 2016 2:49 pm
Re: "How do I ZScript?"
If you're making a map then check this out:viewtopic.php?f=105&t=58168 else idk maybe try using hitscans or actors to try and plot out the map and try every path to find the player?Apeirogon wrote:How make a_chase function more "intelligent", because, as example, monster hard to find entrance into small corridor where stand player?
-
- Posts: 469
- Joined: Sat Apr 16, 2016 6:01 am
- Preferred Pronouns: She/Her
Re: "How do I ZScript?"
2: Use the ** operator.ZippeyKeys12 wrote: EDIT 2: Is there no way to do exponents? exp(x) is only e^x
EDIT 3: I guess I know nothing. Does cos(x) have a relatively significant performance cost like sqrt(x)?
3: Even sqrt() doesn't have a massive performance impact unless you're calling it a lot, so I wouldn't assume that cos() has any significant performance impact either. Don't try and optimise until your code is running slowly, because otherwise you get messy micro-optimised code which is a pain to read.
-
- Posts: 1558
- Joined: Tue Oct 20, 2015 12:50 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Kozolupy, Bohemia
Re: "How do I ZScript?"
OK, how does replaces excatly work in zscript?
Let's say, I have a weapon, here:
But I can find rocket launcher where it should be in map (better said: It is not replaced). Relacers for rocketammo works as expected, replacers for other weapons work as expected, but the replacer for rocketlauncher just dont work. What am I doing wrong?
Let's say, I have a weapon, here:
Code: Select all
class staffBlaster : Weapon replaces RocketLauncher
-
- Posts: 5023
- Joined: Sun Nov 14, 2010 12:59 am
Re: "How do I ZScript?"
Are you loading other mods with yours that replace the rocket launcher (especially ones which to so via DECORATE)?
-
- Posts: 1558
- Joined: Tue Oct 20, 2015 12:50 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Kozolupy, Bohemia
Re: "How do I ZScript?"
No. I'm testing the mod only with basic doom2. And it really suprises me, since the shotgun IS replaced, the armor is replaced, but the rocketlauncher sits there and smiles on me
-
- Posts: 111
- Joined: Wed Jun 15, 2016 2:49 pm
Re: "How do I ZScript?"
Is your rocket launcher in a separate file that you forgot to #include?
Maybe something is left over in AutoLoad?
Maybe something is left over in AutoLoad?
-
- Posts: 1558
- Joined: Tue Oct 20, 2015 12:50 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Kozolupy, Bohemia
Re: "How do I ZScript?"
Yup. forget to remove the rocketlaucnher replacer/remover that I put in and completely forgot about
-
- Posts: 186
- Joined: Tue May 02, 2017 3:54 pm
Re: "How do I ZScript?"
What is the practical effect of the identifier in the random number functions (wiki)?
-
- Posts: 111
- Joined: Wed Jun 15, 2016 2:49 pm
Re: "How do I ZScript?"
From what I can tell, it seems as if running random functions under a specific identifier could somehow bias future random functions with that same identifier. So I supposed if one needed a more independent random value they would use a different identifier?Rip and Tear wrote:What is the practical effect of the identifier in the random number functions (wiki)?
Gonna have to see what someone more informed has to say, I'm interested now.
-
- Posts: 469
- Joined: Sat Apr 16, 2016 6:01 am
- Preferred Pronouns: She/Her
Re: "How do I ZScript?"
The identifier determines which FRandom object is returned internally when parsing the random functions - essentially, each FRandom object is a random number generator which holds an array of "states" (20 states, if interpreted as 32-bit integers). When an RNG function is called, the internal array index is incremented, and the state at that index is returned as a random number. Each FRandom object's states are seperate from the others, meaning that RNGs with different objects act independently of each other. So:
should act the same as:
Code: Select all
int num1 = random(0, 10);
int num2 = random(0, 10);
Console.printf("%d, %d", num1, num2);
Code: Select all
int num1 = random(0, 10);
int throwaway = random[whatever](0, 10);
int num2 = random(0, 10);
Console.printf("%d, %d", num1, num2);