Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Prevent hurting (https://forums.graalonline.com/forums/showthread.php?t=10560)

Silver Knight 08-27-2001 09:43 PM

Prevent hurting
 
Is there any easy way to prevent baddy/player/npc from hurting the player?

BocoC 08-27-2001 10:04 PM

Um. Make a timeout that continually set's the player's hearts to a certain amount, or set their AP to 100 =P

Merlin 08-27-2001 10:16 PM

if (playertouchsme) {toweapons Immortal;
}
if (weaponfired&&!this.on) {set this.on;
setcharprop #c,On.;
}
else
if (weaponfired&&this.on) {unset this.on;
setcharprop #c,Off.
}
while (this.on) {
if (playerhearts<playerfullhearts) {playerhearts=playerfullhearts;}

or something

Merlin 08-27-2001 10:25 PM

i tested this offline and it worked
PHP Code:

// NPC made by Merlin
if (playertouchsme) {toweapons Invincable;
}
if (
weaponfired&&!this.on) {
set this.on;
setplayerprop #c,On.;
}
else
if (
weaponfired&&this.on) {
unset 
this.on;
setplayerprop #c,Off.;
}
while (
this.on) {
if (
playerhearts<playerfullhearts) {
playerhearts=playerfullhearts;
}



Silver Knight 08-27-2001 10:47 PM

I know there's more to getting hit and flying back, but I was wondering if there was a way around it. I wanted to have armor power, sword power, defense power, and attack power, all effect how much damage was done or if the equiped armor would prevent the damage.

ownerofbabylon 08-27-2001 11:30 PM

Is there anyway to prevent the player from flying back?

Merlin 08-27-2001 11:32 PM

Quote:

Originally posted by ownerofbabylon
Is there anyway to prevent the player from flying back?
disableofmovement?

ownerofbabylon 08-27-2001 11:33 PM

:confused: would that work well? I mean u would have to disable and re enable pretty fast to be realistic.

Merlin 08-27-2001 11:38 PM

if (washit) {disableofmovement;
sleep.5;
enablemovement;
}
there would be trouble of they logged off right after being hit
i think im not really good at scripting ;\

08-28-2001 12:01 AM

if (playerhurt) {
playerhearts=playerhearts;
disabledefmovement;
sleep 10000000000000000000000000000000000000;
enabledefmovement;
}

Silver Knight 08-28-2001 01:39 AM

Alright so
1. Rescript movement with keydown
2. Script my own damage system.

Thanks Kaimetsu, and to everyone else who helped.

Silver Knight 08-28-2001 02:25 AM

Ugh
 
I've been trying to rescript movement but it wont work. I do the keydown(0) {playerdir=0;setani walk;y+=.5}
I know I'm doing something wrong, I just can't find it. Any it's no use saying I suck at scripting, I already know that.

08-28-2001 02:41 AM

it will be more like:

NPC Code:

// NPC made by I c e P i c k
if (created || playerenters) {
this.createx=int(x);
this.createy=int(y);
}
if (playertouchsme) {toweapons weaponname;
this.playerhearts=playerhearts;
}
if (weaponfired) {
this.mode = (this.mode+1)%2;
timeout = .05;
}
if (timeout && this.mode==1) {
players[this.id].hearts=this.playerhearts;
timeout = .5;
}


Silver Knight 08-28-2001 02:50 AM

That doesnt work, it makes you die every 3 seconds or so.

Brady2 08-28-2001 03:01 AM

Jadis:

XDaKreepX, in his godlike ways, made a weapon to keep the player from being hurt. (Meaning the player was not moved back).

LiquidIce00 08-28-2001 03:26 AM

if youre going to make armor then all you simply have to do is check to see if the player got hurt . then you of course need to know his hearts before he got hurt and you would need to compare like if hes got armor it doesnt hurt
here i didnt test this but im just like giving a base

NPC Code:


if (!isweapon&&playerenters&&!hasweapon(-armor)) { toweapons -armor; setstring armor,100;}

if (playerhurt) {
this.armorcheck=strtofloat(#s(armor));
if (this.armorcheck>0) {
playerhearts+=.5;
this.armorcheck=abs(this.armorcheck-5);
setstring armor,#s(this.armorcheck);
}
}



considering that baddies do .5 dmg else u have to set string of the current ammount of the player health then check it over or whatever..
okay bye

Silver Knight 08-28-2001 05:38 AM

I didn't test it but it'll probaly work. Thank alot, by the way. Anyone know if there is a command to check if a player hits another player? Sorta like a playerhitsplayer.

Merlin 08-28-2001 05:50 AM

if (playertouchsanother)

Silver Knight 08-28-2001 06:07 AM

Isn't it playertouchother and it's for npc's.

But is there a playertouchanother? and if it was wouldnt it deal with touching and not hitting them?

Tyhm 08-28-2001 07:06 AM

if(playerenters) noplayerkilling;

Silver Knight 08-28-2001 07:13 AM

Ha. I need it to detect being hit, fly back, and then lower the player's client.hp string. Dont think nopkzone would help.

BocoC 08-28-2001 10:32 PM

Quote:

Originally posted by ownerofbabylon
Is there anyway to prevent the player from flying back?
Well, in a script that I once wrote (trashed because it was too buggy), I stored that player's X and Y values.
NPC Code:

if (washit) {
playerhearts=playerfullhearts;
playerx=this.x;
playery=this.y;
setani idle,;
timeout=0.05;
}


Now, you will need a timeout to set the player X and Y.
NPC Code:

if (timeout) {
this.x=playerx;
this.y=playery;
timeout=0.05;
}


Try that.

entravial 08-29-2001 03:35 AM

~AlphaFlame~The Fool~

if (playerhurt){
this.x=playerx;
this.y=playery;
players[0].hearts+=.5;
timeout=.05;
}
if (timeout && strequals(#m,hurt)){
playerx=this.x;
playery=this.y;
timeout=.05;
}


Could that possibly work? o.0
The player will fall backwards just a *tiny* bit (I'm estimating about... .2 or so...), but not much... 0.o

Silver Knight 08-29-2001 08:59 AM

I need the player to fly back, I just want them not to be hurt unless the attacker's weapon power>players defense and armor.

entravial 08-30-2001 02:50 AM

~AlphaFlame~

Well why didn't you say so in the first place! :megaeek:

Anyway, try this...

if (playerenters){
toweapons -blahblah;
setstring armorpower,5;
destroy;
}
if (isweapon){
if (playerhurt){
playerhearts+=.5;
if (strtofloat(#s(armorpower))<Whatever it is you're using as the enemy power here){
playerhearts-=I'll let you do the math here ;
}
}
}

You'll hafta do what's in blue though, since I have no clue what you're using for your enemy strength, and the ratio you want of armor:enemy strength damage o.0

entravial 08-30-2001 03:15 AM

Like I said, I didn't know what he was using for the enemy strength variable, and what amounts he wanted for the damage. He could want .5 for every 1 over, or 1 for every .5... I'm not a mind-reader Kaimetsu ;)

entravial 08-30-2001 03:23 AM

*sighs* Now you're wanting me to give him a script he didn't ask for?

Sheesh, do I have amnesia or something? *goes back to read posts*

I believe he said

Quote:

I need the player to fly back, I just want them not to be hurt unless the attacker's weapon power>players defense and armor.
Implying that he already has the hurting script, just lacked the actual "hurt" part of the script.

entravial 08-30-2001 03:48 AM

I quote again

Quote:

I just want them not to be hurt unless the attacker's weapon power>players defense and armor.
I don't see "I just want to transfer the enemies strength to the player, and I want them not to be..."

In there... sure, it is the hardest part.

Really the only section he could be talking about? Now you know exactly what he was thinking when he asked that question?

Step right up, one and all! The amazing Kaimetsu will astound and amaze by reading your mind!

entravial 08-30-2001 04:04 AM

Alright Kaimetsu, since I don't have the braincells to...


YOU do it.

*giggles like a school girl and runs off* Mwaha

[edit]
Oh, by the way... you're a fun person to argue with Kaimetsu :D
[/edit]

entravial 08-30-2001 04:21 AM

Bad Script Monkey, arguing with people about helping somebody then not helping them yourself and saving about 10 posts worth of space... tsk tsk... mwehe

Silver Knight 08-30-2001 04:24 AM

Kaimetsu does read minds :megaeek:! I wanted to know how to detect the other players attacking power. I stated it in another post. Thanks for trying to help Adrenaline, but I already had that part of the script working perfectly.

entravial 08-30-2001 04:37 AM

I see an ego swelling :rolleyes:

Silver Knight 08-30-2001 04:37 AM

Quote:

Originally posted by Kaimetsu


And thus, I win.

No need for gloating/bragging/stating the obvious.

Adren:I find it very nice of you to try to help me, given are past history wasnt too...friendly.

entravial 08-30-2001 04:50 AM

Beating down your adverseries? Scripting is about SCRIPTING! =/

And plus, what does it hurt to help somebody?

... or are you just scared somebody might become better than you?

Silver Knight 08-30-2001 04:50 AM

Gloating is fun, but it can get you in some pretty nasty situa-ma-ations.

oscarjf1 08-30-2001 08:16 PM

.....
 
I think I'm a pretty good scripter myself. I dont go around bragging "Im the best, Youre a n00b cause you need help" because i need help with some stuff too. Some people are better at some things than others. Like myself, Im kinda new with arrays, so i asked for help with them. It doesnt mean that i couldnt complete the script i was working on, to be just as good as someone elses script, but i wanted to try a new angle of approach to it. Im sure even you have to ask for help from time to time...and people dont call you a newb scripter, do they? Its just like anything else, the more practice you have at it, the better you are. If someone needs help, I try to help them.... if i know how. If i dont...i will say i dont, or just not post.

Anyway...I posted on page 2 of this... or maybe even 1, and didnt bother to read the following pages until the last, because it takes too damn long, so if im off topic, just disreguard my post, lol.

oscarjf1 08-31-2001 12:57 AM

true, true
 
Youre right. But rubbing it in people's faces just makes them mad ;)

entravial 08-31-2001 05:38 AM

Quote:

Anybody who could ever get better than me wouldn't come here asking the stupid newbie questions that they do.
I'm seeing a big ego again... surely you had to ask a question or two when you started scripting?

Sheesh, just like learnin the alphabet for the first time, people new to scripting have to learn someplace...


All times are GMT +2. The time now is 02:39 PM.

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