Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   for(...) and i (https://forums.graalonline.com/forums/showthread.php?t=16121)

nyghtGT 11-04-2001 05:00 AM

for(...) and i
 
can someone explain the following code to me please ... i dont understand it .... Explain all parts and what they do please ...
NPC Code:

NPC Code:

if (wasshot) {
for (i=0; i<npcscount; i++)
callnpc i,swimming;
}




KJS 11-04-2001 05:06 AM

Re: for(...) and i
 
Quote:

Originally posted by nyghtGT
can someone explain the following code to me please ... i dont understand it .... Explain all parts and what they do please ...
NPC Code:

NPC Code:

if (wasshot) {
for (i=0; i<npcscount; i++)
callnpc i,swimming;
}




basically it calls every npc on that level if the npc was shot and gives it a swimming thing

and inside the other npcs you can say

if(swimming){
//coding
}

so humm lets say the npc calling that code is a person npc

and it gets shot

then the person npc would call all the npcs and set
swimming

then in the other npcs that you want it to effect you say

if(swimming){

}

and do whatever you want in that coding once the person npc gets shot

Loriel 11-04-2001 06:35 AM

Re: for(...) and i
 
NPC Code:

if (wasshot) { Makes the following stuff executed when the NPC is hit by an arrow
for Initializes a for-loop
(i=0; Sets the variable "i" to 0 once
i<npcscount; Defines when to repeat the script after the ) thing: When the variable i is lower than the amount of NPCs in the level
i++) Increasing i each time the script after ) is run
callnpc i,swimming; Setting the flag "swimming" to true for the NPC with the index "i"
}



So what it would be doing in "normal" talk:
1) Wait until the NPC is hit by an arrow.
2) Set "i" to 0
3) Tell the NPC with index "i" that "swimming" is called (makes if (swimming) happen)
4) Increase "i" by one
5) Go back to 3 if "i" is lower than the amount of NPCs in the level
6) Stop executing

nyghtGT 11-06-2001 08:13 AM

Re: Re: for(...) and i
 
Quote:

Originally posted by Loriel
NPC Code:

if (wasshot) { Makes the following stuff executed when the NPC is hit by an arrow
for Initializes a for-loop
(i=0; Sets the variable "i" to 0 once
i<npcscount; Defines when to repeat the script after the ) thing: When the variable i is lower than the amount of NPCs in the level
i++) Increasing i each time the script after ) is run
callnpc i,swimming; Setting the flag "swimming" to true for the NPC with the index "i"
}



So what it would be doing in "normal" talk:
1) Wait until the NPC is hit by an arrow.
2) Set "i" to 0
3) Tell the NPC with index "i" that "swimming" is called (makes if (swimming) happen)
4) Increase "i" by one
5) Go back to 3 if "i" is lower than the amount of NPCs in the level
6) Stop executing

thanx to both you peoples ...

mhermher 11-06-2001 11:50 PM

Re: Re: Re: for(...) and i
 
Quote:

Originally posted by nyghtGT

thanx to both you peoples ...

No problem


:spam: :spam: :spam: :spam: :spam: :spam: :spam: :spam:


All times are GMT +2. The time now is 07:12 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.