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

Jump to content

  • 124 Pages +
  • « First
  • 76
  • 77
  • 78
  • 79
  • 80
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

#2297

 Trooper Dan, on 14 August 2018 - 11:16 AM, said:

This should work:

appendevent EVENT_GAME

     ifactor HOLODUKE ifn sprite[].statnum 1 changespritestat THISACTOR 1

endevent



I should say that I'm using the eduke old-mp build, and maybe that's why it wont run your code.

GAME.CON: In event `EVENT_GAME':
GAME.CON:37: error: expected a keyword but found `ifn'.
GAME.CON:37: error: expected a keyword but found `sprite'.
GAME.CON:37: error: expected a keyword but found `.statnum'.
GAME.CON:37: error: expected a keyword but found `1'.


EDIT: I've got it to work - but thanks! I was basically doing the same thing, but under actor holoduke (and that just doesn't work :-P )

This post has been edited by thisbecasper: 14 August 2018 - 11:53 AM

0

User is offline   Danukem 

  • Duke Plus Developer

#2298

Yeah, changing the statnum to 1 in the actor code is pointless since the actor code doesn't run unless the statnum is already 1.
0

#2299

Now another thing: I want the spawners to only spawn a monster by a chance, but it seems the spawn pattern is the same (I have multiple spawners, and each has a 50% chance to spawn a monster every fifth second). Somehow it makes sense, that the rng is doing the same exact thing every run, but I really need some "real" randomness...
0

User is offline   Danukem 

  • Duke Plus Developer

#2300

View Postthisbecasper, on 14 August 2018 - 02:42 PM, said:

Now another thing: I want the spawners to only spawn a monster by a chance, but it seems the spawn pattern is the same (I have multiple spawners, and each has a 50% chance to spawn a monster every fifth second). Somehow it makes sense, that the rng is doing the same exact thing every run, but I really need some "real" randomness...


The only way I know how to "fix" that also breaks sync in multiplayer.
1

#2301

Is there a way for duke to be ignored by monsters? In this coop game mode, when one dies, he will stay on the ground, dead, waiting for someone to revive him. I'd like the monsters to switch from the duke they killed to the other player naturally...
0

#2302

And lastly, the FFIRE doesn't do what it should I think... I set it to 0, but I can still kill my bot in coop mode. Doesn't "friendly fire off" work on bots, or am I doing something wrong here?
0

User is offline   Danukem 

  • Duke Plus Developer

#2303

View Postthisbecasper, on 15 August 2018 - 05:38 PM, said:

Is there a way for duke to be ignored by monsters? In this coop game mode, when one dies, he will stay on the ground, dead, waiting for someone to revive him. I'd like the monsters to switch from the duke they killed to the other player naturally...


The difficulty is that all of the monster movement commands are oriented to the nearest player, even if the player is dead. A properly coded monster will check for "ifp palive" before firing, but they will generally still seek the nearest player regardless.

I guess the easiest way would be to insert some code into the monsters via EVENT_GAME. The code would check for if the nearest player is dead, and if so would change the angle of the monster so that it moved in a more appropriate direction. Depending on how much work you wanted to put into it, you could do something simple like make the monster walk off in a random direction, or you could write your own pathfinding code.

Here's a very simple and untested attempt at what I'm talking about:

move ENEMYWANDERVELS 160

appendevent EVENT_GAME

switch sprite[].picnum
case LIZTROOP
case PIGCOP
case LIZMAN
// keep adding cases...
     ifp palive nullop
     else ifmultiplayer
     {
           ifmove ENEMYWANDERVELS nullop else
              move ENEMYWANDERVELS randomangle
     }
     break
endswitch
endevent


Note: you may need to make adjustments if you are using an old version of EDuke32 that doesn't allow the abbreviated CON commands

This post has been edited by Trooper Dan: 16 August 2018 - 04:45 PM

1

#2304

Thank you very much for your replies so far, I've been working on this survival mod a lot lately, and I have to get the basic elements working properly before I add more "features", so I haven't added your code yet, but looks good... I'm having a rather odd problem here: My monsters spawn from the keycard actor. Different places on the map, several keycards has been placed so that monsters come from all directions. My problem is, that even though the keycards are placed at least 2400 mapster units away from forcefield/cieling door, they go right through it and gets stuck there, making it impossible to complete the round, because the monsters are trapped in a place that can only be unlocked later in the game. It seems that when the monsters spawn, they immediately walk towards a player, and doesn't get stopped by a door or forcefield. Any ideas to prevent this nonsense? I've tried to move the spawners further and further away from the doors and forcefields, but that's not helping either...
0

User is offline   Mark 

#2305

This may be a dumb suggestion but as a coding noob what popped into my head was... As a test I would tie the spawn to a different actor just to rule out the slim possibility that there is some hidden hardcoding for the keycard that is interfering. Probably not but I would want to rule out the chance.
1

User is offline   Danukem 

  • Duke Plus Developer

#2306

It's likely that the monsters are starting where they are supposed to but then are clipping right through the barrier. It's possible that something in your custom monster code is causing that, but it's also possible that it's just happening because Build. And that's no attack on Build -- if you were making a Fallout 4 mod you could have the same issue (monsters end up in strange places in Creation engine...)

If you make a gametype that requires killing all the monsters, you really need to put in safeguards. When I have coded invasion gameplay in the past, I have made all the monsters count the amount of time they have no contact with the player. If the count goes high enough, they get teleported somewhere -- their original start position might be a good choice, or some location that you know the player can get to. If that sound hard or bewildering then you may be in over your head and you may need to change your plans until you have a better grasp of the engine and scripting system.
0

#2307

View PostTrooper Dan, on 19 August 2018 - 12:32 PM, said:

It's likely that the monsters are starting where they are supposed to but then are clipping right through the barrier. It's possible that something in your custom monster code is causing that, but it's also possible that it's just happening because Build. And that's no attack on Build -- if you were making a Fallout 4 mod you could have the same issue (monsters end up in strange places in Creation engine...)

If you make a gametype that requires killing all the monsters, you really need to put in safeguards. When I have coded invasion gameplay in the past, I have made all the monsters count the amount of time they have no contact with the player. If the count goes high enough, they get teleported somewhere -- their original start position might be a good choice, or some location that you know the player can get to. If that sound hard or bewildering then you may be in over your head and you may need to change your plans until you have a better grasp of the engine and scripting system.


Yeah, after some testing I've found that they clip through "doors" that are less than 256 units wide. I've considered what you are suggesting with the teleporting, but for now the map just have huge doors (they still try to clip it, but gets squished instead (mission accomplished?)).

A whole other thing, and I'm kinda embarrased to ask this but: What's the most elegant or simplest way to have a switch for things in general? Let me give an example: Monsters drop this crystalammo from time to time, and when the player picks it up, all monsters run a block of code. So what I'm currently doing is setting a global gamevar = 1 in the crystalammo code when the player picks it up while having the monsters check for this gamevar. Then I would like the gamevar to be set back to 0 when all monsters (actors, really) have been iterated once. I've come up with all kind of weird methods, but in the end they doesn't seem logical...
0

User is offline   Danukem 

  • Duke Plus Developer

#2308

View Postthisbecasper, on 19 August 2018 - 02:18 PM, said:

A whole other thing, and I'm kinda embarrased to ask this but: What's the most elegant or simplest way to have a switch for things in general? Let me give an example: Monsters drop this crystalammo from time to time, and when the player picks it up, all monsters run a block of code.


What does the block of code actually do? My first reaction would be to make the crystalammo run the code instead, by looping through all the monsters. I think this would be less confusing to read, as well.

EDIT:
On a related note, you should probably have a per-actor gamevar set to a certain value on all of the "monsters" when they initialize, so that you can easily identify them.

This post has been edited by Trooper Dan: 19 August 2018 - 02:34 PM

0

#2309

View PostTrooper Dan, on 19 August 2018 - 02:30 PM, said:

What does the block of code actually do? My first reaction would be to make the crystalammo run the code instead, by looping through all the monsters. I think this would be less confusing to read, as well.

EDIT:
On a related note, you should probably have a per-actor gamevar set to a certain value on all of the "monsters" when they initialize, so that you can easily identify them.


The code will do different things depending on the item the player picks up (but in this case it kills them), but stuff has to happen to the player too, but I guess that could be done by looping too. Only reason to why I'm not looping, is because I haven't learned it yet! Is there anything on the wiki about looping though actors?
0

User is offline   Danukem 

  • Duke Plus Developer

#2310

You want to look up whilevarn and headspritestat/nextspritestat

There's lots of examples of looping through sprites in published mods, such as pretty much any of mine.
1

#2311

I have a question regarding modding masked walls. I want to replace the regular waterfalls with a new animation so I use this:


onevent EVENT_ENTERLEVEL
{
	setvar w_wall_number 0
	whilevarvarn w_wall_number NUMWALLS		{
		getwall[w_wall_number].picnum w_wall_picnum
		ifvare w_wall_picnum 889 {
			setwall[w_wall_number].picnum 7224
		}
		addvar w_wall_number 1
	}
} 
endevent


However, this does not cover masked walls. Wat do?
0

User is offline   Danukem 

  • Duke Plus Developer

#2312

Just use an animated texture and you won't have to mess with code at all.
0

#2313

 Trooper Dan, on 03 September 2018 - 03:17 AM, said:

Just use an animated texture and you won't have to mess with code at all.


Does this work when attempting to replace a 4 frame animation with a more-than-4 frame animation (e.g. 8)?
0

User is offline   Danukem 

  • Duke Plus Developer

#2314

 December Man, on 03 September 2018 - 01:01 PM, said:

Does this work when attempting to replace a 4 frame animation with a more-than-4 frame animation (e.g. 8)?


Are you saying there aren't enough spaces in the art file to put your new animation without bumping into some other existing tiles? Then that's a problem. What happens when you make your loop replace overpicnum as well as picnum?
1

#2315

 Trooper Dan, on 03 September 2018 - 01:10 PM, said:

Are you saying there aren't enough spaces in the art file to put your new animation without bumping into some other existing tiles? Then that's a problem. What happens when you make your loop replace overpicnum as well as picnum?


Well damn, haven't thought about doing it like this. It works! Thank you very much!

This post has been edited by December Man: 03 September 2018 - 02:05 PM

0

User is offline   Mark 

#2316

I want to add a lean to some 3D models. According to the wiki there are various commands such as pitch and roll but no example on how to use them. I tried a couple of ways in cons with no success.

Then I had the bright idea that those commands are probably used in the maphacks files. Sure enough, there they are. So I created a MYPROJECT.MHK file and entered in the line "sprite 6673 pitch 128" . I wasn't sure if maphack files need to be called so I typed "include MYPROJECT.MHK at the top of GAME.CON

When run I get an con error message. "expected a keyword but found sprite"

How does one implement pitch, roll and the other similar commands?

Also, for sprite ID is pitch looking for the ID from Mapster or the ID from DEFS.CON? I'm assuming from mapster

This post has been edited by Mark: 07 September 2018 - 01:44 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#2317

 Mark, on 07 September 2018 - 01:38 PM, said:

I want to add a lean to some 3D models. According to the wiki there are various commands such as pitch and roll but no example on how to use them. I tried a couple of ways in cons with no success.


I don't know what went wrong, but you just set the .pitch and .roll members of the sprite struct to the values you want, either with numbers or gamevars.

https://wiki.eduke32.../Model_rotation

So for example seta[].pitch 512 would make the actor face plant.
1

User is offline   Mark 

#2318

Thanks.

This once again points out the severe lack of simple examples for entries. For instance, your example shows that the model to manipulate must be made an actor. Not mentioned in the wiki. Noob coders are not going to automatically know that like the experienced coder does. And since the only example I could find of that command was in a maphack file that was simply: "sprite 6673 pitch 128" I naturally figured thats how to use it. Now I know better.
0

User is offline   Danukem 

  • Duke Plus Developer

#2319

 Mark, on 07 September 2018 - 04:45 PM, said:

This once again points out the severe lack of simple examples for entries. For instance, your example shows that the model to manipulate must be made an actor. Not mentioned in the wiki. Noob coders are not going to automatically know that like the experienced coder does.


You can set the structs on any sprite in the game, it doesn't have to be an actor. I think the real issue here is that people look up individual pages that assume knowledge of how to use sprite structs, without knowing how to use sprite structs. Ideally, the novice CON coder has already read this page first:

https://wiki.eduke32...tructure_access

But it's not desirable to have tutorials on structure access in every entry about a sprite struct. That would make the entries bloated and hard to read, not to mention it would be a ton of work. The correct solution is to have the wiki organized in such a way that the novice has a clear order to read stuff in so they get all the basics. In theory, the novice would come here first and work their way through most of that page.
0

User is offline   Mark 

#2320

I learn better by example. I'm resigned to the fact I will never get so heavily into con coding as you or other "master coders". I haven't the patience. I'm certainly not a role model for other new coders. I will find an example in the wiki or other people's code. With it in front of me I have a much easier time figuring why it works and how to adapt it to what I need. Reading something that looks like techno-babble without a real world example in the wiki frustrates me.
0

#2321

Does someone have some code that teleports monsters close to the player consistently? And how do I make sure you can't pick up handbombs (a single pipe, be it your own or another player's)?

This post has been edited by thisbecasper: 18 September 2018 - 10:00 AM

0

User is offline   Zaxtor 

#2322

I think AMC mod has some code that those floating cultists teleports near or close of you.
Dunno the code but I know what you mean.
I'm trying to find out how is done.

if I find out ill let u know
I'm sure someone with more knowledge on things teleporting near players will help

This post has been edited by Zaxtor: 18 September 2018 - 11:59 AM

1

User is offline   Perro Seco 

#2323

I've got a complicated question:

Posted Image

I want those two sprites to stay with the player. If he moves, they move with him, and if he rotates, they also rotate, but always keeping the same distance. Is this something possible to do?
0

User is offline   Mark 

#2324

I don't know how but it can be done. I'm pretty sure thats how the flashlight in the Graveyard TC works or the player light in DukePlus. Search for Darkus's original flashlight code on the forum. It may give you a hint on how its done.
1

User is offline   Hendricks266 

  • Weaponized Autism

  #2325

defstate doangle
    getactor[THISACTOR].ang temp
    setactor[actor0].ang temp
    setactor[actor1].ang temp

    addvar temp 512 // rotate angle 90 degrees
    cos x temp
    sin y temp

    mulscale x2 radius x 14
    mulscale y2 radius y 14

    getactor[THISACTOR].x temp
    addvarvar temp x2
    setactor[actor0].x temp
    getactor[THISACTOR].y temp
    addvarvar temp y2
    setactor[actor0].y temp

    getactor[THISACTOR].x temp
    subvarvar temp x2
    setactor[actor1].x temp
    getactor[THISACTOR].y temp
    subvarvar temp y2
    setactor[actor1].y temp
ends


There may be more steps for the motion to look correct in relation to movement interpolation.
3

User is offline   Perro Seco 

#2326

Thank you both for your help! I'll try both solutions.
0

Share this topic:


  • 124 Pages +
  • « First
  • 76
  • 77
  • 78
  • 79
  • 80
  • 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