Duke4.net Forums: .CON coding help - Duke4.net Forums

Jump to content

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

.CON coding help

User is online   Striker 

  • Auramancer

#1

I'm currently working on a mod to enhance Dukematch (currently using the OldMP branch), and I'm wondering how I may be able to get the RubberCan to spawn the actor defined in the RubberCan's hitag.

This is my current code:
actor RUBBERCAN WEAK
  ifaction RUBCANDENT
  {
	ifactioncount 16
	{
  	strength 0
  	action ANULLACTION
  	break
	}
  }
  else
	ifhitweapon
  {
	ifwasweapon RADIUSEXPLOSION
	{
  	state rats
  	ifrnd 48
    	spawn BURNING
  	debris SCRAP3 12
  	ifvarn HITAG 0
  	{
		espawnvar HITAG // [SM] Spawn actor in HITAG
  	}
  	// [SM] Prepare for respawn
  	resetcount
  	cstat 32768
  	setvar CAN_BLOWNUP 1
	}
	else
  	action RUBCANDENT
  }
  else
	ifvare CAN_BLOWNUP 1
	{
		state respawnrubbercan
	}
enda


Unfortunately, the actor doesn't spawn... For example, if I set the rubbercan's hitag to 51 (COLA), no medkit spawns.

This post has been edited by Striker: 02 November 2016 - 02:16 AM

0

#2

Hey.

Just put this before your actorcode.

eventloadactor RUBBERCAN
getactor[THISACTOR].hitag HITAG
setactor[THISACTOR].hitag 0
enda



That works for me.
0

User is offline   Darkus 

#3

There is a simpler way instead of using the HITAG variable:

replace
ifvarn HITAG 0
{
        espawnvar HITAG // [SM] Spawn actor in HITAG
}


by
ifvarg sprite[THISACTOR].hitag 0
  espawnvar sprite[THISACTOR].hitag

0

User is online   Striker 

  • Auramancer

#4

View PostDarkus, on 02 November 2016 - 04:59 AM, said:

There is a simpler way instead of using the HITAG variable:

replace
ifvarn HITAG 0
{
        espawnvar HITAG // [SM] Spawn actor in HITAG
}


by
ifvarg sprite[THISACTOR].hitag 0
  espawnvar sprite[THISACTOR].hitag


That one isn't considered valid in the OldMP branch, but this worked:
  	spgethitag
  	ifvarn HITAG 0
  	{
		espawnvar HITAG
  	}


This post has been edited by Striker: 03 November 2016 - 02:01 AM

0

User is online   Striker 

  • Auramancer

#5

Now, a new question... I want to fling the spawned object in a random direction, kind of like debris... How would I go about this? This is to keep spawned objects from always dropping in the same spot and overlapping, should the rubbercan respawn and another of the object is spawned again.
0

User is offline   Danukem 

  • Duke Plus Developer

#6

You could add small +/- random values to the x and y coords of the spawned sprite (RETURN). Or you could use rotatepoint in combination with a random angle if you want to place it a consistent distance away. Or, you could add actor code to each possible spawned sprite such that it will move a short distance at a random angle and then stop if spawned by a can.
0

User is online   Striker 

  • Auramancer

#7

Came up with my own solution.

One more, any way to get the Atomic Health behavior on a new health item? (As in, health greater than 100)... or is it hard-coded no matter what?
0

User is offline   Hendricks266 

  • Weaponized Autism

  #8

getplayer[THISACTOR].i temp
getactor[temp].extra temp2
addvar temp2 50
ifvarg temp2 MAXPLAYERATOMICHEALTH
    setvar temp2 MAXPLAYERATOMICHEALTH
setactor[temp].extra temp2

2

User is offline   Danukem 

  • Duke Plus Developer

#9

View PostStriker, on 02 November 2016 - 09:49 PM, said:

Came up with my own solution.

One more, any way to get the Atomic Health behavior on a new health item? (As in, health greater than 100)... or is it hard-coded no matter what?


Again, there are multiple solutions. You could have the item manipulate the .extra member of the player sprite (notice I did NOT say the .extra member of the player struct, because there is no such thing). Or, you could have the item use cactor. Let's say the item is labeled HEALTHITEM. "cactor ATOMICHEALTH addphealth whatever cactor HEALTHITEM"
3

User is offline   Hendricks266 

  • Weaponized Autism

  #10

View PostTrooper Dan, on 02 November 2016 - 09:56 PM, said:

"cactor ATOMICHEALTH addphealth whatever cactor HEALTHITEM"

I like this for brevity and the automatic assurance of correct hardcoded behavior.
3

User is offline   Danukem 

  • Duke Plus Developer

#11

View PostHendricks266, on 02 November 2016 - 10:01 PM, said:

I like this for brevity and the automatic assurance of correct hardcoded behavior.


Also, somewhere between Ceno and Czol in the pantheon of small gods, there is a god of CON coding who gives bonus points to followers who use the 1.3 commands to get it done whenever possible. ;)
1

User is online   Striker 

  • Auramancer

#12

setplayer[THISACTOR].max_player_health 200
addphealth 2
setplayer[THISACTOR].max_player_health MAXPLAYERHEALTH

This worked.

Also, I'm wondering, are the BOTTLE actors hard-coded? I tried searching through the CON, and can't find code for these, and would like to override them somewhow. Main reason I'm doing this, is because I'm making the breakables respawn over time, to keep the map from getting too empty after a long match.

By the way, even though I'm coming up with my own solutions, your posts help me understand CON coding, also narrows things down what I should be looking at (and gives me alternatives). So thanks.

This post has been edited by Striker: 03 November 2016 - 12:21 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#13

Yeah they are hardcoded. To make them "respawn", I would try making them turn invisible when they spawn the glass, then have them reappear again after however many seconds you want. So...since they are hardcoded, you could place a few lines in EVENT_GAME to make changespritestat THISACTOR 1 (turning them into regular actors), then have actor code to make them behave like the hardcoded bottles, but turn invisible when shattered, do the lotsofglass thing, wait around and then reset to visible and blocking.
0

User is online   Striker 

  • Auramancer

#14

Got an example? I'm not sure how this would work. It would seem that EVENT_GAME executes every frame, and it doesn't seem like it would be good to check for and change the sprite stat every frame.

This post has been edited by Striker: 07 November 2016 - 08:43 PM

0

User is online   Striker 

  • Auramancer

#15

Tried this, doesn't work:

onevent EVENT_GAME
	ifactor BOTTLE4
	{
		changespritestat THISACTOR 1
		quote 127
	}
endevent

useractor notenemy BOTTLE4 WEAK state breakobject enda

0

User is online   Striker 

  • Auramancer

#16

This worked.
gamevar PROP_BLOWNUP 0 2

state respawn_prop
	ifvare PROP_BLOWNUP 1
	{
		ifcount RESPAWNPROPTIME
		{
			spawn TRANSPORTERSTAR
			strength WEAK
			cstat 257
			setvar PROP_BLOWNUP 0
		}
		break
	}
ends

state prepare_respawn
	ifvare PROP_BLOWNUP 0
	{
		action ANULLACTION
		resetcount
		cstat 32768
		setvar PROP_BLOWNUP 1
	}
ends

state prepare_respawn_hardcoded
	changespritestat THISACTOR 1
	state prepare_respawn
	setvar RETURN 1
ends

onevent EVENT_KILLIT
    ifactor BOTTLE1 { state prepare_respawn_hardcoded }
    else ifactor BOTTLE2 { state prepare_respawn_hardcoded }
    else ifactor BOTTLE3 { state prepare_respawn_hardcoded }
    else ifactor BOTTLE4 { state prepare_respawn_hardcoded }
    else ifactor BOTTLE5 { state prepare_respawn_hardcoded }
    else ifactor BOTTLE6 { state prepare_respawn_hardcoded }
    else ifactor BOTTLE7 { state prepare_respawn_hardcoded }
    else ifactor BOTTLE8 { state prepare_respawn_hardcoded }
    else ifactor BOTTLE10 { state prepare_respawn_hardcoded }
    else ifactor BOTTLE11 { state prepare_respawn_hardcoded }
    else ifactor BOTTLE12 { state prepare_respawn_hardcoded }
    else ifactor BOTTLE13 { state prepare_respawn_hardcoded }
    else ifactor BOTTLE14 { state prepare_respawn_hardcoded }
    else ifactor BOTTLE15 { state prepare_respawn_hardcoded }
    else ifactor BOTTLE16 { state prepare_respawn_hardcoded }
    else ifactor BOTTLE17 { state prepare_respawn_hardcoded }
    else ifactor BOTTLE18 { state prepare_respawn_hardcoded }
    else ifactor BOTTLE19 { state prepare_respawn_hardcoded }
endevent

actor BOTTLE1 WEAK state respawn_prop enda
actor BOTTLE2 WEAK state respawn_prop enda
actor BOTTLE3 WEAK state respawn_prop enda
actor BOTTLE4 WEAK state respawn_prop enda
actor BOTTLE5 WEAK state respawn_prop enda
actor BOTTLE6 WEAK state respawn_prop enda
actor BOTTLE7 WEAK state respawn_prop enda
actor BOTTLE8 WEAK state respawn_prop enda
actor BOTTLE10 WEAK state respawn_prop enda
actor BOTTLE11 WEAK state respawn_prop enda
actor BOTTLE12 WEAK state respawn_prop enda
actor BOTTLE13 WEAK state respawn_prop enda
actor BOTTLE14 WEAK state respawn_prop enda
actor BOTTLE15 WEAK state respawn_prop enda
actor BOTTLE16 WEAK state respawn_prop enda
actor BOTTLE17 WEAK state respawn_prop enda
actor BOTTLE18 WEAK state respawn_prop enda
actor BOTTLE19 WEAK state respawn_prop enda


This post has been edited by Striker: 08 November 2016 - 10:11 AM

0

User is online   Striker 

  • Auramancer

#17

Submitted a feature request based on one of my previous questions: http://bugs.eduke32....ails&task_id=37
0

User is online   Striker 

  • Auramancer

#18

Is there any ability to manipulate weapon behavior in the OldMP branch? I tried the weapons.con.sample file in the OldMP Branch, and it errored out.

Reason I want to do this, I want to rig the freezethrower to work like some weapons in DukePlus where you press the weapon key again to switch to another weapon, while it's technically on the same slot. I'm trying to implement my own take on the World Tour flamethrower.
0

User is offline   Danukem 

  • Duke Plus Developer

#19

View PostStriker, on 08 November 2016 - 06:46 PM, said:

Submitted a feature request based on one of my previous questions: http://bugs.eduke32....ails&task_id=37


What was the question? If you want to add more realistic physics to objects, you can do that using the existing commands. The movesprite command is pretty useful in that regard, but it's not the only method.


View PostStriker, on 10 November 2016 - 12:19 AM, said:

Is there any ability to manipulate weapon behavior in the OldMP branch? I tried the weapons.con.sample file in the OldMP Branch, and it errored out.

Reason I want to do this, I want to rig the freezethrower to work like some weapons in DukePlus where you press the weapon key again to switch to another weapon, while it's technically on the same slot. I'm trying to implement my own take on the World Tour flamethrower.


How old is the OldMP branch? You can hack subweapons into the weapon slots in any version of Eduke32 that I have ever worked with for the last 10+ years. EDIT: OK I know what that is now. It is based on a 2009 build so there shouldn't be a problem. The weapons.con sample has some newer syntax that won't compile but you don't need it.

This post has been edited by Trooper Dan: 10 November 2016 - 02:47 AM

0

User is online   Striker 

  • Auramancer

#20

It complains that EVENT_DRAWWEAPON and some other events are there.

Also, the question was this one: https://forums.duke4...post__p__265115

Does movesprite need to be called repeatedly, or can it be called once?

The wiki really needs a "Needs example" template for it's various function pages, so people can provide their own examples.

This post has been edited by Striker: 10 November 2016 - 11:33 AM

1

User is offline   Danukem 

  • Duke Plus Developer

#21

View PostStriker, on 10 November 2016 - 10:49 AM, said:

Does movesprite need to be called repeatedly, or can it be called once?

The wiki really needs a "Needs example" template for it's various function pages, so people can provide their own examples.


movesprite has to be called repeatedly, so it's not like the regular move command.
1

User is offline   Danukem 

  • Duke Plus Developer

#22

View PostStriker, on 10 November 2016 - 10:49 AM, said:

It complains that EVENT_DRAWWEAPON and some other events are there.


You should be able to use EVENT_DISPLAYWEAPON instead.
0

User is offline   Hendricks266 

  • Weaponized Autism

  #23

View PostTrooper Dan, on 10 November 2016 - 01:26 PM, said:

You should be able to use EVENT_DISPLAYWEAPON instead.

The events are not equivalent, and the event is not his problem. There must be a new command or a new structure member that was added in the seven years between r1552 and now.

Use an old weapons.con.sample, Striker.

View PostStriker, on 10 November 2016 - 10:49 AM, said:

The wiki really needs a "Needs example" template for it's various function pages, so people can provide their own examples.

The good thing about a wiki is that when you think it "really needs" something, you can add it yourself.
1

User is online   Striker 

  • Auramancer

#24

View PostHendricks266, on 10 November 2016 - 06:37 PM, said:

The events are not equivalent, and the event is not his problem. There must be a new command or a new structure member that was added in the seven years between r1552 and now.

Use an old weapons.con.sample, Striker.


The good thing about a wiki is that when you think it "really needs" something, you can add it yourself.


I'll look for an older version, then.

By the way- I thought only administrators could make new templates. Goes to show I still need to learn more about wiki editing.

This post has been edited by Striker: 10 November 2016 - 11:02 PM

0

User is offline   Darkus 

#25

Here is an example how to use movesprite: it will make the actor move toward the direction it faces, at player walk speed.

cos movex sprite[THISACTOR].ang
sin movey sprite[THISACTOR].ang
divvar movex 94
divvar movey 94
movesprite THISACTOR movex movey 0 CLIPMASK0 RETURN


For older versions, I think this should work:

getactor[THISACTOR].ang angvar

cos movex angvar
sin movey angvar
divvar movex 94
divvar movey 94
movesprite THISACTOR movex movey 0 CLIPMASK0 RETURN


You can use this to make an actor move at any angle, without changing his original direction.
0

User is offline   oldgamerz 

#26

A little tip from a novice programmer is to make sure all your coding is perfect and has no miss types, Always use correct tagging and have a beginner and an end tags for everything that needs it.. one mistake can cost you your project so make backups of the CON files often. it's pretty easy to mod duke nukem all you need is Mapster32 Eduke32 and the Duke Nukem 3D Atomic Edition grp file along side the DEF, GAME AND USER CON FILES. You could use a hacking program to edit the 3 con files but I just open then up with windows notepad. I learned this way though my manual web site designing course and I have about 4 years of on and off level building under my belt alsoPosted Image

I never really worked on REAL programming, once you have bypassed the lock on the CON files, or download then already hacked like me from steam it is pretty easy to adjust your game from there

This post has been edited by oldgamerz: 11 November 2016 - 02:25 PM

0

User is online   Striker 

  • Auramancer

#27

View Postoldgamerz, on 11 November 2016 - 02:25 PM, said:

A little tip from a novice programmer is to make sure all your coding is perfect and has no miss types, Always use correct tagging and have a beginner and an end tags for everything that needs it.. one mistake can cost you your project so make backups of the CON files often. it's pretty easy to mod duke nukem all you need is Mapster32 Eduke32 and the Duke Nukem 3D Atomic Edition grp file along side the DEF, GAME AND USER CON FILES. You could use a hacking program to edit the 3 con files but I just open then up with windows notepad. I learned this way though my manual web site designing course and I have about 4 years of on and off level building under my belt alsoPosted Image

I never really worked on REAL programming, once you have bypassed the lock on the CON files, or download then already hacked like me from steam it is pretty easy to adjust your game from there


I know all of this already, I used to make CONs for Atomic Edition, and even made a TC back in 2002 that never got released. It's just I've been out of practice for so long, and am unfamiliar with all EDuke32 has to offer as far as it's new CON functions.
0

User is online   Striker 

  • Auramancer

#28

Ok, how do I make it so a weapon doesn't use any ammo? Or use a gamevar as an ammo type? (I'm using weapons.con, tweaked to work with EDuke32-OldMP)

Also, how can I get a projectile to execute CON code? I need to script the projectile a bit.

Lastly, how can I make it so hitradius calls on a projectile impact actor grants frags?

This post has been edited by Striker: 15 November 2016 - 08:16 AM

0

User is online   Striker 

  • Auramancer

#29

I figured out some workarounds in the meantime. However, now I need to know how to make new projectiles have rotations for their sprites. I have a new missile sprite with 7 angles. EDIT: Figured that out, but now I need to know how to make it so the projectile follows the devastator behavior of having random spread, and changing offset depending on which cannon is fired.

This post has been edited by Striker: 16 November 2016 - 02:20 PM

0

User is offline   Hendricks266 

  • Weaponized Autism

  #30

It's hardcoded behavior of the RPG actor. You're probably best off keeping RPG as WEAPON7_SHOOTS and adding detection logic to eshoot a new projectile and transfer over the important properties like x/y/z/angle/xvel/zvel/owner/etc.

If you're feeling bolder, you could hunt down where in the source the behavior takes place and do your best to replicate it in CON. We may not have the necessary events to do it perfectly.
0

Share this topic:


  • 2 Pages +
  • 1
  • 2
  • 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