Basically what I am looking for is an lweapon script that makes it so that when the items projectile hits an enemy projectile (like fire trails, rocks, arrows, wind, magic and so on), it will completely destroy that projectile. Thanks
#1
Posted 10 June 2020 - 09:21 PM
#2
Posted 11 June 2020 - 12:04 AM
lweapon TargetLWeapon; eweapon TargetEWeapon; for(int i = 0; i <= Screen->NumEWeapons(); i++){ TargetEWeapon = Screen->LoadEWeapon(i); if(TargetEWeapon->X == TargetLWeapon->X && TargetEWeapon->Y == TargetLWeapon->Y){ TargetEWeapon->X = -64; TargetEWeapon->Y = -64; } }Some shitty example code, the collision detection here is pixel perfect because I'm too lazy, but you should get the point.
Edited by Mani Kanina, 11 June 2020 - 12:11 AM.
- Anthus and SparksTheUnicorn like this
#3
Posted 11 June 2020 - 02:56 AM
just cycle through all the screen's eweapons and compare their position with your lweapon to see if they collide, and if they do, remove them. It's not super complicated, see Screen->NumEWeapons() and Screen->LoadEWeapon(int num)
lweapon TargetLWeapon; eweapon TargetEWeapon; for(int i = 0; i <= Screen->NumEWeapons(); i++){ TargetEWeapon = Screen->LoadEWeapon(i); if(TargetEWeapon->X == TargetLWeapon->X && TargetEWeapon->Y == TargetLWeapon->Y){ TargetEWeapon->X = -64; TargetEWeapon->Y = -64; } }Some shitty example code, the collision detection here is pixel perfect because I'm too lazy, but you should get the point.
lweapon TargetLWeapon; eweapon TargetEWeapon; for(int i = 0; i <= Screen->NumEWeapons(); i++){ TargetEWeapon = Screen->LoadEWeapon(i); if(Collision(TargetLWeapon, TargetEWeapon)){ Remove(TargetEWeapon); } }
Proper collision, and destruction, using std.zh functions. Even simpler.
- ShadowTiger, Mani Kanina, Jared and 1 other like this
#4
Posted 11 June 2020 - 03:42 AM
Since this is in script requests I'm assuming you were looking for a working script and since you specified lweapon script, I'm assuming you're using 2.55.
lweapon script EWeaponDestroyer{ void run(int sfx, int breakOnHit){ int i; eweapon e; while(true){ for(i=Screen->NumEWeapons(); i>=1; --i){ e = Screen->LoadEWeapon(i); if(e->CollDetection&&e->DeadState==WDS_ALIVE){ if(Collision(this, e)){ if(sfx) Game->PlaySound(sfx); e->DeadState = 0; if(breakOnHit){ this->DeadState = 0; Quit(); } } } } Waitframe(); } } }
Here you go. D0 is a sound to play when the weapon collides with another. If D1 is 1, the weapon dies on the first collision. I'd avoid doing anything too bullet hellish since this kind of thing will always result in a lot of iterations. But with just Link's weapons it should be fine.
Edited by Moosh, 11 June 2020 - 03:43 AM.
- ShadowTiger, Anthus, Mani Kanina and 2 others like this
Also tagged with one or more of these keywords: lweapon
2.55
Zelda Classic →
ZC Development →
Sine Wave Style Weapon ScriptStarted by Timelord , 18 Mar 2019 2.55, Weapon Script, LWeapon and 5 more... |
|
|
||
Bug?
Zelda Classic →
Scripting Discussion →
ZScript can't set the damage of a Sword LWeapon?Started by Orithan , 17 Jul 2014 Bug?, Sword, LWeapon, ZScript and 1 more... |
|
|
||
header
Zelda Classic →
Scripting Discussion →
Script Requests →
Collaborators Wanted for stdWeapons.zhStarted by Timelord , 18 Dec 2013 header, lweapon, eweapon |
|
|
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users