Arrays within structs

The best and quickest support by a group of top-notch editing specialists, guaranteed!

Moderator: Forum Guards

Arrays within structs

Postby Cozmo » Tue Aug 02, 11 3:25 pm

I need to access a variable within an array within a struct, declared by another variable from within another array in a different class.

:?

Code: Select all
if(MPCP.Tag == INTERACTION[MPCS.Condition[i]].CheckNPCTag)


INTERACTION is the struct, MPCS is the other class (ignore MPCP), Condition is the variable in the other class, "i" is from the For() loop before this line, and CheckNPCTag is the name variable I want to access (inside the struct).

I guess if nobody can help me, I could do something hax-y / cheesy with local variables everywhere but that's crap.

I have another problem regarding variables within structs - how do I set the default value? Setting these in the default properties (as just "variable=") gives me an error.

All of this is for an MP SDK thing, which supports making missions via simple var editing and should be finished fairly soon.
Cozmo
Master
 
Posts: 1266
Joined: Tue Jun 28, 05 10:53 am
Location: UK

Postby Poor » Tue Aug 02, 11 6:45 pm

I'm going to need more information. You say INTERACTION is a struct but from the code posted it looks like an array of structs. MPCS.Condition[i] will return an int, correct? Is MPCS a class or an instance of a class?
Poor
Poster
 
Posts: 190
Joined: Tue Jan 04, 11 7:42 pm

Re: Arrays within structs

Postby ~ô¿ô~Nobody~ » Tue Aug 02, 11 8:12 pm

Cozmo wrote:I need to access a variable within an array within a struct, declared by another variable from within another array in a different class.

:?

Code: Select all
if(MPCP.Tag == INTERACTION[MPCS.Condition[i]].CheckNPCTag)


INTERACTION is the struct, MPCS is the other class (ignore MPCP), Condition is the variable in the other class, "i" is from the For() loop before this line, and CheckNPCTag is the name variable I want to access (inside the struct).

I guess if nobody can help me, I could do something hax-y / cheesy with local variables everywhere but that's crap.

I have another problem regarding variables within structs - how do I set the default value? Setting these in the default properties (as just "variable=") gives me an error.

All of this is for an MP SDK thing, which supports making missions via simple var editing and should be finished fairly soon.


The resulting value for the index operator must be an integer.
If MPCS.Condition[] is an array of integers, then the construction with the INTERACTION array should actually work.

According to default values..
From what I know, setting variables in structs goes like this.


Code: Select all
structProperty=(innerProp1=value1, innerProp2=value2,innerProp3=value3)


Just take the PlayerViewOffset property of almost all weapons as example. :)
Nobody is perfect...
------------------------------
Longc[A]t wrote:I still think Dae is a russian spambot.

~[A]Daedalus~ wrote:There will be a day when my patience goes away and you, along with all who rant with you, will get banned.

ô¿ô¥[GODZ]¥NOCHANC wrote:I can ban any one I want ANY time I want. You have no rights here.
User avatar
~ô¿ô~Nobody~
Alpha
 
Posts: 2520
Joined: Fri Dec 31, 04 3:20 pm
Location: Proclarush Taonas

Postby Cozmo » Wed Aug 03, 11 2:15 am

Just got it to recompile perfectly. Both of your comments were useful; thanks. :D INTERACTIONS was a struct array, which I forgot to mention, but I was referencing the struct name rather than variable for it (if that makes any sense. I don't know any terminology at all. :oops: )

Will post the source code here when I finish it, which might be tomorow.
Cozmo_RPG (v1 & v2)
MPConversations - A tool for creating multiplayer RPG stuff
Cozmo
Master
 
Posts: 1266
Joined: Tue Jun 28, 05 10:53 am
Location: UK

Postby Cozmo » Wed Aug 03, 11 11:37 am

Actually, one more quick question while I'm here - for the sake of optimisation, it is possible to change every value in an array at once without the use of a For() loop or otherwise?
Last edited by Cozmo on Wed Aug 03, 11 11:38 am, edited 1 time in total.
Cozmo
Master
 
Posts: 1266
Joined: Tue Jun 28, 05 10:53 am
Location: UK

Postby ~ô¿ô~Nobody~ » Wed Aug 03, 11 7:41 pm

Not in UnrealScript..

..just out of interest.. why would you need it anyway? :o
Nobody is perfect...
------------------------------
Longc[A]t wrote:I still think Dae is a russian spambot.

~[A]Daedalus~ wrote:There will be a day when my patience goes away and you, along with all who rant with you, will get banned.

ô¿ô¥[GODZ]¥NOCHANC wrote:I can ban any one I want ANY time I want. You have no rights here.
User avatar
~ô¿ô~Nobody~
Alpha
 
Posts: 2520
Joined: Fri Dec 31, 04 3:20 pm
Location: Proclarush Taonas

Postby Cozmo » Wed Aug 03, 11 8:59 pm

Storing some information in an external class, but if they leave and the information doesn't get deleted, a new player joining could get all of their mission progress etc. Want to wipe it clean every time it detects values with no owner / when a player leaves game.

I only have one problem left for all of this now; the 255 byte memory limit for arrays from other classes. :x
Cozmo_RPG (v1 & v2)
MPConversations - A tool for creating multiplayer RPG stuff
Cozmo
Master
 
Posts: 1266
Joined: Tue Jun 28, 05 10:53 am
Location: UK

Postby ~ô¿ô~Nobody~ » Wed Aug 03, 11 10:30 pm

Ah, right.. that limit issue occurred when accessing arrays of other classes and not own arrays..
Well.. you could write a goaround..
Just declare a function that lets you set and get entries of the arrays within that class. :o
Nobody is perfect...
------------------------------
Longc[A]t wrote:I still think Dae is a russian spambot.

~[A]Daedalus~ wrote:There will be a day when my patience goes away and you, along with all who rant with you, will get banned.

ô¿ô¥[GODZ]¥NOCHANC wrote:I can ban any one I want ANY time I want. You have no rights here.
User avatar
~ô¿ô~Nobody~
Alpha
 
Posts: 2520
Joined: Fri Dec 31, 04 3:20 pm
Location: Proclarush Taonas

Postby Cozmo » Thu Aug 04, 11 12:24 am

... !

Yes! Thank you - have been trying to overcome this for ages. I'll have a go at this tomorow. :D
Cozmo_RPG (v1 & v2)
MPConversations - A tool for creating multiplayer RPG stuff
Cozmo
Master
 
Posts: 1266
Joined: Tue Jun 28, 05 10:53 am
Location: UK

Postby Cozmo » Thu Aug 04, 11 12:50 pm

Tried a different technique, got the same memory error just from trying to access the struct at all. I actually don't know how to do your workaround; it turns out I'm still a total noob. :lol: How do I declare a function struct? (Assuming I need to)
Cozmo
Master
 
Posts: 1266
Joined: Tue Jun 28, 05 10:53 am
Location: UK

Postby Poor » Thu Aug 04, 11 2:06 pm

It might be a little messy but if you are getting errors accessing a struct in a different class you could have functions that deal with the structs inside the class containing them.
Poor
Poster
 
Posts: 190
Joined: Tue Jan 04, 11 7:42 pm

Postby Shinobi » Thu Aug 04, 11 4:07 pm

I'm gonna hijack t his and say cozmo please sort out logspam in future RPG fixes!!

And nobody/cozmo, how do you learn so much about uscript?? Where?? I wanna learn!
So we beat on, boats against the current, borne back ceaselessly into the past.
User avatar
Shinobi
Master
 
Posts: 1503
Joined: Tue Jul 10, 07 12:10 pm
Location: Wales

Postby ~ô¿ô~Nobody~ » Thu Aug 04, 11 6:46 pm

Poor wrote:It might be a little messy but if you are getting errors accessing a struct in a different class you could have functions that deal with the structs inside the class containing them.

That's what I was suggesting. :)
However, another thing got in my mind which does not work.
In UnrealScript of UE1, it's not possible to use structs of another class as variable type if that class is no parent class of the class where you want to use the struct. :(

So in your case you got a double problem, Cozmo..
You cannot access the struct array directly and you cannot make an function that passes takes or returns structs, that can be used in another class.
That's a hacky way to avert certain functions within a class to be called from another class.. e.g. by just adding a self made struct as parameter to the function, so another class cannot call it because it cannot fill the parameter. :P

@Shinobi: 8 years of experience, I say.. and it always happens again that I get to know something that I didn't know before! :D
Last edited by ~ô¿ô~Nobody~ on Thu Aug 04, 11 6:48 pm, edited 1 time in total.
Nobody is perfect...
------------------------------
Longc[A]t wrote:I still think Dae is a russian spambot.

~[A]Daedalus~ wrote:There will be a day when my patience goes away and you, along with all who rant with you, will get banned.

ô¿ô¥[GODZ]¥NOCHANC wrote:I can ban any one I want ANY time I want. You have no rights here.
User avatar
~ô¿ô~Nobody~
Alpha
 
Posts: 2520
Joined: Fri Dec 31, 04 3:20 pm
Location: Proclarush Taonas

Postby Cozmo » Thu Aug 04, 11 7:36 pm

Looking at the UnrealWiki, a dynamic array might work though, but idk about Unreal Engine 1. Argh, I'm not good enough for this at all. I might have to resort to ultimate noobery and take them out of the structs, send to other class then put back into structs. :lol:

@Shin; actually, I'm a fairly mediocre coder, unlike Nobody & Poor here. My work only seems impressive because a lot of it has (surprisingly) never been done before. :) As for things I did learn though, it was mostly due to a sodacan.uc tutorial in Scripting Society (if anyone still has that) and decompiling DarkForce1.u to see how it worked. Also, I think the logspam is the MPBots I used. I don't know enough about replication to fix them unfortunately.
Cozmo
Master
 
Posts: 1266
Joined: Tue Jun 28, 05 10:53 am
Location: UK

Postby Cozmo » Tue Aug 16, 11 1:24 am

For anyone who was curious, I went for a much more awkward (but efficient) workaround - the NPC never officially dies anymore, so it doesn't have to awkwardly store and recall all the information. Instead, it gets hidden until the respawn time is up, then gets teleported to the spawnpoint, health reset, collision reset etc. Much smoother.

I did still have to access what was basically a dynamic array though, so I used Nobody's/Poor's workaround function thing. Didn't know how to write it so for reference's sake...

Code: Select all
function int GetMissionCondition(DeusExPlayer DEP, int MissionNumber2)
{
   //local int ConditionInt;
   local int i;

   for (i=1; i<40; i++)
   {
      if(StoredVars[i].DXP == DEP)
      {
         return StoredVars[i].Condition[MissionNumber2];
      }
   }
}


and changed this check

Code: Select all
if(MPCP.Tag == INTERACTION[MPCS.Condition[i]].CheckNPCTag)


into this

Code: Select all
if(MPCP.Tag == Interactions[MPCS.GetMissionCondition(TalkingTo, MissionNumber)].CheckNPCTag)
Cozmo
Master
 
Posts: 1266
Joined: Tue Jun 28, 05 10:53 am
Location: UK


Return to Editing issues

Who is online

Users browsing this forum: No registered users and 19 guests