Duke4.net Forums: EDuke32 Scripting - Duke4.net Forums

Jump to content

  • 94 Pages +
  • « First
  • 91
  • 92
  • 93
  • 94
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

User is offline   jimbob 

#2761

awesome :D
0

User is offline   jimbob 

#2762

View PostDanukem, on 19 August 2021 - 12:44 PM, said:

When I get some time I will put an example on the wiki (remind me if the weekend goes by and its still not there). Otherwise, if I post some code for you here, it will just be lost in time like so many other code snippets.

EDIT: You could also start the loop with "for spritesofstatus 1" which might be easier for you to get your head around:

https://wiki.eduke32.com/wiki/For

ive gotten it to work for like 80%, the actor moves towards the right point, ignores other points with a 'wrong' hitag value and clearly reaches the destination ( it sets off an explosion ) but then just keeps going in that direction, the loop doesnt seem to restart with the new COUNT +1 :/ the code could be heavily condensed with this method though.

TEMP in this context is the waypoint, and THISACTOR is whoever needs to go to the waypoint.
state navigate // navigate to the waypoint. 
for TEMP sprofstat 1 { getactor[TEMP].hitag MHITAG  ldist xydist THISACTOR TEMP }
ifvarvare MHITAG COUNT  // make sure the waypoint he is going to is the next sequential one, so he doesnt backtrack.
                                             // IE only find nearactor with a hightag the count currently has, one at a time.
	{
       		 getactor[TEMP].x MX
       		 getactor[TEMP].y MY
       		 getactor[THISACTOR].x x
       		 getactor[THISACTOR].y y
       		 subvarvar MX x
       		 subvarvar MY y
       		 getangle ANGVAR MX MY
       		 setactor[THISACTOR].ang ANGVAR
					ifl xydist 512
					ifvarvare MHITAG COUNT  // add 1 to count only if the current waypoint has the same value as the one where the player was moving towards, 
                                        // used to prevent a retrigger causing the count to rise 1 every tick the actor is within the set distance
					{
						addvar COUNT 1
						spawn EXPLOSION2
						break // force restart of the subroutine
					}

	}
ends


maybe it needs an actor side restart? say if the xydist is lower than 512 run the state again in the actors code?

This post has been edited by jimbob: 21 August 2021 - 08:09 AM

0

User is offline   Danukem 

  • Duke Plus Developer

#2763

You should be getting the hitags of the waypoints into a per actor var using eventloadactor, and then checking the var of the waypoint against the COUNT var. Right now you are pulling the actual hitag, and I'm guessing those are all zero. To be clear: you are using getactor[TEMP].hitag when you should be using getav[TEMP].hitag.

That would explain why it keeps going straight -- you increment COUNT but then no sprites in the map actually have the next hitag of 1.

Also, you need to check for the picnum before checking tags, because right now ANY sprite of statnum 1 with the right hitag will be seen as a target.
0

User is offline   jimbob 

#2764

i have my waypoints set up like a path for the recon car, i manually set the hightag for each pathnode with the apropriate hightag starting at 0 then 1 etc.
for now my code works for like 90% again, it sees the waypoint sprite, gets the angle, moves towards it, when he reaches it does an explosion and then again just keeps going straight. i used some setactor flag to change the pal for some steps so i can visually check what the actor is doing.

anyway, here's my piece of frankencode, im going to bed, not feeling too great meaning i cant focus right. :o

onevent EVENT_LOADACTOR 
//	switch sprite[].picnum // other way of checking the picnum, seems needlessly complicated.
//		case WAYPOINT
ifactor WAYPOINT
			{	
			    getactor[].hitag MHITAG
			    getactor[].lotag MLOTAG
			    // setactor[].hitag ZERO // resetting to zero seems counter intuitive to what i need.
			    // setactor[].lotag ZERO

			
			}
//		break
//	endswitch
endevent


state navigate
for TEMP sprofstat 1   
ife sprite[TEMP].picnum 5427
			{ 
				setactor[THISACTOR].pal 2 // if found the node, turn angry and try to grab it.
				getav[TEMP].HITAG MHITAG  
				ldist xydist THISACTOR TEMP 
			}
ifvarvare MHITAG COUNT  // make sure the waypoint he is going to is the next sequential one, so he doesnt backtrack. 
//IE only find nearactor with a hightag the count currently has, one at a time.
// ife sprite[TEMP].hitag COUNT 
	{
		
       		 getactor[TEMP].x MX
       		 getactor[TEMP].y MY
       		 getactor[THISACTOR].x x
       		 getactor[THISACTOR].y y
       		 subvarvar MX x
       		 subvarvar MY y
       		 getangle ANGVAR MX MY
       		 setactor[THISACTOR].ang ANGVAR

			{ 
				getav[TEMP].HITAG MHITAG  
				ldist xydist THISACTOR TEMP 
			} 
	}
else break

					ifl xydist 512
				 	ife sprite[TEMP].hitag COUNT 
					// ifvarvare MHITAG COUNT 
// add 1 to count only if the current waypoint has the same value as the one where the player was moving towards, 
// used to prevent a retrigger causing the count to rise 1 every tick the actor is within the set distance
					{
						setactor[THISACTOR].pal 1 // visual check, does he reach the point and stay in this line of code?
// it apears not. he immediatly turns to spritepal 2 again after briefly flashing blue. 
/// IE once the nasty node has been grabbed and destroyed move to the next one.
						addvar COUNT 1
						spawn EXPLOSION2
						break // force restart of the subroutine
					}
break
ends



This post has been edited by jimbob: 22 August 2021 - 03:22 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#2765

I've got my own projects to worry about so I'm not spending any more time on this. The one piece of advice I will give you is you need to do more debugging than just spawning an explosion when the actor reaches the first waypoint. You need to be logging vars at key points to check what is going on.
0

User is offline   jimbob 

#2766

View PostDanukem, on 22 August 2021 - 04:34 PM, said:

I've got my own projects to worry about so I'm not spending any more time on this. The one piece of advice I will give you is you need to do more debugging than just spawning an explosion when the actor reaches the first waypoint. You need to be logging vars at key points to check what is going on.

adding logvars helped, managed to track down the issue and now have a working system.

state navigate
for temp sprofstat 1
ife sprite[temp].picnum WAYPOINT
                        { 
				getav[THISACTOR].COUNT COUNT 
				getactor[temp].htowner NODE 
				getactor[temp].hitag FOUNDHITAG
				ifvarvare FOUNDHITAG COUNT
					{
						addlogvar COUNT
						addlogvar FOUNDHITAG
						addlogvar NODE
					}
						ifvarvare FOUNDHITAG COUNT
						{

						        {              
						                 getactor[NODE].x MX
						                 getactor[NODE].y MY	
						                 getactor[THISACTOR].x x	
						                 getactor[THISACTOR].y y
						                 subvarvar MX x
						                 subvarvar MY y
						                 getangle ANGVAR MX MY
						                 setactor[THISACTOR].ang ANGVAR

						                        { 
										getactor[temp].htowner NODE 
						                                getav[NODE].FOUNDHITAG FOUNDHITAG 
						                                ldist xydist THISACTOR temp
						                        } 
										ifl xydist 512
						                        		{
						                                                addvar COUNT 1										
						                                        }
						        }
				
                      		  }
				
			}


ends

1

User is offline   jimbob 

#2767

quick question, how can i make an actor be affected by the masterswitch and or activator? i want my waypoint to be able to be 'switchable' for example, i want actors to stop navigating ( or waiting ) when a certain condition is not met. like a wall that has to be blown up, or a gate to be opened. imho the easiest way is to have a pal switch so when the pal is 1 the actor waits, but after doing X and the activator is activated, switch to pal 0 wich gives the OK to move ahead. right now the actors are piling up on a wall so i need a way to halt them.

another way would be a line of sight check, i tried that but for whatever reason they always seem to come back positive. :/
0

User is offline   Danukem 

  • Duke Plus Developer

#2768

https://wiki.eduke32...activatormotion

You can check for an activator being triggered using that.

Make sure that you test your ability to detect the activation separately from your code that makes the actors wait. I would use ifhitspace to trigger the waiting mechanic first just to make sure it works properly, then change it to trigger on the activator once you have it working. Otherwise if you test everything at once and then the inevitable failures occur you won't know where it is breaking.
0

User is offline   jimbob 

#2769

so activatormotion doesnt mean physical motion, but rather 'switching' motion? well even if it is i can just make a simple 2way train with it i guess. i came across that but it didnt seem like what i needed. guess i was wrong. thanks :)

This post has been edited by jimbob: 09 September 2021 - 11:02 AM

0

User is offline   Danukem 

  • Duke Plus Developer

#2770

You could also set a gamevar when a switch is used by checking its picnum, or have it set when a crack is blown up or whatever the condition is. You don't have to use checkactivatormotion, I just mentioned it because you specifically asked about activators.
1

User is offline   Salvation 

#2771

I was able to implement a scope code but my problem is that the scope won't shut down after i change my weapon.So the scope is active if i once press turnaround -key and then switch weapon and no matter does that other weapon has a scope code or not.

To shut it down i must "disable" scope by clicking turnaround off and then switch weapon.

Here is the code:
onevent EVENT_DISPLAYROOMS
ifvare currentweapon 3
//ifvare player[THISACTOR].curr_weapon 3 // if player has weapon m4 selected

 getinput[THISACTOR].bits TEMP1
 ifvarand TEMP1 268435456
 { addvar turnaround_keytime 1 }
  else
   { setvar  turnaround_keytime 0 }

ifvare turnaround_keytime 1
   { xorvar sight_on 1 }

ifvare sight_on 1
  {
   setaspect 32768 52428 // activate the 4x scope 
  }
endevent


What should i do to do following: If i have scope and i switch weapon which does not have scope code the setaspect will return as it is before scoping?
1

User is offline   Reaper_Man 

  • Once and Future King

#2772

You probably need an "else" for that very first "ifvare currentweapon 3", and/or you need more brackets around things. So something like:

onevent EVENT_DISPLAYROOMS
ifvare currentweapon 3
{
    getinput[THISACTOR].bits TEMP1
    ifvarand TEMP1 268435456
        addvar turnaround_keytime 1
    else
        setvar  turnaround_keytime 0

    ifvare turnaround_keytime 1
        xorvar sight_on 1
}
else
    setvar sight_on 0

ifvare sight_on 1
    setaspect 32768 52428 // activate the 4x scope 
endevent

0

User is offline   Salvation 

#2773

Hey, thanks! It actually worked perfectly!

However i encountered another issue...

I have also another weapon that requires scope, it is in place of the shrinker. I tried to copy-paste the code you described above with only change that currentweapon -> 6

---> Result is that now both scopes does not work. The setaspect -effect is visible only on a 1 microsecond.
I do onevent EVENT_DISPLAYROOMS
---> then i paste code
endevent

Sorry to bother you like this. I thought that this code will work in a weapon like a weapon as long as i change the currentweapon -value. So what i should do so that the code can be modified to work in a more than a one weapon.

EDIT: I FOUND THE SOLUTION!

just a quick testing and felt that this one works: Switch the place of currentweapon and put a few { } more and made a rows for currentweapon 6.
onevent EVENT_DISPLAYROOMS
{
    getinput[THISACTOR].bits TEMP1
    ifvarand TEMP1 268435456
        addvar turnaround_keytime 1
    else
        setvar  turnaround_keytime 0

    ifvare turnaround_keytime 1
        xorvar sight_on 1
}
else
    setvar sight_on 0

ifvare sight_on 1
ifvare currentweapon 3
	{
    setaspect 32768 52428 // activate the 4x scope 
	}
ifvare sight_on 1
ifvare currentweapon 6
	{
    setaspect 32768 52428 // activate the 4x scope 
	}
endevent


This post has been edited by Salvation: 24 September 2021 - 03:04 PM

0

User is offline   Reaper_Man 

  • Once and Future King

#2774

Not sure that is working the way you want, you have an orphan "else" with no "if" because you moved around code. I'm actually surprised that even compiles.

Just FYI, if you have a series of if statements with only a single command within them, you don't need brackets:

ifvare sight_on 1
    ifvare currentweapon 6
        setaspect 32768 52428


You could also tighten up your if logic at the end:

ifvare sight_on 1
{
    ifvare currentweapon 3
        setaspect 32768 52428 // activate the 4x scope 

    ifvare currentweapon 6
        setaspect 32768 52428 // activate the 4x scope 
}


I'd also argue that the key press processing being in the same block of code as the aspect ratio stuff is bad practice. You want your code to do one thing, and only one thing. So here's what I'd do:

appendevent EVENT_TURNAROUND
{
    geti .bits TEMP1
    ifand TEMP1 268435456
        add turnaround_keytime 1
    else
        set turnaround_keytime 0

    ife turnaround_keytime 1
        xor sight_on 1
}
endevent

onevent EVENT_DISPLAYROOMS
{
    ife sight_on 1
    {
        ife currentweapon 3
            setaspect 32768 52428
        else
        ife currentweapon 6
            setaspect 32768 52428
        else
            set sight_on 0
    }
}
endevent

0

User is offline   Salvation 

#2775

Sorry for my late response. I replaced my code with yours but result was that the sight stopped working. :unsure: When i press the turnaround key nothing happens. Could the issue be in my weapon code? I'm not using original renders, i'm using state -renders and scope code is quite interesting.
0

User is offline   Reaper_Man 

  • Once and Future King

#2776

You could try changing EVENT_TURNAROUND to simply:

appendevent EVENT_TURNAROUND
{
    xor sight_on 1
}
endevent


Since you don't need the additional code capturing the key press.
0

User is offline   RPD Guy 

#2777

Hello there,

How can I check if there's a wall between 2 different coords in the game? I think that is something like "ifcansee".
0

#2778

View PostRPD Guy, on 01 October 2021 - 07:52 AM, said:

Hello there,

How can I check if there's a wall between 2 different coords in the game? I think that is something like "ifcansee".

https://wiki.eduke32.com/wiki/Cansee

Do you know how to set in variables?
If you are trying to make 2 actors check if they can see each other, remember that their xyz is the bottom center of the sprite.

This post has been edited by bullerbullerseven: 01 October 2021 - 09:56 AM

0

User is offline   RPD Guy 

#2779

View Postbullerbullerseven, on 01 October 2021 - 09:54 AM, said:

https://wiki.eduke32.com/wiki/Cansee

Do you know how to set in variables?
If you are trying to make 2 actors check if they can see each other, remember that their xyz is the bottom center of the sprite.



Thanks mr. bullerbullerseven.
That's just what I needed.
0

User is offline   Reaper_Man 

  • Once and Future King

#2780

Is there a simple/clean way of detecting when a switch triggers a given channel?

I thought I remember some event for this. EVENT_MOVEEFFECTORS and EVENT_MOVESECTORS come close, but they relate to literal motion I'm really just looking for the actual switch talking on that channel. checkactivatormotion also seems to relate to physical motion.

This post has been edited by Reaper_Man: 14 October 2021 - 05:23 PM

0

User is online   Hendricks266 

  • Weaponized Autism

  #2781

If you can navigate the source code and find the place where that is handled, we might be able to figure something out.
0

User is offline   Reaper_Man 

  • Once and Future King

#2782

Already ahead of you. Working on AWOL and having to look into weird behaviors, I have become more familiar with the source code than I ever thought I would :lol:

I think this is happening in sector.cpp at P_ActivateSwitch, line 1227. Lines at 1480 is where the switches are told to perform the G_OperateActivators / G_ForceFields / G_MasterSwitches (with G_OperateRespawns already happening within G_OperateActivators at line 1061), and then play their sounds. I think an Event could be triggered here carrying the Lotag channel that is currently "talking". It looks like P_ActivateSwitch already handles a return 0 state, so we could even set RETURN 0 to cancel the switch. Although I didn't look into what is calling P_ActivateSwitch to see what returning 0 actually does or breaks. I assume just switches with invalid or orphaned Lotags.
0

User is offline   jimbob 

#2783

is there an easy way to make an enemy impervious to bullet weapons? i want to program a tank, so obviously i want bullets to do no damage. the hard way would be to add the health taken away back to the actor immediatly, but since there are a few types of bullet weapons it would require too much math. and obviously ifwasweapon shotspark1 { break } wont work as it still detracts damage.
0

#2784

View Postjimbob, on 19 October 2021 - 02:36 AM, said:

is there an easy way to make an enemy impervious to bullet weapons? i want to program a tank, so obviously i want bullets to do no damage. the hard way would be to add the health taken away back to the actor immediatly, but since there are a few types of bullet weapons it would require too much math. and obviously ifwasweapon shotspark1 { break } wont work as it still detracts damage.

Bullets all share the same SHOTSPARK1 actor if i remember correctly.
HTpicnum checks the ID of the projectile that hit you, so you can get the picnum of the ID.
HTowner gets the id of the enemy that shot at you, so if you need to do some more digging to figure out if it was a bullet, you can see what the enemy picnum was and see if it's an enemy that shoot bullets.

This post has been edited by bullerbullerseven: 19 October 2021 - 07:20 AM

0

User is offline   jimbob 

#2785

there's this bit of code from the wiki page, but that refers to the actor itself, not sure if it works when i refer to the player doing the damage to the actor.
getactor[THISACTOR].htextra TEMP

ifvarg TEMP 0                            // if the actor is set to take some damage from a weapon...
{
  getactor[THISACTOR].htowner TEMP      // gets the owner of the weapon into TEMP
  ifvarvare TEMP THISACTOR              // if the owner of the weapon IS this actor
    setactor[THISACTOR].htextra 0       // set the damage to 0
}

0

User is offline   Reaper_Man 

  • Once and Future King

#2786

No, check .htpicnum. All hitscan damage shows up as SHOTSPARK1. You only care about .htowner if you care about who the damage is coming from (IE you want bullet damage to count from some sources but not others)

ife sprite[].htpicnum SHOTSPARK1
    seta .htextra -1


Set this before the "ifhitweapon" call.

That example is interesting, in that they set the damage to 0 instead of -1, since 0 will still trigger "ifhitweapon".

This post has been edited by Reaper_Man: 19 October 2021 - 09:21 AM

1

User is offline   jimbob 

#2787

that seems to work just fine, and much simpler than what i was thinking.
0

User is offline   jimbob 

#2788

for some reason whenever i hit the boss character with a rocket that does a good amount of damage the game hangs with this bit of code and i cant figure out why, i added a check to solve the problem but it does nothing
this bit of code came pretty much straight from the package that was shared here for making a lifebar, i just reworked into an enemy lifebar. the boss has 5000 health. and the code is in event EVENT_DISPLAYREST

ifvare BOSSFIGHT2 1
{
getactor[PANZER].extra temp // get the boss'health
divvar temp 50 // divide the health so the lifebar isnt rediculously long. 
	{   
		ifvarl temp 10 { break } else // if health lower than 10 stop doing this code
		setvar xvar 75 // set starting x coordinate   
		whilevarn temp 0  // loop for each hitpoint       
		{   
		rotatesprite xvar 16 49152 0 199 0 2 16 0 0 xdim ydim // draws HEALTHBAR
		screentext BIGALPHANUM 160 14 32768 0 0 132 0 0 0 0 5 16 1 2 1056768 0 0 xdim ydim
		addvar xvar 2 // move to the right  
		subvar temp 1 // next hitpoint  		

		}
	}

}


hmm, this test it went perfectly, maybe because i move iftempl 10 before the actual code instead of after, maybe luck, maybe its a rounding error that happens when the vehicle gets hit and does an odd number of damage.

speaking of the vehicle, i want it to be unable to move into sectors that have an X amount of height difference, for the player you can use autostep, but i cant find a similar command for actors. if there is non i will just make the actor stayput and map accordingly.

This post has been edited by jimbob: 28 October 2021 - 01:55 AM

0

User is offline   Danukem 

  • Duke Plus Developer

#2789

I don't know if this will help, but a few things in that bothered me. You had some braces doing nothing, and were checking the PANZER var without regard to whether it still contained a valid sprite ID. Typically vars for sprite IDs get set to -1 when the sprite is not in the map.

I'm going to assume this code is in a state and is not directly part of a display event, because if it were then the "break" would cause the rest of the event code to abort as well.


ifvare BOSSFIGHT2 1
ifn PANZER -1
ifge sprite[PANZER].extra 0
{
     getactor[PANZER].extra temp // get the boss' health
     divvar temp 50 // divide the health so the lifebar isnt ridiculously long.
     ifvarl temp 10 break  // if health lower than 10 stop doing this code
     setvar xvar 75 // set starting x coordinate   
     whilevarn temp 0  // loop for each hitpoint       
     { 
          rotatesprite xvar 16 49152 0 199 0 2 16 0 0 xdim ydim // draws HEALTHBAR
          screentext BIGALPHANUM 160 14 32768 0 0 132 0 0 0 0 5 16 1 2 1056768 0 0 xdim ydim
          addvar xvar 2 // move to the right  
          subvar temp 1 // next hitpoint  	
     }	
}


0

User is offline   jimbob 

#2790

the code is actually not in a state, but directly in the event... so that might be one of the problems. i use a similar piece of code for the first bossfight, and if that actor is not in the map, his health wont show and would break.. wich is probably why my bar wasnt showing up properly.

just tested it, remmed the ifvar templ 10 line and it seems to work just fine, will do some aditional testing but so far this seems to be working great, thanks :)
the ifvar templ 10 is redundant anyway with the ifge sprite[PANZER].extra 0 line

This post has been edited by jimbob: 28 October 2021 - 10:18 AM

0

Share this topic:


  • 94 Pages +
  • « First
  • 91
  • 92
  • 93
  • 94
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options