
EDuke32 Scripting "CON coding help"
#955 Posted 06 October 2012 - 10:56 AM
How to implement a variable for all the maps of a gameplay, and display the inventory "number of coins" on the screen above the status bar ?...
command to write and draw on the screen ?...
#956 Posted 06 October 2012 - 11:29 AM
gamevar coins 0 1
2. This is where events come in handy. Try EVENT_DISPLAYREST and digitalnumber.
onevent EVENT_DISPLAYREST digitalnumber DIGITALNUM 20 159 coins 0 0 8 0 0 xdim ydim endevent
#957 Posted 07 October 2012 - 02:40 PM
Hendricks266, on 06 October 2012 - 11:29 AM, said:
gamevar coins 0 1
2. This is where events come in handy. Try EVENT_DISPLAYREST and digitalnumber.
onevent EVENT_DISPLAYREST digitalnumber DIGITALNUM 20 159 coins 0 0 8 0 0 xdim ydim endevent
Is it possible to display a typo smaller: like the command "quote" (tiles 2837...) or possible to resize the digitalnum ?
I would also create two cool stuffs:
-a special item that reveals the whole map: the equivalent of the cheat code "dnshowmap"
-I'd like to know how to reproduce the effect of slow motion that exists in the tc "amc": action is slowed when the screen is full of action or killing a boss...
Thank you in advance
#958 Posted 07 October 2012 - 02:53 PM
zazo, on 07 October 2012 - 02:40 PM, said:
digitalnumberz can resize the number. If you want to display text you can use gametext/gametextz or minitext. If you want to include numbers in the text, use qsprintf to assemble the quote.
zazo, on 07 October 2012 - 02:40 PM, said:
Copy the code for one of the items or pickups in the original CONs, like ATOMICHEALTH. Instead of adding health, have it:
setuserdef[THISACTOR].showallmap 1
zazo, on 07 October 2012 - 02:40 PM, said:
The command for this is inittimer.
zazo, on 07 October 2012 - 02:40 PM, said:
No problem!
#959 Posted 08 October 2012 - 06:41 AM
Hendricks266, on 07 October 2012 - 02:53 PM, said:
Copy the code for one of the items or pickups in the original CONs, like ATOMICHEALTH. Instead of adding health, have it:
setuserdef[THISACTOR].showallmap 1
The command for this is inittimer.
No problem!
the bullet time effect is a very cool stuff !!
#960 Posted 09 October 2012 - 08:48 AM
This new projectile would have the effect of paralyzing the player body:
for the time of paralysis :
setplayer[THISACTOR].posx x
setplayer[THISACTOR].posy y
getplayer[THISACTOR].posx x
getplayer[THISACTOR].posy y
but how to disable the firing key to prevent the player to shoot ?...

#961 Posted 09 October 2012 - 09:10 AM
i.e;
onevent EVENT_FIRE ifvare frozen_player 1 { setvar RETURN 1 } endevent
Haven't tested mind, I'm just going by the entry on the Wiki. And of course, replace "frozen_player" with whatever you are using instead.
This post has been edited by High Treason: 09 October 2012 - 09:11 AM
#962 Posted 09 October 2012 - 10:12 AM
action APROJFRAMES 0 1 5 useractor notenemy PROJ 0 APROJFRAMES enda
#963 Posted 09 October 2012 - 11:57 AM
#964 Posted 09 October 2012 - 01:40 PM
Otherwise I believe if it's a custom projectile you can just substitute that. And then work backwards?
I guess it's better if you say what you intend to do with it.
Edit: But isn't KNEE just a hitscan with a short range? So you should be able to use the same data structures.
#965 Posted 09 October 2012 - 02:31 PM
I need to spawn some sprites and play sounds on certain conditions at the right position (like jibs or blood trails) . While the sound could be played by the enemy, the sprite needs to be spawned directly by the projectile.
I could (simply) solve the problem by transforming all knee-type into ranged hitscan-type, or by abandoning sprite effects, but i'm asking if there are some member structures or other tricks to know regard knee-type.
#966 Posted 09 October 2012 - 05:26 PM
#967 Posted 10 October 2012 - 02:40 PM
Mblackwell, on 09 October 2012 - 05:26 PM, said:
how to compare the position x1,y1 of actor1 with the position x2,y2 of Actor2 ? to detect whether two actors are close to each other? these actors are not player...
ifvarvar x1 x2 ifvarvar y1 y2 seems not work ...
#969 Posted 11 October 2012 - 06:53 AM
Hendricks266, on 10 October 2012 - 04:00 PM, said:
For distance, use ldist or dist.
in this case I would like to create an actor which is an ally of player and who can shoot the enemy of the player.
how an actor can detect a line of sight to another actor tagged as enemy ?...
Does it exist a few bits of code for that?
#970 Posted 11 October 2012 - 12:35 PM
#971 Posted 12 October 2012 - 01:44 AM
Reaper_Man, on 11 October 2012 - 12:35 PM, said:
im trying this code:
THISACTOR is the ally
GOBELIN is the enemy
getactor[THISACTOR].z ZPOSITION
subvar ZPOSITION 8192
setactor[THISACTOR].z ZPOSITION
canseespr THISACTOR GOBELIN allyseenemy
addvar ZPOSITION 8192
setactor[THISACTOR].z ZPOSITION
ifvare allyseenemy 1 ai ALLYSHOOT
but nothing appens ...
seems not to work yet
#972 Posted 12 October 2012 - 03:48 AM
You should know that sprites in the map have two parameters, the picnum and an #id (and many others things like x,y,z,spritepal etc )
The picnum is which type of sprite it is (BARREL, EXPLOSION2, GOBELIN, CHAINGUNSPRITE etc) , and it is the same thing when you write "define GOBELIN XX" : a GOBELIN sprite has picnum equal to XX.
The #id is an identification number in the map and is strictly different for each sprite, not depending by its picnum . For example in a map two GOBELIN have surely different id, and this is different from the player sprite, an explosion or another enemy.
Many command like set/getactor, or canseespr etc use the #id. Every time a sprite needs to do something with another sprite, it needs to know its id and store it into a number ( for example, declaring a per-actor variable called "enemyid", "myenemy", or "target" etc, ). THISACTOR always means the id of the sprite are you in.
That's how canseespr works, for example: canseespr (id1) (id2) (result) -> canseespr THISACTOR myenemy allyseenemy (within the ALLY)
So if you want an ALLY fires a GOBELIN , it needs to find a GOBELIN sprite in the map and get its ID.
Here is the hardest part.
To find a sprite with a certain picnum you could use the findnearactor function ( http://wiki.eduke32....i/Findnearactor ) , or using a cycle that checks EVERY sprite in the map by passing through all #ids sequencially and checking if its picnum is GOBELIN or XX ( whilevarn loop http://wiki.eduke32.com/wiki/Whilevarn ) , and there are also other methods from other modders here.
But everytime you acquire a GOBELIN or another enemy by finding its id, you should check many things, like if it's alive, if its visible ( here comes canseespr), is within a certain distance and so on.
If it fails, the actor checks for enemy again. Continuosly.
When all is right the actor (the ally) could stop to scan for enemies.
The enemy dies ? Check for enemy again.
I could post entire code segments and explains many other things (like other people could do), but i think you should understand all these things before.
This post has been edited by RichardStorm: 12 October 2012 - 03:50 AM
#973 Posted 12 October 2012 - 11:37 AM
#974 Posted 13 October 2012 - 02:05 PM
RichardStorm, on 12 October 2012 - 03:48 AM, said:
You should know that sprites in the map have two parameters, the picnum and an #id (and many others things like x,y,z,spritepal etc )
The picnum is which type of sprite it is (BARREL, EXPLOSION2, GOBELIN, CHAINGUNSPRITE etc) , and it is the same thing when you write "define GOBELIN XX" : a GOBELIN sprite has picnum equal to XX.
The #id is an identification number in the map and is strictly different for each sprite, not depending by its picnum . For example in a map two GOBELIN have surely different id, and this is different from the player sprite, an explosion or another enemy.
Many command like set/getactor, or canseespr etc use the #id. Every time a sprite needs to do something with another sprite, it needs to know its id and store it into a number ( for example, declaring a per-actor variable called "enemyid", "myenemy", or "target" etc, ). THISACTOR always means the id of the sprite are you in.
That's how canseespr works, for example: canseespr (id1) (id2) (result) -> canseespr THISACTOR myenemy allyseenemy (within the ALLY)
So if you want an ALLY fires a GOBELIN , it needs to find a GOBELIN sprite in the map and get its ID.
Here is the hardest part.
To find a sprite with a certain picnum you could use the findnearactor function ( http://wiki.eduke32....i/Findnearactor ) , or using a cycle that checks EVERY sprite in the map by passing through all #ids sequencially and checking if its picnum is GOBELIN or XX ( whilevarn loop http://wiki.eduke32.com/wiki/Whilevarn ) , and there are also other methods from other modders here.
But everytime you acquire a GOBELIN or another enemy by finding its id, you should check many things, like if it's alive, if its visible ( here comes canseespr), is within a certain distance and so on.
If it fails, the actor checks for enemy again. Continuosly.
When all is right the actor (the ally) could stop to scan for enemies.
The enemy dies ? Check for enemy again.
I could post entire code segments and explains many other things (like other people could do), but i think you should understand all these things before.
I would like to save time so if you have a piece of code to dissect ... thanks again
#975 Posted 13 October 2012 - 03:01 PM
You need to know that this method is not so light for pc and it could affect the fps ratio, is better to randomize it in some ways; there are also more efficient and lighter methods i know from other people.
You could also visit the wiki page for all descriptions/commands you need to learn...
http://wiki.eduke32.com/wiki/Main_Page
gamevar gid 0 2 // i call it "general id" gamevar targetdist 0 2 // this stores the shortest target distance gamevar temp 0 2 // temporary variables gamevar tempb 0 2 gamevar tempc 0 2 gamevar mytarget 0 2 // self-explanatory gamevar detectrange 0 2 // in build units, the maximum distance the sprite can see an enemy state findnearenemy // put in in your ALLY... setvar detectrange 20000 // for example setvar targetdist 500000 // initialize distance at a big value setvar gid 0 // you need to start from 0, also because if gid is something different it could not work or make Eduke freeze... whilevarn gid 16384 // here start the loop, it stops when gid reaches 16384 { switch sprite[gid].picnum // do this only with enemies; i use a switch case LIZTROOP case LIZMAN case OCTABRAIN case PIGCOP case NEWBEAST case GREENSLIME case ROTATEGUN case COMMANDER case DRONE case RECON case BOSS1 case BOSS2 case BOSS3 case BOSS4 case TANK case GOBELIN // EDIT as mentioned in post #977 ifvarn sprite[gid].statnum 1024 // if it's not "killed" { dist tempb gid THISACTOR // calculate distance between this sprite and the scanned enemy ifvarvarl tempb detectrange ifvarvarl tempb targetdist // if it's within the detectrange and near than the previous { canseespr THISACTOR gid tempc // if there is a line of sight and ... ifvarg sprite[gid].extra 0 ifvare tempc 1 // ... if its hit points are greater than 0 { setvarvar owntargetid gid setvarvar targetdist tempb } // ok, set it as my enemy ... until i don't find the nearest } } break // it refers to all enemy picnum cases endswitch addvar gid 1 // next instance of the loop, for sprite #1, #2, 3#, ... 22# ... #1728 ... } // end of the loop structure ends
This post has been edited by RichardStorm: 14 October 2012 - 12:52 AM
#976 Posted 13 October 2012 - 06:37 PM
#977 Posted 14 October 2012 - 12:49 AM
Consider that i posted it for zazo and i think it's the "simplest" working version to understand, it's a modified version of which i really use, too.
@ zazo: I forgot to add a comment saying that you need to add "case GOBELIN" among all enemy types i wrote there (and you can remove them from there if you want).
This post has been edited by RichardStorm: 14 October 2012 - 12:51 AM
#978 Posted 14 October 2012 - 02:19 PM
I thought the canseespr was easier to use...
#979 Posted 14 October 2012 - 02:36 PM
zazo, on 14 October 2012 - 02:19 PM, said:
I thought the canseespr was easier to use...
also, I just discovered that there is ally AI in "duke plus"
#980 Posted 14 October 2012 - 06:32 PM
zazo, on 14 October 2012 - 02:36 PM, said:
Also, all of the enemies in DukePlus can become allies if they are flagged that way in a map or if hit with the shrinker in mindlbast mode.
#981 Posted 15 October 2012 - 04:10 AM
Trooper Dan, on 14 October 2012 - 06:32 PM, said:
another little problem: how to creat an animated projectile in 5 sides:
"
define flyingaxe 5500
defineprojectile ...... etc (settings for projectile)
action flyingaxeframe 0 4 5 1 10
useractor notenemy flyingaxe 0 flyingaxeframe enda
"
only the first frame appears but not the entire animation ?
#982 Posted 15 October 2012 - 04:31 AM
zazo, on 15 October 2012 - 04:10 AM, said:
"
define flyingaxe 5500
defineprojectile ...... etc (settings for projectile)
action flyingaxeframe 0 4 5 1 10
useractor notenemy flyingaxe 0 flyingaxeframe enda
"
only the first frame appears but not the entire animation ?
An action has to be declared for each frame of the animation
action flyingaxeframe1 0 1 5 1 10 action flyingaxeframe2 5 1 5 1 10 action flyingaxeframe3 10 1 5 1 10 action flyingaxeframe4 15 1 5 1 10 useractor notenemy flyingaxe 0 flyingaxeframe1 enda //initialized to the first action
Then you rig the animation with a peractor variable in EVENT_GAME
gamevar countvar 0 2 gamevar picnum 0 2 onevent EVENT_GAME getactor[THISACTOR].picnum picnum ifvare picnum flyingaxe { addvar countvar 1 ifvarg countvar 1 { setvar countvar 0 ifaction flyingaxeframe1 action flyingaxeframe2 else ifaction flyingaxeframe2 action flyingaxeframe3 else ifaction flyingaxeframe3 action flyingaxeframe4 else ifaction flyingaxeframe4 action flyingaxeframe1 } } endevent
#983 Posted 15 October 2012 - 05:14 AM
EmericaSkater, on 15 October 2012 - 04:31 AM, said:
action flyingaxeframe1 0 1 5 1 10 action flyingaxeframe2 5 1 5 1 10 action flyingaxeframe3 10 1 5 1 10 action flyingaxeframe4 15 1 5 1 10 useractor notenemy flyingaxe 0 flyingaxeframe1 enda //initialized to the first action
Then you rig the animation with a peractor variable in EVENT_GAME
gamevar countvar 0 2 gamevar picnum 0 2 onevent EVENT_GAME getactor[THISACTOR].picnum picnum ifvare picnum flyingaxe { addvar countvar 1 ifvarg countvar 1 { setvar countvar 0 ifaction flyingaxeframe1 action flyingaxeframe2 else ifaction flyingaxeframe2 action flyingaxeframe3 else ifaction flyingaxeframe3 action flyingaxeframe4 else ifaction flyingaxeframe4 action flyingaxeframe1 } } endevent
very subtle, but ils work !
I have never found myself! thanks
#984 Posted 15 October 2012 - 09:17 AM
EmericaSkater, on 15 October 2012 - 04:31 AM, said:
gamevar countvar 0 2 gamevar picnum 0 2 onevent EVENT_GAME getactor[THISACTOR].picnum picnum ifvare picnum flyingaxe { addvar countvar 1 ifvarg countvar 1 { setvar countvar 0 ifaction flyingaxeframe1 action flyingaxeframe2 else ifaction flyingaxeframe2 action flyingaxeframe3 else ifaction flyingaxeframe3 action flyingaxeframe4 else ifaction flyingaxeframe4 action flyingaxeframe1 } } endevent
I would prefer to just use ifactioncount instead of "countvar".