With ZScript how do I add Sword 1 (Wooden) if Link does not have it?
#1
Posted 20 November 2017 - 12:39 AM
I am asking up above so I can know how to add items with ZScript as I please.
What format (example .zscript) do I save up above mentioned coding in NotePad?
How do I make up above mentioned ZScript apply to DMap0 named Kylee?
#2
Posted 20 November 2017 - 05:19 AM
I know nothing except that the proper file extension is .z.
- LikeLike888 likes this
#3
Posted 20 November 2017 - 08:56 AM
Why does this need to be a script? What is the scenario that makes the code run?
Look in zscript.txt and you'll find under the Link heading. And in std_constants.zh under the Items heading. Wooden sword is I_SWORD1.
Here's the entry for Link items from zscript.txt
if(!Link->Item[I_SWORD1]) Link->Item[I_SWORD1]=true;
if ( Game->GetCurDMap() == 2 ) { if(!Link->Item[I_SWORD1]) Link->Item[I_SWORD1]=true; }
const int DMAP_Kylee = 0; if ( Game->GetCurDMap() == DMAP_Kylee ) { }
Edited by justin, 20 November 2017 - 09:01 AM.
- LikeLike888 likes this
#4
Posted 20 November 2017 - 10:18 PM
Using constant definitions is indeed, the best option.
//Declare and define a constant so that you can use its identifier: const int DMAP_Level_1 = 2; if ( Game->GetCurDMap() == DMAP_Level_1 ) //Now we can reference it by name.
DMAP_Level_1 resolves to the literal '2', so the above is identical to : if ( Game->GetCurDMap == 2 ), save that it is more readable this way, and, you can change the DMap comparison throughout a large series of scripts, simply by adjusting the value of the constant definition.
You can also pass DMap IDs into ffc script, or item script args:
ffc script OnlyOnDMap { void run(int dmap_id) { //Quit if we are not on the correct DMap. if ( Game->GetCurDMap() != dmap_id ) { this->Data = 0; Quit(); } //Do everything else here. } } const int SFX_ERROR = 64; //An error sound item script Flame { //Do something different if we are on the specified dmap //We'll say that one of your DMaps is a water level, so, a fire weapon makes no sense. void run(int dmap_id) { lweapon l; if ( Game->GetCurDMap() != dmap_id ) { l = Screen->CreateLWeapon(LW_FIRE); l->X = Link->X+InFrontX(Link->Dir, 8); l->Y = Link->Y+InFrontY(Link->Dir, 8)); Game->PlaySound(SFX_FIRE); } else { //We are on the water DMap, so, make an error sound. Game->PlaySound(SFX_ERROR); } } }
Here's a bonus, generic item giving FFC:
ffc script GiveItem { void run(int item_id) { if ( !Link->item[item_id] ) Link->Item[item_id] = true; Quit(); } }
;
Here is an example of how to invert an boolean state:
ffc script GiveItem { void run(int item_id) { Link->Item[item_id] = (!(Link->item[item_id])); Quit(); //Flips the state. } }
Edited by ZoriaRPG, 20 November 2017 - 10:31 PM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users