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

Jump to content

  • 120 Pages +
  • « First
  • 31
  • 32
  • 33
  • 34
  • 35
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

#961

Set the RETURN var to any non-zero value in EVENT_FIRE

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

0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#962

To make a projectile display sides you must use an action, like this:

action APROJFRAMES            0    1    5

useractor notenemy PROJ 0 APROJFRAMES enda

0

#963

How can i get the id of the sprite hit by a knee-type projectile (just like "htg_t 8" for hitscan projectiles) ?
0

User is offline   Mblackwell 

  • Evil Overlord

#964

ifhitweapon ifwasweapon KNEE ?

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.
0

#965

Using htg_t(8) member actually does nothing, it always return 0.

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.
0

User is offline   Mblackwell 

  • Evil Overlord

#966

I've always just used the spawn property to spawn an actor that does all of the fancy effects I want.
0

User is offline   zazo 

#967

 Mblackwell, on 09 October 2012 - 05:26 PM, said:

I've always just used the spawn property to spawn an actor that does all of the fancy effects I want.

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 ...
0

User is offline   Hendricks266 

  • Weaponized Autism

  #968

ifvarvare

For distance, use ldist or dist.
0

User is offline   zazo 

#969

 Hendricks266, on 10 October 2012 - 04:00 PM, said:

ifvarvare

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?
0

User is offline   Reaper_Man 

  • Once and Future King

#970

canseespr will handle the line of sight stuff. You will need to figure out exactly what differentiates an "enemy" from an "ally". Assuming your ally is a unique actor, then you could just have it check the picnum of actors it finds and match them to known enemies.
0

User is offline   zazo 

#971

 Reaper_Man, on 11 October 2012 - 12:35 PM, said:

canseespr will handle the line of sight stuff. You will need to figure out exactly what differentiates an "enemy" from an "ally". Assuming your ally is a unique actor, then you could just have it check the picnum of actors it finds and match them to known enemies.

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
0

#972

Ok, it's time to explain something about it. I don't know what you already know about CON coding, but i'll talk about all is needed.

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

0

User is offline   m210® 

#973

I remember that polymer lights was changed for user actors to statnum14. So, how to use it now?
0

User is offline   zazo 

#974

 RichardStorm, on 12 October 2012 - 03:48 AM, said:

Ok, it's time to explain something about it. I don't know what you already know about CON coding, but i'll talk about all is needed.

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
0

#975

Here is the scanning system i use in my project, it's based on a whilevarn loop which checks all sprites in the map.
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

0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#976

Checking all sprite avaiables up to 16384 is the wrong way. You should check all sectors up to NUMSECTORS and use headspritesect.
2

#977

In fact it needs optimization, but it works for now and i'm on other features and fixes to do, I'll improve it later.
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

0

User is offline   zazo 

#978

interesting to study...
I thought the canseespr was easier to use...
0

User is offline   zazo 

#979

 zazo, on 14 October 2012 - 02:19 PM, said:

interesting to study...
I thought the canseespr was easier to use...


also, I just discovered that there is ally AI in "duke plus"
0

User is online   Danukem 

  • Duke Plus Developer

#980

 zazo, on 14 October 2012 - 02:36 PM, said:

also, I just discovered that there is ally AI in "duke plus"


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.
0

User is offline   zazo 

#981

View PostTrooper Dan, on 14 October 2012 - 06:32 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.

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 ?
0

User is offline   CruX 

#982

View Postzazo, on 15 October 2012 - 04:10 AM, 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 ?


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

0

User is offline   zazo 

#983

View PostEmericaSkater, on 15 October 2012 - 04:31 AM, said:

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


very subtle, but ils work !
I have never found myself! thanks
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#984

View PostEmericaSkater, 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".
0

User is offline   zazo 

#985

Is it possible to create a sprite blocking for the actors but not for projectiles: can be traversed by bullets, but not by the bodies of the characters .. ? a special cstat value?
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#986

Yes, it is very possible. The cstat flag that control the sprite blocking is 1, and the projectile collision 256.

The problem is that when a map is loaded, by default all sprites with a cstat of 1 are set to 257 automatically. Meaning that you must force it to remain at 1 via CON.
0

User is offline   zazo 

#987

View PostFox, on 17 October 2012 - 11:05 AM, said:

Yes, it is very possible. The cstat flag that control the sprite blocking is 1, and the projectile collision 256.

The problem is that when a map is loaded, by default all sprites with a cstat of 1 are set to 257 automatically. Meaning that you must force it to remain at 1 via CON.

getplayer[THISACTOR]. .....
member structur to get the player health as a variable ?
0

#988

getplayer[THISACTOR].extra

Why don't you get a look to this ? http://wiki.eduke32....ructure_members

// EDIT
Sorry i read wrong. If you need to use it inside the aplayer actor you could simply write getactor[THISACTOR].extra. In other cases use getactor[player[THISACTOR].i].extra.

This post has been edited by RichardStorm: 17 October 2012 - 01:42 PM

0

User is offline   zazo 

#989

View PostRichardStorm, on 17 October 2012 - 01:33 PM, said:

getplayer[THISACTOR].extra

Why don't you get a look to this ? http://wiki.eduke32....ructure_members

// EDIT
Sorry i read wrong. If you need to use it inside the aplayer actor you could simply write getactor[THISACTOR].extra. In other cases use getactor[player[THISACTOR].i].extra.

thanks, with the cstat values i search a property for actor to cross any other: this actor can not be stopped by actors "solid" in cstat 1.257 ...: it could be a single projectile (or actor) that pierce a line of ennemies and finally stops in the walls ... :D
Is it possible ?? also would try to force the coordinates with the x,y variables...
0

User is offline   zazo 

#990

View Postzazo, on 18 October 2012 - 01:43 AM, said:

thanks, with the cstat values i search a property for actor to cross any other: this actor can not be stopped by actors "solid" in cstat 1.257 ...: it could be a single projectile (or actor) that pierce a line of ennemies and finally stops in the walls ... :D
Is it possible ?? also would try to force the coordinates with the x,y variables...

possible to change the spritepal of the weapons in hands in first person view (tiles 2524) in game ?
in the player code, spritepal change only the color in third person view (F7).
0

Share this topic:


  • 120 Pages +
  • « First
  • 31
  • 32
  • 33
  • 34
  • 35
  • 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