Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (dr_panther, 1 invisible), 620 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
my 1st plugin: eLL alpha 0.01 #70027
04/08/06 01:13
04/08/06 01:13
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline OP
Serious User
testDummy  Offline OP
Serious User
T

Joined: Oct 2004
Posts: 1,655
*I am not a C/C++ programmer. (Java was my primary language of interest.)
*This is my first plugin, and simultaneously, it is also essentially my hello word program for C/C++.
*I wrote this, for the same reason I write many things, for practice...to learn.
*I might have chosen to try to use the STL, but for certain reasons, I chose not to.
*Although there may be many bugs, this plugin may be proof that you don't really have to know C/C++.
---to write a simple plugin for 3D GameStudio (with memory leaks and bugs?).
---Rather, it may be proof, of what not to do.
*Although some features of C++ were used and abused and intermingled with C,
---the language of the source code is not really C++.
---Sadly, there is no real evidence of object-oriented programming in the source.

*I am well aware that an entity linked list can be easily implemented in C-Script,
---and, of course, I have traveled this route.
---Note that ptr_for_handle is an instruction rated medium in the manual.
---Note that entity1 and entity2 are depreciated, and the replacement is the ptr_for_handle instruction rated medium?
---Although, in some cases, if some functionality is sacrificed,
---this .dll can offer a faster alternative to scan_entity,
---I don't claim that this .dll provides and absolute replacement for scan_entity,
---or that such is necessary.
---This exercise did not necessarily require that the end result be something
---that could not be produced in C-Script.
*I'm not going to suggest some of the uses for entity linked lists,
---nor am I going to debate whether entity linked lists are necessary.
---It's obvious, if you've never needed or used an entity linked list,
---you don't require them (ha ha).
*Of course, I haven't purchased the SDK, so the plugin is open source and the source is included.
---You are free to improve or fix bugs in the code.
---Suggestions and bug fixes are always welcome,
---nitpicking about code conventions, coding styles, decisions made,...
---repetitive comments about the noobishness of the code, etc. I can do without.
---Compiled with Visual C++ 6. SDK 6.3 used.

*eLL is an acronym for entity linked list.
*The eLL.dll offers an array of simulated entity linked lists.
---Note: little more than self-referential struct wrapped around an entity pointer.
*The max number of entity linked lists is set with a call of eLLsNew(_eLLsMax),
---where _eLLsMax is the max number of linked lists desired.
---_eLLsMax -1 is the max accessible index.
---Although it should not crash if you invoke some other function first,
---eLLsNew(_eLLsMax), which might be placed in C-Script function main(),
---should be the first function called for the .dll.
*eLLsDelete() is invoked when everything in the lists and associated memory should be deleted.
---This might be invoked before a level change.
---After invoking eLLsDelete(), eLLsNew(_eLLsMax) might be invoked again.
---This function (eLLsDelete) should be invoked automatically,
---when the application closes and the acknex engine shuts down,
---via a destructor of an object that goes out of scope.
---Note this function (eLLsDelete()), differs from eLLDelete(_eLLIndex, _ent), and eLLDeleteAll(_eLLIndex).
---eLLDelete(_eLLIndex, _ent) deletes the element containing entity _ent from
---the entity linked list referenced by _eLLIndex (in the array).
---eLLDeleteAll(_eLLIndex) deletes every element (each containing an entity) from
---the entity linked list referenced by _eLLIndex (in the array).

Perhaps, I'm just wasting my time and no one else downloads or uses this, so I suppose
I'll just dump the link, then the .wdl, followed by the comments in the source.
If there are any actual questions, I'll address them.

WARNING: alpha. Slightly tested. Probably many bugs.
Beware of pop-ups at url. For a limited time only.
6.51KB eLL.zip alpha 0.01
Code:

//eLL.wdl
//(Included in download. If these aren't in alphabetical order, it's a bug.)
dllfunction eLLAppend(_eLLIndex, _ent);
dllfunction eLLContains(_eLLIndex, _ent);
dllfunction eLLDelete(_eLLIndex, _ent);
dllfunction eLLDeleteAll(_eLLIndex, _eLLClearInUse);
dllfunction eLLGetLength(_eLLIndex);
dllfunction eLLIsEmpty(_eLLIndex);
dllfunction eLLIsInUse(_eLLIndex);
dllfunction eLLNext(_eLLIndex);
dllfunction eLLNextReset(_eLLIndex);
dllfunction eLLPop(_eLLIndex);
dllfunction eLLPush(_eLLIndex, _ent);
dllfunction eLLsDelete();
dllfunction eLLsGet1stFree();
dllfunction eLLsGetIndexOf(_ent);
dllfunction eLLSetInUse(_eLLIndex, _inUse);
dllfunction eLLsGetMaxLimit();
dllfunction eLLsNew(_eLLsMax);

//comments from the source
//(Included in download twice...once in source and again separately as eLL-comments.txt)
/********************************
eLLAppend(var _eLLIndex, ENTITY* _ent)
Creates eLL with index _eLLIndex if it does not exist.
Appends entity _ent to end of entity linked list with index _eLLIndex.
Slower than eLLPush.
Warning: allocates memory on the heap (free store).
No duplicates allowed.
Returns 1 on success and 0 on failure.
example:
eLLAppend(my.teamId, me);
*********************************/
/********************************
eLLContains(var _eLLIndex, ENTITY* _ent)
Returns 1 if entity linked list referenced by _eLLIndex
contains entity _ent or 0 if it does not.
*********************************/
/********************************
eLLDelete(var _eLLIndex, ENTITY* _ent)
Deletes entity _ent from eLL with index _eLLIndex.
Returns memory of element to heap (free store).
Not ent_remove.
Returns 1 on success and 0 on failure.
example:
if (strState0_ == strStateDead) {
eLLDelete(my.teamId, me);
}
*********************************/
/********************************
eLLDeleteAll(var _eLLIndex, var _eLLClearInUse)
Deletes entire entity linked list with index _eLLIndex.
Optionally clear the flag for the list which indicates if it is in use (had additions).
Not ent_remove.
Returns memory of elements to heap (free store).
Returns 1 on success and 0 on failure.
*********************************/
/********************************
eLLGetLength(var _eLLIndex)
Returns length or count of elements for entity linked list with _eLLIndex.
example:
if (eLLGetLength(my.teamIdEnemy) > 0) {
//iterate through the list
}
*********************************/
/********************************
eLLIsEmpty(var _eLLIndex)
Returns 1 if eLL with index _eLLIndex is empty.
example:
if (!eLLIsEmpty(my.teamIdEnemy)) {
//iterate through the list
}
*********************************/
/********************************
eLLIsInUse(var _eLLIndex)
Returns 1 if any elements were added to
or the in use flag was set for eLL with _eLLIndex.
The in use flag is automatically set to TRUE
for eLLAppend and eLLPush,
but it is not automatically reset to FALSE when
there are no elements left in the list.
An empty list may be in use and a list containing elements
may be set to not in use.
Such is user defined.
More or less, in use is meant to indicate that,
even if the list is empty,
there were items added to the list,
or that items will be added to the list.
Indexes don't have to be contiguous.
*********************************/
/********************************
eLLNext(var _eLLIndex)
Iterates through eLL with index _eLLIndex.
Iterating through list A and then list B
should not void list A's iteration.
If the list is half-iterated,
an invocation of eLLNextReset will reset it.
example:
entity* ent0;
//...
eLLNextReset(my.teamIdEnemy);
ent0 = eLLNext(my.teamIdEnemy);
while(ent0 != null) {
// ...evaluate ent0
ent0 = eLLNext(my.teamIdEnemy);
}
*********************************/
/********************************
eLLNextReset(var _eLLIndex)
Resets the current iteration so that the next invocation
of eLLNext will return the first entity in the list.
*********************************/
/********************************
eLLPop(var _eLLIndex)
Deletes the top element from entity linked list with _eLLIndex.
Returns the entity of that top element.
Returns memory of element to heap (free store).
example:
entity* ent0;
ent0 = eLLPop(0);
while(ent0 != NULL) {
eLLPush(1, ent0);
ent0 = eLLPop(0);
}
*********************************/
/********************************
eLLPush(int _eLLIndex, ENTITY* _ent)
Push an entity onto the top of entity linked list with index _eLLIndex.
Quicker than eLLAppend.
For performance reasons, does not check for duplicate items.
Voids the current iteration for the list.
The iteration restarts from the beginning of the list.
*********************************/
/********************************
eLLsDelete()
Delete all eLLs and all eLLElements.
Warning: In order to return memory to the heap and avoid memory leaks,
this function (__eLLsDelete) should be invoked before the application exits.
(__eLLsDelete) invoked automatically when eLLAutomaticCleanup eLLAC goes out of scope.
There should be no need for the user to
invoke this function directly when the application exits.
This function may also be invoked on level change, I think.
Returns memory to the heap (free store).
Should delete/reset everything.
Does not ent_remove.
Note the s in eLLs.
example:
function exit0() {
eLLsDelete();
exit;
}
on_esc = exit0;
*********************************/
/********************************
eLLsGet1stFree()
Returns the index of the first entity linked list with flag in use off.
see: eLLIsInUse, eLLSetInUse, eLLDeleteAll
*********************************/
/********************************
eLLsGetIndexOf(ENTITY *_ent)
Returns an index of an entity linked list containing entity _ent
or -1 if entity _ent is not found in any entity linked list.
*********************************/
/********************************
eLLSetInUse(var _eLLIndex, var _inUse)
*********************************/
/********************************
eLLsGetMaxLimit()
Returns the max number of lists that were allocated.
No more than this number of eLLs can be used unless the array of lists is reset.
*********************************/
/********************************
eLLsNew
Allocates arrays of pointers on the heap.
Allows for count of _eLLsMax entity linked lists.
Initializes all pointers to NULL.
Invoke this prior to invoking any other eLL function.
This function might be called in main.
Returns 1 on success and 0 on failure.
Note the s in eLLs.
example:
function main() {
/...
eLLsNew(5); // allocate 5 entity linked lists
}
*********************************/



Re: my 1st plugin: eLL alpha 0.01 [Re: testDummy] #70028
04/08/06 14:20
04/08/06 14:20
Joined: Aug 2005
Posts: 1,185
Ukraine
Lion_Ts Offline
Serious User
Lion_Ts  Offline
Serious User

Joined: Aug 2005
Posts: 1,185
Ukraine
Thank you, testDummy.
Try to show this thing usability (may be in demo or in a short story about: how to use all this stuff and what it'll give to game project)

Re: my 1st plugin: eLL alpha 0.01 [Re: Lion_Ts] #70029
04/13/06 06:41
04/13/06 06:41
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
whats this used for?


xXxGuitar511
- Programmer
Re: my 1st plugin: eLL alpha 0.01 [Re: xXxGuitar511] #70030
04/14/06 02:38
04/14/06 02:38
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline OP
Serious User
testDummy  Offline OP
Serious User
T

Joined: Oct 2004
Posts: 1,655
Note: I had anticipated that question and this was the unapproved, archived response.
(I don't think this response is accurate, appropriate or necessarily correct, but the choice was either post the response or send it to oblivion.)

Hypothetical situation: perhaps for an RTS simulation, where a solution using scan_entity isn't as practical or apparent:
Assuming that the player is in combat against emperor Bob (AI) and emperor Bob has a number of generals, each of these generals is in charge of an army, eLL could be used to simplify some logic in associations.
Emperor Bob could have an index to an entity linked list (a group) of generals on the board. Each general could have an index into an entity linked list of its army. If Emperor Bob needs to know the status of all of his armies, he can iterate through the list of generals, each general can iterate through their armies, if necessary, and return the results back to Emperor Bob. If while iterating through the list, Emperor Bob requests the status of an army A, the position of the army, etc., learns that army A is hopelessly outnumbered, and has previously noted that another general controlling army B has an army doing nothing nearby, Emperor Bob may instruct general of army B to move army B to the position of army A. To do this, the Emperor instructs the general, and the general instructs the army (iterating through the army if necessary).

If a general is about to die, perhaps Emperor Bob can access the army directly, by grabbing the generals index into the entity linked list of the general's army. Emperor Bob can then promote a new general, by selecting a candidate, assigning the army index grabbed from the dying general to the candidate and placing the candidate into Emperor Bob's list of generals.

You might use eLL to have a leader of a squad, coordinate the movements of a squad.
If you only have a few opposing squads in combat against each other, given that some functionality is sacrificed or replaced,
eLL may be faster than scan_entity for target assignment.

Hypothetical situation: If you have every StormTrooper in the level looking for targets player, HanSolo and R2D2, with scan_entity (not every frame),perhaps using eLL instead, and adding targets player, HanSolo and R2D2 to an eLL 0, having the StormTroopers iterate through eLL 0, check the distances of each entity in eLL 0, and if entity is in range, assign the entity as a target (perhaps assign the weakest, nearest entity as the target), perform a look trace to see if the my StormTrooper can see the target entity, then such may be faster than doing something similar with scan_entity.

Essentially, eLL offers dynamic groups of entities (maybe for team against team play).

Exactly how do you currently count specific entities in a specific area using scan_entity?
If I want to know the count of StormTroopers (perhaps after some have died(been removed) and others have been added) when the index into the linked list of StormTroopers is 1,
Code:

// assuming eLLPush(1, my) at beginning of StormTrooper action
var stormTrooperCount = eLLGetLength(1);


If I want to know how many StormTroopers are near a position + the weakest StormTrooper without using scan_entity:
Code:

entity* ent0_;
entity* ent1_;
//...
stormTrooperCount = 0;
if (!eLLIsEmpty(1)) {
var position[3];
var healthMin = 100;
eLLNextReset(1);
ent0_ = eLLNext(1);
ent1_ = ent0_;
while (ent0_ != null) {
if (vec_dist(ent0_.x, position) < 100) { // he's near position
stormTrooperCount += 1; // add one to how many StormTroopers are near position
if (ent0_.health < healthMin) {
ent1_ = ent0_;
healthMin = ent0_.health;
}
}
ent0_ = eLLNext(1);
}
}
// if ent1_ != null, HanSolo can target the weakest StormTrooper near position


Again, you could use eLL to move entities as a group, get the average position of the group, keep entities in formation, etc.
Note that eLL is meant to represent a dynamic list of entities, and not an array of entities, but in some cases, it can be used in place of a static array of handles.

Re: my 1st plugin: eLL alpha 0.01 [Re: testDummy] #70031
04/14/06 23:05
04/14/06 23:05
Joined: Aug 2005
Posts: 1,185
Ukraine
Lion_Ts Offline
Serious User
Lion_Ts  Offline
Serious User

Joined: Aug 2005
Posts: 1,185
Ukraine
Thank you again!

Re: my 1st plugin: eLL alpha 0.01 [Re: Lion_Ts] #70032
04/23/06 19:07
04/23/06 19:07

A
Anonymous
Unregistered
Anonymous
Unregistered
A



Hey, this looks really useful! I'm just wondering about the implementation: how can I add the script to a level? Just include eLL.wdl?

Re: my 1st plugin: eLL alpha 0.01 [Re: ] #70033
04/24/06 01:09
04/24/06 01:09
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline OP
Serious User
testDummy  Offline OP
Serious User
T

Joined: Oct 2004
Posts: 1,655
I answered some questions here.

Note: Unlike the version with somewhat non-functional, untested ea instructions posted in this thread, the new eLL has some (working) support for dynamic entity arrays in addition to entity linked lists. If there is evidence of a real demand for such dynamic entity arrays, I will post the update, otherwise I won't bother wasting time on documenting and explaining additional features in updates.

Re: my 1st plugin: eLL alpha 0.01 [Re: testDummy] #70034
04/26/06 01:01
04/26/06 01:01
Joined: Oct 2004
Posts: 1,655
T
testDummy Offline OP
Serious User
testDummy  Offline OP
Serious User
T

Joined: Oct 2004
Posts: 1,655
Hello, my name is testDummy and I'm a village idiot.

Although judging from the lack of complaints, I can gauge the lack of interest, and its obvious that very few would care one way or the other, but like a complete an utter half-wit, I forgot to include the compiled .dll in the original distribution.
Here is a later distribution, complete with source, compiled .dll and additional working ea instructions. The ea instructions are not completely finished, but they do allow the use and slight management of true "dynamic, anonymous" entity arrays.
eLL (entity linked lists & arrays) alpha 0.03b plugin for 3DGS

Re: my 1st plugin: eLL alpha 0.01 [Re: testDummy] #70035
04/26/06 14:37
04/26/06 14:37

A
Anonymous
Unregistered
Anonymous
Unregistered
A



Well, I'm interested. Seriously, this stuff is extremely useful. Just like the DLL will be...

Thanks

Re: my 1st plugin: eLL alpha 0.01 [Re: ] #70036
04/28/06 06:21
04/28/06 06:21
Joined: Apr 2006
Posts: 36
India
G
gamespider Offline
Newbie
gamespider  Offline
Newbie
G

Joined: Apr 2006
Posts: 36
India
test dummy..

It is one thing o make a great product .... and another thing to market it....

many great products have gone down the drain because of lack of marketing skills...

marketing rules:
1.use simple language that is easily understandable

2.Emphasize on how the product can help you.. not on how the product works, how u developed it, etc. etc.

3.make it short and sweet. NO ONE HAS THE ENERGY TO READ A WHOLE PAGE .

4.make ur language interesting...

Seriously.. I havent still understood what ur plugin does. Most people wouldnt either. That is the principal reason for lack of interest..

Page 1 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1