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

Jump to content

  • 124 Pages +
  • « First
  • 18
  • 19
  • 20
  • 21
  • 22
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

User is online   Danukem 

  • Duke Plus Developer

#571

View PostTX, on Aug 13 2010, 01:36 AM, said:

Err, he's saying he wants the actual door to be what uses the key, not any kind of separate unlocking switch. Maybe he would be best off just having the keycard pickup on top of a touchplate that unlocks the door. The key itself would never actually be used but it would give the illusion of having things the way he mentioned.


But then the player would still be holding the keycard after the door opens.
0

User is offline   Chip 

#572

View PostDeeperThought, on Aug 13 2010, 04:57 PM, said:

But then the player would still be holding the keycard after the door opens.


That's how it works in Doom, so you know what doors you can open since these doors are always locked after each time they close - preventing enemies from opening them.
Personally I wouldn't do this the way TX suggested for the purpose of enemies being able to open doors the moment you pick up the key. Instead I would make it so the player actor would always check the door / wall in front of him when space is hit - checking for a hitag (or even the lotag, actually that'll work better - give the keycard a lotag that matches all the doors' lotags it can open) on the door's sector determine what key would be needed.
But as for making the locked door open, well that is what I'll need to look into..... I have never tried anything like this so can't comment on exactly what to do but there could very well be a simple way to activate an ACTIVATOR and even lock it again or even a way to open a door regardless of locks. (Although useractors can open doors, completely ignoring locked MASTERSWITCHES.)

This post has been edited by Chip: 13 August 2010 - 09:16 AM

0

User is online   Danukem 

  • Duke Plus Developer

#573

View PostChip, on Aug 13 2010, 10:01 AM, said:

That's how it works in Doom, so you know what doors you can open since these doors are always locked after each time they close - preventing enemies from opening them.
Personally I wouldn't do this the way TX suggested for the purpose of enemies being able to open doors the moment you pick up the key. Instead I would make it so the player actor would always check the door / wall in front of him when space is hit - checking for a hitag (or even the lotag, actually that'll work better - give the keycard a lotag that matches all the doors' lotags it can open) on the door's sector determine what key would be needed.
But as for making the locked door open, well that is what I'll need to look into..... I have never tried anything like this so can't comment on exactly what to do but there could very well be a simple way to activate an ACTIVATOR and even lock it again or even a way to open a door regardless of locks. (Although useractors can open doors, completely ignoring locked MASTERSWITCHES.)


If the only problem is monsters opening the doors, then just code them not to open the doors. That would be a lot easier than the stuff you are suggesting.
0

User is offline   MIKE SIMS 

#574

Good suggestions guys, I kinda have an idea of how to get it done now. Also, kind of a noobish question for coding enemies. I've never really dabbled too much in it because I used to think it was complicated but after actually reading through it I realized it's not complicated at all. I guess I have ADD. anyways, I added a couple new actors/useractors/enemies whatever you want to call them to the con files, the only problem is they begin to roam as soon as the map is loaded, I want them to chill out until they see they player, is this because of the useractor code?
0

User is online   Danukem 

  • Duke Plus Developer

#575

View PostMIKE SIMS, on Aug 13 2010, 01:49 PM, said:

I added a couple new actors/useractors/enemies whatever you want to call them to the con files, the only problem is they begin to roam as soon as the map is loaded, I want them to chill out until they see they player, is this because of the useractor code?


Yeah, I think useractors start running code before the player sees them. You can try making them actor instead of useractor, but keep in mind that they won't be considered enemies by the game (even if you code them to attack the player) and this leads to some hardcoded differences, in addition to throwing off the kill count. I would leave them useractor enemy but code them not to do anything after initializing until they can see the player.
0

User is offline   MIKE SIMS 

#576

any tips on how to have them INIT. upon seeing the player?
0

User is offline   Chip 

#577

If you keep the actor a useractor (so its awake and you need it asleep) then you can use the method fom the previous page to control this.

Putting something like this right at the top of the actor's code should work.
ifai 0
{
ai AIACTORDOSOMETIHNG
changespritestat THISACTOR 2
setactor[THISACTOR].httimetosleep 1
}

ifai 0 means the actor hasn't started up yet so all follwing code with those { } will be initiated once, just remember to set an AI within that block to break it out of the loop (my example was ai AIACTORDOSOMETIHNG)
changespritestat set to 2 will put the actor asleep and setting httimetosleep to 1 ensures it asleep.
The actor will automatically wake up upon seeing the player and will eventually fall back to sleep again if the player is not present for a while.

This post has been edited by Chip: 14 August 2010 - 05:58 AM

0

User is offline   MIKE SIMS 

#578

Hmm. It's giving me a syntax error... blah

This post has been edited by MIKE SIMS: 15 August 2010 - 02:09 PM

0

User is offline   Awesomebob 

#579

Is it possible to get a mob to drop a keycard? I know some can drop weapons and ammo.
0

User is offline   CruX 

#580

View PostAwesomebob, on Aug 16 2010, 02:14 PM, said:

Is it possible to get a mob to drop a keycard? I know some can drop weapons and ammo.


Very possible. Open up the game con and search "state checktroophit". Under the line "ifdead" in that state, put in this
 ifspritepal 10 { espawn ACCESSCARD 
setactor[RETURN].pal 23 }


This code will make the basic liztroop spawn a yellow access card when he dies, if his pallet is 10 (dark red).
0

User is offline   darkcaleb 

#581

I got a quistion, if i may, is there a code for a grapple gun(you know something like in batman and LostPlanet)
0

User is online   Danukem 

  • Duke Plus Developer

#582

View Postdarkcaleb, on Aug 24 2010, 12:10 PM, said:

I got a quistion, if i may, is there a code for a grapple gun(you know something like in batman and LostPlanet)


AFAIK a grappling gun has never been coded for Duke. Getting the physics and look of the rope and hook right would be a lot of work. It would be much easier to make a grappling beam, with designated grappling points, like in the Metroid Prime series.
0

User is offline   darkcaleb 

#583

grappling beam would look cool 2, you know :wacko:
0

User is offline   Awesomebob 

#584

View PostDeeperThought, on Aug 24 2010, 11:15 AM, said:

AFAIK a grappling gun has never been coded for Duke. Getting the physics and look of the rope and hook right would be a lot of work. It would be much easier to make a grappling beam, with designated grappling points, like in the Metroid Prime series.


Would this be similar to the barnacle from half life opposing force (never played metroid)? Cause that sounds interesting.

This post has been edited by Awesomebob: 24 August 2010 - 02:46 PM

0

User is offline   darkcaleb 

#585

yeah i would think so? something like this maybe http://www.youtube.c...h?v=WI8Y6dimUTk
0

User is offline   XThX2 

#586

Oh damn, it's been awhile since someone last posted in here... I hope I can get a reply for this one.

I have a tough problem with differentiating trails spawned by same kind of projectile. Here's what I'm trying to do :

* I'm trying to have my shotgun have ripper projectiles, the way I made it is similar to a railgun. It's "trails" do the damage, but to prevent from all trails doing damage I make it so that there's a variable to check if the target has taken damage from that set of rail trails. It is set to 0 in a short time so the target can get hit again.

* My problem => My shotgun has pellets and each pellet works in this logic. They spawn invisible trails to do the damage, with some limited range. Even if I'm too far (but still in trail's travel range) and even if one single pellet hits, it deals full damage of all pellets. I want to differentiate the trails of one pellet from those of other pellets, so I can make other pellets deal damage; also disabling the damage factor of all trails behind one of the pellets.

I'm sorry if I couldn't explain it better, but here's my code just in case :

state finishraildamage
				getactor[THISACTOR].owner owner //hitsprite
				ifvarn owner -1
				{
					ifvarvarn owner hitsprite // making sure enemy doesn't hit itself
					{
						getactor[hitsprite].htextra DMG
						addvarvar DMG randomvar4
						ifvare picnum UFORSAKEN { divvar DMG 4 mulvar DMG 3 } ifvare picnum ZOMBIER { setvar DMG -1 setvar htflag 1405 }
						ifvare picnum APLAYER { getplayer[THISACTOR].i ID ifvarvare ID owner { setvar DMG -1 setvar htflag 1405 } }
						setactor[hitsprite].htextra DMG
						ifactor FUSTRAIL ifvarg DMG -1 { getactor[hitsprite].extra DMG ifvarg DMG 0 sound LASGUNHIT }
						setactor[hitsprite].htpicnum htflag
						setvar returnvar1 1
					}
				}
ends

state railhurtcode
ifvarn returnvar1 1
{
	getactor[THISACTOR].x x
	getactor[THISACTOR].y y
	getactor[THISACTOR].sectnum TEMP
	getactor[THISACTOR].ang TEMPT
	sin my TEMPT
	cos mx TEMPT
	getactor[THISACTOR].z z
	getplayervar[THISACTOR].power_up POWERUPMODE
		hitscan x y z TEMP mx my 0 hitsect hitwall hitsprite hitx hity hitz CLIPMASK1

	ifvarn hitsprite -1
	{
		getactor[hitsprite].picnum picnum
		switch picnum
			case LIZTROOP
			case CDEMON
			case DEVIL
			case REVENANT
			case DEMON
			case CHAINGUNNER
			case CHAINGUNNER2
			case ZOMBIEPLS
			case DOUBLEGUNNER
			case TANK
			case BOSS1
			case BOSS2
			case PAINE
			case LSOUL
			case ENLISTEE
			case BLOODSEEKER
			case ZCAPTAIN
			case SHADE
			case IONIMP
			case UFORSAKEN
			case EXTERMINATOR
			case ROBOTGUARD
			case CACODEMON
			case SHOTGUNZOMBIE
			case SENTINEL
			case FSPIDER
			case APLAYER
			case HEAVYTROOPER
			case SHADOWSHIELD
			case ZOMBIER
			case BEAST
			case SOULCUBE
			case BIGIMP
			case BRUISERDEMON

			getactorvar[hitsprite].hitbysrail temp3
			ifvare temp3 1 nullop else
			{
				ifactor RIPPERTRAIL
				{
					setvar randomvar4 0
					randvarvar randomvar4 returnvar2 // RANDOM DAMAGE
					mulvarvar randomvar4 returnvar3 // MULTIPLIER
					ifvare randomvar4 0 setvarvar randomvar4 returnvar4 // MIN DAMAGE
					ifvarand POWERUPMODE 16 mulvar randomvar4 2
					setvar htflag SHOTGUNRIPPER
					
					state finishraildamage
					
					getactor[hitsprite].x mx
					getactor[hitsprite].y my
					getactor[hitsprite].z mz
					subvar mz 4096
					espawn JIBS6
					setactor[RETURN].x mx
					setactor[RETURN].y my
					setactor[RETURN].z mz
					
					setactorvar[hitsprite].hitbysrail 1 // There needs to be a variable for all types of rails, because then all trails would deal damage and it would be immense.
				}
			}			
			break
		endswitch
	}
}
ends

state resetrailstate // Reset the rail stuff as fast as possible
getactorvar[THISACTOR].hitbysrail railtemp
ifvare railtemp 1
{
	addvar railcount2 1
	ifvarg railcount2 0
	{
		setvar railcount2 0
		setactorvar[THISACTOR].hitbysrail 0
	}
}
ends

defineprojectile SHOTGUNRIPPER PROJ_WORKSLIKE 1
defineprojectile SHOTGUNRIPPER PROJ_SOUND -1
defineprojectile SHOTGUNRIPPER PROJ_EXTRA 12
defineprojectile SHOTGUNRIPPER PROJ_TRAIL RIPPERTRAIL
defineprojectile SHOTGUNRIPPER PROJ_TXREPEAT 45
defineprojectile SHOTGUNRIPPER PROJ_TYREPEAT 45
defineprojectile SHOTGUNRIPPER PROJ_TNUM 900
// defineprojectile SHOTGUNRIPPER PROJ_DECAL -1
defineprojectile SHOTGUNRIPPER PROJ_OFFSET 14354

useractor notenemy RIPPERTRAIL TOUGH
cstat 32768
ifvarn countvar 1
{
	setvar returnvar2 28
	setvar returnvar3 8
	setvar returnvar4 16
	state railhurtcode
	setvar countvar 1
}
else
killit
enda


This post has been edited by XThX2: 25 December 2010 - 09:37 AM

0

User is online   Danukem 

  • Duke Plus Developer

#587

View PostXThX2, on Dec 25 2010, 09:37 AM, said:

Oh damn, it's been awhile since someone last posted in here... I hope I can get a reply for this one.

I have a tough problem with differentiating trails spawned by same kind of projectile. Here's what I'm trying to do :

* I'm trying to have my shotgun have ripper projectiles, the way I made it is similar to a railgun. It's "trails" do the damage, but to prevent from all trails doing damage I make it so that there's a variable to check if the target has taken damage from that set of rail trails. It is set to 0 in a short time so the target can get hit again.


I'm back from my little vacation.

I don't feel like reading all that code, but based on your description it seems to me you could just use a timer. When something gets hit, check the victim's variable and don't do damage unless it is 0. If nonzero, cause the damage and set the variable to the desired timer length. Make the victim count down the timer in its own code.
0

User is offline   CruX 

#588

Posted a tutorial over on the eDuke wiki, but since there hasn't been any tutorials over there in awhile, I'm slapping it up in this thread too, just to make sure it doesn't fly under the radar.
This is a relatively simple example that will allow the player to manually reload the pistol, like in DukePlus.

First, we'll declare the necessary gamevars...

gamevar PISTOLAMMO 0 1 
gamevar KICKBACK 0 1
gamevar PWEAPON 0 1 
gamevar PISTOLMAGAZINE 0 1
gamevar PERPLAYER1 0 1
gamevar WEAPON1_CLIP 0 0 // this last gamevar disable's the game's automatic reloading


then, under the APLAYER line in the game.con, we'll store our static variables that will be used, and code in a few functions that the reload is supposed to perform...

actor APLAYER MAXPLAYERHEALTH PSTAND 0 0
getplayer[THISACTOR].curr_weapon PWEAPON // the player's current weapon
getplayer[THISACTOR].kickback_pic KICKBACK // the frame of animation the player's weapon is at
getplayer[THISACTOR].ammo_amount 1 PISTOLAMMO // the player's pistol ammo

ifvare PWEAPON 1 { // if the player has the pistol selected...
ifvarl PISTOLMAGAZINE 1 { // and his magazine count is at zero...

getplayer[THISACTOR].weapon_pos PERPLAYER1 ifvarn PERPLAYER1 0 break // if he has a weapon that's lowering off screen, break


 else { ifvarl PISTOLAMMO 1 break else setplayer[THISACTOR].reloading 1 setplayer[THISACTOR].kickback_pic 4 } } // otherwise, if he has ammo for the pistol, start the reloading anim	  

ifvare KICKBACK 5 { // if the reloading animation is on its second frame...
ifvarg PISTOLAMMO 11 { setvar PISTOLMAGAZINE 12 } // if the player has at least twelve pistol rounds left, then set his magazine counter to a full magazine
else setvarvar PISTOLMAGAZINE PISTOLAMMO } } // otherwise set the magazine counter equal to his remaining ammo


Next we'll access the DOFIRE event, which is called if/when a weapon fires its projectile...

onevent EVENT_DOFIRE 

ifvare PWEAPON 1 { // if the player has the pistol selected when he fires a projectile...

ifvarl PISTOLMAGAZINE 1 break else { subvar PISTOLMAGAZINE 1 } } // subtract 1 from the magazine count, unless it's already at zero

endevent


In order to perform a reload, you'll need to assign it a key, which means booting out one of the game's more useless functions. In this example, it'll be the TURNAROUND key...

definegamefuncname 36 RELOAD // rename it, so it'll appear as RELOAD in the control settings menu

onevent EVENT_TURNAROUND 
setvar RETURN -1 // disable the event
ifvare PWEAPON 1 { // if the player has the pistol armed

 ifvare PISTOLMAGAZINE 12 break // and his magazine is full, break

else ifvarvare PISTOLMAGAZINE PISTOLAMMO break // if his magazine is equal to his pistol ammo, break

 else setplayer[THISACTOR].reloading 1 setplayer[THISACTOR].kickback_pic 4 } // otherwise, start the reloading sequence
endevent


Because the game's original reloading system is disabled, the player won't load in a clip when the game starts up. We'll take care of that, as well as another potential glitch, by accessing the RESET_PLAYER event.

onevent EVENT_RESETPLAYER
setvar PISTOLMAGAZINE 0 // if the player was reset to his starting position (i.e, he died), reset the clip amount to zero.
ifvare PWEAPON 1 { // if he has the pistol selected when he loads into the map...
setplayer[THISACTOR].reloading 1 
setplayer[THISACTOR].kickback_pic 4 } // start the reloading sequence.
endevent


The code that was under the APLAYER line made sure the player will automatically reload the pistol if his magazine's empty (and of course, he has the ammunition to do so), however he'll still shoot the projectile even if the magazine's empty, unless the firing key is disabled appropriately...

onevent EVENT_PRESSEDFIRE //when the player presses the fire button...
ifvare PWEAPON 1 { // and he has the pistol armed...
ifvarl PISTOLMAGAZINE 1 { setvar RETURN -1 } } // if his magazine is at zero, disable the firing key
endevent


And lastly, we're going to want the player to know what his magazine count's at, so we'll put a small counter next to the ammo amount...

onevent EVENT_DISPLAYREST
digitalnumberz 2930 280 175 PISTOLMAGAZINE 0 0 0 0 0 xdim ydim 50000 // display the magazine count at a slightly smaller size (50000) next to the ammo
endevent


This post has been edited by EmericaSkater: 26 February 2011 - 09:57 AM

0

User is online   Danukem 

  • Duke Plus Developer

#589

That looks nice, and probably cleaner and more efficient than what I cobbled together a few years ago.

One thing that people should understand is that by looking at tutorials like this they can learn a lot more than just how to add the feature in question. The basics of manipulating variables, members of the player struct, using game events and drawing to the screen are all there. There's also stuff like that in older tutorials.

That's why I get impatient with people who keep posting about one little thing they are trying to do, when I see no evidence that they are actively trying to learn by looking at existing code in released CON files, tutorials, etc.

Good job!
0

User is offline   Hendricks266 

  • Weaponized Autism

  #590

I cleaned up the formatting on your tutorial so it looks a lot nicer and is a lot more understandable.
0

User is offline   Mblackwell 

  • Evil Overlord

#591

View PostDeeperThought, on Aug 24 2010, 01:15 PM, said:

AFAIK a grappling gun has never been coded for Duke. Getting the physics and look of the rope and hook right would be a lot of work. It would be much easier to make a grappling beam, with designated grappling points, like in the Metroid Prime series.



In fact I have some old sloppy code laying around that does something like that.

One thing you could do though if you just wanted a quick grapple like say, Batman's hooks, even if you sucked at math you could just code an invisible trail on a projectile and move the player to the sprites.
0

#592

Could it be that there is something wrong with the code in the Manual Reloading Tutorial? It seems like when you reload that the magazine doesn't want to be resetted.
I perfectly included the code, no errors or whatsoever.
0

User is offline   CruX 

#593

I just copy/pasted the code to a fresh install of DN3D and it worked without a hitch. Here's a few questions (sorry if they seem patronizing, but it's the best way to figure out what went wrong)

A) Did you copy the code to a con file that's been modified? If so, there's no guarantee the code will work with other code that's already been added (not without some extra modification, at least)
B ) When you copied the code beneath the APLAYER line, did you erase the APLAYER line itself? Two APLAYER lines could cause some problems if not an error itself.
C) When you copied the code, did you erase the notes that were slashed out on the sides? Those were only meant to help you understand what each step was doing, but if they were copied in with the code, they could possibly cause some kinks.

If the magazine isn't being reloaded, then something must be going wrong beneath the APLAYER line, because that's the only line in the code that actually reloads the magazine. If none of that helps, post your con file, and I'll take a look at it. Rest assure, though, I've done enough testing to know that it works.

This post has been edited by EmericaSkater: 01 March 2011 - 03:28 AM

0

#594

Jep, I copied the code in a new fresh installed duke3D, I hadn't got 2 APLAYER lines so that wasn't the problem either. I removed the slashes like you told me, but it still got no different effect. The gamevars are on top of the game.con (under the includes). The code for the APLAYER is right under the APLAYER line. And all the rest (like the events) are in a separate con file and is included at the bottom of the game.con, maybe I am doing something wrong with that?

Thanks for helping me out :P
0

User is offline   CruX 

#595

Could be. Try pasting all the events (in the order they appear) down at the very end of the game.con. If that doesn't help, post the con itself.
0

#596

These are my con files I use.

Attached File(s)


0

User is offline   CruX 

#597

You got the code from the edited wiki entry, huh? Okay, makes sense now. Hate to pin in it on Hendricks, but when he edited the tutorial the first time, he messed up the brackets in the APLAYER line that made the clip refresh correctly.

Change the block of code that's beneath the APLAYER line to this...

  getplayer[THISACTOR].curr_weapon PWEAPON
  getplayer[THISACTOR].kickback_pic KICKBACK
  getplayer[THISACTOR].ammo_amount 1 PISTOLAMMO
  
  ifvare PWEAPON 1
  {
	ifvarl PISTOLMAGAZINE 1
	{
	  getplayer[THISACTOR].weapon_pos PERPLAYER1
	  
	  ifvarn PERPLAYER1 0 break
	  else ifvarl PISTOLAMMO 1
		break
	  else
	  {
		setplayer[THISACTOR].reloading 1
		setplayer[THISACTOR].kickback_pic 4
	  } }
	  
	  ifvare KICKBACK 5
	  {
		ifvarg PISTOLAMMO 11
		  setvar PISTOLMAGAZINE 12 
		else 
		  setvarvar PISTOLMAGAZINE PISTOLAMMO 
	  }
	}


When I opened your con file (as well as Hendrick's first edit), the code was like this - -
getplayer[THISACTOR].curr_weapon PWEAPON
  getplayer[THISACTOR].kickback_pic KICKBACK
  getplayer[THISACTOR].ammo_amount 1 PISTOLAMMO
  
  ifvare PWEAPON 1
  {
	ifvarl PISTOLMAGAZINE 1
	{
	  getplayer[THISACTOR].weapon_pos PERPLAYER1
	  
	  ifvarn PERPLAYER1 0
		break
	  else ifvarl PISTOLAMMO 1
		break
	  else
	  {
		setplayer[THISACTOR].reloading 1
		setplayer[THISACTOR].kickback_pic 4
	  }
	  
	  ifvare KICKBACK 5
	  {
		ifvarg PISTOLAMMO 11
		  setvar PISTOLMAGAZINE 12 
		else 
		  setvarvar PISTOLMAGAZINE PISTOLAMMO 
	  }
	}
  }  // this last bracket here is what did it. This belongs further up, beneath the code that sets the kickback pic to 4. With the code like this, the clip ONLY gets refreshed if the magazine count is less than zero.


You'll notice in the version of the tutorial on this thread, and the first version of the tutorial that was on the wiki, that bracket was where it belonged. Sorry for the confusion, I'll fix the wiki entry immediately.

This post has been edited by EmericaSkater: 01 March 2011 - 05:11 AM

0

#598

Oh so that was what went wrong :P Well, thanks EmericaSkater. It works perfectly now!^^
0

User is offline   Hendricks266 

  • Weaponized Autism

  #599

Sorry about that. I fixed the formatting on the brace and the level of indentation of the affected code. Try to keep it consistent.
0

User is offline   The Commander 

  • I used to be a Brown Fuzzy Fruit, but I've changed bro...

#600

Hendricks loves to mess with peoples wiki pages, ugh.
0

Share this topic:


  • 124 Pages +
  • « First
  • 18
  • 19
  • 20
  • 21
  • 22
  • Last »
  • 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