PDA

View Full Version : Some item/weapon scripting questions.



Gleeok
09-05-2007, 06:17 AM
So i'm moving on to some weapon scripts (it's going very slowly) and have a few questions as to the easiest way to proceed with them.

Script 1; Basically a lightning bolt that shoots across the screen. Some problems:
Is there a way without using an ffc script to use combos as animation for this?
Also enemy damage detection; Again without using even more ffc scripts to detect damage?

So I guess my question is, can I combine all three of these into one easy-to-use (not neccesarally easy to write up ) item script.


If that's possible what would be the easiest way to check NPC_Damage?

-off the top of my head...

if ((attack->X = Link->X - 16()attack->Y = Link->Y)&&
Screen->LoadNPC(1) == Link->X - 16() Link->Y)){
npc enemy = Screen->LoadNPC(1);
enemy->HP -= 16;
Game->PlaySound(11);
}
Something like this doesn't seem that appealing when realizing there's like 10,000 else if's involveed. :(

Has anyone done something like this yet?

(I know C-Dawg has, but that's a little too advanced for me ;p)

ShadowMancer
09-05-2007, 11:54 AM
Enemy Damage Script:


void ene_damage(int damage,int xn, int yn) {
int ene_chk = 1;

while (ene_chk <= Screen->NumNPCs()) {
npc trg_ene = Screen->LoadNPC(ene_chk);
if (trg_ene->X+8 >= xn-8 && trg_ene->X+8 <= xn+24 && trg_ene->Y+8 >= yn-8 && trg_ene->Y+8 <= yn+24) {
//Enemy is Hit

int timer = 10;
trg_ene->HP -= damage;
int def_cset = trg_ene->CSet;

while(timer > 0) {
//Flash CSet
trg_ene->CSet++;
//Push enemy back
//Up,Dn,Lt,Rt
if (trg_ene->Y < Link->Y) {
if (is_walkable(trg_ene->X,trg_ene->Y-4)) {trg_ene->Y-=4;}
}
if (trg_ene->Y > Link->Y) {
if (is_walkable(trg_ene->X,trg_ene->Y+4)) {trg_ene->Y+=4;}
}
if (trg_ene->X < Link->X) {
if (is_walkable(trg_ene->X-4,trg_ene->Y)) {trg_ene->X-=4;}
}
if (trg_ene->X > Link->X) {
if (is_walkable(trg_ene->X+4,trg_ene->Y)) {trg_ene->X+=4;}
}
timer -= 1;
Waitframe();
}
trg_ene->CSet = def_cset;
}
ene_chk += 1;


} //ends while (ene_chk <= Screen->NumNPCs())
return;
}

You call the script from the FFC each frame to check if it damages an enemy, like so:

ene_damage(5,this->X,This->Y)

The '5' is the damage amount, set it anything you like
My CSet flashing and enemy knockback is a bit messed up right now, I will be redoing this soon
UPDATE: enemy knockback is fixed now, I used C-Dawg's technique of haveing enemy alway fall back away from Link (I wanted to have the knockback relitive the the position of the weapon, but this should work just as well, besides you don't want to accidentaly slam an enemy into yourself)



So I guess my question is, can I combine all three of these into one easy-to-use (not neccesarally easy to write up ) item script
The answer to that is.. no, You will need to have the item script 'spawn' the FFC (best way to do this is to pre setup the FFC on the screen, change its combo to 0, have the Item script set the FFC's combo to what you want) the script in the FFC will be set to 'activate' when its combo is not 0
if (this->Data != 0) {//activate FFC}
once activated move the FFC weapon how you want (put the ene damage in the loop)

You could do this w/out an FFC but it would be more difucult and probley look sloppy (but please feel free to prove me wrong :D )

C-Dawg
09-05-2007, 01:49 PM
Shadow, you can copy and paste the CSet flash and damage code from Zodiac if you're still looking for it. The only tricky bit is keeping multiple enemies straight, and you've done that already by using functions instead of raw if-then logic.

ShadowMancer
09-05-2007, 03:09 PM
Thanks, yea I've been pageing through the Zodiac scripts today seeing if anything I can use. Also C, I would like to use some of your enemy tiles from Zodiac if you don't mind, some of them would make great demons for GoE :)

Gleeok
09-07-2007, 09:38 PM
Thanks ShadowMancer. I've put this one on hold untill I become more proficient at scripting, but what i'd like to eventually do is create a multi-usable ffc weapon script that functions as enemy hit detection, enemy damage effects, item ffc combo animation, and such, to be used for all the custom weapon scripts, which I must admit, is currently way beyond my scope of scripting ability.

ShadowMancer
09-07-2007, 11:20 PM
heh, what a conidence that is exactly what I am working on next, my 'FFC arsenal' is going to use humm I think 6 'reusable' FFC's for all the weapons, they will be triggered by the Item Script and run by a Global Script. I will probley get some weapons (and the engine) done by Monday night (gotta work this weekend) So, you (and anyone for that matter) are welcome to take the basic arsenal engine and make custom weapons to your hearts content :D