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

Jump to content

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

EDuke32 Scripting  "CON coding help"

User is offline   Mark 

#2821

Darn, I was hoping it was down because a huge update was being uploaded with hundreds of easier to understand examples for all the con commands. :D
1

#2822

Does a program exists that can output meta information about a map given the .map file? Things such as num wall, sectors, num of different items etc...?

Edit: Seems I asked too quickly. I found this: https://github.com/lewster32/webbuild, which has what I would need

This post has been edited by thisbecasper: 14 April 2022 - 02:53 PM

0

User is offline   dandouglas 

#2823

Is it possible to link a security camera viewscreen to a switch, i.e. have something activate when the player presses use to view through the camera? I have a number of "TV channels" in my mod and I'd like to have effects and sounds starting when the player views them.

At the moment i'm placing a touchpad right in front of the viewscreen but obviously that creates some sync issues, as I'm relying on the player to hit use immediately upon walking up or the effect is missed.

Cheers!
0

User is offline   Danukem 

  • Duke Plus Developer

#2824

View Postdandouglas, on 18 April 2022 - 05:43 AM, said:

Is it possible to link a security camera viewscreen to a switch, i.e. have something activate when the player presses use to view through the camera? I have a number of "TV channels" in my mod and I'd like to have effects and sounds starting when the player views them.

At the moment i'm placing a touchpad right in front of the viewscreen but obviously that creates some sync issues, as I'm relying on the player to hit use immediately upon walking up or the effect is missed.

Cheers!


Yes, but the first way that comes to mind is a bit convoluted. You would start by tagging the camera sprite with the channel that will activate, but tag it on EXTRA since that isn't used for anything.

If you don't have one already, declare a per actor var for storing channels, and then load that var with the tag.

In your var declarations, add: gamevar mychannel -1 2

Then to save this as a var on the sprite:

eventloadactor CAMERA1 geta[].extra mychannel enda 


Then in the player code, you have to detect whether you are viewing from a camera, and if so check to see if the camera is supposed to activate stuff. Activate stuff if applicable, and then reset the var so it doesn't keep activating continuously.

// this part goes in the APLAYER actor

ifn player[].newowner -1
{
  ifn actorvar[player[].newowner].mychannel -1
  {
    getav[player[].newowner].mychannel mychannel
    operatemasterswitches mychannel
    operaterespawns mychannel
    operateactivators mychannel 0
    setav[player[].newowner].mychannel -1
    set mychannel -1
  }
}

0

User is offline   dandouglas 

#2825

Hi Dan, really sorry but I can't seem to get this working. The setup I currently have is: a Touchplate right in front of the Viewscreen activates a Shooter to kick a sprite in the room I've placed the Camera in, and triggers a sound effect which is only audible when viewing through the camera.

I've removed the Touchplate, given the Camera sprite an Extra value equivalent to the Lotag of the Activator and added your code, but no sound plays now. I've tried using this new setup with another effect (floor rise) and it doesn't trigger the effect either. Any idea what I could be doing wrong? Thank you!
0

User is offline   Danukem 

  • Duke Plus Developer

#2826

Make sure that the eventloadactor part was added; without that the camera will do nothing. I can't really debug it because I don't have the project files.

ifn player[].newowner -1
{
  al THISACTOR
  ifn actorvar[player[].newowner].mychannel -1
  {
    getav[player[].newowner].mychannel mychannel
    al mychannel
    operatemasterswitches mychannel
    operaterespawns mychannel
    operateactivators mychannel 0
    setav[player[].newowner].mychannel -1
    set mychannel -1
  }
}


The "al THISACTOR" will add the player's sprite ID to the log. That should completely spam the log when using a camera so if that doesn't happen then you know the code isn't firing at all and the block of code is most likely in the wrong place.

The "al mychannel" only get logged one time if the camera did get set successfully with a channel. You will need to search the log for an instance of "mychannel" after closing the game since it will be hard to see in the other spam. If that does not appear in the log then you know the camera failed to load the channel number into the var. If it does appear then that means that the operate commands using the channel were insufficient to trigger the shooter for some reason.
0

User is offline   dandouglas 

#2827

Hi Dan, thanks for getting back to me. Still not having any luck with this I'm afraid. Nothing relevant is showing up in eduke32.log (I'm using the Debug version of EDuke32). I tried changing CAMERA1 to VIEWSCREEN in the code and adding the EXTRA tag to the VIEWSCREEN sprite to see if that would work, but no joy either.

This is how I've added the code to my GAME.CON - I appreciate that you may not have any more time to look into this.

gamevar mychannel -1 2

eventloadactor CAMERA1 geta[].extra mychannel enda 

actor APLAYER MAXPLAYERHEALTH PSTAND 0 0

ifn player[].newowner -1
{
  al THISACTOR
  ifn actorvar[player[].newowner].mychannel -1
  {
    getav[player[].newowner].mychannel mychannel
    al mychannel
    operatemasterswitches mychannel
    operaterespawns mychannel
    operateactivators mychannel 0
    setav[player[].newowner].mychannel -1
    set mychannel -1
  }
}

0

User is offline   Danukem 

  • Duke Plus Developer

#2828

So that code isn't making the value of THISACTOR be spammed to the log when the player is using a camera?

https://wiki.eduke32.com/wiki/Newowner

I don't really see how that's possible unless the GAME.CON you are editing isn't even being used in the game.
0

User is offline   dandouglas 

#2829

Here's the log I'm seeing - I'm sure the game is using that GAME.CON, I deliberately inserted a typo into it just to double-check and the game failed to compile, and when I removed it from the directory loads of stuff in my mod broke.

Spoiler

0

User is offline   Danukem 

  • Duke Plus Developer

#2830

Alright, I did a little test on my own end. It turns out that the newowner member somehow is always -1 when read from the APLAYER actor, even though it is set elsewhere. This is bizarre to me and I wasn't aware of this until now. Possibly the player sprite that has newowner set is a dummy sprite that is spawned to be viewable via cameras and is not the same as the player actor. In any case, the good news is this is fixable if you move the code out of the APLAYER actor and into EVENT_GAME


gamevar mychannel -1 2

eventloadactor CAMERA1 geta[].extra mychannel enda 

onevent EVENT_GAME

ifactor APLAYER
ifn player[].newowner -1
{
  ifn actorvar[player[].newowner].mychannel -1
  {
    getav[player[].newowner].mychannel mychannel
    al mychannel
    operatemasterswitches mychannel
    operaterespawns mychannel
    operateactivators mychannel 0
    setav[player[].newowner].mychannel -1
    set mychannel -1
  }
}
endevent

0

User is offline   dandouglas 

#2831

Hi Dan, thanks so much - this works perfectly. Really excited to see what I can do with it in the mod and I hugely appreciate you taking the time to put this together.
0

User is offline   Danukem 

  • Duke Plus Developer

#2832

View Postdandouglas, on 21 April 2022 - 01:13 PM, said:

Hi Dan, thanks so much - this works perfectly. Really excited to see what I can do with it in the mod and I hugely appreciate you taking the time to put this together.


Glad to help. I never would have guessed that whether the struct member is set depends on whether you access it from the actor or in the event. Scripting Duke has a lot of weirds quirks, though, so I shouldn't be that surprised.
0

User is offline   zazo 

#2833

Hi everybody,
After a long period of posing, i have fun with mapster again.
I have some questions regarding code modification to solve some bugs and improve some visual effects:
- how to prevent enemies from killing each other with their shots ? Silly but usefull to avoid this...
- it is possible to create different sort of bullet holes when a player's shot hits differents kinds of wall textures (concrete, metal, wood, etc)?
- a way to determine the id of the wall closest to an actor (like the command "findnearactor" but for walls ?)
Thanks in advance if you have any ideas how to do this, or find pieces of code for this...
0

User is offline   Danukem 

  • Duke Plus Developer

#2834

View Postzazo, on 27 April 2022 - 06:35 AM, said:

Hi everybody,
After a long period of posing, i have fun with mapster again.
I have some questions regarding code modification to solve some bugs and improve some visual effects:
- how to prevent enemies from killing each other with their shots ? Silly but usefull to avoid this...
- it is possible to create different sort of bullet holes when a player's shot hits differents kinds of wall textures (concrete, metal, wood, etc)?
- a way to determine the id of the wall closest to an actor (like the command "findnearactor" but for walls ?)
Thanks in advance if you have any ideas how to do this, or find pieces of code for this...


The first of those three is pretty easy to do. The second and third a quite a bit more involved. There just aren't any simple commands for them that do the job.

The friendly fire thing: Every enemy uses the ifhitweapon command. Right before that command in the enemy's code, you can insert a line of code that checks where the damage is coming from and nullifies it if it is coming from another actor that is not the player:

ifn sprite[].htextra -1 ifn sprite[].htowner -1 ifn sprite[].htowner player[].i seta[].htextra -1
ifhitweapon
{
// ... etc


So you would find each place it says ifhitweapon and insert that line of code above it. In English, what that line of code says is "If you are taking damage and if that damage is coming from a specific sprite and if that sprite is not the player, then negate that damage." This might also prevent them from taking damage from environmental explosions, but hopefully it doesn't do that. I'm hoping that environmental explosions set htowner to -1, in which case they will still take damage from those.

Note that this will not work properly in multiplayer because it only allows damage from the *closest* player. Also, in a more sophisticated mod that has other stuff going on like enemy factions and so on, it should not be used.
0

User is offline   zazo 

#2835

Works very well for the first point. Thanks you...
0

Share this topic:


  • 95 Pages +
  • « First
  • 93
  • 94
  • 95
  • 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