Gamestudio Links
Zorro Links
Newest Posts
blogherenowcenter
by 3s05bmmc. 06/05/24 06:08
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, VoroneTZ), 779 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19057 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How do I use vec_set or something similar for ARRAYS? #227833
09/16/08 11:23
09/16/08 11:23
Joined: Aug 2008
Posts: 133
Sweden, Stockholm
E
Enduriel Offline OP
Member
Enduriel  Offline OP
Member
E

Joined: Aug 2008
Posts: 133
Sweden, Stockholm
Hello, I've got a problem.

What I want to do is transfer the players stats within the array to the temp array and that way control multiple npc/player/enemies stats depending on situation, it's a turn based game, worked in c-script but can't figure it out how to do it in lite-c


Code:
var player1_stats[6]; //has hp,mp,str,mgc,def,agi
var temp_defender_stats[6];



and then I have a pointer ofc for the players action called

Code:
ENTITY* player1;


I also have a temp POINTER

Code:
ENTITY* temp_defender;


Now I want to use something like this to transfer the stats to the temp array, do damage, increase stats, and then I have anotehr function which transfers the stats back to the correct player depending on who temp_defender is on that moment.

Code:
if (temp_defender == player1) {vec_set(temp_defender_stats, player1_stats);}



but it doesn't work when I use vec_set to do it. I decrease/increase the the for example HP of temp_defender, even if player1_stats is assigned to temp_defender_stats it doesn't work, but it works if I increase or decrase the stat of the player1 directly,

i've tried using this instead of vet_set but it didn't work either =/

Code:
function array_switch(var* array1, var* array2)
{
	array1[0] = array2[0];
	array1[1] = array2[1];
	array1[2] = array2[2];
	array1[3] = array2[3];
	array1[4] = array2[4];
	array1[5] = array2[5];
	array1[6] = array2[6];
	array1[7] = array2[7];
	array1[8] = array2[8];
	array1[9] = array2[9];
}


Last edited by Enduriel; 09/16/08 11:47.
Re: How do I use vec_set or something similar for ARRAYS? [Re: Enduriel] #227852
09/16/08 13:22
09/16/08 13:22
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
try this
Code:
if (temp_defender == player1) 
{  var idx;   
   for(idx=0; idx<6; idx++)   
      temp_defender[idx]=player1_stats[idx];   //or other way round
}

should do the job


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: How do I use vec_set or something similar for ARRAYS? [Re: EvilSOB] #227873
09/16/08 15:37
09/16/08 15:37
Joined: Aug 2008
Posts: 133
Sweden, Stockholm
E
Enduriel Offline OP
Member
Enduriel  Offline OP
Member
E

Joined: Aug 2008
Posts: 133
Sweden, Stockholm
hmm, but i'm using 6 variables and 2 arrays:

Code:
var hp = 0;
var mp = 1;
var str = 2;
var mgc = 3;
var def = 4;
var agi = 5;

player1_stats[6]; //will contain the ones I posted above
temp_defender_stats[6]; //becomes player1_stats when it's players turn, becomes player2_stats when it is player 2s turn etc etc.


not sure how that is done with with the method you suggested :<
The reason I have a temp is because of player turns and enemy turns in a final fantasy based game, and whenever it's someones turn I tell the pointer of the player to be temp_defender


Last edited by Enduriel; 09/16/08 15:37.
Re: How do I use vec_set or something similar for ARRAYS? [Re: Enduriel] #227961
09/17/08 01:34
09/17/08 01:34
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
EvilSOB's way will work, but if you want to use vec_set, you'll need to put
Code:
vec_set(array1[0],array2[0]);
vec_set(array1[3],array2[3]);
vec_set(array1[6],array2[6]);
as you're only setting a 'vector' it will only store/copy the 1st 3 vars


Re: How do I use vec_set or something similar for ARRAYS? [Re: MrGuest] #227998
09/17/08 08:24
09/17/08 08:24
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
if you want it in a function like you suggested, try this.

Code:
function array_switch(var* array1, var* array2, var LEN)
{
   var idx;   
   for(idx=0; idx<LEN; idx++)   
      array1[idx] = array2[idx];   //make array1 = array2
}

you need to add the "len" parameter if the array is ever going to be
other than 6 elements, otherwise you could hard-code it.

You would use it like this
Code:
if (temp_defender == player1) {array_switch(temp_defender_stats, player1_stats,6);}

so if temp_defender==player1 then the temp_defender_stats will be replaced
by a copy of player1_stats.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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