[Solved] [Script] Always "thrust away"

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Tormentor667
Posts: 13554
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

[Solved] [Script] Always "thrust away"

Post by Tormentor667 »

I have a question and maybe I simply don't get how things are working.... I have various forcefields in a map. When the player touches it, I want the forcefield to hurt the player and always thrust the player away in the opposite direction, no matter what the forcefield line is facing at. So I made a generic script that looks like this:

Code: Select all

script 400 (void)
{
    Thing_Damage(0, 5, 0);
    ThrustThing(-(GetActorAngle(0)), 32, 0, 0);
    delay(10);
}
What I want to do?

Damage the player, get his angle, reverse it and thrust him away. Unfortunatly it doesnt work so I guess I made something wrong :P
Last edited by Tormentor667 on Wed Jul 29, 2015 1:50 pm, edited 1 time in total.
User avatar
Isle
Posts: 687
Joined: Fri Nov 21, 2003 1:30 am
Location: Arizona, USA

Re: [Script] Always "thrust away"

Post by Isle »

don't negate the angle to get the opposite direction, add 256 to it. also, the value from getactorangle is a fixed point angle and thrustthing uses a byte angle, you have to convert it. the easiest way is with a bit shift: getactorangle(0)>>8
User avatar
MaxED
Posts: 2246
Joined: Tue Feb 28, 2012 12:55 pm

Re: [Script] Always "thrust away"

Post by MaxED »

Code: Select all

ThrustThing(-(GetActorAngle(0)), 32, 0, 0);
That will thrust player into the forcefield if he backpedals into it...
User avatar
Tormentor667
Posts: 13554
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Re: [Script] Always "thrust away"

Post by Tormentor667 »

Isle wrote:don't negate the angle to get the opposite direction, add 256 to it. also, the value from getactorangle is a fixed point angle and thrustthing uses a byte angle, you have to convert it. the easiest way is with a bit shift: getactorangle(0)>>8
Would you mind giving me a actual script example for that? I really have no idea how to do what you talk about :)
User avatar
cocka
Posts: 1520
Joined: Sat Jul 02, 2011 7:21 am
Location: Hungary

Re: [Script] Always "thrust away"

Post by cocka »

Code: Select all

script 400 (void)
{
    int angle = ((GetActorAngle(0) >> 8) + 128) % 256;
    DamageThing(5, 0);
    ThrustThing(angle, 32, 1, 0);
    delay(10);  // Why do you need this?
}
User avatar
edward850
Posts: 5886
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: [Script] Always "thrust away"

Post by edward850 »

Just to note, as MaxED pointed out, that's still not away. The player angle does not relate to the line at all, so you need to pass the angle from the line.
User avatar
cocka
Posts: 1520
Joined: Sat Jul 02, 2011 7:21 am
Location: Hungary

Re: [Script] Always "thrust away"

Post by cocka »

Yeah, I forgot to mention that it only works properly if the player's angle points towards the thrusting wall perpendicularly.
User avatar
MaxED
Posts: 2246
Joined: Tue Feb 28, 2012 12:55 pm

Re: [Script] Always "thrust away"

Post by MaxED »

GetLineAngle(int tag) would be really welcomed here... Is there a slightest chance such a thing would be added if I request for it politely?..
User avatar
MaxED
Posts: 2246
Joined: Tue Feb 28, 2012 12:55 pm

Re: [Script] Always "thrust away"

Post by MaxED »

Well, here's example which works, but requires a bit more setup (you need to pass byte angle of the line to the script).

Code: Select all

script 400 (int byteangle)
{
    Thing_Damage(0, 5, 0);
    if(LineSide() == LINE_BACK) byteangle += 128;
    ThrustThing(byteangle, 8, 0, 0);
    delay(10);
}
Attachments
forcefield.wad
(6.79 KiB) Downloaded 28 times
User avatar
Kappes Buur
 
 
Posts: 4167
Joined: Thu Jul 17, 2003 12:19 am
Graphics Processor: nVidia (Legacy GZDoom)
Location: British Columbia, Canada
Contact:

Re: [Script] Always "thrust away"

Post by Kappes Buur »

See also the forcefields in
and
User avatar
Tormentor667
Posts: 13554
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Re: [Script] Always "thrust away"

Post by Tormentor667 »

MaxED wrote:Well, here's example which works
Thanks, that works well :)
Locked

Return to “Editing (Archive)”