Jump to content

Photo

A few ZScript Questions considering weapons


  • Please log in to reply
6 replies to this topic

#1 Jambu

Jambu

    Doyen(ne)

  • Members
  • Pronouns:He / Him

Posted 25 April 2024 - 08:06 AM

1) Is there a flag i can toggle to make weapons always unblockable.

2) Is there a way to spawn those fireballs that spread (aquamentus)

3) What's the difference between lweapons and eweapons Other then which weapon effects whom?

4) Can the boomerang/hookshot/switch hooks direction be changed mid flight. I want to make it bounce off mirrors and for the boomerang I want it to RICOCHET off walls a certain number of times

5) Can thrown weapons be larger then 1 combo?


Edited by Jambu, 27 April 2024 - 11:16 PM.


#2 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 25 April 2024 - 08:55 PM

1) Yes. It's actually fairly simple. Directions 8-15 correspond to directions 1-7 but can't be blocked. Here's a simple internal function from ghost to convert a weapon's direction (weapon->Dir) to an unblockable one.

 

// Get the unblockable version (8-15) of a direction
int __UnblockableDir(int dir)
{
    if(dir==DIR_UP)
        return 8;
    if(dir==DIR_DOWN)
        return 12;
    if(dir==DIR_LEFT)
        return 14;
    if(dir==DIR_RIGHT)
        return 10;
    if(dir==DIR_LEFTUP)
        return 15;
    if(dir==DIR_RIGHTUP)
        return 9;
    if(dir==DIR_LEFTDOWN)
        return 13;
    if(dir==DIR_RIGHTDOWN)
        return 11;
    
    // Should never get here
    return dir;
}

 

2) You could script the behaviour easily enough with a weapon script.

 

3) Literally just who they affect. Internally, they're the same thing. The lweapon/eweapon divide is entirely arbitrary and a bit annoying. Having them be the same type with just a flag for hitting Link, enemies, or both would be much easier.

 

4) You're basically gonna need to rescript hookshots to do that, because of the pulling Link to them bit. Boomerangs are a bit easier.

 

5) Like, with engine picking up and throwing? Or just firing a weapon. The latter is trivial by setting a few flags. Here's a ghost function that does it to demonstrate. The former... I honestly couldn't tell you, not having messed much with liftable objects.

 

// Fire an eweapon larger than 1x1
eweapon FireBigEWeapon(int weaponID, int x, int y, float angle, int step, int damage, int sprite, int sound, int flags, int width, int height)
{
    eweapon wpn=FireEWeapon(weaponID, x, y, angle, step, damage, sprite, sound, flags);
    wpn->Extend=3;
    wpn->TileWidth=width;
    wpn->TileHeight=height;
    wpn->HitWidth=16*width;
    wpn->HitHeight=16*height;
    return wpn;
}


#3 Emily

Emily

    Scripter / Dev

  • ZC Developers
  • Pronouns:She / Her

Posted 25 April 2024 - 10:05 PM

1. You can simply set `weapon->Unblockable`, a variable that controls the blockability of weapons. More information here: https://zquestclassi...on::unblockable(It isn't just a simple on/off; you can separately set if it goes through blocks, ignores, the player shield, and reflects)

 

2. What Russ said

 

3. What Russ said, mostly. There's some tiny differences between them but there really is no reason there should be any difference in a well-designed system. Sadly we can't really fix this without rewriting everything and breaking old quests.

 

4. No. Any attempt to make the engine brang or hookshot do those things will likely go very poorly and not work, as the engine will actively fight your attempts. These things are very hardcoded, annoyingly so. The solution, as Russ said, will basically require scripting your own hookshot from scratch.

 

5. The engine currently cannot lift something above your head and have it be large; but scripts can put whatever weapon, of whatever size they want, in the player's hands.


  • Jambu likes this

#4 Jambu

Jambu

    Doyen(ne)

  • Members
  • Pronouns:He / Him

Posted 27 April 2024 - 12:29 PM

Scratch that... I came up with another way. Custom Weapon 1... But now ZC crashes when it should blocked by shields

eweapon script RotationFix{
	void run(){
		this->Step = 200;
		this->Angular = true;
		this->AutoRotate = true;
	}
}

Edited by Jambu, 27 April 2024 - 01:07 PM.


#5 Emily

Emily

    Scripter / Dev

  • ZC Developers
  • Pronouns:She / Her

Posted 27 April 2024 - 03:26 PM

 

Scratch that... I came up with another way. Custom Weapon 1... But now ZC crashes when it should blocked by shields

eweapon script RotationFix{
	void run(){
		this->Step = 200;
		this->Angular = true;
		this->AutoRotate = true;
	}
}

Crashes? Please file a bug report if you ever run into an actual crash.

 

Keep in mind that changing the type of a weapon changes a lot about it, not just makes it be blocked differently. (Also, the player's shield can be set to block custom weapons as well). If your goal is specifically to make it unblockable and nothing else, I highly recommend using the solution I said previously (which would use `this->Unblockable` here)


  • Jambu likes this

#6 Jambu

Jambu

    Doyen(ne)

  • Members
  • Pronouns:He / Him

Posted 27 April 2024 - 07:30 PM

Crashes? Please file a bug report if you ever run into an actual crash.

 

Keep in mind that changing the type of a weapon changes a lot about it, not just makes it be blocked differently. (Also, the player's shield can be set to block custom weapons as well). If your goal is specifically to make it unblockable and nothing else, I highly recommend using the solution I said previously (which would use `this->Unblockable` here)

Not sure why it was crashing but I got it working. Lynel 3's are a go now. yey

 

BTW: I should explain what I was trying to do. the Swords were not rotated, so for the breath weapon and 8 shot i wanted to make that happen.


Edited by Jambu, 28 April 2024 - 09:20 AM.


#7 Jambu

Jambu

    Doyen(ne)

  • Members
  • Pronouns:He / Him

Posted 27 April 2024 - 11:15 PM

eweapon script GleeokTripleShot{
	void run(int WeaponDriftSlot){
		float angle = WrapAngle(RadianAngle(this->X, this->Y, Link->X, Link->Y));
		eweapon fireballA = FireAimedEWeapon(this->ID, this->X, this->Y, angle, 100, this->Power, SP_FIREBALL, SFX_FIREBALL, EWF_UNBLOCKABLE);
		eweapon fireballB = FireAimedEWeapon(this->ID, this->X, this->Y, angle, 100, this->Power, SP_FIREBALL, SFX_FIREBALL, EWF_UNBLOCKABLE);
		SetEWeaponMovement(fireballA, EWM_DRIFT, DIR_LEFT,1);
		SetEWeaponMovement(fireballB, EWM_DRIFT, DIR_RIGHT,1);
	}
}

So I;m trying to make the gleeoks fireballs behave like Gohma L3 and Aquamentus with a spread shot. But it's not working.




2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users