Is it possible to change actor properties, specifically player's? I tried using variables but since I can't initialize them on the same line I declare them, it throws an error.
The goal here was to ensure that I can change player speed on specific inventory and conditions but I have other plans.
Changing player properties dynamicaly in 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: 1730
- Joined: Tue Mar 22, 2011 11:54 pm
-
- 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: Changing player properties dynamicaly in zscript
It is possible (and speed specifically is a simple "speed=0.0001" or whatever) but it really depends on what exactly you're trying to do and there's no way to figure out why you'd be getting an error without more information.
-
- Posts: 1730
- Joined: Tue Mar 22, 2011 11:54 pm
Re: Changing player properties dynamicaly in zscript
I'm trying to dynamically adjust the following:
from both interacting with specific actors with the use key or if another actor has specific booleans triggered true or false.
initially, I thought of replacing (value here) with double variable like so:
and be able to manipulate the variables like this
(What I wanted to achieve, will most likely not work)
but as variables can not be initialized after declared unless it's a constant or meta, which defeats the point, how do I get around this?
Code: Select all
Player.ForwardMove (value here);
Player.SideMove (value here);
initially, I thought of replacing (value here) with double variable like so:
Code: Select all
double test = 4.0;
default{
Player.ForwardMove test;
Player.SideMove test;
}
(What I wanted to achieve, will most likely not work)
Code: Select all
override bool used(Actor user)
{
holdCounter++;
user.A_GiveInventory ("WeaponInstall" , 1);
user.test = 1.0;
if(holdCounter >= 100)
{
user.A_TakeInventory ("WeaponInstall" , 0);
Super.touch(user);
}
if (user.player) { user.player.usedown = false; }
return true;
}
-
- Posts: 1606
- Joined: Mon Jun 12, 2017 12:57 am
Re: Changing player properties dynamicaly in zscript
You must use if you define new variable on any actor.
Because, in simple, engine know about existing of this new variable on/at new actor class, but require from you to confirm that you mean this right variable on this actor. Or something like that.
It just works this way...
Code: Select all
actor class name which have new defined variable(pointer to actor with that variable). variable name
Because, in simple, engine know about existing of this new variable on/at new actor class, but require from you to confirm that you mean this right variable on this actor. Or something like that.
It just works this way...
-
- 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: Changing player properties dynamicaly in zscript
........I have no idea what you're trying to accomplish or what means you are trying to accomplish it with.
What is the specific desired end result?
EDIT: If the need is to just modify the player's forwardmove and sidemove, the variables are playerpawn.[forward/side]move[1/2], 1 being walk and 2 being run:
What is the specific desired end result?
EDIT: If the need is to just modify the player's forwardmove and sidemove, the variables are playerpawn.[forward/side]move[1/2], 1 being walk and 2 being run:
Code: Select all
class foof:explosivebarrel
{
bool togged;
override bool used(actor other)
{
let pp=playerpawn(other);
if(pp)
{
if(!togged)
{
A_Log("stupid speed enabled");
togged=true;
pp.sidemove1=0.1;
pp.sidemove2=0.2;
pp.forwardmove1=3.5;
pp.forwardmove2=0.3;
}
else
{
A_Log("stupid speed disabled");
togged=false;
pp.sidemove1=1.;
pp.sidemove2=1.;
pp.forwardmove1=1.;
pp.forwardmove2=1.;
}
}
return false;
}
}
-
- Posts: 1730
- Joined: Tue Mar 22, 2011 11:54 pm
Re: Changing player properties dynamicaly in zscript
oh so THAT's how you do it, I was wondering if I did somethign wrong, I thought the variable was just playerpawn.[forward/side]move. I forgot 2 varables can be stuffed in the thing, is there a list of these somewhere I can find?Matt wrote:EDIT: If the need is to just modify the player's forwardmove and sidemove, the variables are playerpawn.[forward/side]move[1/2], 1 being walk and 2 being run
EDIT: Never mind, found it in player pawn, thanks for pointing me in the right direction, too bad there is none for crouch height.
Thanks matt! Crab walking gun mode here I come!
This was meant to disable movement when interacting with the item, interaction works, just not the disabling movement part. But i've had more ideas with the concept and wanted to know how to manipulate player variablesMatt wrote:........I have no idea what you're trying to accomplish or what means you are trying to accomplish it with.
Also, what does foof: do to the barrel?
-
- Posts: 1235
- Joined: Thu Nov 06, 2014 1:53 pm
Re: Changing player properties dynamicaly in zscript
That's the class name and the inheritance symbol.insightguy wrote:Also, what does foof: do to the barrel?
-
- 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: Changing player properties dynamicaly in zscript
I only knew where to find that because when PlayerThink() was first ported to ZScript I spent a lot of time going through the GZDoom source on Github to find out what did or did not affect movement.is there a list of these somewhere I can find?